List of usage examples for android.content SharedPreferences getFloat
float getFloat(String key, float defValue);
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void saved() { ////////S-A-V-E-D/////////// LinearLayout SavedParent = (LinearLayout) V.findViewById(R.id.group_pinned); LayoutInflater inflater = getActivity().getLayoutInflater(); //If there are no pinned alarms if (touchSaveIndex(0) < 1) { View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText("No Pinned Alarms"); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); LinearLayout.LayoutParams sparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(sparams); SavedParent.addView(Saved);/*from w ww . ja va 2 s.c o m*/ } else { for (int i = 1; i <= touchSaveIndex(0); i++) { // View Saved = new View(getApplicationContext()); View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); Location location = new Location("POINT_LOCATION"); location.setLatitude(0); location.setLongitude(0); String address = "No Pinned Alarms"; if (prefs.contains(SAVED_LATITUDE_KEY + i)) { location.setLatitude(prefs.getFloat(SAVED_LATITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_LONGITUDE_KEY + i)) { location.setLongitude(prefs.getFloat(SAVED_LONGITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_ADDRESS_KEY + i)) { address = (prefs.getString(SAVED_ADDRESS_KEY + i, "")); } CharSequence name; if (!address.equals("")) { name = address; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDDFFFFFF); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setTag(i); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); } else { name = "Error"; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); } ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText(name); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextSize(14); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(params); SavedParent.addView(Saved); } } }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void cleanup(int tag) { SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.remove(SAVED_LATITUDE_KEY + tag); prefsEditor.remove(SAVED_LONGITUDE_KEY + tag); prefsEditor.remove(SAVED_RADIUS_KEY + tag); prefsEditor.remove(SAVED_ADDRESS_KEY + tag); for (int i = tag; i < touchSaveIndex(0); i++) { prefsEditor.putFloat(SAVED_LATITUDE_KEY + i, prefs.getFloat(SAVED_LATITUDE_KEY + (i + 1), 0)); prefsEditor.putFloat(SAVED_LONGITUDE_KEY + i, prefs.getFloat(SAVED_LONGITUDE_KEY + (i + 1), 0)); prefsEditor.putString(SAVED_ADDRESS_KEY + i, prefs.getString(SAVED_ADDRESS_KEY + (i + 1), "")); }/*from www .ja va 2 s . c o m*/ prefsEditor.remove(SAVED_LATITUDE_KEY + touchSaveIndex(0)); prefsEditor.remove(SAVED_LONGITUDE_KEY + touchSaveIndex(0)); prefsEditor.remove(SAVED_ADDRESS_KEY + touchSaveIndex(0)); prefsEditor.commit(); }
From source file:com.openatk.rockapp.MainActivity.java
private void setUpMapIfNeeded() { if (map == null) { map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getExtendedMap(); }/*from w w w . java 2s .co m*/ markerHandler = new MarkerHandler(this, map, dbHelper, mCurrentRockSelected); slideMenu.setMarkerHandler(markerHandler); if (map != null) { setUpMap(); map.setOnMarkerDragListener(this); map.setOnMarkerClickListener(this); map.setOnMapClickListener(this); map.setOnCameraChangeListener(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Float startLat = prefs.getFloat("StartupLat", START_LAT); Float startLng = prefs.getFloat("StartupLng", START_LNG); Float startZoom = prefs.getFloat("StartupZoom", START_ZOOM); map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(startLat, startLng), startZoom)); } }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void initTopicSpinner() { // Get topics in category. Null accepts all user sources. Modify // according to user selection final String[] saTopicIDs = SearchTopicActivity.saTopicIDs; final String[] saTitles = SearchTopicActivity.saTopicTitles; final String[] saDates = SearchTopicActivity.saTopicDates; // TODO add TopicInfo for SearchResults as well and parse accordingly // final String[] saTopicIDs = extras.getStringArray("searchresults"); final TextView title = (TextView) findViewById(R.id.title); // Fill topic spinner ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, saTitles); final TextView tx = (TextView) findViewById(R.id.textView1); // tx.setMovementMethod(LinkMovementMethod.getInstance()); // final float minm = tx.getTextSize(); // final float maxm = (minm + 24); // create an invisible spinner just to control the summaries of the // category (i will use it later on Swipe) Spinner spinner = (Spinner) findViewById(R.id.spinner1); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);//from ww w .ja v a 2s . c o m // Scroll view init final ScrollView scroll = (ScrollView) findViewById(R.id.scrollView1); // Add selection event spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // Show waiting dialog showWaitingDialog(); // Changing summary loading = true; // Update visibility of rating bar final RatingBar rb = (RatingBar) findViewById(R.id.ratingBar); rb.setRating(0.0f); rb.setVisibility(View.VISIBLE); final TextView rateLbl = (TextView) findViewById(R.id.rateLbl); rateLbl.setVisibility(View.VISIBLE); scroll.scrollTo(0, 0); // String[] saTopicIDs = sTopicIds.split(sSeparator); SharedPreferences settings = getSharedPreferences("urls", 0); // get user settings for sources String UserSources = settings.getString("UserLinks", "All"); String[] Summary = NewSumServiceClient.getSummary(saTopicIDs[arg2], UserSources); if (Summary.length == 0) { // WORK. Updated: CHECK // Close waiting dialog closeWaitingDialog(); AlertDialog.Builder alert = new AlertDialog.Builder(SearchViewActivity.this); alert.setMessage(R.string.shouldReloadSummaries); alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { startActivity(new Intent(getApplicationContext(), NewSumUiActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); } }); alert.setCancelable(false); alert.show(); loading = false; return; } // track summary views per Search and topic title if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(VIEW_SUMMARY_ACTION, "From Search", saTitles[arg2] + ": " + saDates[arg2], 0l); } // Generate summary text sText = ViewActivity.generateSummaryText(Summary, SearchViewActivity.this); pText = ViewActivity.generatesummarypost(Summary, SearchViewActivity.this); tx.setText(Html.fromHtml(sText)); tx.setMovementMethod(LinkMovementMethod.getInstance()); title.setText(saTitles[arg2] + ": " + saDates[arg2]); float defSize = tx.getTextSize(); SharedPreferences usersize = getSharedPreferences("textS", 0); float newSize = usersize.getFloat("size", defSize); tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize); // update the TopicActivity with viewed item TopicActivity.addVisitedTopicID(saTopicIDs[arg2]); // Close waiting dialog closeWaitingDialog(); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:locationkitapp.locationkit.locationkitapp.MapsActivity.java
private void updateLocation() { if (!stopShowingLocationUpdates) { SharedPreferences prefs = getSharedPreferences(AppConstants.PREFS_FILE, Context.MODE_PRIVATE); if (prefs.contains(AppConstants.LATITUDE)) { mCurrentLocation = new LatLng(prefs.getFloat(AppConstants.LATITUDE, 0f), prefs.getFloat(AppConstants.LONGITUDE, 0f)); if (mMap != null) { // mLocationMarker.setPosition(mCurrentLocation); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCurrentLocation, AppConstants.MAP_ZOOM)); }/* www .j av a 2s .c o m*/ } } }
From source file:com.nextgis.forestinspector.activity.MainActivity.java
protected boolean loadDocuments(long resourceId, String accountName, MapBase map) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); float minX = prefs.getFloat(SettingsConstants.KEY_PREF_USERMINX, -180.0f); float minY = prefs.getFloat(SettingsConstants.KEY_PREF_USERMINY, -90.0f); float maxX = prefs.getFloat(SettingsConstants.KEY_PREF_USERMAXX, 180.0f); float maxY = prefs.getFloat(SettingsConstants.KEY_PREF_USERMAXY, 90.0f); NGWVectorLayerUI ngwVectorLayer = new NGWVectorLayerUI(getApplicationContext(), map.createLayerStorage(Constants.KEY_LAYER_DOCUMENTS)); ngwVectorLayer.setName(getString(R.string.title_notes)); ngwVectorLayer.setRemoteId(resourceId); ngwVectorLayer.setServerWhere(String.format(Locale.US, "bbox=%f,%f,%f,%f", minX, minY, maxX, maxY)); ngwVectorLayer.setVisible(true);//from ww w. j a va 2s .c o m //TODO: add layer draw default style and quarter labels ngwVectorLayer.setAccountName(accountName); ngwVectorLayer.setSyncType(com.nextgis.maplib.util.Constants.SYNC_DATA); ngwVectorLayer.setMinZoom(0); ngwVectorLayer.setMaxZoom(100); map.addLayer(ngwVectorLayer); return ngwVectorLayer.download() == null; }
From source file:com.nextgis.forestinspector.activity.MainActivity.java
protected boolean loadForestCadastre(long resourceId, String accountName, MapBase map) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); float minX = prefs.getFloat(SettingsConstants.KEY_PREF_USERMINX, -180.0f); float minY = prefs.getFloat(SettingsConstants.KEY_PREF_USERMINY, -90.0f); float maxX = prefs.getFloat(SettingsConstants.KEY_PREF_USERMAXX, 180.0f); float maxY = prefs.getFloat(SettingsConstants.KEY_PREF_USERMAXY, 90.0f); NGWVectorLayerUI ngwVectorLayer = new NGWVectorLayerUI(getApplicationContext(), map.createLayerStorage(Constants.KEY_LAYER_CADASTRE)); ngwVectorLayer.setName(getString(R.string.cadastre)); ngwVectorLayer.setRemoteId(resourceId); ngwVectorLayer.setServerWhere(String.format(Locale.US, "bbox=%f,%f,%f,%f", minX, minY, maxX, maxY)); ngwVectorLayer.setVisible(true);/*w w w . j ava2 s. c o m*/ //TODO: add layer draw default style and quarter labels ngwVectorLayer.setAccountName(accountName); ngwVectorLayer.setSyncType(com.nextgis.maplib.util.Constants.SYNC_NONE); ngwVectorLayer.setMinZoom(0); ngwVectorLayer.setMaxZoom(100); SimplePolygonStyle style = new SimplePolygonStyle(Color.GREEN); style.setFill(false); SimpleFeatureRenderer renderer = new SimpleFeatureRenderer(ngwVectorLayer, style); ngwVectorLayer.setRenderer(renderer); map.addLayer(ngwVectorLayer); return ngwVectorLayer.download() == null; }
From source file:Steps.StepsFragment.java
/** * Update the steps count/*from w w w . j a v a 2 s.c o m*/ * TODO: this method needs refactoring */ private void updateViews() { Log.w("updateView", "updateViews"); //Log.w("update VIew", Integer.toString(total_start + steps)); if (!goalAnimationPlaying) { if (isChecked) { textSteps.setText(Integer.toString(steps) + " steps today "); } else { SharedPreferences prefs = getActivity().getSharedPreferences("pedometer", Context.MODE_MULTI_PROCESS); float height_value = prefs.getFloat("height_value", Fragment_Settings.DEFAULT_Human_Height); float stride_lenght; if (prefs.getString("sex", Fragment_Settings.DEFAULT_SEX).equals("male")) { stride_lenght = (float) (height_value * 0.415); } else { stride_lenght = (float) (height_value * 0.413); } float distance_today = (total_start + steps) * stride_lenght; if (prefs.getString("stepsize_unit", Fragment_Settings.DEFAULT_STEP_UNIT).equals("cm")) { distance_today /= 100000; } else { distance_today /= 5280; } textSteps.setText(String.format("%.3f km.", distance_today)); } } }
From source file:com.nextgis.forestinspector.fragment.MapFragment.java
@Override public void onResume() { super.onResume(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean showControls = prefs.getBoolean(SettingsConstants.KEY_PREF_SHOW_ZOOM_CONTROLS, false); showMapButtons(showControls, mMapRelativeLayout); Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF")); if (null != mMap) { float mMapZoom; try {/*from www . j a v a2 s .co m*/ mMapZoom = prefs.getFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getMinZoom()); } catch (ClassCastException e) { mMapZoom = mMap.getMinZoom(); } double mMapScrollX; double mMapScrollY; try { mMapScrollX = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_X, 0)); mMapScrollY = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_Y, 0)); } catch (ClassCastException e) { mMapScrollX = 0; mMapScrollY = 0; } mMap.setZoomAndCenter(mMapZoom, new GeoPoint(mMapScrollX, mMapScrollY)); mMap.addListener(this); } mCoordinatesFormat = prefs.getInt(SettingsConstants.KEY_PREF_COORD_FORMAT + "_int", Location.FORMAT_DEGREES); if (null != mCurrentLocationOverlay) { mCurrentLocationOverlay.updateMode(PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3")); mCurrentLocationOverlay.startShowingCurrentLocation(); } if (null != mGpsEventSource) { mGpsEventSource.addListener(this); } mShowStatusPanel = prefs.getBoolean(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, true); if (null != mStatusPanel) { if (mShowStatusPanel) { mStatusPanel.setVisibility(View.VISIBLE); fillStatusPanel(null); } else { mStatusPanel.removeAllViews(); } } mCurrentCenter = null; }
From source file:it.angrydroids.epub3reader.EpubReaderMain.java
protected void loadState(SharedPreferences preferences) { updateView1(ViewStateEnum// w w w . jav a2s . c om .valueOf(preferences.getString(getString(R.string.firstState), ViewStateEnum.books.name()))); updateView2(ViewStateEnum .valueOf(preferences.getString(getString(R.string.secondState), ViewStateEnum.invisible.name()))); float viewSize = preferences.getFloat(getString(R.string.firstViewSize), getFirstViewWeight()); changeViewsSize(viewSize); if (!navigator.loadState(preferences)) errorMessage(getString(R.string.error_cannotLoadState)); }