Example usage for android.os Bundle putSerializable

List of usage examples for android.os Bundle putSerializable

Introduction

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

Prototype

@Override
public void putSerializable(@Nullable String key, @Nullable Serializable value) 

Source Link

Document

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

Usage

From source file:com.feathercoin.wallet.feathercoin.ui.PeerListFragment.java

@Override
public void onResume() {
    super.onResume();

    handler.postDelayed(new Runnable() {
        public void run() {
            adapter.notifyDataSetChanged();

            final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
            final boolean loaderRunning = loader != null && loader.isStarted();

            if (!loaderRunning) {
                for (int i = 0; i < adapter.getCount(); i++) {
                    final Peer peer = adapter.getItem(i);
                    final InetAddress address = peer.getAddress().getAddr();

                    if (!hostnames.containsKey(address)) {
                        final Bundle args = new Bundle();
                        args.putSerializable("address", address);
                        loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks)
                                .forceLoad();

                        break;
                    }/*from  ww w  .j a v  a2  s .c  o m*/
                }
            }

            handler.postDelayed(this, REFRESH_MS);
        }
    }, REFRESH_MS);
}

From source file:com.github.mobile.ui.commit.CommitFileViewActivity.java

private void loadMarkdown() {
    ViewUtils.setGone(loadingBar, false);
    ViewUtils.setGone(codeView, true);/*www .ja  v  a 2s  .  co m*/

    String markdown = new String(EncodingUtils.fromBase64(blob.getContent()));
    Bundle args = new Bundle();
    args.putCharSequence(ARG_TEXT, markdown);
    args.putSerializable(ARG_REPO, repo);
    getSupportLoaderManager().restartLoader(0, args, this);
}

From source file:br.ufsc.das.gtscted.shibbauth.SPSelectionActivity.java

