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:cn.com.caronwer.activity.AuthSecondActivity.java

private void setPicToView(Intent data) {

    Bundle extras = data.getExtras();
    if (extras != null) {

        Bitmap bitmap = extras.getParcelable("data");

        Drawable drawable = new BitmapDrawable(null, bitmap);

        //String HeadPortrait = BitmapUtil.getImgStr(bitmap);
        switch (imgType) {
        case 0:/*from w ww . j av  a 2  s .c o m*/
            cardNoImg.setImageDrawable(drawable);
            cardNoImg.setVisibility(View.VISIBLE);
            cardNoUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("Sfz", HeadPortrait);
            //                    isCardNoImgSuccess = true;
            break;
        case 1:
            drivingLicenseImg.setImageDrawable(drawable);
            drivingLicenseImg.setVisibility(View.VISIBLE);
            drivingLicenseUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("Driver", HeadPortrait);
            //                    isDrivingLicenseImgSuccess = true;
            break;
        case 2:
            carHeadImg.setImageDrawable(drawable);
            carHeadImg.setVisibility(View.VISIBLE);
            carHeadUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("CarFront", HeadPortrait);
            //                    isCarHeadImgSuccess = true;
            break;
        case 3:
            carTailImg.setImageDrawable(drawable);
            carTailImg.setVisibility(View.VISIBLE);
            carTailUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("CarBack", HeadPortrait);
            //                    isCarTailImgSuccess = true;
            break;
        case 4:
            carLeftImg.setImageDrawable(drawable);
            carLeftImg.setVisibility(View.VISIBLE);
            carLeftUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("CarLeft", HeadPortrait);
            //                    isCarLeftImgSuccess = true;
            break;
        case 5:
            carRightImg.setImageDrawable(drawable);
            carRightImg.setVisibility(View.VISIBLE);
            carRightUpload.setVisibility(View.INVISIBLE);
            //                    jsonObject.addProperty("CarRight", HeadPortrait);
            //                    isCarRightImgSuccess = true;
            break;
        }

    }

}

From source file:com.akop.bach.fragment.playstation.TrophiesFragment.java

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

    mCp = new CachePolicy();
    mCp.resizeHeight = 96;/* w  w w  .j  a v a 2  s  .  c  o  m*/

    if (mAccount == null) {
        Bundle args = getArguments();

        mAccount = (PsnAccount) args.getParcelable("account");
        mTitleId = args.getLong("titleId", -1);
    }

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

    setHasOptionsMenu(true);
}

From source file:org.klnusbaum.udj.EventListFragment.java

public Loader<EventsLoader.EventsLoaderResult> onCreateLoader(int id, Bundle args) {
    int eventSearchType = args.getInt(EVENT_SEARCH_TYPE_EXTRA, -1);
    if (eventSearchType == LocationEventSearch.SEARCH_TYPE) {
        return new EventsLoader(getActivity(), account, (Location) args.getParcelable(LOCATION_EXTRA));
    } else if (eventSearchType == NameEventSearch.SEARCH_TYPE) {
        return new EventsLoader(getActivity(), account, args.getString(EVENT_SEARCH_QUERY));
    } else {//from  w ww.  j  av a  2s.c o  m
        return null;
    }
}

