Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@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.akop.bach.fragment.xboxlive.MessagesFragment.java

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

    if (mAccount == null) {
        Bundle args = getArguments();
        ContentResolver cr = getActivity().getContentResolver();

        mAccount = (XboxLiveAccount) args.getParcelable("account");
        mTitleId = getFirstTitleId(cr.query(Messages.CONTENT_URI, new String[] { Messages._ID, },
                Messages.ACCOUNT_ID + "=" + mAccount.getId(), null, Messages.DEFAULT_SORT_ORDER));
    }//from  www .  j a  v a 2s  .co m

    if (state != null && state.containsKey("account")) {
        mAccount = (XboxLiveAccount) state.getParcelable("account");
        mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
}

From source file:com.android.settings.users.RestrictedProfileSettings.java

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

    if (icicle != null) {
        mSavedPhoto = (Bitmap) icicle.getParcelable(KEY_SAVED_PHOTO);
        mWaitingForActivityResult = icicle.getBoolean(KEY_AWAITING_RESULT, false);
    }/*ww  w . j  a  v  a 2 s .  com*/

    init(icicle);
}

From source file:chinanurse.cn.nurse.Fragment_Nurse_job.IdentityFragment_ACTIVITY.java

/**
 * ????//from   www .  j av a  2 s.co m
 *
 * @param data
 */
private void getImageToView(Intent data) {
    Bundle extras = data.getExtras();
    if (extras != null) {
        Bitmap photo = extras.getParcelable("data");
        Drawable drawable = new BitmapDrawable(this.getResources(), photo);
        picname = "avatar" + user.getUserid() + String.valueOf(new Date().getTime());
        storeImageToSDCARD(photo, picname, filepath);
        if (HttpConnect.isConnnected(activity)) {
            new StudyRequest(activity, handler).updateUserImg(head, KEY);
        } else {
            Toast.makeText(activity, R.string.net_erroy, Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:cl.chileagil.agileday2012.fragment.MainFragment.java

void gotAccount() {
    Account account = accountManager.getAccountByName(accountName);
    if (account == null) {
        chooseAccount();/*from w w w .j  a  v a2s.  c  o  m*/
        return;
    }
    if (authToken != null) {
        //Ya tengo elegido mi cuenta.
        //Solo si no tengo datos en la DB, lo pido, sino cargo lo que hay
        //y actualizo solo a peticion del usuario
        DatabaseAdapter dbAdapter = null;
        try {
            dbAdapter = new DatabaseAdapter(this);
            dbAdapter.open();
            if (dbAdapter.fetchCountEvents() <= 0) {
                onAuthToken();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                dbAdapter.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return;
    }
    accountManager.getAccountManager().getAuthToken(account, AUTH_TOKEN_TYPE, true,
            new AccountManagerCallback<Bundle>() {

                public void run(AccountManagerFuture<Bundle> future) {
                    try {
                        Bundle bundle = future.getResult();
                        if (bundle.containsKey(AccountManager.KEY_INTENT)) {
                            Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
                            intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivityForResult(intent, REQUEST_AUTHENTICATE);
                        } else if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
                            setAuthToken(bundle.getString(AccountManager.KEY_AUTHTOKEN));
                            onAuthToken();
                        }
                    } catch (Exception e) {
                        Log.e(TAG, e.getMessage(), e);
                    }
                }
            }, null);
}

From source file:ca.uwaterloo.magic.goodhikes.AddMilestoneDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mapsActivity = (MapsActivity) getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View dialog = inflater.inflate(R.layout.dialog_add_milestone, null);
    previewImage = (ImageView) dialog.findViewById(R.id.previewImage);

    if (savedInstanceState != null) {
        Bitmap image = savedInstanceState.getParcelable("image");
        if (image != null) {
            previewImage.setImageBitmap(image);
        }//from  ww  w  . ja  v  a2s .c  om
    }

    builder.setView(dialog).setTitle(R.string.add_milestone)
            .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    EditText noteField = (EditText) ((Dialog) dialog).findViewById(R.id.note);
                    String note = noteField.getText().toString();
                    Bitmap image = previewImage.getDrawable() == null ? null
                            : ((BitmapDrawable) previewImage.getDrawable()).getBitmap();

                    mapsActivity.imageSelected(image, note);
                    Toast.makeText(getActivity(), "Milestone added", Toast.LENGTH_SHORT).show();
                    Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone added");
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone cancelled");
                }
            });

    Button addImageButton = (Button) dialog.findViewById(R.id.addImageButton);
    addImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Create intent to Open Image applications like Gallery, Google Photos
            Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
        }
    });

    Button cameraButton = (Button) dialog.findViewById(R.id.cameraButton);
    cameraButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Create intent to open device's Camera
            Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, RESULT_CAPTURE_IMG);
        }
    });

    return builder.create();
}

