List of usage examples for android.os Bundle putLong
public void putLong(@Nullable String key, long 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);/*w w w.j av a 2 s.com*/ 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:com.bexkat.feedlib.ItemDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.Theme_Sherlock);//from w w w.j ava 2 s . c om Bundle b = new Bundle(); Intent intent = getIntent(); long id = intent.getLongExtra(ItemTable._ID, 0); ItemTable table = new ItemTable(this); EnclosureTable et = new EnclosureTable(this); Item item = table.getItem(id); List<Enclosure> encs = et.getEnclosures(item); b.putString("title", item.getTitle()); b.putString("pubDate", item.getPubdate().toString()); b.putString("content", item.getContent()); b.putBoolean("fav", item.isFavorite()); b.putLong("id", id); try { b.putString("uri", item.getLink().toURI().toString()); } catch (URISyntaxException e) { try { b.putString("uri", encs.get(0).getURL().toURI().toString()); } catch (URISyntaxException e1) { Toast.makeText(this, "Article can't be loaded", Toast.LENGTH_SHORT).show(); finish(); } } Fragment f = getSupportFragmentManager().findFragmentById(android.R.id.content); if (f == null) { f = ItemDetailFragment.newInstance(b); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(android.R.id.content, f).commit(); } }
From source file:com.brq.wallet.activity.modern.ModernMain.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(LAST_SYNC, _lastSync); outState.putBoolean(APP_START, _isAppStart); }
From source file:com.android.calendar.month.SimpleDayPickerFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putLong(KEY_CURRENT_TIME, mSelectedDay.toMillis(true)); }
From source file:com.hijridatepicker.HijriDatePickerAndroidModule.java
private boolean parseOptionsWithKey(String ARG_KEY, ReadableMap options, Bundle args, Promise promise) { ReadableType argDateType = options.getType(ARG_KEY); if (ReadableType.String.equals(argDateType)) { try {/*from w w w .jav a2s .co m*/ long milliSeconds = 0; milliSeconds = (long) convertHijriDateToGregorianMilliseconds(options.getString(ARG_KEY)); args.putLong(ARG_KEY, milliSeconds); return true; } catch (PatternSyntaxException | IndexOutOfBoundsException | NumberFormatException e) { promise.reject(ERROR_PARSING_OPTIONS, "Exception happened while parsing " + ARG_KEY + " we only accept object of Date or String with the format \"dd-MM-yyyy\" in Hijri"); return false; } } else if (ReadableType.Number.equals(argDateType)) { args.putLong(ARG_KEY, (long) options.getDouble(ARG_KEY)); return true; } else { promise.reject(ERROR_PARSING_OPTIONS, "Exception happened while parsing " + ARG_KEY + " we only accept object of Date or String with the format \"dd-MM-yyyy\" in Hijri"); return false; } }
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; }//from w ww . j av a 2s .c om // 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:bucci.dev.freestyle.TimerActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { outState.putLong(TIME_LEFT_PARAM, timeLeft); outState.putString(START_PAUSE_STATE_PARAM, (String) playButton.getTag()); if (isExtraButtonShown) outState.putBoolean(SHOW_EXTRA_ROUND_BUTTON_PARAM, true); if (DEBUG)//from ww w.j a v a 2 s .c o m Log.i(TAG, "onSaveInstanceState(): " + outState.toString()); super.onSaveInstanceState(outState); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java
/** * Set up and launch the postCommentFragment when the user wishes to reply * to a comment. The fragment takes as input the index of the thread and the * comment object to reply to.//from ww w. j a v a2 s . c o m * * @param comment The Comment being replied to. * @param threadIndex The index of the ThreadComment where the reply is taking place. */ public void replyToComment(Comment comment, int threadIndex) { Fragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putParcelable("cmt", comment); bundle.putLong("id", threadIndex); fragment.setArguments(bundle); boolean fromFavs = false; Fragment fav = getFragmentManager().findFragmentByTag("favThrFragment"); if (fav != null) { fromFavs = true; } bundle.putBoolean("fromFavs", fromFavs); getFragmentManager().beginTransaction().replace(container, fragment, "postFrag").addToBackStack(null) .commit(); getFragmentManager().executePendingTransactions(); }
From source file:com.google.android.apps.authenticator.dataexport.Exporter.java
private Bundle getPreferencesBundle(SharedPreferences preferences) { Map<String, ?> preferencesMap = preferences.getAll(); if (preferencesMap == null) { preferencesMap = Collections.emptyMap(); }// www .j av a2s . co m Bundle result = new Bundle(); for (String key : preferencesMap.keySet()) { Object value = preferencesMap.get(key); if (value instanceof Boolean) { result.putBoolean(key, (Boolean) value); } else if (value instanceof Float) { result.putFloat(key, (Float) value); } else if (value instanceof Integer) { result.putInt(key, (Integer) value); } else if (value instanceof Long) { result.putLong(key, (Long) value); } else if (value instanceof String) { result.putString(key, (String) value); } else { // Can only be Set<String> at the moment (API Level 11+), which we don't use anyway. // Ignore this type of preference, since losing preferences on export is not lethal } } return result; }
From source file:com.lugia.timetable.SubjectDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_subject_detail); mWeekName = Utils.getWeekNameString(SubjectDetailActivity.this, Utils.SHORT_WEEK_NAME); mTimeName = Utils.getTimeNameString(SubjectDetailActivity.this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager()); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); PagerTabStrip tabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip); RelativeLayout headerLayout = (RelativeLayout) findViewById(R.id.layout_header); TextView subjectTitleTextView = (TextView) findViewById(R.id.text_subject_title); TextView lectureSectionTextView = (TextView) findViewById(R.id.text_lecture_section); TextView tutorialSectionTextView = (TextView) findViewById(R.id.text_tutorial_section); TextView creditHoursTextView = (TextView) findViewById(R.id.text_credit_hour); Bundle intentExtra = getIntent().getExtras(); SubjectList subjectList = SubjectList.getInstance(SubjectDetailActivity.this); String subjectCode = intentExtra.getString(EXTRA_SUBJECT_CODE); mSubject = subjectList.findSubject(subjectCode); String subjectDescription = mSubject.getSubjectDescription(); String lectureSection = mSubject.getLectureSection(); String tutorialSection = mSubject.getTutorialSection(); int colorIndex = mSubject.getColor(); int creditHours = mSubject.getCreditHours(); mColors = Utils.getForegroundColor(SubjectDetailActivity.this, colorIndex); mBackgrounds = Utils.getBackgroundDrawableResourceId(colorIndex); viewPager.setAdapter(adapter);/* ww w. j av a2 s .c o m*/ headerLayout.setBackgroundColor(mColors); tabStrip.setTextColor(mColors); tabStrip.setTabIndicatorColor(mColors); subjectTitleTextView.setText(subjectCode + " - " + subjectDescription); lectureSectionTextView.setText(lectureSection); tutorialSectionTextView.setText(tutorialSection); creditHoursTextView.setText(creditHours + " Credit Hours"); if (tutorialSection == null) tutorialSectionTextView.setVisibility(View.GONE); // user click the event reminder notification, show the event detail if (getIntent().getAction() != null && getIntent().getAction().equals(ACTION_VIEW_EVENT)) { long eventId = intentExtra.getLong(EXTRA_EVENT_ID, -1); Event event = mSubject.findEvent(eventId); if (event != null) { Bundle args = new Bundle(); args.putString(EventDetailDialogFragment.EXTRA_SUBJECT_CODE, mSubject.getSubjectCode()); args.putLong(EventDetailDialogFragment.EXTRA_EVENT_ID, event.getId()); // dont allow event editing in such situation args.putBoolean(EventDetailDialogFragment.EXTRA_EDITABLE, false); EventDetailDialogFragment f = EventDetailDialogFragment.newInstance(args); f.show(getFragmentManager(), event.getName()); } else Toast.makeText(SubjectDetailActivity.this, "No such event.", Toast.LENGTH_SHORT).show(); } }