List of usage examples for android.os Bundle getLong
public long getLong(String key, long defaultValue)
From source file:com.oakonell.dndcharacter.views.character.CharacterActivity.java
@DebugLog private void loadCharacter(@Nullable Bundle savedInstanceState) { long savedId = -1; // try to get a character id from // 1. the saved bundle if (savedInstanceState != null) { savedId = savedInstanceState.getLong(CHARACTER_ID, -1); }//from w ww .j a va 2 s.c o m // 2. the passed intent if (savedId == -1 && getIntent().getExtras() != null) { savedId = getIntent().getExtras().getLong(CHARACTER_ID, -1); if (savedId == -1) { if (getIntent().getExtras().getBoolean(CREATE_CHARACTER)) { createNewCharacter(); loading.setVisibility(View.GONE); return; } } } // 3. find the last viewed character if (savedId == -1) { SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); savedId = sharedpreferences.getLong(CHARACTER_ID, -1); } if (savedId == -1) { createNewCharacter(); loading.setVisibility(View.GONE); return; } loadCharacter(savedId); }
From source file:de.ub0r.android.callmeter.ui.PlansFragment.java
/** * {@inheritDoc}/*from ww w. jav a2 s. co m*/ */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); Bundle args = getArguments(); if (args == null) { now = -1L; uid = -1; } else { now = args.getLong("now", -1L); uid = args.getInt("uid", -1); } }
From source file:com.xandy.calendar.agenda.AgendaFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int screenWidth = mActivity.getResources().getDisplayMetrics().widthPixels; View v = inflater.inflate(R.layout.agenda_fragment, null); mAgendaListView = (AgendaListView) v.findViewById(R.id.agenda_events_list); mAgendaListView.setClickable(true);//from w w w . j a va 2 s .c om if (savedInstanceState != null) { long instanceId = savedInstanceState.getLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, -1); if (instanceId != -1) { mAgendaListView.setSelectedInstanceId(instanceId); } } View eventView = v.findViewById(R.id.agenda_event_info); if (!mShowEventDetailsWithAgenda) { eventView.setVisibility(View.GONE); } View topListView; // Set adapter & HeaderIndexer for StickyHeaderListView StickyHeaderListView lv = (StickyHeaderListView) v.findViewById(R.id.agenda_sticky_header_list); if (lv != null) { Adapter a = mAgendaListView.getAdapter(); lv.setAdapter(a); if (a instanceof HeaderViewListAdapter) { mAdapter = (AgendaWindowAdapter) ((HeaderViewListAdapter) a).getWrappedAdapter(); lv.setIndexer(mAdapter); lv.setHeaderHeightListener(mAdapter); } else if (a instanceof AgendaWindowAdapter) { mAdapter = (AgendaWindowAdapter) a; lv.setIndexer(mAdapter); lv.setHeaderHeightListener(mAdapter); } else { Log.wtf(TAG, "Cannot find HeaderIndexer for StickyHeaderListView"); } // Set scroll listener so that the date on the ActionBar can be set while // the user scrolls the view lv.setOnScrollListener(this); lv.setHeaderSeparator(getResources().getColor(R.color.agenda_list_separator_color), 1); topListView = lv; } else { topListView = mAgendaListView; } // Since using weight for sizing the two panes of the agenda fragment causes the whole // fragment to re-measure when the sticky header is replaced, calculate the weighted // size of each pane here and set it if (!mShowEventDetailsWithAgenda) { ViewGroup.LayoutParams params = topListView.getLayoutParams(); params.width = screenWidth; topListView.setLayoutParams(params); } else { ViewGroup.LayoutParams listParams = topListView.getLayoutParams(); listParams.width = screenWidth * 4 / 10; topListView.setLayoutParams(listParams); ViewGroup.LayoutParams detailsParams = eventView.getLayoutParams(); detailsParams.width = screenWidth - listParams.width; eventView.setLayoutParams(detailsParams); } return v; }
From source file:com.brq.wallet.activity.export.BackupToPdfActivity.java
/** * Called when the activity is first created. *//*from w ww .j a v a 2 s. c om*/ @Override public void onCreate(Bundle savedInstanceState) { this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.export_to_pdf_activity); Utils.preventScreenshots(this); _mbwManager = MbwManager.getInstance(this.getApplication()); // Load saved state if (savedInstanceState != null) { _backupTime = savedInstanceState.getLong("backupTime", 0); _password = savedInstanceState.getString("password"); _isPdfGenerated = savedInstanceState.getBoolean("isPdfGenerated"); } if (_backupTime == 0) { _backupTime = new Date().getTime(); } if (_password == null) { _password = MrdExport.V1.generatePassword(new AndroidRandomSource()).toUpperCase(Locale.US); } _fileName = getExportFileName(_backupTime); _taskExecutionServiceController = new TaskExecutionServiceController(); // Populate Password ((TextView) findViewById(R.id.tvPassword)).setText(splitPassword(_password)); // Populate Checksum char checksumChar = MrdExport.V1.calculatePasswordChecksum(_password); String checksumString = (" " + checksumChar).toUpperCase(Locale.US); ((TextView) findViewById(R.id.tvChecksum)).setText(checksumString); findViewById(R.id.btSharePdf).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { sharePdf(); } }); _progressUpdater = new ProgressUpdater(); }
From source file:es.uniovi.imovil.fcrtrainer.BaseExerciseFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState == null) { return;/*from w ww . j a va2 s . c om*/ } mIsPlaying = savedInstanceState.getBoolean(STATE_IS_PLAYING); if (mIsPlaying) { setGameInfoPanelVisibility(View.VISIBLE); mScore = savedInstanceState.getInt(STATE_SCORE); updateScore(); showLevel(); mDurationMs = savedInstanceState.getLong(STATE_DURATION_TIME_MS, DEFAULT_GAME_DURATION_MS); long consumedTime = savedInstanceState.getLong(STATE_CONSUMED_TIME_MS, mDurationMs); mStartMs = System.currentTimeMillis() - consumedTime; printRemainingTime(); mTimerHandler.postDelayed(mUpdateTimeTask, CLOCK_UPDATE_PERIOD_MS); } }
From source file:de.spiritcroc.ownlog.ui.fragment.LogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mRestoreListPosition = savedInstanceState.getInt(KEY_LIST_POSITION, -1); mNextFilterId = savedInstanceState.getLong(KEY_FILTER_ID, mNextFilterId); mLayoutContinuous = savedInstanceState.getBoolean(KEY_LAYOUT_CONTINUOUS, mLayoutContinuous); }//ww w . j a va 2s . c o m setHasOptionsMenu(true); loadContent(true); IntentFilter broadcastIntentFilter = new IntentFilter(); broadcastIntentFilter.addAction(Constants.EVENT_LOG_UPDATE); broadcastIntentFilter.addAction(Constants.EVENT_TAG_UPDATE); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mBroadcastReceiver, broadcastIntentFilter); }
From source file:com.ultramegatech.ey.ElementListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = getContext(); if (context == null) { return;//w w w . j a va 2s. c om } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(this); if (savedInstanceState != null) { mSort = savedInstanceState.getInt(KEY_SORT, mSort); mSortReverse = savedInstanceState.getBoolean(KEY_SORT_REVERSE, mSortReverse); mFilter = savedInstanceState.getString(KEY_FILTER); mActivatedItem = savedInstanceState.getLong(KEY_ACTIVATED_ITEM, mActivatedItem); } mAdapter = new ElementListAdapter(context); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); setActivatedPosition(mAdapter.getItemPosition(mActivatedItem)); } }); mAdapter.getFilter().filter(mFilter); mAdapter.setSort(mSort, mSortReverse); setListAdapter(mAdapter); setupFilter(); setupSort(); }
From source file:com.android.calendar.agenda.AgendaFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int screenWidth = mActivity.getResources().getDisplayMetrics().widthPixels; View v = inflater.inflate(R.layout.agenda_fragment, null); mAgendaListView = (AgendaListView) v.findViewById(R.id.agenda_events_list); mAgendaListView.setClickable(true);/*from www .j a v a 2s .c om*/ if (savedInstanceState != null) { long instanceId = savedInstanceState.getLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, -1); if (instanceId != -1) { mAgendaListView.setSelectedInstanceId(instanceId); } } View eventView = v.findViewById(R.id.agenda_event_info); if (!mShowEventDetailsWithAgenda) { eventView.setVisibility(View.GONE); } View topListView; // Set adapter & HeaderIndexer for StickyHeaderListView StickyHeaderListView lv = (StickyHeaderListView) v.findViewById(R.id.agenda_sticky_header_list); if (lv != null) { Adapter a = mAgendaListView.getAdapter(); lv.setAdapter(a); if (a instanceof HeaderViewListAdapter) { mAdapter = (AgendaWindowAdapter) ((HeaderViewListAdapter) a).getWrappedAdapter(); if (mLaunchedInShareMode) { mAdapter.launchInShareMode(true, mShouldSelectSingleEvent); mAgendaListView.launchInShareMode(true, mShouldSelectSingleEvent); if (mShareEventListener != null) { mAgendaListView.setShareEventListener(mShareEventListener); } } lv.setIndexer(mAdapter); lv.setHeaderHeightListener(mAdapter); } else if (a instanceof AgendaWindowAdapter) { mAdapter = (AgendaWindowAdapter) a; lv.setIndexer(mAdapter); lv.setHeaderHeightListener(mAdapter); } else { Log.wtf(TAG, "Cannot find HeaderIndexer for StickyHeaderListView"); } // Set scroll listener so that the date on the ActionBar can be set while // the user scrolls the view lv.setOnScrollListener(this); lv.setHeaderSeparator(getResources().getColor(R.color.agenda_list_separator_color), 1); topListView = lv; } else { topListView = mAgendaListView; } // Since using weight for sizing the two panes of the agenda fragment causes the whole // fragment to re-measure when the sticky header is replaced, calculate the weighted // size of each pane here and set it if (!mShowEventDetailsWithAgenda) { ViewGroup.LayoutParams params = topListView.getLayoutParams(); params.width = screenWidth; topListView.setLayoutParams(params); } else { ViewGroup.LayoutParams listParams = topListView.getLayoutParams(); listParams.width = screenWidth * 4 / 10; topListView.setLayoutParams(listParams); ViewGroup.LayoutParams detailsParams = eventView.getLayoutParams(); detailsParams.width = screenWidth - listParams.width; eventView.setLayoutParams(detailsParams); } return v; }
From source file:com.sysdata.demo.accordionview.SampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample); mRecyclerView = (FancyAccordionView) findViewById(R.id.alarms_recycler_view); // bind the factory to create view holder for item collapsed mRecyclerView.setCollapsedViewHolderFactory( SampleCollapsedViewHolder.Factory.create(R.layout.sample_layout_collapsed), mListener); // bind the factory to create view holder for item expanded mRecyclerView.setExpandedViewHolderFactory( SampleExpandedViewHolder.Factory.create(R.layout.sample_layout_expanded), mListener); // restore the expanded item from state if (savedInstanceState != null) { mRecyclerView.setExpandedItemId(savedInstanceState.getLong(KEY_EXPANDED_ID, Item.INVALID_ID)); }/*ww w . j a v a 2 s . co m*/ // populate RecyclerView with mock data loadData(); }
From source file:com.csipsimple.ui.filters.AccountFiltersListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ListView lv = getListView();//from w ww. j a v a 2s . co m //getListView().setSelector(R.drawable.transparent); lv.setCacheColorHint(Color.TRANSPARENT); // View management View detailsFrame = getActivity().findViewById(R.id.details); dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE; if (savedInstanceState != null) { // Restore last state for checked position. curCheckFilterId = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID); //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD); } setListShown(false); if (mAdapter == null) { if (mHeaderView != null) { lv.addHeaderView(mHeaderView, null, true); } mAdapter = new AccountFiltersListAdapter(getActivity(), null); //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container)); //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE); setListAdapter(mAdapter); registerForContextMenu(lv); lv.setVerticalFadingEdgeEnabled(true); } if (dualPane) { // In dual-pane mode, the list view highlights the selected item. Log.d("lp", "dual pane mode"); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); //lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT); lv.setVerticalScrollBarEnabled(false); lv.setFadingEdgeLength(50); updateCheckedItem(); // Make sure our UI is in the correct state. //showDetails(curCheckPosition, curCheckWizard); } else { //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT); lv.setVerticalScrollBarEnabled(true); lv.setFadingEdgeLength(100); } }