List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.codebutler.farebot.activity.CardInfoActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_card_info); final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabPagerAdapter(this, viewPager); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.loading); new AsyncTask<Void, Void, Void>() { private Exception mException; public boolean mSpeakBalanceEnabled; @Override/*from ww w .ja v a 2 s .com*/ protected Void doInBackground(Void... voids) { try { Uri uri = getIntent().getData(); Cursor cursor = getContentResolver().query(uri, null, null, null, null); startManagingCursor(cursor); cursor.moveToFirst(); String data = cursor.getString(cursor.getColumnIndex(CardsTableColumns.DATA)); mCard = Card.fromXml(FareBotApplication.getInstance().getSerializer(), data); mTransitData = mCard.parseTransitData(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(CardInfoActivity.this); mSpeakBalanceEnabled = prefs.getBoolean("pref_key_speak_balance", false); } catch (Exception ex) { mException = ex; } return null; } @Override protected void onPostExecute(Void aVoid) { findViewById(R.id.loading).setVisibility(View.GONE); findViewById(R.id.pager).setVisibility(View.VISIBLE); if (mException != null) { if (mCard == null) { Utils.showErrorAndFinish(CardInfoActivity.this, mException); } else { Log.e("CardInfoActivity", "Error parsing transit data", mException); showAdvancedInfo(mException); finish(); } return; } if (mTransitData == null) { showAdvancedInfo(new UnsupportedCardException()); finish(); return; } String titleSerial = (mTransitData.getSerialNumber() != null) ? mTransitData.getSerialNumber() : Utils.getHexString(mCard.getTagId(), ""); actionBar.setTitle(mTransitData.getCardName() + " " + titleSerial); Bundle args = new Bundle(); args.putString(AdvancedCardInfoActivity.EXTRA_CARD, mCard.toXml(FareBotApplication.getInstance().getSerializer())); args.putParcelable(EXTRA_TRANSIT_DATA, mTransitData); if (mTransitData instanceof UnauthorizedClassicTransitData) { mTabsAdapter.addTab(actionBar.newTab(), UnauthorizedCardFragment.class, args); return; } if (mTransitData.getBalanceString() != null) { mTabsAdapter.addTab(actionBar.newTab().setText(R.string.balance), CardBalanceFragment.class, args); } if (mTransitData.getTrips() != null || mTransitData.getRefills() != null) { mTabsAdapter.addTab(actionBar.newTab().setText(R.string.history), CardTripsFragment.class, args); } if (mTransitData.getSubscriptions() != null) { mTabsAdapter.addTab(actionBar.newTab().setText(R.string.subscriptions), CardSubscriptionsFragment.class, args); } if (mTransitData.getInfo() != null) { mTabsAdapter.addTab(actionBar.newTab().setText(R.string.info), CardInfoFragment.class, args); } if (mTabsAdapter.getCount() > 1) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } if (mTransitData.hasUnknownStations()) { findViewById(R.id.need_stations).setVisibility(View.VISIBLE); } boolean speakBalanceRequested = getIntent().getBooleanExtra(SPEAK_BALANCE_EXTRA, false); if (mSpeakBalanceEnabled && speakBalanceRequested) { mTTS = new TextToSpeech(CardInfoActivity.this, mTTSInitListener); } if (savedInstanceState != null) { viewPager.setCurrentItem(savedInstanceState.getInt(KEY_SELECTED_TAB, 0)); } } }.execute(); }
From source file:com.akop.bach.fragment.playstation.GamesFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mAccount != null) { outState.putParcelable("account", mAccount); outState.putLong("currentId", mTitleId); }/*from ww w .java2s .c o m*/ }
From source file:com.appsimobile.appsii.module.home.appwidget.WidgetChooserActivity.java
@Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable("providerInfo", mSelectedAppWidgetProviderInfo); outState.putInt("selection", mSingleSelectionDecoration.mSelectedPosition); outState.putInt("pendingAppWidgetId", mPendingAddWidgetId); }
From source file:com.dahl.brendan.wordsearch.view.controller.WordSearchActivityController.java
public void saveState(Bundle outState) { if (outState != null) { this.timePause(); outState.putLong(BUNDLE_TIME, this.timeSum); outState.putParcelable(BUNDLE_GRID, this.grid); if (this.hs != null) { outState.putBundle(BUNDLE_HIGH_SCORE, this.hs.toBundle()); }//from w ww . j a v a2 s . c o m } }
From source file:com.auth0.lock.util.LockFragmentBuilder.java
private Fragment enterpriseLoginWithConnection(Connection connection, boolean isRoot) { final DatabaseLoginFragment fragment = new DatabaseLoginFragment(); Bundle arguments = new Bundle(); arguments.putSerializable(BaseTitledFragment.AUTHENTICATION_PARAMETER_ARGUMENT, new HashMap<>(lock.getAuthenticationParameters())); arguments.putBoolean(BaseTitledFragment.AUTHENTICATION_USES_EMAIL_ARGUMENT, lock.shouldUseEmail()); if (connection != null) { arguments.putParcelable(DatabaseLoginFragment.AD_ENTERPRISE_CONNECTION_ARGUMENT, connection); }//from w w w .ja v a 2 s. c om arguments.putBoolean(DatabaseLoginFragment.IS_MAIN_LOGIN_ARGUMENT, isRoot); fragment.setArguments(arguments); return fragment; }
From source file:com.marianhello.bgloc.LocationService.java
public void handleStationary(BackgroundLocation location) { log.debug("New stationary {}", location.toString()); Bundle bundle = new Bundle(); bundle.putParcelable("location", location); Message msg = Message.obtain(null, MSG_ON_STATIONARY); msg.setData(bundle);//from w w w . j av a 2 s.c om sendClientMessage(msg); }
From source file:com.quarterfull.newsAndroid.NewsReaderDetailFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(LAYOUT_MANAGER_STATE, getLayoutManager().onSaveInstanceState()); }
From source file:fr.eyal.lib.data.service.DataLibService.java
/** * Send the result of a request to the linked {@link ServiceHelper} * /* www. j a va 2 s .co m*/ * @param request the request * @param response the response * @param code the status of the request */ protected void sendResult(final DataLibRequest request, final BusinessResponse response, final int code) { Out.d(TAG, "sendResult"); final Intent intent = request.intent; final ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra(INTENT_EXTRA_RECEIVER); if (receiver != null) { final Bundle b = new Bundle(); if (response != null && response.response != null) { //if the Business Object have to be transmit inside the Bundle if (request.isParcelableMethodEnabled()) b.putParcelable(ServiceHelper.RECEIVER_EXTRA_RESULT, response.response); //we add the request id to the response if (response.response instanceof ResponseBusinessObjectDAO) { ResponseBusinessObjectDAO r = (ResponseBusinessObjectDAO) response.response; b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, r._id); } else { //in case of no data cache, we set an invalid ID b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, BusinessObjectDAO.ID_INVALID); } } else { Out.e(TAG, "Unfined response"); } //we copy the content of the response in the intent's bundle b.putInt(ServiceHelper.RECEIVER_EXTRA_REQUEST_ID, intent.getIntExtra(INTENT_EXTRA_REQUEST_ID, -1)); b.putInt(ServiceHelper.RECEIVER_EXTRA_WEBSERVICE_TYPE, intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1)); b.putInt(ServiceHelper.RECEIVER_EXTRA_RETURN_CODE, response.returnCode); b.putInt(ServiceHelper.RECEIVER_EXTRA_RESULT_CODE, response.status); b.putString(ServiceHelper.RECEIVER_EXTRA_RESULT_MESSAGE, ""); receiver.send(code, b); } }
From source file:com.android.messaging.ui.conversationlist.ConversationListFragment.java
@Override public void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); if (mListState != null) { outState.putParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY, mListState); }//from ww w . j av a2 s .c o m }
From source file:com.ant.sunshine.app.activities.MainActivity.java
@Override public void onItemSelected(Uri contentUri, ForecastAdapter.ForecastAdapterViewHolder vh) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle args = new Bundle(); args.putParcelable(DetailFragment.DETAIL_URI, contentUri); DetailFragment fragment = new DetailFragment(); fragment.setArguments(args);//from w w w . java 2 s.com getFragmentManager().beginTransaction() .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG).commit(); } else { Intent intent = new Intent(this, DetailActivity.class).setData(contentUri); ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, new Pair<View, String>(vh.mIconView, getString(R.string.detail_icon_transition_name))); ActivityCompat.startActivity(this, intent, activityOptions.toBundle()); } }