Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:it.gulch.linuxday.android.activities.TrackScheduleEventActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    events = new ArrayList<>();
    setupServices();/*from   w  w w.j a v a  2  s  .co m*/

    setContentView(R.layout.track_schedule_event);

    Bundle extras = getIntent().getExtras();
    track = (Track) extras.getSerializable(EXTRA_TRACK);

    progress = findViewById(R.id.progress);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new TrackScheduleEventAdapter(getSupportFragmentManager());
    pageIndicator = (PageIndicator) findViewById(R.id.indicator);

    if (savedInstanceState == null) {
        initialPosition = extras.getInt(EXTRA_POSITION, -1);
        pager.setAdapter(adapter);
        pageIndicator.setViewPager(pager);
    }

    ActionBar bar = getSupportActionBar();
    bar.setDisplayHomeAsUpEnabled(true);
    bar.setTitle(R.string.event_details);
    bar.setSubtitle(track.getTitle());

    // Enable Android Beam
    NfcUtils.setAppDataPushMessageCallbackIfAvailable(this, this);

    setCustomProgressVisibility(true);

    setupLoaderCallbacks();
}

From source file:com.by_syk.lib.nanoiconpack.fragment.IconsFragment.java

private void init() {
    Bundle bundle = getArguments();
    pageId = bundle.getInt("pageId");
    iconsGetter = (IconsGetter) bundle.getSerializable("iconsGetter");
    gridItemMode = bundle.getInt("mode", IconAdapter.MODE_ICON);

    RecyclerView recyclerView = (RecyclerView) contentView.findViewById(R.id.recycler_view);

    int[] gridNumAndWidth = calculateGridNumAndWidth();
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), gridNumAndWidth[0]));

    iconAdapter = new IconAdapter(getContext(), gridNumAndWidth[1]);
    iconAdapter.setMode(gridItemMode);//from   w ww  .  j av  a 2 s.  c o  m
    iconAdapter.setOnItemClickListener(new IconAdapter.OnItemClickListener() {
        @Override
        public void onClick(int pos, IconBean bean) {
            IconDialog.newInstance(bean, ExtraUtil.isFromLauncherPick(getActivity().getIntent()))
                    .show(getFragmentManager(), "iconDialog");
        }
    });
    recyclerView.setAdapter(iconAdapter);
}

From source file:com.orange.essentials.otb.OtbActivity.java

private void restoreFactory(Bundle savedInstanceState) {
    if (null != savedInstanceState && null != savedInstanceState.getSerializable(BADGES_KEY)) {
        Log.d(TAG, "Restoring factory from instanceState");
        List<TrustBadgeElement> badges = (List<TrustBadgeElement>) savedInstanceState
                .getSerializable(BADGES_KEY);
        List<Term> terms = (List<Term>) savedInstanceState.getSerializable(TERMS_KEY);
        TrustBadgeManager.INSTANCE.initialize(getApplicationContext(), badges, terms);
    }// w  ww .j  a  v a  2 s .  c  om
}

From source file:de.skubware.opentraining.activity.create_workout.SendExerciseFeedbackDialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mExercise = (ExerciseType) savedInstanceState.getSerializable(KEY_EXERCISE);
        mUserMessage = savedInstanceState.getString(KEY_USER_MESSAGE);
        mReasonSelected = savedInstanceState.getInt(KEY_EXERCISE_UPDATE_REASON);
    }/*from w  w  w .  ja va 2  s. co  m*/
}

From source file:app.presentation.foundation.views.BaseActivity.java

private void configureFragment() {
    Bundle bundle = getIntent().getExtras();
    if (bundle == null || bundle.getSerializable(Behaviour.FRAGMENT_CLASS_KEY) == null) {
        Log.w(BaseActivity.class.getSimpleName(),
                "When using " + BaseActivity.class.getSimpleName() + " you could supply"
                        + " a fragment which extends from " + BaseFragment.class.getSimpleName()
                        + " by extra argument in the intent" + " as value and " + Behaviour.FRAGMENT_CLASS_KEY
                        + " as key, but a <FrameLayout android:id=\"@id/fl_fragment\" .../>"
                        + " will be mandatory in your activity layout.");
        return;//  www  . ja  v  a 2 s.  co  m
    }

    Serializable serializable = bundle.getSerializable(Behaviour.FRAGMENT_CLASS_KEY);
    Class<BaseFragment> clazz = (Class<BaseFragment>) serializable;

    BaseFragment baseFragment = replaceFragment(clazz);
    Bundle bundleFragment = bundle.getBundle(Behaviour.BUNDLE_FOR_FRAGMENT);
    baseFragment.setArguments(bundleFragment);
}

