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:ca.rmen.android.poetassistant.main.PagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    Bundle bundle = (Bundle) state;
    if (bundle.containsKey(EXTRA_EXTRA_TAB)) {
        mExtraTab = (Tab) bundle.getSerializable(EXTRA_EXTRA_TAB);
        notifyDataSetChanged();//from  w ww . j a v a 2s.  com
    }
}

From source file:com.commov.app.dv.PhotoViewActivity.java

@SuppressWarnings("unchecked")
@Override/*  w ww . ja v a2 s.c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_photoview);
    mViewPager = (HackyViewPager) findViewById(R.id.hacky_viewpager);
    imgIndexInfo = (TextView) findViewById(R.id.img_index_info);
    saveIB = (ImageButton) findViewById(R.id.ib_save);
    saveIB.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //TODO
            //String imagePath = mImages.get(mViewPager.getCurrentItem());
            //Utils.Toast(PhotoViewActivity.this, "??");
        }

    });
    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
        finish();
    }
    Object obj = bundle.getSerializable(KEY_IMAGE_ARRAY);
    if (obj instanceof ArrayList == false) {
        finish();
    } else {
        mImages = (ArrayList<String>) obj;
    }
    if (mImages == null || mImages.size() <= 0) {
        finish();
    }
    int position = bundle.getInt(KEY_IMAGE_START_POSITION);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setAdapter(new SamplePagerAdapter(mImages));
    mViewPager.setCurrentItem(position, false);
    showImgIndexInfo(position, false);
}

From source file:br.com.moviecreator.views.home.HomeFragment.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);/*www.j  a  va2s .  co m*/

    Bundle bundle = this.getArguments();
    navigationListner = (AppNavigationListner) bundle.getSerializable("NAVIGATION_LISTNER");
}

From source file:com.robwilliamson.healthyesther.edit.MealEventActivity.java

@Override
protected void resumeFromIntentExtras(@Nonnull Bundle bundle) {
    final EventTable.Row event = Utils
            .checkNotNull((EventTable.Row) bundle.getSerializable(HealthDatabase.EVENT_TABLE.getName()));

    if (!event.getTypeId().equals(EventTypeTable.MEAL.getId())) {
        throw new EventTypeTable.BadEventTypeException(EventTypeTable.MEAL, event.getTypeId().getId());
    }//w ww .j a v a2  s  .  co  m

    getEventFragment().setRow(event);

    if (event.getConcretePrimaryKey() != null) {

        getExecutor().perform(new TransactionExecutor.Operation() {
            @Override
            public void doTransactionally(@Nonnull Database database, @Nonnull Transaction transaction) {
                mMealEvent = DatabaseAccessor.MEAL_EVENT_TABLE.select1(database, new Where() {
                    @Nullable
                    @Override
                    public String getWhere() {
                        return MealEventTable.EVENT_ID + " = " + event.getConcretePrimaryKey().getId();
                    }
                });

                getExecutor().perform(new TransactionExecutor.Operation() {
                    @Override
                    public void doTransactionally(@Nonnull Database database,
                            @Nonnull Transaction transaction) {
                        MealTable.Row meal = DatabaseAccessor.MEAL_TABLE.select1(database,
                                WhereContains.foreignKey(MealTable._ID,
                                        mMealEvent.getConcretePrimaryKey().getMealId().getId()));

                        getMealFragment().setRow(meal);
                    }
                });
            }
        });
    }
}

From source file:com.iopixel.watchface.wear.app.main.grid.WatchfaceGridFragment.java

@SuppressWarnings("unchecked")
@Override/*from   w w  w  . j a  v a2  s. c o  m*/
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mSelection = (Set<Long>) savedInstanceState.getSerializable("selection");
        mSendingPublicId = savedInstanceState.getString("sendingPublicId");
    }
    getLoaderManager().initLoader(0, null, this);
}

From source file:com.liferay.tasks.activity.AddTaskActivity.java

