Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

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

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

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

Usage

From source file:com.audiokernel.euphonyrmt.fragments.SongsFragment.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    outState.putParcelable(EXTRA_ALBUM, mAlbum);
    super.onSaveInstanceState(outState);
}

From source file:com.marcosedo.lagramola.MainActivity.java

public void onEditarEvento(Evento event) {

    EditarEventosFragment editorFragment = new EditarEventosFragment();
    Bundle args = new Bundle();
    args.putParcelable("event", event);
    editorFragment.setArguments(args);//from w  w  w.j  a  va 2s  .  c  o  m

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.outTabContent, editorFragment, "editor");
    transaction.addToBackStack(null);
    transaction.commit();// Commit the transaction*/
}

From source file:com.alboteanu.android.sunshine.app.MainActivity.java

@Override
public void onItemSelected(Uri contentUri, ForecastAdapter.ForecastAdapterViewHolder vh) {
    if (mTwoPane) {
        // In two-pane mode, show the detail view in this activity by
        // adding or replacing the detail fragment using a
        // fragment transaction.
        Bundle args = new Bundle();
        args.putParcelable(DetailFragment.DETAIL_URI, contentUri);

        DetailFragment fragment = new DetailFragment();
        fragment.setArguments(args);//w  ww .j a  va 2  s. c o  m

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG).commit();
    } else {
        Intent intent = new Intent(this, DetailActivity.class).setData(contentUri);

        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
                new Pair<View, String>(vh.mIconView, getString(R.string.detail_icon_transition_name)));
        ActivityCompat.startActivity(this, intent, activityOptions.toBundle());
    }
}

From source file:com.marcosedo.lagramola.MainActivity.java

public void onMostrarDetalleEvento(Evento event) {
    Bundle args = new Bundle();
    args.putParcelable("event", event);

    if (mostrarDetalleEventoFragment == null) {
        mostrarDetalleEventoFragment = new MostrarDetalleEventoFragment();
    }//from  www .  j  a va  2 s .co  m

    mostrarDetalleEventoFragment.setArguments(args);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.outTabContent, mostrarDetalleEventoFragment, "mostrar detalle");
    transaction.addToBackStack(null);
    transaction.commit();// Commit the transaction
}

From source file:com.burhan.udacity.popularmovies.ui.fragment.MovieFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(STATE_SCROLL_VIEW, mScrollView.onSaveInstanceState());
    if (mReviews != null)
        outState.putParcelableArrayList(STATE_REVIEWS, new ArrayList<>(mReviews));
    if (mVideos != null)
        outState.putParcelableArrayList(STATE_VIDEOS, new ArrayList<>(mVideos));
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadListFragment.java

/**
 * Initializes our fragment with various variables, displays the threads,
 * sets up a onItemClickListener so the user is sent to the appropriate
 * thread when they click on it, then sorts the threads according to the
 * method the user has chosen.//from   w w w .  ja v a2  s .co m
 */
@Override
public void onStart() {
    super.onStart();
    if (locationListener == null) {
        locationListener = new LocationListenerService(getActivity());
    }
    if (prefManager == null) {
        prefManager = PreferencesManager.getInstance();
    }
    if (cacheManager == null) {
        cacheManager = CacheManager.getInstance();
    }
    threadListView = (PullToRefreshListView) getActivity().findViewById(R.id.thread_list);
    // On start, get the threadList from the cache
    ArrayList<ThreadComment> list = cacheManager.deserializeThreadList();
    ThreadList.setThreads(list);
    adapter = new ThreadListAdapter(getActivity(), ThreadList.getThreads());
    threadListView.setEmptyView(getActivity().findViewById(R.id.empty_list_view));
    threadListView.setAdapter(adapter);

    threadListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        /*
         * On click, launch the fragment responsible for thread viewing
         */
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Fragment fragment = new ThreadViewFragment();
            Bundle bundle = new Bundle();
            bundle.putParcelable("thread", ThreadList.getThreads().get((int) id));
            bundle.putLong("id", id);
            fragment.setArguments(bundle);
            getFragmentManager().beginTransaction()
                    .replace(R.id.fragment_container, fragment, "thread_view_fragment")
                    .addToBackStack("thread_view_fragment").commit();
            getFragmentManager().executePendingTransactions();
        }
    });

    int sort = prefManager.getThreadSort();
    SortUtil.sortThreads(sort, ThreadList.getThreads());
    //setSortCheck(sort);
    adapter.notifyDataSetChanged();

    threadListView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (!connectHelper.isConnected()) {
                Toaster.toastShort("No network connection.");
                threadListView.onRefreshComplete();
            } else {
                reload();
            }
        }
    });

    // Toggle PullToRefresh programatically on start
    if (!refresh && connectHelper.isConnected()) {
        threadListView.setRefreshing();
        ThreadManager.startGetThreadComments(this);
        refresh = true;
    }

    updateReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (isVisible() && connectHelper.getWasNotConnected() == true) {
                connectHelper.setWasNotConnected(false);
                UpdateDialogFragment fragment = new UpdateDialogFragment();
                fragment.show(getFragmentManager(), "updateDialogFrag");
            }
        }

    };

    getActivity().getApplicationContext().registerReceiver(updateReceiver,
            new IntentFilter(ConnectivityBroadcastReceiver.UPDATE_FROM_SERVER_INTENT));
}

