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:com.charabia.SmsViewActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mode = savedInstanceState.getInt("mode");
    prefPhoneNumber = savedInstanceState.getString("prefPhoneNumber");
    keypair = (KeyPair) savedInstanceState.getSerializable("keypair");
    key = savedInstanceState.getByteArray("key");
    phoneNumber = savedInstanceState.getString("phoneNumber");
}

From source file:com.nearnotes.NoteEdit.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // access options menu from fragment
    setHasOptionsMenu(true);//from   w ww .  jav  a2 s.  co  m
    mDbHelper = new NotesDbAdapter(getActivity());
    mDbHelper.open();
    mRowId = (savedInstanceState == null) ? null
            : (Long) savedInstanceState.getSerializable(NotesDbAdapter.KEY_ROWID);

    return inflater.inflate(R.layout.note_edit, container, false);
}

From source file:com.kuloud.android.aboutlibraries.ui.LibsFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    Libs libs;/*  w w w  . jav a2 s.  co m*/

    String[] fields = null;
    String[] internalLibraries = null;
    String[] excludeLibraries = null;

    //read and get our arguments
    Bundle bundle = getArguments();
    if (bundle != null) {
        fields = bundle.getStringArray(Libs.BUNDLE_FIELDS);
        internalLibraries = bundle.getStringArray(Libs.BUNDLE_LIBS);
        excludeLibraries = bundle.getStringArray(Libs.BUNDLE_EXCLUDE_LIBS);

        autoDetect = bundle.getBoolean(Libs.BUNDLE_AUTODETECT, true);
        sort = bundle.getBoolean(Libs.BUNDLE_SORT, true);
        animate = bundle.getBoolean(Libs.BUNDLE_ANIMATE, true);

        showLicense = bundle.getBoolean(Libs.BUNDLE_LICENSE, false);
        showLicenseDialog = bundle.getBoolean(Libs.BUNDLE_LICENSE_DIALOG, true);
        showVersion = bundle.getBoolean(Libs.BUNDLE_VERSION, false);

        try {
            libraryModification = (HashMap<String, HashMap<String, String>>) bundle
                    .getSerializable(Libs.BUNDLE_LIBS_MODIFICATION);
        } catch (Exception ex) {

        }
    }

    //init the Libs instance with fields if they were set
    if (fields == null) {
        libs = new Libs(getActivity());
    } else {
        libs = new Libs(getActivity(), fields);
    }

    //The last step is to look if we would love to show some about text for this project
    aboutShowIcon = extractBooleanBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_ICON,
            "aboutLibraries_description_showIcon");
    aboutShowVersion = extractBooleanBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_VERSION,
            "aboutLibraries_description_showVersion");
    aboutShowVersionName = extractBooleanBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_VERSION_NAME,
            "aboutLibraries_description_showVersionName");
    aboutShowVersionCode = extractBooleanBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_VERSION_CODE,
            "aboutLibraries_description_showVersionCode");

    aboutAppName = extractStringBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_NAME,
            "aboutLibraries_description_name");
    aboutDescription = extractStringBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_DESCRIPTION,
            "aboutLibraries_description_text");

    aboutSpecial1 = extractStringBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_SPECIAL1,
            "aboutLibraries_description_special1_name");
    aboutSpecial1Description = extractStringBundleOrResource(libs, bundle,
            Libs.BUNDLE_APP_ABOUT_SPECIAL1_DESCRIPTION, "aboutLibraries_description_special1_text");
    aboutSpecial2 = extractStringBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_SPECIAL2,
            "aboutLibraries_description_special2_name");
    aboutSpecial2Description = extractStringBundleOrResource(libs, bundle,
            Libs.BUNDLE_APP_ABOUT_SPECIAL2_DESCRIPTION, "aboutLibraries_description_special2_text");
    aboutSpecial3 = extractStringBundleOrResource(libs, bundle, Libs.BUNDLE_APP_ABOUT_SPECIAL3,
            "aboutLibraries_description_special3_name");
    aboutSpecial3Description = extractStringBundleOrResource(libs, bundle,
            Libs.BUNDLE_APP_ABOUT_SPECIAL3_DESCRIPTION, "aboutLibraries_description_special3_text");

    //apply modifications
    libs.modifyLibraries(libraryModification);

    //fetch the libraries and sort if a comparator was set
    libraries = libs.prepareLibraries(internalLibraries, excludeLibraries, autoDetect, sort);

    if (comparator != null) {
        Collections.sort(libraries, comparator);
    }
}