protected void initialize(Bundle extras) {
    if (extras == null) {
        return;//  ww w .  j av a 2 s.  c om
    }

    _update = extras.getBoolean(EXTRA_UPDATE, false);
    _task = (TaskModel) extras.getSerializable(EXTRA_TASK);

    if (!_update) {
        return;
    }

    View container = findViewById(R.id.status_bar_container);
    container.setVisibility(View.VISIBLE);

    int progress = _task.getStatus() - 1;
    TextView percentageView = (TextView) findViewById(R.id.percentage);
    percentageView.setText(String.valueOf(progress * 20) + "%");

    OnStatusChangedListener listener = new OnStatusChangedListener(percentageView);

    _titleView.setText(_task.getTitle());
    _seekBar.setProgress(progress);
    _seekBar.setOnSeekBarChangeListener(listener);
}

From source file:ch.scythe.hsr.DayFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (savedInstanceState != null && savedInstanceState.containsKey(FRAGMENT_PARAMETER_DATA)) {
        week = (UiWeek) (savedInstanceState.getSerializable(FRAGMENT_PARAMETER_DATA));
        weekDay = (Weekday) (savedInstanceState.getSerializable(FRAGMENT_PARAMETER_WEEKDAY));
    }//from   w w  w . java2  s .co  m

    layoutInflater = getLayoutInflater(savedInstanceState);
    View v = inflater.inflate(R.layout.timetable_day, container, false);
    TableLayout timeTable = (TableLayout) v.findViewById(R.id.timeTable);

    updateTable(timeTable);

    return v;
}

From source file:com.supremainc.biostar2.base.BaseActivity.java

@SuppressWarnings("unchecked")
protected <T> T getBundleData(String tag, Bundle bundle) {
    try {//from  ww  w  .  jav a 2  s.c om
        T result = (T) bundle.getSerializable(tag);
        if (BuildConfig.DEBUG) {
            if (result == null) {
                Log.e(TAG, "getExtraData null, tag:" + tag);
            }
        }
        return result;
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "getExtraData tag:" + tag + " error:" + e.getMessage());
        }
    }
    return null;
}

From source file:ca.rmen.android.networkmonitor.app.dialog.filechooser.FileChooserDialogFragment.java

/**
 * Returns the initial folder to open in the file chooser dialog.
 * First we look in the savedInstanceState, if any, to see if the user selected a folder before
 * rotating the screen./*from   w  w  w  . j  a v  a 2 s  .c om*/
 * Then we look in the arguments given when creating this dialog.
 * Then we fall back to the SD card folder.
 */
private File getInitialFolder(Bundle savedInstanceState) {
    File initialFolder = null;

    if (savedInstanceState != null) {
        initialFolder = (File) savedInstanceState.getSerializable(EXTRA_FILE_CHOOSER_INITIAL_FOLDER);
    }

    if (initialFolder == null) {
        initialFolder = (File) getArguments().getSerializable(EXTRA_FILE_CHOOSER_INITIAL_FOLDER);
    }

    if (initialFolder == null) {
        initialFolder = Environment.getExternalStorageDirectory();
    }

    // We need a folder to start with.
    if (!initialFolder.isDirectory()) {
        initialFolder = initialFolder.getParentFile();
    }
    return initialFolder;
}

From source file:com.boko.vimusic.menu.DeleteDialog.java

/**
 * {@inheritDoc}//from w ww .j  a  va  2s .c  om
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final String delete = getString(R.string.context_menu_delete);
    final Bundle arguments = getArguments();
    // Get the image cache key
    final String key = arguments.getString("cachekey");
    // Get the track(s) to delete
    mItemList = (Song[]) arguments.getSerializable("items");
    // Get the dialog title
    final String title = arguments.getString(Config.NAME);
    final String dialogTitle = getString(R.string.delete_dialog_title, title);
    // Initialize the image cache
    mFetcher = CommonUtils.getImageFetcher(getActivity());
    // Build the dialog
    return new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setMessage(R.string.cannot_be_undone)
            .setPositiveButton(delete, new OnClickListener() {

                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    // Remove the items from the image cache
                    mFetcher.removeFromCache(key);
                    // Delete the selected item(s)
                    MusicUtils.deleteTracks(getActivity(), mItemList);
                    if (getActivity() instanceof DeleteDialogCallback) {
                        ((DeleteDialogCallback) getActivity()).onDelete(mItemList);
                    }
                    dialog.dismiss();
                }
            }).setNegativeButton(R.string.cancel, new OnClickListener() {

                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.dismiss();
                }
            }).create();
}