/** Called when the activity is first created. */
@Override/*from   www  .  j a v a 2 s  . c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sp_selection);

    nextButton = (Button) findViewById(R.id.nextButton);
    exitButton = (Button) findViewById(R.id.exitButton);
    spEditText = (EditText) findViewById(R.id.spUrlEditText);

    //SP para testes   
    spEditText.setText("https://sp.ufrgs.br/chimarrao/");

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String serviceUrl = spEditText.getText().toString();

            try {
                Connection connection = new Connection();
                String[] getResponseAndEndpoint = connection.httpGetWithEndpoint(serviceUrl);
                String wayfLocation = getResponseAndEndpoint[0];
                String responseBody = getResponseAndEndpoint[1];

                Bundle bundle = new Bundle();
                bundle.putString("html_source", responseBody);
                bundle.putString("wayf_location", wayfLocation);
                bundle.putSerializable("cookie", connection.getSerializableCookie(0));

                Intent newIntent = new Intent(SPSelectionActivity.this, ShibAuthenticationActivity.class);
                newIntent.putExtras(bundle);
                startActivity(newIntent);

            } catch (KeyManagementException e) {
                String message = "KeyManagementException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (NoSuchAlgorithmException e) {
                String message = "NoSuchAlgorithmException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (KeyStoreException e) {
                String message = "KeyStoreException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (UnrecoverableKeyException e) {
                String message = "UnrecoverableKeyException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (ClientProtocolException e) {
                String message = "ClientProtocolException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (IOException e) {
                String message = "IOException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (Exception e) {
                String message = "Exception";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            }
        }
    });

    exitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.teleca.jamendo.activity.SearchActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (mSearchMode != null) {
        outState.putSerializable("mode", mSearchMode);
        if (mSearchMode.equals(SearchMode.Artist) || mSearchMode.equals(SearchMode.Tag)
                || mSearchMode.equals(SearchMode.UserStarredAlbums)) {
            AlbumAdapter adapter = (AlbumAdapter) mSearchListView.getAdapter();
            outState.putSerializable("values", adapter.getList());
        }//from   w ww . j  av a  2  s .co  m

        if (mSearchMode.equals(SearchMode.UserPlaylist)) {
            PlaylistRemoteAdapter adapter = (PlaylistRemoteAdapter) mSearchListView.getAdapter();
            outState.putSerializable("values", adapter.getList());
        }

        outState.putInt("flipper_page", mViewFlipper.getDisplayedChild());
    }
    super.onSaveInstanceState(outState);
}

From source file:com.basesmartframe.pickphoto.PickPhotosPreviewFragment.java

public void initViews(View view) {
    Bundle bundle = getArguments();//  ww w.  j  av a 2 s  .c o  m
    if (bundle != null) {
        mMaxImageNum = bundle.getInt(PickPhotosFragment.MAX_IMAGE_NUM, 4);
        mCanChooseImage = bundle.getBoolean(CAN_CHOOSE_IMAGE, true);
        mChoosedData = getPhotoListFromArg(bundle, CHOOSE_DATA_LIST);
        mCurPhotoIndex = bundle.getInt(INDEX, 0);
    }
    mImageIndexText = (TextView) view.findViewById(R.id.image_index_tv);
    mSelectLayout = view.findViewById(R.id.select_layout);
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mSelectCheckBox = (CheckBox) view.findViewById(R.id.select_checkbox);
    mSelectCheckBox.setClickable(false);
    mBottomBar = view.findViewById(R.id.bottom_bar);
    mComplete = (Button) view.findViewById(R.id.pick_complete);

    mComplete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Bundle bundles = new Bundle();
            bundles.putSerializable(CHOOSE_DATA_LIST, mChoosedData);
            Intent data = new Intent();
            data.putExtras(bundles);
            getActivity().setResult(PickPhotosFragment.RESULT_COMPLETE, data);
            getActivity().finish();
        }
    });
    view.findViewById(R.id.pick_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    if (!mCanChooseImage) {
        mSelectLayout.setVisibility(View.GONE);
        mComplete.setVisibility(View.GONE);
        mBottomBar.setVisibility(View.GONE);
    }
    mAdapter = new ViewPagerAdapter(getActivity());
    mViewPager.setAdapter(mAdapter);
    mViewPager.setBackgroundColor(0xFF000000);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            updateCheckbox(arg0);
            updatePhotoIndex(arg0);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    mViewPager.setCurrentItem(mCurPhotoIndex);
    updateCheckbox(mCurPhotoIndex);
    updatePhotoIndex(mCurPhotoIndex);
    updateCompleteBtn();
    mSelectLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mImageGroupData == null)
                return;
            int current = mViewPager.getCurrentItem();
            ImageBean bean = mImageGroupData.get(current);
            if (mSelectCheckBox.isChecked()) {
                mSelectCheckBox.setChecked(false);
                mChoosedData.remove(bean);
            } else {
                if (mChoosedData.size() >= mMaxImageNum) {
                    mSelectCheckBox.setChecked(false);
                    SFToast.showToast(getString(R.string.four_pics_most, mMaxImageNum));
                    return;
                }
                File file = new File(bean.getPath());
                if (!file.exists()) {
                    mSelectCheckBox.setChecked(false);
                    SFToast.showToast(R.string.photo_donot_exist);
                    return;
                }
                mChoosedData.add(bean);
                mSelectCheckBox.setChecked(true);
            }
            updateCompleteBtn();
        }
    });
    mAdapter.notifyDataSetChanged();
}

From source file:com.github.riotopsys.malforandroid2.activity.HubActivity.java

private void setupMangaAdapter() {
    mangaListPager.setAdapter(mangaAdapter);
    mangaListPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.standard_padding));
    for (MangaReadStatus filter : MangaReadStatus.values()) {
        Log.i(TAG, filter.getServerKey());
        Bundle args = new Bundle();
        args.putSerializable("filter", filter);
        Fragment f = new MangaListFragment();
        f.setArguments(args);//from ww  w.  ja  v a 2  s  . co m
        mangaAdapter.addFragment(getString(filter.getResource()), f);
    }
    Bundle args = new Bundle();
    args.putSerializable("filter", null);
    Fragment f = new MangaListFragment();
    f.setArguments(args);
    mangaAdapter.addFragment(getString(R.string.all), f);

    if (!state.getMangaSearchResults().isEmpty()) {
        mangaAdapter.addFragment(getString(R.string.search), new MangaSearchListFragment());
    }
}

From source file:com.github.riotopsys.malforandroid2.activity.HubActivity.java

private void setupAnimeAdapter() {
    animeListPager.setAdapter(animeAdapter);
    animeListPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.standard_padding));
    for (AnimeWatchedStatus filter : AnimeWatchedStatus.values()) {
        Log.i(TAG, filter.getServerKey());
        Bundle args = new Bundle();
        args.putSerializable("filter", filter);
        Fragment f = new AnimeListFragment();
        f.setArguments(args);//w w  w. ja v a  2s . c  o m
        animeAdapter.addFragment(getString(filter.getResource()), f);
    }
    Bundle args = new Bundle();
    args.putSerializable("filter", null);
    Fragment f = new AnimeListFragment();
    f.setArguments(args);
    animeAdapter.addFragment(getString(R.string.all), f);

    if (!state.getAnimeSearchResults().isEmpty()) {
        animeAdapter.addFragment(getString(R.string.search), new AnimeSearchListFragment());
    }

}

From source file:com.death.yttorrents.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    haveStoragePermission();/*from   ww w.j  a  v  a2 s. c o m*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setTitle(R.string.app_name);

    final SharedPreferences preferences = getSharedPreferences(Constants.PREFERENCE_NAME, MODE_APPEND);
    Boolean isFirstRun = preferences.getBoolean(Constants.PREFERENCE_KEY_FOR_FIRSTRUN, true);

    if (isFirstRun) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, R.style.MyDialogTheme);
        alertDialogBuilder.setTitle(Html.fromHtml("<font color='#ffffff'>Disclaimer/License</font>"));
        alertDialogBuilder.setCancelable(true);
        alertDialogBuilder.setMessage(
                Html.fromHtml("<font color='#ffffff'>" + getResources().getString(R.string.terms) + "</font>"));
        alertDialogBuilder.setIcon(R.drawable.ic_icon);
        alertDialogBuilder.setCancelable(false)
                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                        MainActivity.this.finish();
                        finishActivity(0);
                    }
                }).setPositiveButton("Accept", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        SharedPreferences.Editor editor = preferences.edit();
                        editor.putBoolean(Constants.PREFERENCE_KEY_FOR_FIRSTRUN, false);
                        editor.apply();
                        editor.commit();
                    }
                });
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.setCancelable(true);
        alertDialog.show();
    }

    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    pDialog = new ProgressDialog(this);
    movies = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), movies);

    mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.addItemDecoration(new GridItemDecoration(2, UrlUtils.dpToPx(this, 5), true));
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

    /**
     * Click event handler on recycler view.
     */
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("movies", movies);
                    bundle.putInt("position", position);
                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    fetchMovies(endpoint);
}

From source file:net.reichholf.dreamdroid.fragment.abs.AbstractHttpListFragment.java

@Override
public Bundle getLoaderBundle(int loader) {
    Bundle args = new Bundle();
    args.putSerializable("params", getHttpParams(loader));
    return args;/*from w w w.j av  a2s .co m*/
}

From source file:biz.wiz.android.wallet.ui.PeerListFragment.java

@Override
public void onResume() {
    super.onResume();

    handler.postDelayed(new Runnable() {
        @Override/*from   ww  w.  j av a  2s.c om*/
        public void run() {
            adapter.notifyDataSetChanged();

            final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
            final boolean loaderRunning = loader != null && loader.isStarted();

            if (!loaderRunning) {
                for (int i = 0; i < adapter.getCount(); i++) {
                    final Peer peer = adapter.getItem(i);
                    final InetAddress address = peer.getAddress().getAddr();

                    if (!hostnames.containsKey(address)) {
                        final Bundle args = new Bundle();
                        args.putSerializable("address", address);
                        loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks)
                                .forceLoad();

                        break;
                    }
                }
            }

            handler.postDelayed(this, REFRESH_MS);
        }
    }, REFRESH_MS);
}