From source file:edgargtzg.popularmovies.MovieDetailsFragment.java

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

    // The detail Activity called via intent.  Inspect the intent for movie data.
    Intent intent = getActivity().getIntent();
    if (intent != null && intent.hasExtra(MovieItem.class.getCanonicalName())) {
        Bundle movieData = intent.getExtras();
        mMovieItem = movieData.getParcelable(MovieItem.class.getCanonicalName());

        if (mMovieItem != null) {

            // The MovieItemVideoAdapter will take data from a source and
            // use it to populate the list it's attached to.
            mMovieVideoAdapter = new MovieItemVideoAdapter(getActivity(), // The current context (this activity)
                    R.layout.list_video_movie_item, new ArrayList<MovieItemVideo>());

            // The MovieItemReviewAdapter will take data from a source and
            // use it to populate the list it's attached to.
            mMovieReviewAdapter = new MovieItemReviewAdapter(getActivity(), // The current context (this activity)
                    R.layout.list_review_movie_item, new ArrayList<MovieItemReview>());

            if (savedInstanceState != null) {
                mListOfVideos = (ArrayList<MovieItemVideo>) savedInstanceState.get(VIDEO_LIST_KEY);
                if (mListOfVideos != null) {
                    mMovieVideoAdapter.addAll(mListOfVideos);
                }/*  www.ja  v  a2s  . co  m*/
                mListOfReviews = (ArrayList<MovieItemReview>) savedInstanceState.get(REVIEW_LIST_KEY);
                if (mListOfReviews != null) {
                    mMovieReviewAdapter.addAll(mListOfReviews);
                }
            } else {
                mListOfVideos = new ArrayList<>();
                mListOfReviews = new ArrayList<>();
                updateMovieData(mMovieItem);
            }
        }
    }
}

From source file:com.cuddlesoft.nori.fragment.SearchResultGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_search_result_grid, container, false);
    // Restore SearchResult from saved instance state to preserve search results across screen rotations.
    if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_ID_SEARCH_RESULT)) {
        searchResult = savedInstanceState.getParcelable(BUNDLE_ID_SEARCH_RESULT);
    }//from  w w  w  .  j  a  v  a  2  s  . c o  m
    // Set adapter for GridView.
    gridView = (GridView) view.findViewById(R.id.image_grid);
    gridView.setColumnWidth(getGridViewColumnWidth());
    gridView.setAdapter(gridAdapter);
    gridView.setOnScrollListener(this);
    gridView.setOnItemClickListener(this);

    // Return inflated view.
    return view;
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //??-1??/*from w w  w. j av a 2  s . c o  m*/
    if (resultCode != Activity.RESULT_OK) {
        return;
    }
    if (requestCode == ALL_PHOTO) {
        //
        Cursor cursor = getActivity().getContentResolver().query(data.getData(),
                new String[] { MediaStore.Images.Media.DATA }, null, null, null);
        //????
        cursor.moveToFirst();
        String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
        cursor.close();
        //?
        startPhoneZoom(Uri.fromFile(new File(path)));
    } else if (requestCode == REQUEST_CODE) {
        //?
        startPhoneZoom(Uri.fromFile(new File(path)));
    } else if (requestCode == RESULT_PHOTO) {
        //??
        Bundle bundle = data.getExtras();
        if (bundle != null) {
            Bitmap bitmap = bundle.getParcelable("data");
            //???
            // TODO: 2017/2/13 ?
            Log.e("Daniel", "---bitmap.toString()---" + bitmap.toString());
            uploadAvatars(bitmap);
            //
        }
    }
}

From source file:com.akop.bach.fragment.xboxlive.GamesFragment.java

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

    if (mAccount == null) {
        Bundle args = getArguments();
        ContentResolver cr = getActivity().getContentResolver();

        mAccount = (XboxLiveAccount) args.getParcelable("account");
        mTitleId = getFirstTitleId(cr.query(Games.CONTENT_URI, new String[] { Games._ID, },
                Games.ACCOUNT_ID + "=" + mAccount.getId(), null, Games.DEFAULT_SORT_ORDER));
    }/*from w  w  w  . j  av a2  s  .c om*/

    if (state != null && state.containsKey("account")) {
        mAccount = (XboxLiveAccount) state.getParcelable("account");
        mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
}

From source file:co.codecrunch.musicplayerlite.recyclerviewutils.ItemSelectionSupport.java

public void onRestoreInstanceState(Bundle state) {
    mChoiceMode = ChoiceMode.values()[state.getInt(STATE_KEY_CHOICE_MODE)];
    mCheckedStates = state.getParcelable(STATE_KEY_CHECKED_STATES);
    mCheckedIdStates = state.getParcelable(STATE_KEY_CHECKED_ID_STATES);
    mCheckedCount = state.getInt(STATE_KEY_CHECKED_COUNT);

    // TODO confirm ids here
}