From source file:br.com.GUI.perfil.PerfilAluno.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {

        if (requestCode == 200 || requestCode == 202) {

            if (requestCode == 200) {

                selectedImageUri = data.getData();

                cortar(requestCode);//  w w  w. java2s .c  o m

                /*selectedImageUri = Uri.fromFile(photo);
                        
                ContentResolver cr = getContentResolver();
                        
                Bitmap foto;
                try{
                   foto = android.provider.MediaStore.Images.Media.getBitmap(cr,  selectedImageUri);
                   bmp = ImageUtils.compactImages(foto);
                   imagem.setImageBitmap(foto);
                        
                }catch(FileNotFoundException e){
                   Log.i("Exception", e.toString());
                   e.printStackTrace();
                } catch (IOException e){
                           
                           
                }*/
            } else if (requestCode == 202) {
                //get the returned data
                Bundle extras = data.getExtras();
                //get the cropped bitmap
                Bitmap foto = extras.getParcelable("data");
                bmp = ImageUtils.compactImages(foto);
                img.setImageBitmap(bmp);

                //Log.i("tirei a foto ",  "e setei no canvas");
                Aluno p = new Aluno();
                p.setUsuario(pref.getString("usuario", null));
                if (p.editarFotoAlunoWeb(ImageUtils.bitmapToByteArray(bmp))) {
                    if (p.atualizarFotoAluno(b, ImageUtils.bitmapToByteArray(bmp))) {
                        Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show();
                    }
                }
                refresh();

            }

        } else if (requestCode == 100 || requestCode == 102) {

            if (requestCode == 100) {
                selectedImageUri = data.getData();

                cortar(requestCode);

            } else if (requestCode == 102) {
                //get the returned data
                Bundle extras = data.getExtras();
                //get the cropped bitmap
                Bitmap foto = extras.getParcelable("data");
                bmp = ImageUtils.compactImages(foto);
                img.setImageBitmap(bmp);

                Aluno p = new Aluno();
                p.setUsuario(pref.getString("usuario", null));
                if (p.editarFotoAlunoWeb(ImageUtils.bitmapToByteArray(bmp))) {
                    if (p.atualizarFotoAluno(b, ImageUtils.bitmapToByteArray(bmp))) {
                        Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show();
                    }
                }
                refresh();

            }
            /*try {
                       
                Uri selectedImage = data.getData();
                        
                String[] nomeCaminho = {MediaStore.Images.Media.DATA};
                        
                Cursor cursor = getContentResolver().query(selectedImage, nomeCaminho, null, null, null);
                cursor.moveToFirst();
                        
                int indexColuna = cursor.getColumnIndex(nomeCaminho[0]);
                String caminho = cursor.getString(indexColuna);
                        
                bmp = ImageUtils.compactImages(BitmapFactory.decodeFile(caminho));
                imagem.setImageBitmap(BitmapFactory.decodeFile(caminho));
                               
                      
            } catch (Exception e) {
               Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT).show();
               Log.e("Camera", e.toString());
            }
            */
        }

    } else {
        selectedImageUri = null;
        img.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.profile));
    }
}

From source file:com.otaupdater.SettingsActivity.java

private void showGetProKeyDialog() {
    if (cfg.hasProKey())
        return;/*from w ww. ja  va  2s .c  o  m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.settings_prokey_title);
    final boolean playServices = Utils.checkPlayServices(this);
    builder.setItems(playServices ? R.array.prokey_ops : R.array.prokey_ops_nomarket,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    which -= playServices ? 1 : 0;
                    switch (which) {
                    case -1:
                        try {
                            Bundle buyIntentBundle = service.getBuyIntent(3, getPackageName(),
                                    Config.PROKEY_SKU, "inapp", null);
                            PendingIntent buyIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            if (buyIntent != null)
                                startIntentSenderForResult(buyIntent.getIntentSender(), PROKEY_REQ_CODE,
                                        new Intent(), 0, 0, 0);
                        } catch (Exception e) {
                            Toast.makeText(SettingsActivity.this, R.string.prokey_error_init,
                                    Toast.LENGTH_SHORT).show();
                        }
                        break;
                    case 0:
                        redeemProKey();
                        break;
                    //                case 1:
                    //                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL)));
                    //                    break;
                    }
                }
            });

    final AlertDialog dlg = builder.create();
    dlg.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            onDialogShown(dlg);
        }
    });
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            onDialogClosed(dlg);
        }
    });
    dlg.show();
}

From source file:li.barter.fragments.SelectPreferredLocationFragment.java

@Override
public void onSuccess(final int requestId, final IBlRequestContract request, final ResponseInfo response) {
    if (requestId == RequestId.FOURSQUARE_VENUES) {
        mVenues = (Venue[]) response.responseBundle.getParcelableArray(HttpConstants.LOCATIONS);
        if ((mVenues == null) || (mVenues.length == 0)) {
            fetchVenuesForLocationWithoutCategoryFilter(DeviceInfo.INSTANCE.getLatestLocation(),
                    SEARCH_RADIUS_IN_METERS);
        } else {/*  www. j a va 2  s  .  c om*/
            mSelectLocationAdapter.setVenues(mVenues);
        }

    } else if (requestId == RequestId.FOURSQUARE_VENUES_WITHOUT_CATEGORIES) {
        mVenues = (Venue[]) response.responseBundle.getParcelableArray(HttpConstants.LOCATIONS);
        mSelectLocationAdapter.setVenues(mVenues);
        mSelectLocationAdapter.notifyDataSetChanged();
        if ((mVenues == null) || (mVenues.length == 0)) {
            mEmptyView.setVisibility(View.VISIBLE);
        } else {
            mEmptyView.setVisibility(View.GONE);
            mSelectLocationAdapter.setVenues(mVenues);
        }

    } else if (requestId == RequestId.SET_USER_PREFERRED_LOCATION) {

        SharedPreferenceHelper.set(R.string.pref_location,
                response.responseBundle.getString(HttpConstants.ID_LOCATION));

        final Intent returnIntent = new Intent();
        final Bundle arguments = getArguments();
        if (arguments != null) {
            final Intent onwardIntent = arguments.getParcelable(Keys.ONWARD_INTENT);

            if (onwardIntent != null) {
                returnIntent.putExtra(Keys.ONWARD_INTENT, onwardIntent);
            }

        }

        getActivity().setResult(ActionBarActivity.RESULT_OK, returnIntent);
        getActivity().finish();

    }
}

