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:de.grobox.transportr.ui.TimeDateFragment.java

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

    if (savedInstanceState == null) {
        if (getArguments() == null)
            throw new IllegalArgumentException("Arguments missing");
        calendar = (Calendar) getArguments().getSerializable(CALENDAR);
        if (calendar == null)
            throw new IllegalArgumentException("Calendar missing");
    } else {//from   w  w  w . j a  v a 2  s  .  c  o m
        calendar = (Calendar) savedInstanceState.getSerializable(CALENDAR);
    }
}

From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java

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

    if (savedInstanceState != null) {
        viewType = (BookmarkViewType) savedInstanceState.getSerializable(STATE_VIEWTYPE);
    }//w  w w . j av a 2s.  co m

    base = (FragmentBaseActivity) getActivity();

    container = (View) getView().findViewById(R.id.view_bookmark_container);
    mBookmarkView = (ScrollView) getView().findViewById(R.id.bookmark_scroll_view);
    mTitle = (TextView) getView().findViewById(R.id.view_bookmark_title);
    mUrl = (TextView) getView().findViewById(R.id.view_bookmark_url);
    mNotes = (TextView) getView().findViewById(R.id.view_bookmark_notes);
    mTags = (TextView) getView().findViewById(R.id.view_bookmark_tags);
    mTime = (TextView) getView().findViewById(R.id.view_bookmark_time);
    mUsername = (TextView) getView().findViewById(R.id.view_bookmark_account);
    mIcon = (ImageView) getView().findViewById(R.id.view_bookmark_icon);
    mWebContent = (WebView) getView().findViewById(R.id.web_view);
    readSection = getView().findViewById(R.id.read_bookmark_section);
    readTitle = (TextView) getView().findViewById(R.id.read_bookmark_title);
    readView = (TextView) getView().findViewById(R.id.read_view);

    mWebContent.getSettings().setJavaScriptEnabled(true);
    readView.setMovementMethod(LinkMovementMethod.getInstance());

    setHasOptionsMenu(true);
    //setRetainInstance(true);
}

From source file:com.example.android.foodrecipes.app.RecipeDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle args = getArguments();
    if (args != null) {
        mRecipeExternalId = args.getString(RECIPE_EXTERNAL_ID);
        RecipesLoaderAdapterFactory factory = (RecipesLoaderAdapterFactory) args
                .getSerializable(LOADER_ADAPTER_FACTORY);
        if (factory != null)
            mLoaderAdapter = factory.newLoaderAdapter();

        mExecuteRecipeRemove = args.getBoolean(EXECUTE_RECIPE_REMOVE, false);
        mTwoPane = args.getBoolean(TWO_PANE, false);
    }//from  ww  w . j ava2 s.  c o m

    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    mRecipeTitle = (TextView) rootView.findViewById(R.id.detail_recipe_title);
    mRecipeImage = (SquareImageView) rootView.findViewById(R.id.detail_recipe_picture);
    mSocialRank = (RatingBar) rootView.findViewById(R.id.detail_recipe_rating);
    mIngredients = (TextView) rootView.findViewById(R.id.detail_recipe_ingredients);

    Button openInBrowserButton = (Button) rootView.findViewById(R.id.detail_recipe_source);
    openInBrowserButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(mRecipe.getSourceUrl()));
            startActivity(i);
        }
    });

    mRecipeDetailsLayout = (ScrollView) rootView.findViewById(R.id.recipe_details_layout);
    mOfflineItems = (LinearLayout) rootView.findViewById(R.id.offline_items);
    mFavoritesActionButton = (Button) rootView.findViewById(R.id.detail_recipe_favourites_action);
    int textId = mExecuteRecipeRemove ? R.string.recipe_details_remove_from_favorites
            : R.string.recipe_details_save_in_favourites;

    mFavoritesActionButton.setText(getActivity().getString(textId));
    mFavoritesActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mRecipe != null) {
                if (mExecuteRecipeRemove)
                    removeCurrentRecipeFromFavorites();
                else
                    saveCurrentRecipeInFavorites();
            }
        }
    });

    if (mRecipeExternalId != null && mLoaderAdapter != null) {
        // if there is recipe id set and the loader adapter then show the progress dialog
        // indicating the recipe load started
        mProgressDialog = UIUtil.createAndShowDefaultProgressDialog(getActivity());

        mProgressDialog.setOnKeyListener(new Dialog.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    if (mLoaderAdapter != null)
                        mLoaderAdapter.cancelLoading();
                    mProgressDialog.dismiss();

                    // if it's not the tablet layout and user cancelled the loading,
                    // then there is no point to stay in this Activity
                    if (!mTwoPane)
                        getActivity().finish();
                }
                return true;
            }
        });
    }

    return rootView;
}

From source file:com.prasanna.android.stacknetwork.QuestionActivity.java

