Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

In this page you can find the example usage for android.os Bundle putParcelable.

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

Inserts a Parcelable value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.auth0.lock.util.LockFragmentBuilder.java

public Fragment enterpriseLoginWithSocial(Connection connection) {
    final Fragment fragment = loginWithSocial();
    Bundle bundle = fragment.getArguments() == null ? new Bundle() : fragment.getArguments();
    bundle.putParcelable(DatabaseLoginFragment.DEFAULT_CONNECTION_ARGUMENT, connection);
    fragment.setArguments(bundle);//from  w  ww  . j ava 2  s. com
    return fragment;
}

From source file:Main.java

public static Intent mapToIntent(Context context, Class<?> clazz, Map<String, Object> map) {
    Intent intent = new Intent(context, clazz);
    Bundle bundle = new Bundle();
    if (map != null && map.size() > 0) {
        for (String key : map.keySet()) {
            if (map.get(key) instanceof String) {
                bundle.putString(key, (String) map.get(key));
            } else if (map.get(key) instanceof Integer) {
                bundle.putInt(key, (Integer) map.get(key));
            } else if (map.get(key) instanceof Boolean) {
                bundle.putBoolean(key, (Boolean) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Long) {
                bundle.putLong(key, (Long) map.get(key));
            } else if (map.get(key) instanceof Float) {
                bundle.putFloat(key, (Float) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Serializable) {
                bundle.putSerializable(key, (Serializable) map.get(key));
            } else if (map.get(key) instanceof Parcelable) {
                bundle.putParcelable(key, (Parcelable) map.get(key));
            }//from  ww  w  . ja  va 2 s  .com
        }
    }
    return intent.putExtras(bundle);
}

From source file:com.codebutler.farebot.activities.AdvancedCardInfoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advanced_card_info);

    findViewById(R.id.error_button).setOnClickListener(new View.OnClickListener() {
        @Override/*from  www .ja v  a 2s. c om*/
        public void onClick(View v) {
            reportError();
        }
    });

    mCard = (Card) getIntent().getParcelableExtra(AdvancedCardInfoActivity.EXTRA_CARD);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabPagerAdapter(this, viewPager);

    Bundle args = new Bundle();
    args.putParcelable(AdvancedCardInfoActivity.EXTRA_CARD, mCard);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mCard.getCardType().toString() + " " + Utils.getHexString(mCard.getTagId(), "<error>"));

    if (mCard.getScannedAt().getTime() > 0) {
        String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(mCard.getScannedAt());
        String time = new SimpleDateFormat("h:m a", Locale.US).format(mCard.getScannedAt());
        actionBar.setSubtitle(String.format("Scanned on %s at %s.", date, time));
    }

    if (getIntent().hasExtra(EXTRA_ERROR)) {
        mError = (Exception) getIntent().getSerializableExtra(EXTRA_ERROR);
        if (mError instanceof UnsupportedCardException) {
            findViewById(R.id.unknown_card).setVisibility(View.VISIBLE);
        } else if (mError instanceof UnauthorizedException) {
            findViewById(R.id.unauthorized_card).setVisibility(View.VISIBLE);
            findViewById(R.id.load_keys).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    new AlertDialog.Builder(AdvancedCardInfoActivity.this)
                            .setMessage(R.string.add_key_directions)
                            .setPositiveButton(android.R.string.ok, null).show();
                }
            });
        } else {
            findViewById(R.id.error).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.error_text)).setText(Utils.getErrorMessage(mError));
        }
    }

    CardHasManufacturingInfo infoAnnotation = mCard.getClass().getAnnotation(CardHasManufacturingInfo.class);
    if (infoAnnotation == null || infoAnnotation.value()) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.hw_detail), CardHWDetailFragment.class, args);
    }

    CardRawDataFragmentClass annotation = mCard.getClass().getAnnotation(CardRawDataFragmentClass.class);
    Class rawDataFragmentClass = annotation.value();
    if (rawDataFragmentClass != null) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.data), rawDataFragmentClass, args);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java

@Override
public void onSignBrowserAdapterSignClicked(Sign sign) {
    Log.d(TAG, "onSignBrowserAdapterSignClicked() " + this.hashCode());
    final Intent intent = new Intent(this, SignSearchVideoActivity.class);
    final Bundle bundle = new Bundle();
    bundle.putString(SignSearchActivity.QUERY, this.query);
    bundle.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign);
    intent.putExtra(SignSearchVideoActivity.EXTRA, bundle);
    startActivity(intent);/*from ww  w  .  java 2  s.c  o  m*/
}