From source file:com.owncloud.android.ui.activity.Uploader.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    prepareStreamsToUpload();//from  w w  w.  ja  v a  2  s  .c  o  m

    if (savedInstanceState == null) {
        mParents = new Stack<String>();
        mAccountSelected = false;
        mAccountSelectionShowing = false;
        mNumCacheFile = 0;

        // ArrayList for files with path in private storage
        mRemoteCacheData = new ArrayList<String>();
    } else {
        mParents = (Stack<String>) savedInstanceState.getSerializable(KEY_PARENTS);
        mFile = savedInstanceState.getParcelable(KEY_FILE);
        mAccountSelected = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTED);
        mAccountSelectionShowing = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTION_SHOWING);
        mNumCacheFile = savedInstanceState.getInt(KEY_NUM_CACHE_FILE);
        mRemoteCacheData = savedInstanceState.getStringArrayList(KEY_REMOTE_CACHE_DATA);
    }

    super.onCreate(savedInstanceState);

    if (mAccountSelected) {
        setAccount((Account) savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
    }
}

From source file:com.uncc.finalproject.GalleryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_gallery, container, false);
    rootView.setTag(TAG);//w  ww .  jav  a2 s.  co  m

    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.setImageResource(R.drawable.ic_menu_gallery);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentManager().beginTransaction()
                    .replace(R.id.sample_content_fragment, new NewPhotoFragment(), "New Photo")
                    .addToBackStack("New Photo").commit();
        }
    });

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }

    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);
    mAdapter = new CustomAdapter(mDataset, getActivity(), getContext(), "albums");
    mRecyclerView.setAdapter(mAdapter);
    setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER);

    return rootView;
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentJournalMainHome.java

/**
 * Get the saved date before the views are created/updated
 *//*w  w w .j a  v  a2  s  .c o  m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mDate = (Date) savedInstanceState.getSerializable(Globals.JOURNAL_DATE);
    }
}

From source file:com.uncc.finalproject.MessengerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_gallery, container, false);
    rootView.setTag(TAG);/*from  w ww  .ja  v a2 s.c o  m*/

    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.setImageResource(R.drawable.ic_menu_send);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentManager().beginTransaction()
                    .replace(R.id.sample_content_fragment, new NewMessageFragment(), "New Message")
                    .addToBackStack("New Message").commit();
        }
    });

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }

    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);
    setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER);

    return rootView;
}

From source file:com.github.yuukis.businessmap.app.MainActivity.java

@SuppressWarnings("unchecked")
private void initialize(Bundle savedInstanceState) {
    Bundle args = getIntent().getExtras();

    FragmentManager fm = getSupportFragmentManager();
    mMapFragment = (ContactsMapFragment) fm.findFragmentById(R.id.contacts_map);
    mListFragment = (ContactsListFragment) fm.findFragmentById(R.id.contacts_list);
    mTaskFragment = (ContactsTaskFragment) fm.findFragmentById(R.id.contacts_task);
    mGroupList = ContactUtils.getContactsGroupList(this);

    GroupAdapter adapter = new GroupAdapter(this, mGroupList);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(adapter, this);

    int navigationIndex = 0;
    if (savedInstanceState != null) {
        navigationIndex = savedInstanceState.getInt(KEY_NAVIGATION_INDEX);
        mContactsList = (List<ContactsItem>) savedInstanceState.getSerializable(KEY_CONTACTS_LIST);
    } else if (args != null) {
        if (args.containsKey(KEY_CONTACTS_GROUP_ID)) {
            long groupId = args.getLong(KEY_CONTACTS_GROUP_ID);
            for (int i = 0; i < mGroupList.size(); i++) {
                ContactsGroup contactsGroup = mGroupList.get(i);
                if (groupId == contactsGroup.getId()) {
                    navigationIndex = i;
                    break;
                }/* www  .j  a  va2s.  c  om*/
            }
        }
    }
    actionBar.setSelectedNavigationItem(navigationIndex);
    mCurrentGroupContactsList = new ArrayList<ContactsItem>();
}

