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:br.com.brolam.cloudvision.ui.helpers.ActivityHelper.java

/**
 * Salvar o state view do CoordinatorLayout principal da atividade.
 * @param outState informar um Bundle vlido.
 *///w w w.  jav  a2  s.  c o m
protected void saveCoordinatorLayoutHelper(Bundle outState) {
    CoordinatorLayoutHelper coordinatorLayoutHelper = (CoordinatorLayoutHelper) findViewById(
            R.id.coordinatorLayout);
    if (coordinatorLayoutHelper != null) {
        outState.putParcelable(COORDINATOR_LAYOUT_HELPER_VIEW_STATE,
                coordinatorLayoutHelper.getRestoreInstanceState());
    }
}

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

public void onGetObject(Object o, String tag) {
    if (destroyed)
        return;/*from  w ww.  j  a  va2s . c o  m*/
    if (tag.equals(IMAGE)) {
        try {
            JSONObject singleImageData = (JSONObject) o;
            Log.d("data", singleImageData.toString());
            SingleImageFragment singleImageFragment = new SingleImageFragment();
            Bundle bundle = new Bundle();
            bundle.putBoolean("gallery", true);
            JSONParcelable data = new JSONParcelable();
            data.setJSONObject(singleImageData.getJSONObject("data"));
            bundle.putParcelable("imageData", data);
            singleImageFragment.setArguments(bundle);
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.frame_layout, singleImageFragment).commitAllowingStateLoss();
        } catch (JSONException e) {
            Log.e("Error!", e.toString());
        }
    } else if (tag.equals(ALBUM)) {
        try {
            JSONObject albumData = (JSONObject) o;
            Log.d("data", albumData.toString());
            ImagesFragment fragment = new ImagesFragment();
            Bundle bundle = new Bundle();
            bundle.putString("imageCall", "/3/album/" + album);
            bundle.putString("id", album);
            JSONParcelable data = new JSONParcelable();
            data.setJSONObject(albumData.getJSONObject("data"));
            bundle.putParcelable("albumData", data);
            fragment.setArguments(bundle);
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.frame_layout, fragment).commitAllowingStateLoss();
        } catch (JSONException e) {
            Log.e("Error!", e.toString());
        }
    }
}

From source file:br.com.brolam.cloudvision.ui.helpers.ActivityHelper.java

/**
 * Salvar o state view do NestedScroll principal da atividade.
 * @param outState informar um Bundle vlido.
 *//*from w  ww .  j a  v a 2s . c  om*/
protected void saveNestedScrollHelperViewState(Bundle outState) {
    NestedScrollViewHelper nestedScrollViewHelper = (NestedScrollViewHelper) findViewById(
            R.id.nestedScrollViewHelper);
    if (nestedScrollViewHelper != null) {
        outState.putParcelable(NESTED_SCROLL_HELPER_VIEW_STATE,
                nestedScrollViewHelper.getRestoreInstanceState());
    }
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(ParamIntent.BUNDLE_SAVE, true);
    if (getModelActivity().getNearResp() != null) {
        outState.putParcelable(ParamIntent.NEAR_RESP, getModelActivity().getNearResp());
    } else {//from w  ww.j  a va 2  s.  c om
        outState.putBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, getModelActivity().isForceResearch());
    }
    if (getModelActivity().getLocalisation() != null) {
        outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE,
                getModelActivity().getLocalisation().getLatitude());
        outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE,
                getModelActivity().getLocalisation().getLongitude());
    }
    outState.putString(ParamIntent.ACTIVITY_SEARCH_THEATER_ID, getModelActivity().getFavTheaterId());
    outState.putInt(ParamIntent.ACTIVITY_SEARCH_DAY, getModelActivity().getDay());
    outState.putString(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName());
    outState.putString(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME, getModelActivity().getMovieName());
    outState.putIntegerArrayList(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND,
            new ArrayList<Integer>(getModelActivity().getGroupExpanded()));
    super.onSaveInstanceState(outState);
}

From source file:com.purplefrog.glitchclocka.LearningReadout.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putParcelable("learningState", learningState);
    outState.putString("glitchToken", glitch.accessToken);
}

