Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/middleware/GeneralActivity.java
Show All 19 Lines | |||||
import android.view.View; | import android.view.View; | ||||
import android.view.inputmethod.InputMethodManager; | import android.view.inputmethod.InputMethodManager; | ||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.backend.utils; | import it.reyboz.bustorino.backend.utils; | ||||
import it.reyboz.bustorino.data.PreferencesHolder; | |||||
/** | /** | ||||
* Activity class that contains all the generally useful methods | * Activity class that contains all the generally useful methods | ||||
*/ | */ | ||||
public abstract class GeneralActivity extends AppCompatActivity { | public abstract class GeneralActivity extends AppCompatActivity { | ||||
final static protected int PERMISSION_REQUEST_POSITION = 33; | final static protected int PERMISSION_REQUEST_POSITION = 33; | ||||
final static protected String LOCATION_PERMISSION_GIVEN = "loc_permission"; | final static protected String LOCATION_PERMISSION_GIVEN = "loc_permission"; | ||||
final static protected int STORAGE_PERMISSION_REQ = 291; | final static protected int STORAGE_PERMISSION_REQ = 291; | ||||
Show All 17 Lines | public abstract class GeneralActivity extends AppCompatActivity { | ||||
} | } | ||||
protected boolean getOption(String optionName, boolean optDefault) { | protected boolean getOption(String optionName, boolean optDefault) { | ||||
SharedPreferences preferences = getPreferences(MODE_PRIVATE); | SharedPreferences preferences = getPreferences(MODE_PRIVATE); | ||||
return preferences.getBoolean(optionName, optDefault); | return preferences.getBoolean(optionName, optDefault); | ||||
} | } | ||||
protected SharedPreferences getMainSharedPreferences(){ | protected SharedPreferences getMainSharedPreferences(){ | ||||
return getSharedPreferences(getString(R.string.mainSharedPreferences),MODE_PRIVATE); | return PreferencesHolder.getMainSharedPreferences(this); | ||||
} | } | ||||
public void hideKeyboard() { | public void hideKeyboard() { | ||||
View view = getCurrentFocus(); | View view = getCurrentFocus(); | ||||
if (view != null) { | if (view != null) { | ||||
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) | ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) | ||||
.hideSoftInputFromWindow(view.getWindowToken(), | .hideSoftInputFromWindow(view.getWindowToken(), | ||||
InputMethodManager.HIDE_NOT_ALWAYS); | InputMethodManager.HIDE_NOT_ALWAYS); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register