From source file:com.bitants.wally.fragments.SavedImagesFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (recyclerSavedImagesAdapter != null) {
        outState.putParcelable(STATE_SELECTED_ITEMS, recyclerSavedImagesAdapter.getSelectedItems());
    }//from w ww .  j  a  v a 2  s .co m
    super.onSaveInstanceState(outState);
}

From source file:com.krayzk9s.imgurholo.activities.ImgurHoloActivity.java

public void imageSelected(ArrayList<JSONParcelable> data, int position) {
    FrameLayout displayFrag = (FrameLayout) findViewById(R.id.frame_layout_child);
    if (displayFrag == null) {
        // DisplayFragment (Fragment B) is not in the layout (handset layout),
        // so start DisplayActivity (Activity B)
        // and pass it the info about the selected item
        if (getApiCall().settings.getBoolean("ImagePagerEnabled", false) == false) {
            Intent intent = new Intent();
            intent.putExtra("id", data.get(position));
            Log.d("data", data.get(position).toString());
            intent.setAction(ImgurHoloActivity.IMAGE_INTENT);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(intent);/*from w  w w.  jav  a  2  s  .  co m*/
        } else {
            Intent intent = new Intent();
            intent.putExtra("ids", data);
            intent.putExtra("start", position);
            intent.setAction(ImgurHoloActivity.IMAGE_PAGER_INTENT);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(intent);
        }
    } else {
        // DisplayFragment (Fragment B) is in the layout (tablet layout),
        // so tell the fragment to update
        try {
            if (data.get(position).getJSONObject().has("is_album")
                    && data.get(position).getJSONObject().getBoolean("is_album")) {
                ImagesFragment fragment = new ImagesFragment();
                Bundle bundle = new Bundle();
                bundle.putString("imageCall", "3/album/" + data.get(position).getJSONObject().getString("id"));
                bundle.putString("id", data.get(position).getJSONObject().getString("id"));
                bundle.putParcelable("albumData", data.get(position));
                fragment.setArguments(bundle);
                FragmentManager fragmentManager = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                fragmentTransaction.replace(R.id.frame_layout_child, fragment).commitAllowingStateLoss();
            } else {
                SingleImageFragment singleImageFragment = new SingleImageFragment();
                Bundle bundle = new Bundle();
                bundle.putBoolean("gallery", true);
                bundle.putParcelable("imageData", data.get(position));
                singleImageFragment.setArguments(bundle);
                FragmentManager fragmentManager = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                fragmentTransaction.replace(R.id.frame_layout_child, singleImageFragment)
                        .commitAllowingStateLoss();
            }
        } catch (JSONException e) {
            Log.e("Error!", e.toString());
        }
    }
}

From source file:com.afwsamples.testdpc.SetupManagementFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(EXTRA_PROVISIONING_LOGO_URI, mLogoUri);
    outState.putInt(EXTRA_PROVISIONING_MAIN_COLOR, mCurrentColor);
    super.onSaveInstanceState(outState);
}

From source file:co.carlosjimenez.android.currencyalerts.app.DetailActivityFragment.java

/**
 * Helper method to open a create alert dialog
 *///  w  w w  .  j  a  v  a2  s  .c om
private void openCreateAlertDialog() {
    Bundle arguments = new Bundle();
    arguments.putParcelable(DetailActivityFragment.CURRENCY_FROM, new Currency(mCurrencyFromId));
    arguments.putParcelable(DetailActivityFragment.CURRENCY_TO, new Currency(mCurrencyToId));

    AddAlertFragment fragment = new AddAlertFragment();
    fragment.setArguments(arguments);

    fragment.show(mContext.getSupportFragmentManager(), null);
}