List of usage examples for android.os Bundle getDouble
public double getDouble(String key)
From source file:fr.cph.chicago.activity.BusActivity.java
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mBusStopId = savedInstanceState.getInt("busStopId"); mBusRouteId = savedInstanceState.getString("busRouteId"); mBound = savedInstanceState.getString("bound"); mBusStopName = savedInstanceState.getString("busStopName"); mBusRouteName = savedInstanceState.getString("busRouteName"); mLatitude = savedInstanceState.getDouble("latitude"); mLongitude = savedInstanceState.getDouble("longitude"); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Called from FindActivity.onActivityResult(). Used to * update the Find's View, specifically the date, lat, long, * and alarm icon fields.//from ww w . ja v a 2 s. co m * * @param context, the calling Activity * @param find, the current Find * @param view, the FindActivity's content view * @param intent, the Intent that is passed to the menu activity */ public void onActivityResultCallback(Context context, Find find, View view, Intent intent) { Log.i(TAG, "onActivityResultCallbac"); // Intent is NOT null, meaning it includes reminder // date and location information set by the user if (intent != null) { Bundle bundle = intent.getExtras(); // Get date, longitude, and latitude String date = bundle.getString(Find.TIME); Double longitude = bundle.getDouble(Find.LONGITUDE); Double latitude = bundle.getDouble(Find.LATITUDE); TextView tv = (TextView) view.findViewById(R.id.isAdhocTextView); Integer is_adhoc = bundle.getInt(Find.IS_ADHOC); Log.i(TAG, "is_adhoc = " + is_adhoc); if (tv != null) { Log.i(TAG, "Setting isAdhocTextView to " + is_adhoc); tv.setText("" + is_adhoc); } // Display user specified longitude and latitude tv = (TextView) view.findViewById(R.id.longitudeValueTextView); tv.setText(String.valueOf(longitude)); tv = (TextView) view.findViewById(R.id.latitudeValueTextView); tv.setText(String.valueOf(latitude)); // Remove the old row that displays time and replace it // with a new row that include an alarm clock icon to // visually indicate this find has a reminder attached ViewGroup parent = (ViewGroup) view.findViewById(R.id.timeValueTextView).getParent(); parent.removeAllViews(); ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); TableRow.LayoutParams lp1 = new TableRow.LayoutParams(30, 30); lp1.setMargins(0, 6, 80, 0); parent.addView(alarmIcon, lp1); TextView mCloneTimeTV = new TextView(context); mCloneTimeTV.setId(R.id.timeValueTextView); mCloneTimeTV.setText(date); mCloneTimeTV.setTextSize(12); TextView mTimeTV = (TextView) view.findViewById(R.id.timeValueTextView); mTimeTV = mCloneTimeTV; TableRow.LayoutParams lp2 = new TableRow.LayoutParams(); lp2.setMargins(6, 6, 0, 0); parent.addView(mTimeTV, lp2); } }
From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java
/** * Called to have the fragment instantiate its user interface view. This is optional, * and non-graphical fragments can return null (which is the default implementation). T * his will be called between onCreate(Bundle) and onActivityCreated(Bundle). * * If you return a View from here, you will later be called in onDestroyView * when the view is being released./* w w w .j a v a 2 s . com*/ * * @param inflater Inflater used to create the widgets. * @param container ViewGroup parent of this view. * @param savedInstanceState Bundle that contains all the information for this activity. * @return View that will be used to present the information. */ @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_add_amount, container, false); // Recover the values to restore the edit values. if (savedInstanceState != null) { mCurrentAmount = savedInstanceState.getDouble(AMOUNT_KEY); mSelectedAccount = savedInstanceState.getInt(ACCOUNT_KEY); mCurrentDate = savedInstanceState.getLong(DATE_KEY); mCurrentNotes = savedInstanceState.getString(NOTES_KEY); hideDialog = true; } customizeAmountButton(rootView, mCurrentAmount); if (!hideDialog) { displayInputMoneyDialog(mCurrentAmount); } // Get adapter this will be filled by the loader. mAccountsSpinner = (Spinner) rootView.findViewById(R.id.accounts_spinner); mAccountsSpinner.postInvalidate(); mAccountsSpinner.setAdapter(mAdapter); // Set the current date as a formattedString. final Date currentDate = new Date(); mDateText = (TextView) rootView.findViewById(R.id.current_date); if (mCurrentDate != 0) { currentDate.setTime(mCurrentDate); } // Set the date on the current label. setCurrentDateText(currentDate); createDateTimeDialog(); mNotes = (EditText) rootView.findViewById(R.id.notesText); if (mCurrentNotes != null) { mNotes.setText(mCurrentNotes); } createActionBar(inflater); mFragmentTitle = (TextView) rootView.findViewById(R.id.title_amount); createAddCashInstance(getArguments().getBoolean(MainActivity.SUBSTRACT_MOVEMENT)); return rootView; }
From source file:com.evandroid.musica.broadcastReceiver.MusicBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { /** Google Play Music //bool streaming long position //long albumId String album //bool currentSongLoaded String track //long ListPosition long ListSize //long id bool playing //long duration int previewPlayType //bool supportsRating int domain //bool albumArtFromService String artist //int rating bool local //bool preparing bool inErrorState *///from ww w . j av a 2 s . co m Bundle extras = intent.getExtras(); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); boolean lengthFilter = sharedPref.getBoolean("pref_filter_20min", true); if (extras != null) try { extras.getInt("state"); } catch (BadParcelableException e) { return; } if (extras == null || extras.getInt("state") > 1 //Tracks longer than 20min are presumably not songs || (lengthFilter && (extras.get("duration") instanceof Long && extras.getLong("duration") > 1200000) || (extras.get("duration") instanceof Double && extras.getDouble("duration") > 1200000) || (extras.get("duration") instanceof Integer && extras.getInt("duration") > 1200)) || (lengthFilter && (extras.get("secs") instanceof Long && extras.getLong("secs") > 1200000) || (extras.get("secs") instanceof Double && extras.getDouble("secs") > 1200000) || (extras.get("secs") instanceof Integer && extras.getInt("secs") > 1200))) return; String artist = extras.getString("artist"); String track = extras.getString("track"); long position = extras.containsKey("position") ? extras.getLong("position") : -1; if (extras.get("position") instanceof Double) position = Double.valueOf(extras.getDouble("position")).longValue(); boolean isPlaying = extras.getBoolean("playing", true); if (intent.getAction().equals("com.amazon.mp3.metachanged")) { artist = extras.getString("com.amazon.mp3.artist"); track = extras.getString("com.amazon.mp3.track"); } else if (intent.getAction().equals("com.spotify.music.metadatachanged")) isPlaying = spotifyPlaying; else if (intent.getAction().equals("com.spotify.music.playbackstatechanged")) spotifyPlaying = isPlaying; if ((artist == null || "".equals(artist)) //Could be problematic || (track == null || "".equals(track) || track.startsWith("DTNS"))) // Ignore one of my favorite podcasts return; SharedPreferences current = context.getSharedPreferences("current_music", Context.MODE_PRIVATE); String currentArtist = current.getString("artist", ""); String currentTrack = current.getString("track", ""); SharedPreferences.Editor editor = current.edit(); editor.putString("artist", artist); editor.putString("track", track); editor.putLong("position", position); editor.putBoolean("playing", isPlaying); if (isPlaying) { long currentTime = System.currentTimeMillis(); editor.putLong("startTime", currentTime); } editor.apply(); autoUpdate = autoUpdate || sharedPref.getBoolean("pref_auto_refresh", false); int notificationPref = Integer.valueOf(sharedPref.getString("pref_notifications", "0")); if (autoUpdate && App.isActivityVisible()) { Intent internalIntent = new Intent("Broadcast"); internalIntent.putExtra("artist", artist).putExtra("track", track); LyricsViewFragment.sendIntent(context, internalIntent); forceAutoUpdate(false); } SQLiteDatabase db = new DatabaseHelper(context).getReadableDatabase(); boolean inDatabase = DatabaseHelper.presenceCheck(db, new String[] { artist, track, artist, track }); db.close(); if (notificationPref != 0 && isPlaying && (inDatabase || OnlineAccessVerifier.check(context))) { Intent activityIntent = new Intent("com.geecko.QuickLyric.getLyrics").putExtra("TAGS", new String[] { artist, track }); Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE").putExtra("artist", artist) .putExtra("track", track); PendingIntent openAppPending = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent wearablePending = PendingIntent.getBroadcast(context, 8, wearableIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Action wearableAction = new NotificationCompat.Action.Builder(R.drawable.ic_watch, context.getString(R.string.wearable_prompt), wearablePending).build(); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context); NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context); if ("0".equals(sharedPref.getString("pref_theme", "0"))) notifBuilder.setColor(context.getResources().getColor(R.color.primary)); notifBuilder.setSmallIcon(R.drawable.ic_notif).setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setGroupSummary(true); wearableNotifBuilder.setSmallIcon(R.drawable.ic_notif) .setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setOngoing(false).setGroupSummary(false) .extend(new NotificationCompat.WearableExtender().addAction(wearableAction)); if (notificationPref == 2) { notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN } else notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW Notification notif = notifBuilder.build(); Notification wearableNotif = wearableNotifBuilder.build(); if (notificationPref == 2) notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; else notif.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManagerCompat.from(context).notify(0, notif); try { context.getPackageManager().getPackageInfo("com.google.android.wearable.app", PackageManager.GET_META_DATA); NotificationManagerCompat.from(context).notify(8, wearableNotif); } catch (PackageManager.NameNotFoundException ignored) { } } else if (track.equals(current.getString("track", ""))) NotificationManagerCompat.from(context).cancel(0); }
From source file:com.geecko.QuickLyric.broadcastReceiver.MusicBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { /** Google Play Music //bool streaming long position //long albumId String album //bool currentSongLoaded String track //long ListPosition long ListSize //long id bool playing //long duration int previewPlayType //bool supportsRating int domain //bool albumArtFromService String artist //int rating bool local //bool preparing bool inErrorState *//*from ww w . ja v a 2s . c o m*/ Bundle extras = intent.getExtras(); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); boolean lengthFilter = sharedPref.getBoolean("pref_filter_20min", true); if (extras != null) try { extras.getInt("state"); } catch (BadParcelableException e) { return; } if (extras == null || extras.getInt("state") > 1 //Tracks longer than 20min are presumably not songs || (lengthFilter && (extras.get("duration") instanceof Long && extras.getLong("duration") > 1200000) || (extras.get("duration") instanceof Double && extras.getDouble("duration") > 1200000) || (extras.get("duration") instanceof Integer && extras.getInt("duration") > 1200)) || (lengthFilter && (extras.get("secs") instanceof Long && extras.getLong("secs") > 1200000) || (extras.get("secs") instanceof Double && extras.getDouble("secs") > 1200000) || (extras.get("secs") instanceof Integer && extras.getInt("secs") > 1200)) || (extras.containsKey("com.maxmpz.audioplayer.source") && Build.VERSION.SDK_INT >= 19)) return; String artist = extras.getString("artist"); String track = extras.getString("track"); long position = extras.containsKey("position") && extras.get("position") instanceof Long ? extras.getLong("position") : -1; if (extras.get("position") instanceof Double) position = Double.valueOf(extras.getDouble("position")).longValue(); boolean isPlaying = extras.getBoolean(extras.containsKey("playstate") ? "playstate" : "playing", true); if (intent.getAction().equals("com.amazon.mp3.metachanged")) { artist = extras.getString("com.amazon.mp3.artist"); track = extras.getString("com.amazon.mp3.track"); } else if (intent.getAction().equals("com.spotify.music.metadatachanged")) isPlaying = spotifyPlaying; else if (intent.getAction().equals("com.spotify.music.playbackstatechanged")) spotifyPlaying = isPlaying; if ((artist == null || "".equals(artist)) //Could be problematic || (track == null || "".equals(track) || track.startsWith("DTNS"))) // Ignore one of my favorite podcasts return; SharedPreferences current = context.getSharedPreferences("current_music", Context.MODE_PRIVATE); String currentArtist = current.getString("artist", ""); String currentTrack = current.getString("track", ""); SharedPreferences.Editor editor = current.edit(); editor.putString("artist", artist); editor.putString("track", track); if (!(artist.equals(currentArtist) && track.equals(currentTrack) && position == -1)) editor.putLong("position", position); editor.putBoolean("playing", isPlaying); if (isPlaying) { long currentTime = System.currentTimeMillis(); editor.putLong("startTime", currentTime); } editor.apply(); autoUpdate = autoUpdate || sharedPref.getBoolean("pref_auto_refresh", false); int notificationPref = Integer.valueOf(sharedPref.getString("pref_notifications", "0")); if (autoUpdate && App.isActivityVisible()) { Intent internalIntent = new Intent("Broadcast"); internalIntent.putExtra("artist", artist).putExtra("track", track); LyricsViewFragment.sendIntent(context, internalIntent); forceAutoUpdate(false); } boolean inDatabase = DatabaseHelper.getInstance(context) .presenceCheck(new String[] { artist, track, artist, track }); if (notificationPref != 0 && isPlaying && (inDatabase || OnlineAccessVerifier.check(context))) { Intent activityIntent = new Intent("com.geecko.QuickLyric.getLyrics").putExtra("TAGS", new String[] { artist, track }); Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE").putExtra("artist", artist) .putExtra("track", track); PendingIntent openAppPending = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent wearablePending = PendingIntent.getBroadcast(context, 8, wearableIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Action wearableAction = new NotificationCompat.Action.Builder(R.drawable.ic_watch, context.getString(R.string.wearable_prompt), wearablePending).build(); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context); NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context); int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red, R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark }; int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); TypedValue primaryColorValue = new TypedValue(); context.setTheme(themes[themeNum]); context.getTheme().resolveAttribute(R.attr.colorPrimary, primaryColorValue, true); notifBuilder.setSmallIcon(R.drawable.ic_notif).setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setColor(primaryColorValue.data).setGroupSummary(true); wearableNotifBuilder.setSmallIcon(R.drawable.ic_notif) .setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setOngoing(false).setColor(primaryColorValue.data) .setGroupSummary(false) .extend(new NotificationCompat.WearableExtender().addAction(wearableAction)); if (notificationPref == 2) { notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN wearableNotifBuilder.setPriority(-2); } else notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW Notification notif = notifBuilder.build(); Notification wearableNotif = wearableNotifBuilder.build(); if (notificationPref == 2) notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; else notif.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManagerCompat.from(context).notify(0, notif); try { context.getPackageManager().getPackageInfo("com.google.android.wearable.app", PackageManager.GET_META_DATA); NotificationManagerCompat.from(context).notify(8, wearableNotif); } catch (PackageManager.NameNotFoundException ignored) { } } else if (track.equals(current.getString("track", ""))) NotificationManagerCompat.from(context).cancel(0); }
From source file:com.nearnotes.NoteEdit.java
@Override public void onStart() { super.onStart(); mTitleText = (EditText) getActivity().findViewById(R.id.title_edit); mCallback.setActionItems(NOTE_EDIT); if (mRowId == null) { Bundle extras = getArguments();//from w w w .j a va2 s.c om mRowId = extras.containsKey(NotesDbAdapter.KEY_ROWID) ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null; } getActivity().setTitle(R.string.edit_note); Bundle bundle = getArguments(); mLongitude = bundle.getDouble("longitude"); mLatitude = bundle.getDouble("latitude"); mTitleText = (EditText) getActivity().findViewById(R.id.title_edit); mBodyText = (EditText) getView().findViewById(R.id.body); mTblAddLayout = (TableLayout) getActivity().findViewById(R.id.checkbody); mTblAddLayout.setPadding(0, 0, 0, 0); acAdapter = new PlacesAutoCompleteAdapter(getActivity(), R.layout.list_item); mCheckBox = (CheckBox) getActivity().findViewById(R.id.checkbox_on_top); mCheckBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (((CheckBox) v).isChecked() && mRowId != null) { mDbHelper.updateSetting(mRowId); } else if (mRowId != null) { mDbHelper.removeSetting(); } } }); autoCompView = (DelayAutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1); autoCompView.setAdapter(acAdapter); //int height = autoCompView.getDropDownHeight(); //autoCompView.setDropDownHeight(height + 20); autoCompView.setOnItemClickListener(this); autoCompView.setLoadingIndicator((ProgressBar) getView().findViewById(R.id.progressAPI), (ImageView) getView().findViewById(R.id.location_icon)); autoCompView.setCompletionHint(""); if (mRowId != null) { autoCompView.setTextColor(getResources().getColor(R.color.deepgreen)); } else { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean checklistPref = sharedPref.getBoolean("pref_key_note_checklist", false); if (checklistPref) { mChecklist = true; } } mBodyText.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { //This listener is added to make sure the globalLayout has been displayed // before accessing getLayout().getLineEnd() ViewTreeObserver obs = mBodyText.getViewTreeObserver(); obs.removeGlobalOnLayoutListener(this); if (!mChecklist) { return; } mBodyText.addTextChangedListener(bodyTextWatcher); // Run the code below just once on startup to populate the global listArray mRealRow String tempBoxes = mBodyText.getText().toString(); if (mBodyText.getLayout() != null) { mRealRow = populateBoxes(tempBoxes); int row = 0; for (NoteRow line : mRealRow) { switch (line.getType()) { case 0: TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible, null); mTblAddLayout.addView(inflate); break; case 1: TableRow checkRow = (TableRow) View.inflate(getActivity(), R.layout.table_row, null); CheckBox temp = (CheckBox) checkRow.getChildAt(0); temp.setTag(Integer.valueOf(row)); mTblAddLayout.addView(checkRow); temp.setOnClickListener(checkBoxListener); break; case 2: TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null); CheckBox temp1 = (CheckBox) checkRow1.getChildAt(0); temp1.setTag(Integer.valueOf(row)); temp1.setChecked(true); mTblAddLayout.addView(checkRow1); temp1.setOnClickListener(checkBoxListener); break; } for (int k = 1; line.getSize() > k; k++) { TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible, null); mTblAddLayout.addView(inflate); } row++; } } } }); }
From source file:org.croudtrip.fragments.offer.MyTripDriverFragment.java
private void createOffer(Bundle arguments) { int maxDiversion = arguments.getInt("maxDiversion"); int pricePerKilometer = arguments.getInt("pricePerKilometer"); double fromLat = arguments.getDouble("fromLat"); double fromLng = arguments.getDouble("fromLng"); double toLat = arguments.getDouble("toLat"); double toLng = arguments.getDouble("toLng"); long vehicleId = arguments.getLong("vehicle_id"); TripOfferDescription tripOffer = new TripOfferDescription(new RouteLocation(fromLat, fromLng), new RouteLocation(toLat, toLng), maxDiversion * 1000L, pricePerKilometer, vehicleId); tripsResource.addOffer(tripOffer).compose(new DefaultTransformer<TripOffer>()).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<TripOffer>() { @Override/*from w ww .j av a 2 s.c o m*/ public void call(TripOffer tripOffer) { // SUCCESS Timber.d("Your offer was successfully sent to the server"); offerID = tripOffer.getId(); // show route information on the map generateRouteOnMap(tripOffer, NavigationResult.createNavigationResultForDriverRoute(tripOffer)); loadPassengers(); // Remember that a trip was offered to show "My Trip" instead of "Offer Trip" // in the Navigation drawer getActivity() .getSharedPreferences(Constants.SHARED_PREF_FILE_PREFERENCES, Context.MODE_PRIVATE) .edit().putBoolean(Constants.SHARED_PREF_KEY_RUNNING_TRIP_OFFER, true).apply(); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { // ERROR Timber.e(throwable.getMessage()); // Inform user Toast.makeText(getActivity(), getString(R.string.offer_trip_failed), Toast.LENGTH_LONG) .show(); removeRunningTripOfferState(); } }); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java
/** * Overriden method from Fragment. Sets the appropriate TextView and ImageView * if the user is returning from changing the location or image. If the user is * returning from changing the location, the new coordinates are placed on the * edit_location_button Button./*from w w w . j a v a 2s.co m*/ */ @Override public void onResume() { super.onResume(); Bundle args = getArguments(); if (EditFragment.oldText != null) { TextView oldTextView = (TextView) getActivity().findViewById(R.id.old_comment_text); oldTextView.setText(EditFragment.oldText); } if (args != null) { if (args.containsKey("LATITUDE") && args.containsKey("LONGITUDE")) { Button locButton = (Button) getActivity().findViewById(R.id.edit_location_button); if (args.getString("LocationType") == "CURRENT_LOCATION") { locButton.setText("Current Location"); } else { GeoLocation geoLocation = editComment.getLocation(); Double lat = args.getDouble("LATITUDE"); Double lon = args.getDouble("LONGITUDE"); geoLocation.setCoordinates(lat, lon); String locationDescription = args.getString("locationDescription"); geoLocation.setLocationDescription(locationDescription); DecimalFormat format = new DecimalFormat(); format.setRoundingMode(RoundingMode.HALF_EVEN); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(4); locButton.setText("Location: Set"); } } } }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the transparent blank screen as a background for dialogs setContentView(R.layout.blank_screen); // Exit the Activity if the proper settings are not enabled SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean allowReminder = prefs.getBoolean("allowReminderKey", true); boolean allowGeoTag = prefs.getBoolean("geotagKey", true); // If the user allows, set the "Set Reminder" menu option if (!allowReminder || !allowGeoTag) { Toast.makeText(this, "Sorry. Geotagging and Allow Reminder settings must " + " be enabled to run the Set Reminder Activity.", Toast.LENGTH_LONG).show(); finish();/* ww w .j av a2s.c o m*/ } mDbEntries = getIntent().getParcelableExtra("DbEntries"); dateSetPressed = false; // Get intent passed in from FindActivity Bundle bundle = getIntent().getExtras(); date = bundle.getString("Date"); // Initialize variables for Date Picker Dialog year = date.substring(0, 4); month = date.substring(5, 7); day = date.substring(8, 10); // Initialize variables for longitude and latitude findsLongitude = bundle.getDouble("FindsLongitude"); findsLatitude = bundle.getDouble("FindsLatitude"); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location netLocation = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); Location gpsLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); Location loc = null; if (gpsLocation != null) { loc = gpsLocation; } else { loc = netLocation; } if (loc != null) { currentLongitude = loc.getLongitude(); currentLatitude = loc.getLatitude(); } showDatePickerDialog(); }
From source file:com.luke.lukef.lukeapp.fragments.MapViewFragment.java
/** * Fetches arguments from given bundle or calls {@link MapViewFragment#getLastLoc()} for * previously known location.//w w w . ja v a 2s .com * * @return {@link Location} object */ private Location fetchArgsFromBundle() { Bundle b = getArguments(); if (b != null && b.containsKey("latitude")) { Location location = new Location("jes"); location.setLatitude(b.getDouble("latitude")); location.setLongitude(b.getDouble("longitude")); getArguments().clear(); return location; } else if (getLastLoc() != null) { Location location = new Location("jes"); location.setLatitude(getLastLoc().getLatitude()); location.setLongitude(getLastLoc().getLongitude()); return location; } else { return null; } }