From source file:com.dahl.brendan.wordsearch.view.controller.WordSearchActivityController.java

public void restoreState(Bundle inState) {
    if (inState != null) {
        Bundle hsBundle = inState.getBundle(BUNDLE_HIGH_SCORE);
        if (hsBundle != null) {
            hs = new HighScore(hsBundle);
        } else {//from ww  w .  j a  v  a  2  s .  co m
            hs = null;
        }
        this.grid = inState.getParcelable(BUNDLE_GRID);
        this.setGrid(grid);
        wordSearch.setupViewGrid();
        updateTheme();
        this.timeSum = inState.getLong(BUNDLE_TIME, 0);
    } else {
        this.newWordSearch();
    }
}

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

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i("Daniel", "---resultCode---" + resultCode);
    //??-1??/*from  w  w w . ja v a2  s  .  c  om*/
    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));
        Log.i("Daniel", "---path---" + path);
        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.thunder.iap.IAPActivity.java

/**
 *
 * @param sku the item that the user wants to buy
 * @param developerPayload the developer payload string, more info here http://developer.android.com/training/in-app-billing/purchase-iab-products.html
 * @param buyItemListener//from  w  ww.  j a v  a 2s. com
 */
public void buyItem(final String sku, final String developerPayload, final BuyItemListener buyItemListener) {
    this.buyItemListener = buyItemListener;
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                        developerPayload);
                int response = buyIntentBundle.getInt("RESPONSE_CODE");
                if (response == 0) {
                    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                    try {
                        startIntentSenderForResult(pendingIntent.getIntentSender(), RC_INAPP_BUY, new Intent(),
                                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        //the onSuccess callback of the listener will be called on the method onActivityResult
                    } catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                        buyItemListener.onError(e);
                    }
                } else {
                    buyItemListener.onServerError(buyIntentBundle);
                }
            } catch (RemoteException e) {
                e.printStackTrace();
                buyItemListener.onError(e);
            }
        }
    }).start();
}

From source file:de.j4velin.wifiAutoOff.Locations.java

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

    Database db = Database.getInstance(this);
    locations = db.getLocations();/*from   w w  w.java  2 s .  c  o m*/
    db.close();

    setContentView(R.layout.locations);

    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (PREMIUM_ENABLED || locations.size() < 1) {
                startActivityForResult(new Intent(Locations.this, Map.class), REQUEST_LOCATION);
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(Locations.this);
                builder.setMessage(R.string.buy_pro);
                builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, int which) {
                        try {
                            Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
                                    "de.j4velin.wifiautomatic.billing.pro", "inapp", getPackageName());
                            if (buyIntentBundle.getInt("RESPONSE_CODE") == 0) {
                                PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                                startIntentSenderForResult(pendingIntent.getIntentSender(), REQUEST_BUY, null,
                                        0, 0, 0);
                            }
                        } catch (Exception e) {
                            if (BuildConfig.DEBUG)
                                Logger.log(e);
                            Toast.makeText(Locations.this, e.getClass().getName() + ": " + e.getMessage(),
                                    Toast.LENGTH_LONG).show();
                            e.printStackTrace();
                        }
                        dialog.dismiss();
                    }
                });
                builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.create().show();
            }
        }
    });

    mRecyclerView = (RecyclerView) findViewById(R.id.locations);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mAdapter = new LocationsAdapter();
    mRecyclerView.setAdapter(mAdapter);

    PREMIUM_ENABLED |= getSharedPreferences("settings", Context.MODE_PRIVATE).getBoolean("pro", false);
    if (!PREMIUM_ENABLED) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND")
                .setPackage("com.android.vending"), mServiceConn, Context.BIND_AUTO_CREATE);
    }

    findViewById(R.id.timeoutwarning).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            getSharedPreferences(getPackageName() + "_preferences", Context.MODE_MULTI_PROCESS).edit()
                    .putInt("no_network_timeout", 5).commit();
            v.setVisibility(View.GONE);
        }
    });

}