From source file:net.reichholf.dreamdroid.loader.AsyncSimpleLoader.java

@SuppressWarnings("unchecked")
private void init(Context context, AbstractSimpleRequestHandler handler, Bundle args) {
    mHandler = handler;/*w ww. j a  va 2  s  . c om*/
    DreamDroid.loadCurrentProfile(context);
    mShc = new SimpleHttpClient();
    if (args != null && args.containsKey("params"))
        mParams = (ArrayList<NameValuePair>) args.getSerializable("params");
    else
        mParams = null;
}

From source file:com.microsoft.identity.client.testapp.CacheFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.fragment_cache, container, false);

    mLvCacheItems = (ListView) view.findViewById(R.id.lv_cache);
    final Bundle args = getArguments();
    final List<TokenListElement> elements = (List<TokenListElement>) args.getSerializable(ARG_LIST_CONTENTS);
    mLvCacheItems.setAdapter(createAdapter(elements));

    mProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);

    return view;//from w w  w .j a v a  2 s  . c  o  m
}

From source file:com.nbossard.packlist.gui.MassImportFragment.java

/**
 * During creation, if arguments have been supplied to the fragment
 * then parse those out.//from   w  w  w .  j  a v a  2s .  co m
 */
@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mIHostingActivity = (IMassImportFragmentActivity) getActivity();

    Bundle args = getArguments();
    mTrip = null;
    if (args != null) {
        mTrip = (Trip) args.getSerializable(BUNDLE_PAR_TRIP);

    } else {
        Log.e(TAG, "onCreate() : This should never occur");
    }
    if (mTrip == null) {
        mTrip = new Trip();
    }
}

From source file:com.task.ui.mvp.tasks.TasksActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Load previously saved state, if available.
    if (savedInstanceState != null) {
        TasksFilterType currentFiltering = (TasksFilterType) savedInstanceState
                .getSerializable(CURRENT_FILTERING_KEY);
        presenter.setFiltering(currentFiltering);
    }//from   w  w  w.  j a  v a2s.  c o m
}

From source file:edu.usf.cutr.opentripplanner.android.util.DateTimeDialog.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//ww w . ja v  a  2  s .co m
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Bundle bundle;

    if (savedInstanceState == null) {
        bundle = this.getArguments();
        Date tripDate = (Date) bundle.getSerializable(OTPApp.BUNDLE_KEY_TRIP_DATE);
        boolean arriveBy = bundle.getBoolean(OTPApp.BUNDLE_KEY_ARRIVE_BY);

        Calendar cal = Calendar.getInstance();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            if (cal.getTimeInMillis() < tripDate.getTime()) {
                //min time should preceede setted time and setted time will be set with 0 seconds, so we aloud one minute less
                pickerDate.setMinDate(cal.getTimeInMillis() - 60000);
            } else {
                //min time should preceede setted time and setted time will be set with 0 seconds, so we aloud one minute less
                pickerDate.setMinDate(tripDate.getTime() - 60000);
            }
        }

        cal.setTime(tripDate);

        if (!arriveBy) {
            spinScheduleType.setSelection(0);
        } else {
            spinScheduleType.setSelection(1);
        }
        pickerTime.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
        pickerTime.setCurrentMinute(cal.get(Calendar.MINUTE));
        pickerDate.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    } else {
        //TimePicker state needs to be saved manually because of this bug in Android that affects at least ICS: http://code.google.com/p/android/issues/detail?id=22754
        bundle = savedInstanceState;
        pickerTime.setCurrentHour(bundle.getInt(OTPApp.BUNDLE_KEY_TIMEPICKER_SAVED_HOUR));
        pickerTime.setCurrentMinute(bundle.getInt(OTPApp.BUNDLE_KEY_TIMEPICKER_SAVED_MINUTE));
    }

}