From source file:cmput301.f13t01.editstory.EditStoryActivity.java

@Override
/**/* w  w  w .ja  va2 s.c o  m*/
 * Override onCreate function
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_story);
    getActionBar().setDisplayHomeAsUpEnabled(false);

    final Button button = (Button) findViewById(R.id.edit_set_first_page);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            buttonPressed = true;
            showFragmentSelection();
        }
    });

    // Get the story manager
    GlobalManager app = (GlobalManager) getApplication();
    manager = GlobalManager.getStoryManager();

    if (savedInstanceState != null) {
        isNew = savedInstanceState.getBoolean(getResources().getString(R.string.story_is_new));
        storyId = (UUID) savedInstanceState.getSerializable(getResources().getString(R.string.story_id));

        app.setStoryManager(storyId);
    } else {
        Intent intent = getIntent();

        isNew = (boolean) intent.getBooleanExtra(getResources().getString(R.string.story_is_new), false);

        if (isNew == false) {
            storyId = (UUID) intent.getSerializableExtra(getResources().getString(R.string.story_id));
            app.setStoryManager(storyId);

            EditText title = (EditText) findViewById(R.id.edit_story_title);
            EditText author = (EditText) findViewById(R.id.edit_story_author);
            EditText desc = (EditText) findViewById(R.id.edit_story_description);

            title.setText(manager.getTitle());
            author.setText(manager.getAuthor());
            desc.setText(manager.getDescription());

        } else {
            storyId = app.createAndSetStory();
        }
    }

    TextView firstPage = (TextView) findViewById(R.id.edit_first_page);
    StoryFragment firstPageFragment = manager.getFirstPage();

    if (firstPageFragment == null) {
        firstPage.setText(getResources().getString(R.string.first_page) + " "
                + getResources().getString(R.string.first_page_empty));
    } else {
        firstPage.setText(
                getResources().getString(R.string.first_page) + " " + manager.getFirstPage().getTitle());
    }

}

From source file:com.optimusinfo.elasticpath.cortex.profile.address.AddressActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set the content view
    setContentView(R.layout.activity_address);
    // Initialize the params objects
    super.initializeParams();
    // Disable the title
    mObjActionBar.setDisplayShowTitleEnabled(false);
    mObjActionBar.setDisplayHomeAsUpEnabled(false);

    mObjAddress = (AddressElement) getIntent().getSerializableExtra(Constants.PageUrl.INTENT_ADRESS);
    // Initialize views
    initializeViews();/*from  w  ww  .j ava 2 s  .  c  o  m*/

    if (savedInstanceState != null) {
        mGeographies = (Geographies) savedInstanceState.getSerializable(KEY_GEOGRAPHIES);
        mRegions = (Regions) savedInstanceState.getSerializable(KEY_REGIONS);
        posCountry = savedInstanceState.getInt(KEY_POSITION_COUNTRIES);
        posRegion = savedInstanceState.getInt(KEY_POSITION_REGIONS);
        mAddressPostUrl = savedInstanceState.getString(KEY_ADDRESS_POST);

    }

    if (mGeographies == null) {
        // Populate the geographies views
        getGeographies();
    } else {
        setUpCountries(mGeographies);
        setUpRegions(mRegions);
    }

    if (mObjAddress != null) {
        bindContent();
    }
    if (mAddressPostUrl == null) {
        getAddressForm();
    }
}