List of usage examples for android.os Bundle getLong
public long getLong(String key)
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
/** * Current activity may be killed when the memory is low. Once it is killed, for another time * user load this activity, we should restore the former state *///from w w w. j av a 2 s.c o m @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(Intent.EXTRA_UID)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.putExtra(Intent.EXTRA_UID, savedInstanceState.getLong(Intent.EXTRA_UID)); if (!initActivityState(intent)) { finish(); return; } Log.d(TAG, "Restoring from killed activity"); } }
From source file:com.app.uafeed.fragment.EntryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry, container, false); mCancelFullscreenBtn = rootView.findViewById(R.id.cancelFullscreenBtn); mCancelFullscreenBtn.setOnClickListener(new View.OnClickListener() { @Override/*from www .j a v a2s. c o m*/ public void onClick(View view) { toggleFullScreen(); } }); mEntryPager = (ViewPager) rootView.findViewById(R.id.pager); //mEntryPager.setPageTransformer(true, new DepthPageTransformer()); mEntryPager.setAdapter(mEntryPagerAdapter); if (savedInstanceState != null) { mBaseUri = savedInstanceState.getParcelable(STATE_BASE_URI); mEntriesIds = savedInstanceState.getLongArray(STATE_ENTRIES_IDS); mInitialEntryId = savedInstanceState.getLong(STATE_INITIAL_ENTRY_ID); mCurrentPagerPos = savedInstanceState.getInt(STATE_CURRENT_PAGER_POS); mEntryPager.getAdapter().notifyDataSetChanged(); mEntryPager.setCurrentItem(mCurrentPagerPos); mEntryPagerAdapter.setScrollPercentage(savedInstanceState.getFloat(STATE_SCROLL_PERCENTAGE)); } mEntryPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { } @Override public void onPageSelected(int i) { mCurrentPagerPos = i; mEntryPagerAdapter.onPause(); // pause all webviews mEntryPagerAdapter.onResume(); // resume the current webview refreshUI(mEntryPagerAdapter.getCursor(i)); } @Override public void onPageScrollStateChanged(int i) { } }); return rootView; }
From source file:com.onesignal.NotificationExtenderService.java
private void processIntent(Intent intent) { Bundle bundle = intent.getExtras(); // Service maybe triggered without extras on some Android devices on boot. // https://github.com/OneSignal/OneSignal-Android-SDK/issues/99 if (bundle == null) { OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "No extras sent to NotificationExtenderService in its Intent!\n" + intent); return;//from w ww . j a v a 2 s.c o m } String jsonStrPayload = bundle.getString("json_payload"); if (jsonStrPayload == null) { OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "json_payload key is nonexistent from bundle passed to NotificationExtenderService: " + bundle); return; } try { currentJsonPayload = new JSONObject(jsonStrPayload); currentlyRestoring = bundle.getBoolean("restoring", false); if (bundle.containsKey("android_notif_id")) { currentBaseOverrideSettings = new OverrideSettings(); currentBaseOverrideSettings.androidNotificationId = bundle.getInt("android_notif_id"); } if (!currentlyRestoring && OneSignal.notValidOrDuplicated(this, currentJsonPayload)) return; restoreTimestamp = bundle.getLong("timestamp"); processJsonObject(currentJsonPayload, currentlyRestoring); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.nononsenseapps.notepad.MainActivity.java
private void leftOrTabletCreate(Bundle savedInstanceState) { if (savedInstanceState != null) { // currentListId = savedInstanceState.getLong(CURRENT_LIST_ID); listIdToSelect = savedInstanceState.getLong(CURRENT_LIST_ID); // currentListPos = savedInstanceState.getInt(CURRENT_LIST_POS); }//w ww .ja va2 s.c o m // Set up dropdown navigation final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Will set cursor in Loader // mSpinnerAdapter = new ExtrasCursorAdapter(this, // R.layout.actionbar_dropdown_item, null, // new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, // new int[] { android.R.id.text1 }, new int[] { -9, -8 }, // new int[] { R.string.show_from_all_lists, R.string.error_title }); mSpinnerAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null, new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0); mSpinnerAdapter.setDropDownViewResource(R.layout.actionbar_dropdown_item); // This will listen for navigation callbacks actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); // setContentView(R.layout.fragment_layout); // setUpList(); mSectionAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null, new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0); mSectionsPagerAdapter = new ListPagerAdapter(this, getFragmentManager(), mSectionAdapter); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.leftFragment); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int pos) { currentListId = mSectionsPagerAdapter.getItemId(pos); currentListPos = pos; actionBar.setSelectedNavigationItem(pos); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); // Set up navigation list // Set a default list to open if one is set if (listIdToSelect < 0) { listIdToSelect = getAList(this, -1); // Select the first note in that list to open also noteIdToSelect = getANote(this, listIdToSelect); } // Handle the intent first, so we know what to possibly select once // the // loader is finished beforeBoot = true; if (!resuming) { onNewIntent(getIntent()); } getLoaderManager().initLoader(0, null, this); }
From source file:com.ichi2.anki.CardTemplateEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { Timber.d("onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.card_template_editor_activity); // Load the args either from the intent or savedInstanceState bundle if (savedInstanceState == null) { // get model id mModelId = getIntent().getLongExtra("modelId", -1L); if (mModelId == -1) { Timber.e("CardTemplateEditor :: no model ID was provided"); finishWithoutAnimation();/* w ww .j a va 2 s . c o m*/ return; } // get id for currently edited card (optional) mNoteId = getIntent().getLongExtra("noteId", -1L); } else { mModelId = savedInstanceState.getLong("modelId"); mNoteId = savedInstanceState.getLong("noteId"); try { mModelBackup = new JSONObject(savedInstanceState.getString("modelBackup")); } catch (JSONException e) { Timber.e(e, "Malformed model in savedInstanceState"); } } // Disable the home icon Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); } startLoadingCollection(); }
From source file:com.viktorrudometkin.burramys.fragment.EntryFragment.java
@Override public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry, container, true); mCancelFullscreenBtn = rootView.findViewById(R.id.cancelFullscreenBtn); mCancelFullscreenBtn.setOnClickListener(new View.OnClickListener() { @Override//from w w w. ja va2 s .c om public void onClick(View view) { setImmersiveFullScreen(false); } }); mEntryPager = (ViewPager) rootView.findViewById(R.id.pager); //mEntryPager.setPageTransformer(true, new DepthPageTransformer()); mEntryPager.setAdapter(mEntryPagerAdapter); if (savedInstanceState != null) { mBaseUri = savedInstanceState.getParcelable(STATE_BASE_URI); mEntriesIds = savedInstanceState.getLongArray(STATE_ENTRIES_IDS); mInitialEntryId = savedInstanceState.getLong(STATE_INITIAL_ENTRY_ID); mCurrentPagerPos = savedInstanceState.getInt(STATE_CURRENT_PAGER_POS); mEntryPager.getAdapter().notifyDataSetChanged(); mEntryPager.setCurrentItem(mCurrentPagerPos); } mEntryPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { } @Override public void onPageSelected(int i) { mCurrentPagerPos = i; mEntryPagerAdapter.onPause(); // pause all webviews mEntryPagerAdapter.onResume(); // resume the current webview refreshUI(mEntryPagerAdapter.getCursor(i)); } @Override public void onPageScrollStateChanged(int i) { } }); disableSwipe(); return rootView; }
From source file:com.glanznig.beepme.view.ViewSampleActivity.java
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.view_sample_pager); pagerAdapter = new ViewSamplePagerAdapter(getSupportFragmentManager(), this); pager = (ViewPager) findViewById(R.id.view_sample_swipe_pager); pager.setAdapter(pagerAdapter);//from w ww . j a v a2 s. com // set gap between pages //pager.setPageMargin((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, this.getResources().getDisplayMetrics())); //pager.setPageMarginDrawable(R.drawable.swipe_filler); // listening for page changes SimpleOnPageChangeListener listener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { invalidateOptionsMenu(); getActionBar().setTitle(pagerAdapter.getPageTitle(position)); sampleId = pagerAdapter.getSampleId(position); TextView pos = (TextView) findViewById(R.id.sample_swipe_pos); pos.setText( String.format(getString(R.string.sample_swipe_pos), position + 1, pagerAdapter.getCount())); } }; pager.setOnPageChangeListener(listener); listener.onPageSelected(0); // due to a bug in listener implementation if (savedState != null) { if (savedState.getLong("sampleId") != 0) { sampleId = savedState.getLong("sampleId"); } } else { Bundle b = getIntent().getExtras(); if (b != null) { sampleId = b.getLong(getApplication().getClass().getPackage().getName() + ".SampleId"); } } }
From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java
private void restoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState.containsKey(ID_FEED_STRING) && savedInstanceState.containsKey(IS_FOLDER_BOOLEAN) && savedInstanceState.containsKey(OPTIONAL_FOLDER_ID)) { NewsListRecyclerAdapter adapter = new NewsListRecyclerAdapter(this, getNewsReaderDetailFragment().recyclerView, this); adapter.setTotalItemCount(savedInstanceState.getInt(LIST_ADAPTER_TOTAL_COUNT)); adapter.setCachedPages(savedInstanceState.getInt(LIST_ADAPTER_PAGE_COUNT)); getNewsReaderDetailFragment().getRecyclerView().setAdapter(adapter); StartDetailFragment(savedInstanceState.getLong(OPTIONAL_FOLDER_ID), savedInstanceState.getBoolean(IS_FOLDER_BOOLEAN), savedInstanceState.getLong(ID_FEED_STRING), false);/* w w w .ja v a 2s. c om*/ } }
From source file:com.carlrice.reader.fragment.EntryFragment.java
@Override public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry, container, true); mCancelFullscreenBtn = rootView.findViewById(R.id.cancelFullscreenBtn); mCancelFullscreenBtn.setOnClickListener(new View.OnClickListener() { @Override// w w w . j av a 2s .c o m public void onClick(View view) { setImmersiveFullScreen(false); } }); mEntryPager = (ViewPager) rootView.findViewById(R.id.pager); //mEntryPager.setPageTransformer(true, new DepthPageTransformer()); mEntryPager.setAdapter(mEntryPagerAdapter); if (savedInstanceState != null) { mBaseUri = savedInstanceState.getParcelable(STATE_BASE_URI); mEntriesIds = savedInstanceState.getLongArray(STATE_ENTRIES_IDS); mInitialEntryId = savedInstanceState.getLong(STATE_INITIAL_ENTRY_ID); mCurrentPagerPos = savedInstanceState.getInt(STATE_CURRENT_PAGER_POS); mEntryPager.getAdapter().notifyDataSetChanged(); mEntryPager.setCurrentItem(mCurrentPagerPos); } mEntryPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { } @Override public void onPageSelected(int i) { mCurrentPagerPos = i; mEntryPagerAdapter.onPause(); // pause all webviews mEntryPagerAdapter.onResume(); // resume the current webview refreshUI(mEntryPagerAdapter.getCursor(i)); } @Override public void onPageScrollStateChanged(int i) { } }); disableSwipe(); return rootView; }
From source file:be.billington.calendar.recurrencepicker.RecurrencePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity())); getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); boolean endCountHasFocus = false; if (savedInstanceState != null) { RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL); if (m != null) { mModel = m;/* w w w.j a v a 2 s.co m*/ } endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS); } else { Bundle b = getArguments(); if (b != null) { mTime.set(b.getLong(BUNDLE_START_TIME_MILLIS)); String tz = b.getString(BUNDLE_TIME_ZONE); if (!TextUtils.isEmpty(tz)) { mTime.timezone = tz; } mTime.normalize(false); // Time days of week: Sun=0, Mon=1, etc mModel.weeklyByDayOfWeek[mTime.weekDay] = true; String rrule = b.getString(BUNDLE_RRULE); if (!TextUtils.isEmpty(rrule)) { mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE; mRecurrence.parse(rrule); copyEventRecurrenceToModel(mRecurrence, mModel); // Leave today's day of week as checked by default in weekly view. if (mRecurrence.bydayCount == 0) { mModel.weeklyByDayOfWeek[mTime.weekDay] = true; } } } else { mTime.setToNow(); } } mResources = getResources(); mView = inflater.inflate(R.layout.recurrencepicker, container, true); final Activity activity = getActivity(); final Configuration config = activity.getResources().getConfiguration(); mRepeatSwitch = (Switch) mView.findViewById(R.id.repeat_switch); mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE); mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE : RecurrenceModel.STATE_NO_RECURRENCE; togglePickerOptions(); } }); mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner); mFreqSpinner.setOnItemSelectedListener(this); ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.recurrence_freq, R.layout.recurrencepicker_freq_item); freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item); mFreqSpinner.setAdapter(freqAdapter); mInterval = (EditText) mView.findViewById(R.id.interval); mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) { @Override void onChange(int v) { if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) { mModel.interval = v; updateIntervalText(); mInterval.requestLayout(); } } }); mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText); mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText); mEndNeverStr = mResources.getString(R.string.recurrence_end_continously); mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label); mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label); mEndSpinnerArray.add(mEndNeverStr); mEndSpinnerArray.add(mEndDateLabel); mEndSpinnerArray.add(mEndCountLabel); mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner); mEndSpinner.setOnItemSelectedListener(this); mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray, R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text); mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item); mEndSpinner.setAdapter(mEndSpinnerAdapter); mEndCount = (EditText) mView.findViewById(R.id.endCount); mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) { @Override void onChange(int v) { if (mModel.endCount != v) { mModel.endCount = v; updateEndCountText(); mEndCount.requestLayout(); } } }); mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount); mEndDateTextView = (TextView) mView.findViewById(R.id.endDate); mEndDateTextView.setOnClickListener(this); if (mModel.endDate == null) { mModel.endDate = new Time(mTime); switch (mModel.freq) { case RecurrenceModel.FREQ_DAILY: case RecurrenceModel.FREQ_WEEKLY: mModel.endDate.month += 1; break; case RecurrenceModel.FREQ_MONTHLY: mModel.endDate.month += 3; break; case RecurrenceModel.FREQ_YEARLY: mModel.endDate.year += 3; break; } mModel.endDate.normalize(false); } mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup); mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2); // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7 String[] dayOfWeekString = new DateFormatSymbols().getWeekdays(); mMonthRepeatByDayOfWeekStrs = new String[7][]; // from Time.SUNDAY as 0 through Time.SATURDAY as 6 mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun); mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon); mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues); mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed); mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs); mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri); mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat); // In Time.java day of week order e.g. Sun = 0 int idx = Utils.getFirstDayOfWeek(getActivity()); // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7 dayOfWeekString = new DateFormatSymbols().getShortWeekdays(); int numOfButtonsInRow1; int numOfButtonsInRow2; if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) { numOfButtonsInRow1 = 7; numOfButtonsInRow2 = 0; mWeekGroup2.setVisibility(View.GONE); mWeekGroup2.getChildAt(3).setVisibility(View.GONE); } else { numOfButtonsInRow1 = 4; numOfButtonsInRow2 = 3; mWeekGroup2.setVisibility(View.VISIBLE); // Set rightmost button on the second row invisible so it takes up // space and everything centers properly mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE); } /* First row */ for (int i = 0; i < 7; i++) { if (i >= numOfButtonsInRow1) { mWeekGroup.getChildAt(i).setVisibility(View.GONE); continue; } mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i); mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]); mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]); mWeekByDayButtons[idx].setOnCheckedChangeListener(this); if (++idx >= 7) { idx = 0; } } /* 2nd Row */ for (int i = 0; i < 3; i++) { if (i >= numOfButtonsInRow2) { mWeekGroup2.getChildAt(i).setVisibility(View.GONE); continue; } mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i); mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]); mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]); mWeekByDayButtons[idx].setOnCheckedChangeListener(this); if (++idx >= 7) { idx = 0; } } mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup); mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup); mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this); mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek); mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth); mDone = (Button) mView.findViewById(R.id.done); mDone.setOnClickListener(this); togglePickerOptions(); updateDialog(); if (endCountHasFocus) { mEndCount.requestFocus(); } return mView; }