From source file:com.abhijitvalluri.android.fitnotifications.AppSettingsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(STATE_APP_SELECTION, mAppSelection);
    outState.putInt(STATE_START_TIME_HOUR, mStartTimeHour);
    outState.putInt(STATE_START_TIME_MINUTE, mStartTimeMinute);
    outState.putInt(STATE_STOP_TIME_HOUR, mStopTimeHour);
    outState.putInt(STATE_STOP_TIME_MINUTE, mStopTimeMinute);
    outState.putBoolean(STATE_DISCARD_EMPTY_NOTIFICATIONS, mDiscardEmptyNotifications);
    outState.putBoolean(STATE_ALL_DAY_SCHEDULE, mAllDaySchedule);

    super.onSaveInstanceState(outState);
}

From source file:com.appniche.android.sunshine.app.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLocation = Utility.getPreferredLocation(this);
    Uri contentUri = getIntent() != null ? getIntent().getData() : null;

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w  ww.  j a v  a2 s . com
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    if (findViewById(R.id.weather_detail_container) != null) {
        // 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.
        mTwoPane = true;
        // In two-pane mode, show the detail view in this activity by
        // adding or replacing the detail fragment using a
        // fragment transaction.
        if (savedInstanceState == null) {
            DetailFragment fragment = new DetailFragment();
            if (contentUri != null) {
                Bundle args = new Bundle();
                args.putParcelable(DetailFragment.DETAIL_URI, contentUri);
                fragment.setArguments(args);
            }
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG).commit();
        }
    } else {
        mTwoPane = false;
        getSupportActionBar().setElevation(0f);
    }

    ForecastFragment forecastFragment = ((ForecastFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_forecast));
    forecastFragment.setUseTodayLayout(!mTwoPane);
    if (contentUri != null) {
        forecastFragment.setInitialSelectedDate(WeatherContract.WeatherEntry.getDateFromUri(contentUri));
    }

    SunshineSyncAdapter.initializeSyncAdapter(this);

    // If Google Play Services is up to date, we'll want to register GCM. If it is not, we'll
    // skip the registration and this device will not receive any downstream messages from
    // our fake server. Because weather alerts are not a core feature of the app, this should
    // not affect the behavior of the app, from a user perspective.
    if (checkPlayServices()) {
        // Because this is the initial creation of the app, we'll want to be certain we have
        // a token. If we do not, then we will start the IntentService that will register this
        // application with GCM.
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        boolean sentToken = sharedPreferences.getBoolean(SENT_TOKEN_TO_SERVER, false);
        if (!sentToken) {
            Intent intent = new Intent(this, RegistrationIntentService.class);
            startService(intent);
        }
    }
}

From source file:at.jclehner.rxdroid.DrugSupplyEditFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);

    FractionInputDialog dialog = getDialog();
    if (dialog != null)
        savedInstanceState.putParcelable("value", dialog.getValue());
}

From source file:com.krayzk9s.imgurholo.tools.CommentsAsync.java

@Override
protected void onPostExecute(Void aVoid) {
    if (galleryAlbumData != null) {
        SingleImageFragment fragment = new SingleImageFragment();
        Bundle bundle = new Bundle();
        bundle.putBoolean("gallery", true);
        JSONParcelable data = new JSONParcelable();
        data.setJSONObject(galleryAlbumData);
        bundle.putParcelable("imageData", data);
        fragment.setArguments(bundle);//from  w ww.  ja va  2  s.co m
        if (activity != null) {
            FragmentManager fragmentManager = activity.getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            FrameLayout displayFrag = (FrameLayout) activity.findViewById(R.id.frame_layout_child);
            if (displayFrag != null)
                fragmentTransaction.replace(R.id.frame_layout_child, fragment).commitAllowingStateLoss();
            else
                fragmentTransaction.replace(R.id.frame_layout, fragment).commitAllowingStateLoss();
        }
    }
}

From source file:org.ohmage.auth.Authenticator.java

@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) {
    // TODO: decide if we should allow more than one account, and if not, make it clear to the
    // user that they need to logout and login with a new account

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:ca.marklauman.dominionpicker.SupplyActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(KEY_SUPPLY, supply);
}