List of usage examples for android.os Bundle putDouble
public void putDouble(@Nullable String key, double value)
From source file:com.kobi.metalsexchange.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCurrencyId = Utility.getPreferredCurrency(this); mWeightUnitId = Utility.getPreferredWeightUnit(this); setContentView(R.layout.activity_main); // Creating The Toolbar and setting it as the Toolbar for the activity Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar);/*from w w w.java 2 s . c om*/ Utility.setTwoPanesView(findViewById(R.id.rate_detail_container) != null); // Get the ViewPager and set it's PagerAdapter so that it can display items ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(new ExchangeRatesFragmentPagerAdapter(getSupportFragmentManager(), MainActivity.this)); // Give the SlidingTabLayout the ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); // Set custom tab layout // /*with icon*/ slidingTabLayout.setCustomTabView(R.layout.custom_tab, 0); // Center the tabs in the layout slidingTabLayout.setDistributeEvenly(false); // slidingTabLayout.setBackgroundColor(getResources().getColor(R.color.primary)); // // // Customize tab color slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @Override public int getIndicatorColor(int position) { return getResources().getColor(R.color.white); } }); slidingTabLayout.setViewPager(viewPager); ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { super.onPageSelected(position); Utility.setCurrentMetalId(Utility.getMetalIdForTabPosition(position), MainActivity.this); //pageSelected = position; if (Utility.isTwoPanesView()) { DetailFragment detailFragment = (DetailFragment) getSupportFragmentManager() .findFragmentByTag(DETAILFRAGMENT_TAG); TrendGraphFragment trendGraphFragment = (TrendGraphFragment) getSupportFragmentManager() .findFragmentByTag(CHARTFRAGMENT_TAG); if (detailFragment != null) { getSupportFragmentManager().beginTransaction().remove(detailFragment).commit(); } if (trendGraphFragment != null) { getSupportFragmentManager().beginTransaction().remove(trendGraphFragment).commit(); } if (mFloatingActionButton != null) { mFloatingActionButton.hide(); } } } }; slidingTabLayout.setOnPageChangeListener(pageChangeListener); viewPager.setCurrentItem(Utility.getTabIdxForMetal(Utility.getCurrentMetalId(this))); mLastUpdatedTextView = (TextView) findViewById(R.id.last_updated_textview); updateTheLastUpdatedTime(); if (Utility.isTwoPanesView()) { // The detail container view will be present only in the large-screen layouts // (res/layout-sw600dp). If this view is present, then the activity should be // in two-pane mode. // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. mFloatingActionButton = (ActionButton) findViewById(R.id.action_button); mFloatingActionButton.hide(); if (mFloatingActionButton != null) { mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DetailFragment df = (DetailFragment) getSupportFragmentManager() .findFragmentByTag(DETAILFRAGMENT_TAG); Bundle b = new Bundle(); b.putString("METAL_ID", Utility.getCurrentMetalId(MainActivity.this)); b.putDouble("CURRENT_VALUE", df.getRawRate()); b.putLong("CURRENT_DATE", df.getDate()); FragmentManager fm = MainActivity.this.getSupportFragmentManager(); CalculatorDialogFragment myDialogFragment = new CalculatorDialogFragment(); myDialogFragment.setArguments(b); //myDialogFragment.getDialog().setTitle(getResources().getString(R.string.calculator_fragment_name)); myDialogFragment.show(fm, "dialog_fragment"); } }); } if (savedInstanceState == null) { DetailFragment detailFragment = (DetailFragment) getSupportFragmentManager() .findFragmentByTag(DETAILFRAGMENT_TAG); TrendGraphFragment trendGraphFragment = (TrendGraphFragment) getSupportFragmentManager() .findFragmentByTag(CHARTFRAGMENT_TAG); if (detailFragment != null) { getSupportFragmentManager().beginTransaction().remove(detailFragment).commit(); } if (trendGraphFragment != null) { getSupportFragmentManager().beginTransaction().remove(trendGraphFragment).commit(); } } } else { getSupportActionBar().setElevation(0f); } MetalsExchangeSyncAdapter.initializeSyncAdapter(this); }
From source file:net.czlee.debatekeeper.PrepTimeBellsEditActivity.java
private static Bundle createBellBundleFromAddOrEditDialog(final Dialog dialog) { final Spinner typeSpinner = (Spinner) dialog.findViewById(R.id.addPrepTimeBellDialog_typeSpinner); final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.addPrepTimeBellDialog_timePicker); final EditText editText = (EditText) dialog.findViewById(R.id.addPrepTimeBellDialog_editText); int typeSelected = typeSpinner.getSelectedItemPosition(); Bundle bundle = new Bundle(); switch (typeSelected) { case ADD_PREP_TIME_BELL_TYPE_START: case ADD_PREP_TIME_BELL_TYPE_FINISH: // We're using this in hours and minutes, not minutes and seconds int minutes = timePicker.getCurrentHour(); int seconds = timePicker.getCurrentMinute(); long time = minutes * 60 + seconds; if (typeSelected == ADD_PREP_TIME_BELL_TYPE_START) bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_START); else/* w ww . ja v a 2 s. c om*/ bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_FINISH); bundle.putLong(PrepTimeBellsManager.KEY_TIME, time); break; case ADD_PREP_TIME_BELL_TYPE_PERCENTAGE: Editable text = editText.getText(); bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_PROPORTIONAL); Double percentage = Double.parseDouble(text.toString()); double value = percentage / 100; bundle.putDouble(PrepTimeBellsManager.KEY_PROPORTION, value); break; } return bundle; }
From source file:planets.position.Planets.java
public void loadPlanets(String name, int num, int x) { Bundle b = new Bundle(); b.putDouble("Lat", latitude); b.putDouble("Long", longitude); b.putDouble("Elevation", elevation); b.putDouble("Offset", offset); b.putInt("num", num); b.putString("name", name); if (x == 1) { // Sky Position Intent i = new Intent(getApplicationContext(), Position.class); i.putExtras(b);/*from ww w . j av a 2 s. c o m*/ startActivity(i); } else { // Real Time Position Intent i = new Intent(getApplicationContext(), LivePosition.class); i.putExtras(b); startActivity(i); } }
From source file:name.gumartinm.weather.information.activity.MapActivity.java
/***************************************************************************************************** * * MapProgressFragment * I am not using fragment transactions in the right way. But I do not know other way for doing what I am doing. * Android sucks./* w ww . java 2 s .c o m*/ * * "Avoid performing transactions inside asynchronous callback methods." :( * see: http://stackoverflow.com/questions/16265733/failure-delivering-result-onactivityforresult * see: http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html * How do you do what I am doing in a different way without using fragments? *****************************************************************************************************/ private void addProgressFragment(final double latitude, final double longitude) { final Fragment progressFragment = new MapProgressFragment(); progressFragment.setRetainInstance(true); final Bundle args = new Bundle(); args.putDouble("latitude", latitude); args.putDouble("longitude", longitude); progressFragment.setArguments(args); final FragmentManager fm = this.getSupportFragmentManager(); final FragmentTransaction fragmentTransaction = fm.beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.weather_map_enter_progress, R.anim.weather_map_exit_progress); fragmentTransaction.add(R.id.weather_map_buttons_container, progressFragment, PROGRESS_FRAGMENT_TAG) .commit(); fm.executePendingTransactions(); }
From source file:com.nearnotes.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDbHelper = new NotesDbAdapter(this); // Create new custom database class for sqlite and pass the current context as a variable mDbHelper.open(); // Gets the writable database // enable ActionBar app icon to behave as action to toggle nav drawer LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL); View customNav = getLayoutInflater().inflate(R.layout.edit_title, null); // layout which contains your button. getActionBar().setDisplayShowCustomEnabled(true); getActionBar().setCustomView(customNav, lp); getActionBar().setDisplayHomeAsUpEnabled(true); // getActionBar().setHomeButtonEnabled(true); // Start nav drawer mTitle = mDrawerTitle = getTitle();// w w w . j a v a 2 s . co m mMenuTitles = getResources().getStringArray(R.array.drawer_menu_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set a custom shadow that overlays the main content when the drawer opens mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mMenuTitles)); // set up the drawer's list view with items and click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // ActionBarDrawerToggle ties together the the proper interactions between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); NoteList newFragment = new NoteList(); Bundle args = new Bundle(); args.putDouble("latitude", mLatitude); args.putDouble("longitude", mLongitude); newFragment.setArguments(args); FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction(); transaction1.replace(R.id.fragment_container, newFragment); // transaction1.addToBackStack(null); transaction1.commit(); //fetchAllNotes(); }
From source file:net.naonedbus.fragment.impl.ItineraireFragment.java
private void sendRequest() { if (mFromLocation.bearingTo(mToLocation) == 0.0f) { hideProgress();//from ww w .j a va 2 s .com mItineraryWrappers.add(ItineraryWrapper.getUnicornItinerary()); mAdapter.notifyDataSetChanged(); } else { final Bundle bundle = new Bundle(); bundle.putDouble(ItineraryLoader.PARAM_FROM_LATITUDE, mFromLocation.getLatitude()); bundle.putDouble(ItineraryLoader.PARAM_FROM_LONGITUDE, mFromLocation.getLongitude()); bundle.putDouble(ItineraryLoader.PARAM_TO_LATITUDE, mToLocation.getLatitude()); bundle.putDouble(ItineraryLoader.PARAM_TO_LONGITUDE, mToLocation.getLongitude()); bundle.putLong(ItineraryLoader.PARAM_TIME, mDateTime.getMillis()); bundle.putBoolean(ItineraryLoader.PARAM_ARRIVE_BY, mArriveBy); getLoaderManager().restartLoader(0, bundle, this); } }
From source file:org.croudtrip.gcm.GcmIntentService.java
private void handleFoundMatches(Intent intent) { Timber.d("FOUND_MATCHES"); // extract join request and offer from message long queryId = Long.parseLong(intent.getExtras().getString(GcmConstants.GCM_MSG_FOUND_MATCHES_QUERY_ID)); // download the join trip request tripsResource.getQuery(queryId).observeOn(Schedulers.io()).subscribeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<RunningTripQuery>() { @Override//from ww w .j a va 2 s. com public void call(RunningTripQuery query) { final SharedPreferences prefs = getApplicationContext() .getSharedPreferences(Constants.SHARED_PREF_FILE_PREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(Constants.SHARED_PREF_KEY_SEARCHING, true); editor.putBoolean(Constants.SHARED_PREF_KEY_ACCEPTED, false); editor.putLong(Constants.SHARED_PREF_KEY_QUERY_ID, -1); editor.apply(); Bundle extras = new Bundle(); extras.putDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LATITUDE, query.getQuery().getStartLocation().getLat()); extras.putDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LONGITUDE, query.getQuery().getStartLocation().getLng()); extras.putDouble(JoinDispatchFragment.KEY_DESTINATION_LATITUDE, query.getQuery().getDestinationLocation().getLat()); extras.putDouble(JoinDispatchFragment.KEY_DESTINATION_LONGITUDE, query.getQuery().getDestinationLocation().getLng()); extras.putInt(JoinDispatchFragment.KEY_MAX_WAITING_TIME, (int) query.getQuery().getMaxWaitingTimeInSeconds()); if (LifecycleHandler.isApplicationInForeground()) { Intent startingIntent = new Intent(Constants.EVENT_CHANGE_JOIN_UI); startingIntent.putExtras(extras); LocalBroadcastManager.getInstance(getApplicationContext()) .sendBroadcast(startingIntent); } else { // create notification for the user Intent startingIntent = new Intent(getApplicationContext(), MainActivity.class); startingIntent.putExtras(extras); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, startingIntent, PendingIntent.FLAG_UPDATE_CURRENT); createNotification(getString(R.string.found_matches_title), getString(R.string.found_matches_msg), GcmConstants.GCM_NOTIFICATION_FOUND_MATCHES_ID, contentIntent); } } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { Timber.e("Something went wrong when downloading join request: " + throwable.getMessage()); } }); }
From source file:com.nearnotes.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { // The action bar home/up action should open or close the drawer. ActionBarDrawerToggle will take care of this. return true; }/* w w w . ja v a2s . co m*/ // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_new: invalidateOptionsMenu(); NoteEdit newFragment1 = new NoteEdit(); Bundle args2 = new Bundle(); args2.putDouble("latitude", mLatitude); args2.putDouble("longitude", mLongitude); newFragment1.setArguments(args2); FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction(); transaction1.replace(R.id.fragment_container, newFragment1); transaction1.addToBackStack(null); transaction1.commit(); return true; case R.id.action_done: NoteEdit noteFrag = (NoteEdit) getSupportFragmentManager().findFragmentById(R.id.fragment_container); if (noteFrag.mRowId != null) Toast.makeText(this, "Note Saved", Toast.LENGTH_SHORT).show(); if (noteFrag.saveState() && !noteFrag.mNetworkTask) { invalidateOptionsMenu(); fetchAllNotes(); } else if (noteFrag.mNetworkTask) { mInvalidLocationDialog = customAlert("Location Running", "Still updating location", "Cancel", "OK"); mInvalidLocationDialog.show(); } else { mInvalidLocationDialog = customAlert("Location Invalid", "The location needs to be selected from the drop down list to be valid. An active internet connection is also required.", "Cancel Note", "Fix Location"); mInvalidLocationDialog.show(); } return true; case R.id.action_location: showDialogs(NOTE_LIST); return true; case R.id.action_sub_toggle: NoteEdit noteFrag1 = (NoteEdit) getSupportFragmentManager().findFragmentById(R.id.fragment_container); noteFrag1.toggleChecklist(); return true; case R.id.action_sub_delete: NoteEdit noteFrag2 = (NoteEdit) getSupportFragmentManager().findFragmentById(R.id.fragment_container); OverflowDialog newFragment = new OverflowDialog(); Bundle args = new Bundle(); if (noteFrag2.mRowId != null) { args.putLong("_id", noteFrag2.mRowId); args.putInt("confirmSelection", 1); } else args.putInt("confirmSelection", 2); newFragment.setArguments(args); if (getFragmentManager().findFragmentByTag("ConfirmDialog") == null) newFragment.show(getSupportFragmentManager(), "ConfirmDialog"); return true; case R.id.action_sub_clear: NoteEdit noteFrag3 = (NoteEdit) getSupportFragmentManager().findFragmentById(R.id.fragment_container); OverflowDialog newFragment2 = new OverflowDialog(); Bundle args3 = new Bundle(); if (noteFrag3.mRowId != null) { args3.putLong("_id", noteFrag3.mRowId); } args3.putInt("confirmSelection", 0); newFragment2.setArguments(args3); if (getFragmentManager().findFragmentByTag("ConfirmDialog") == null) newFragment2.show(getSupportFragmentManager(), "ConfirmDialog"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:biz.bokhorst.bpt.BPTService.java
private void sendLocation(Location location) { Bundle b = new Bundle(); b.putDouble("Latitude", location.getLatitude()); b.putDouble("Longitude", location.getLongitude()); b.putDouble("Altitude", location.getAltitude()); b.putFloat("Speed", location.getSpeed()); b.putFloat("Accuracy", location.getAccuracy()); b.putString("Provider", location.getProvider()); b.putLong("Time", location.getTime()); sendMessage(BackPackTrack.MSG_LOCATION, b); }
From source file:com.mahmoud.popularmovies.Activity.MainActivity.java
public void onArticleSelected(int position) { // Capture the article fragment from the activity layout MovieDetailsFragment movieDetailsFragment = (MovieDetailsFragment) getSupportFragmentManager() .findFragmentById(R.id.article_fragment); if (movieDetailsFragment != null) { // If article frag is available, we're in two-pane layout... isTwoPane = true;/*from ww w. j ava2s .c o m*/ // Call a method in the ArticleFragment to update its content movieDetailsFragment.updateMovieDetailsFragment(position, listMovies.get(position)); } else { // If the frag is not available, we're in the one-pane layout and must swap frags... isTwoPane = false; isHideMenu = true; invalidateOptionsMenu(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { setMoviesFragment(); isHideMenu = false; invalidateOptionsMenu(); getSupportActionBar().setDisplayHomeAsUpEnabled(false); switch (listType) { case 0: getSupportActionBar().setTitle(getResources().getString(R.string.action_most_popular)); break; case 1: getSupportActionBar().setTitle(getResources().getString(R.string.action_top_rated)); break; case 2: getSupportActionBar().setTitle(getResources().getString(R.string.action_my_favourites)); break; } } }); MoviesResultModel model = listMovies.get(position); // Create fragment and give it an argument for the selected article MovieDetailsFragment newFragment = new MovieDetailsFragment(); Bundle args = new Bundle(); args.putInt(Keys.INTENT_POSTER_ID, model.getId()); args.putString(Keys.INTENT_POSTER_ORIGINAL_TITLE, model.getOriginalTitle()); args.putString(Keys.INTENT_POSTER_THUMBNAIL, model.getPosterPath()); args.putString(Keys.INTENT_POSTER_RELEASE_DATE, model.getReleaseDate()); args.putDouble(Keys.INTENT_POSTER_VOTE_AVERAGE, model.getVoteAverage()); args.putString(Keys.INTENT_POSTER_OVERVIEW, model.getOverview()); newFragment.setArguments(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); getSupportActionBar().setTitle(model.getOriginalTitle()); } }