From source file:com.cloudbees.gasp.activity.GaspRESTLoaderActivity.java

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

    // Set main content view for Gasp! Reviews
    setContentView(R.layout.gasp_review_activity);

    // Use the Fragments API to display review data
    FragmentManager fm = getFragmentManager();
    ListFragment list = (ListFragment) fm.findFragmentById(R.id.gasp_review_content);
    if (list == null) {
        list = new ListFragment();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.gasp_review_content, list);
        ft.commit();//from   w w  w . j ava  2 s  . c o  m
    }

    // Array adapter provides access to the review list data
    mAdapter = new ArrayAdapter<String>(this, R.layout.gasp_review_list);
    list.setListAdapter(mAdapter);

    // Load shared preferences from res/xml/preferences.xml (first time only)
    // Subsequent activations will use the saved shared preferences from the device
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Log.i(TAG, "Using Gasp Server URI: " + gaspSharedPreferences.getString("gasp_endpoint_uri", ""));
    Uri gaspReviewsUri = Uri.parse(gaspSharedPreferences.getString("gasp_endpoint_uri", ""));

    // Loader arguments: LoaderManager will maintain the state of our Loaders
    // and reload if necessary. 
    Bundle args = new Bundle();
    Bundle params = new Bundle();
    args.putParcelable(ARGS_URI, gaspReviewsUri);
    args.putParcelable(ARGS_PARAMS, params);

    // Initialize the Loader.
    getLoaderManager().initLoader(LOADER_GASP_REVIEWS, args, this);

    // Use gasp-mongo REST service
    new ReviewsRequest().execute();

    try {
        LocationsRequest locations = new LocationsRequest(
                new SpatialQuery(new Location(-122.1139858, 37.3774655), 0.005));

        List<GeoLocation> locationList = locations.execute().get();
        for (GeoLocation geoLocation : locationList) {
            Log.i(TAG, geoLocation.getName());
            Log.i(TAG, " " + geoLocation.getFormattedAddress());
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLng()));
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLat()));
        }
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
    }
}

From source file:com.app.encontreibvrr.uploadImagem.MainActivityStorage.java

@Override
public void onSaveInstanceState(Bundle out) {
    super.onSaveInstanceState(out);
    out.putParcelable(KEY_FILE_URI, mFileUri);
    out.putParcelable(KEY_DOWNLOAD_URL, mDownloadUrl);
}

From source file:my.home.lehome.service.SendMsgIntentService.java

private void preparePengindCommand(Intent intent) {
    Messenger messenger;/*from   w  w  w .  j av  a 2  s.c  o m*/
    if (intent.hasExtra("messenger"))
        messenger = (Messenger) intent.getExtras().get("messenger");
    else
        messenger = null;
    Message repMsg = Message.obtain();
    repMsg.what = MSG_BEGIN_SENDING;

    boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false);
    if (isSysCmd) {
        Log.d(TAG, "sys cmd item");
        return;
    }

    ChatItem item = intent.getParcelableExtra("update");
    if (item == null) {
        item = new ChatItem();
        item.setContent(intent.getStringExtra("cmd"));
        item.setType(ChatItemConstants.TYPE_CLIENT);
        item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR
        item.setDate(new Date());
        DBStaticManager.addChatItem(getApplicationContext(), item);
    }
    item.setState(Constants.CHATITEM_STATE_PENDING);

    Log.d(TAG, "enqueue item: \n" + item);
    Bundle bundle = new Bundle();
    bundle.putBoolean("update", intent.hasExtra("update"));
    bundle.putParcelable("item", item);
    if (messenger != null) {
        repMsg.setData(bundle);
        try {
            messenger.send(repMsg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN);
        Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN);
        newIntent.putExtras(bundle);
        sendBroadcast(newIntent);
    }

    intent.putExtra("pass_item", item);
}

From source file:com.binomed.showtime.android.screen.widget.results.CineShowTimeResultsWidgetActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (getModelActivity().getNearResp() != null) {
        outState.putBoolean(ParamIntent.BUNDLE_SAVE, true);
        if (getModelActivity().getNearResp() != null) {
            outState.putParcelable(ParamIntent.NEAR_RESP, getModelActivity().getNearResp());
        } else {/*  ww  w  .  j  a v  a2s  .co m*/
            outState.putBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST,
                    getModelActivity().isForceResearch());
        }
        if (getModelActivity().getLocalisation() != null) {
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE,
                    getModelActivity().getLocalisation().getLatitude());
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE,
                    getModelActivity().getLocalisation().getLongitude());
        }
        outState.putString(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName());
    }
    super.onSaveInstanceState(outState);
}

From source file:com.facebook.notifications.internal.asset.AssetManager.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    Bundle bundle = new Bundle();
    for (Map.Entry<String, ParcelableAssetHandler> entry : registeredHandlers.entrySet()) {
        bundle.putParcelable(entry.getKey(), entry.getValue());
    }//from  ww  w .j a v a  2s  .  c  o  m

    dest.writeBundle(bundle);
}