private void handleError(Bundle resultData) {
    setProgressBarIndeterminateVisibility(false);

    HttpException e = (HttpException) resultData.getSerializable(StringConstants.EXCEPTION);
    int requestCode = resultData.getInt(StringConstants.REQUEST_CODE, -1);

    if (requestCode == WriteIntentService.ACTION_ADD_COMMENT) {
        PostCommentFragment lastPostCommentFragment = findFragmentByTag("postCommentFragment",
                PostCommentFragment.class);
        if (lastPostCommentFragment != null)
            lastPostCommentFragment.setSendError(e.getErrorResponse());
        else if (postCommentFragment != null)
            postCommentFragment.setSendError(e.getErrorResponse());
    } else/*from w  ww .  j a  va  2 s. com*/
        AppUtils.getErrorView(this, e);
}

From source file:name.gumartinm.weather.information.fragment.current.CurrentFragment.java

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

    if (savedInstanceState != null) {
        // Restore UI state
        final Current current = (Current) savedInstanceState.getSerializable("Current");

        if (current != null) {
            final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
            store.saveCurrent(current);/*from   ww  w. j ava2s  .c o  m*/
        }
    }

    this.setHasOptionsMenu(false);

    this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE);
    this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE);
    this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
}

From source file:fi.mikuz.boarder.gui.internet.Uploads.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Internet Uploads");
    setContentView(R.layout.internet_uploads_list);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mList = new ArrayList<InternetFullBoard>();
    mListView = (ListView) findViewById(android.R.id.list);
    mMaxResults = 40;/* w  ww.  ja  v a2s. c  o m*/

    mWaitDialog = new TimeoutProgressDialog(Uploads.this, "Waiting for response", TAG, true);

    Bundle extras = getIntent().getExtras();
    @SuppressWarnings("unchecked")
    HashMap<String, String> lastSession = (HashMap<String, String>) extras
            .getSerializable(InternetMenu.LOGIN_KEY);

    try {
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);

        refreshList();
        getListView().setOnScrollListener(this);
    } catch (NullPointerException e) {
        Toast.makeText(Uploads.this, "Please login", Toast.LENGTH_LONG).show();
        Uploads.this.finish();
    }

}

From source file:com.cw.litenote.note_add.Note_addCameraVideo.java

void doCreate(Bundle savedInstanceState) {
    videoUriInDB = "";
    cameraVideoUri = "";
    enSaveDb = true;/*from   www  .java2 s. c om*/

    // get row Id from saved instance
    noteId = (savedInstanceState == null) ? null
            : (Long) savedInstanceState.getSerializable(DB_page.KEY_NOTE_ID);

    // get picture Uri in DB if instance is not null
    dB_page = new DB_page(this, TabsHost.getCurrentPageTableId());
    if (savedInstanceState != null) {
        System.out.println("Note_addCameraVideo / onCreate / noteId =  " + noteId);
        if (noteId != null)
            videoUriInDB = dB_page.getNotePictureUri_byId(noteId);
    }

    // at the first beginning
    if (savedInstanceState == null)
        takeVideoWithName();

}

From source file:com.bukanir.android.activities.MovieActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_movie);

    fragmentManager = getSupportFragmentManager();

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    if (savedInstanceState != null) {
        movie = (Movie) savedInstanceState.getSerializable("movie");
    } else {/*from  w w  w  .j a  v  a2 s .c o  m*/
        Bundle bundle = getIntent().getExtras();
        movie = (Movie) bundle.get("movie");

        movieTask = new MovieTask();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            movieTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            movieTask.execute();
        }
    }
}

From source file:com.meetingninja.csse.agenda.AgendaActivity.java

@SuppressWarnings("unchecked")
@Override/*from ww  w  .  j  ava  2s .c  om*/
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    boolean newCollapsible;
    setContentView(R.layout.activity_agenda);

    if (savedInstanceState == null) {
        manager = new InMemoryTreeStateManager<Topic>();
        newCollapsible = false;
        displayedAgenda = new Agenda();
    } else {
        manager = (TreeStateManager<Topic>) savedInstanceState.getSerializable("treeManager");
        newCollapsible = savedInstanceState.getBoolean("collapsible");
        displayedAgenda = ((AgendaParcel) savedInstanceState.getParcelable(Keys.Agenda.PARCEL)).getAgenda();
    }

    setupViews();
    treeBuilder = new TreeBuilder<Topic>(manager);

    if (displayedAgenda != null) {
        int depth = displayedAgenda.getDepth();
        mAgendaAdpt = new AgendaItemAdapter(this, manager, treeBuilder, depth);
        mTitleView.setText(displayedAgenda.getTitle());
        buildTree(treeBuilder);
    }
    treeView.setAdapter(mAgendaAdpt);

    setCollapsible(newCollapsible);

    // registerForContextMenu(treeView);
}

From source file:com.tenmiles.helpstack.fragments.NewIssueFragment.java

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

    if (savedInstanceState != null) {
        subjectField.setText(savedInstanceState.getString("subject"));
        messageField.setText(savedInstanceState.getString("message"));
        selectedAttachment = (HSAttachment) savedInstanceState.getSerializable("attachment");
    }/*from  w w w. java 2 s. c om*/

    resetAttachmentImage();
}