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:br.com.GUI.perfil.PerfilPersonal.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);/* www  . ja  va 2s.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");
                Personal p = new Personal();
                p.setUsuario(pref.getString("usuario", null));
                if (p.editarFotoPersonalWeb(ImageUtils.bitmapToByteArray(bmp))) {
                    Log.i("salvei web", "salvei web");
                    if (p.editarFotoPersonal(b, ImageUtils.bitmapToByteArray(bmp))) {
                        Log.i("salvei local", "salvei local");
                        refresh();
                        Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show();
                    }
                }
                Log.i("setei", "no primeirro");

            }

        } 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);

                Log.i("tirei a foto ", "e setei no canvas");
                Personal p = new Personal();
                p.setUsuario(pref.getString("usuario", null));
                if (p.editarFotoPersonalWeb(ImageUtils.bitmapToByteArray(bmp))) {
                    Log.i("salvei web", "salvei web");

                    if (p.editarFotoPersonal(b, ImageUtils.bitmapToByteArray(bmp))) {
                        Log.i("salvei local", "salvei local");
                        img.setImageBitmap(bmp);
                        Toast.makeText(getActivity(), "Atualizada com sucesso!", Toast.LENGTH_SHORT).show();
                    }
                }
                Log.i("setei", "no primeirro");

                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.antew.redditinpictures.library.ui.ImageViewerFragment.java

protected void loadSavedInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState.containsKey(IMAGE_DATA_EXTRA)) {
        mImage = savedInstanceState.getParcelable(IMAGE_DATA_EXTRA);
    }//from   w  w w  .j  a  v  a 2  s  .c  om

    if (savedInstanceState.containsKey(IMAGE_ALBUM_EXTRA)) {
        mAlbum = savedInstanceState.getParcelable(IMAGE_ALBUM_EXTRA);
    }
}

From source file:de.unclenet.dehabewe.CalendarActivity.java

private void gotAccount(final AccountManager manager, final Account account) {
    SharedPreferences settings = getSharedPreferences(PREF, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("accountName", account.name);
    editor.commit();// ww  w.j  ava2 s .  c  o  m
    new Thread() {

        @Override
        public void run() {
            try {
                final Bundle bundle = manager.getAuthToken(account, AUTH_TOKEN_TYPE, true, null, null)
                        .getResult();
                runOnUiThread(new Runnable() {

                    public void run() {
                        try {
                            if (bundle.containsKey(AccountManager.KEY_INTENT)) {
                                Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
                                int flags = intent.getFlags();
                                flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK;
                                intent.setFlags(flags);
                                startActivityForResult(intent, REQUEST_AUTHENTICATE);
                            } else if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
                                authenticatedClientLogin(bundle.getString(AccountManager.KEY_AUTHTOKEN));
                            }
                        } catch (Exception e) {
                            handleException(e);
                        }
                    }
                });
            } catch (Exception e) {
                handleException(e);
            }
        }
    }.start();
}

From source file:com.community.yuequ.bottombar.BottomBarTab.java

@Override
public void onRestoreInstanceState(Parcelable state) {
    if (badge != null && state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        badge.restoreState(bundle, indexInContainer);

        state = bundle.getParcelable("superstate");
    }// ww w .j a v a 2s . co m
    super.onRestoreInstanceState(state);
}

From source file:com.game.simple.Game3.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (Session.getActiveSession() != null)
        Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);

    ////////////////////image////////////////////
    if (resultCode != RESULT_OK) {
        return;//from  w w w  .  ja v a2  s  .c om
    }
    switch (requestCode) {
    case PICK_FROM_FILE:
        if (data == null) {
            Log.e("PICK_FROM_FILE", "NULL");
            return;
        }
        selectedImage = data.getData();

        cropImage(selectedImage);
        break;
    case PIC_CROP:
        if (data == null) {
            return;
        }
        Bundle extras = data.getExtras();
        Bitmap thePic = extras.getParcelable("data");
        Boolean isSDPresent = android.os.Environment.getExternalStorageState()
                .equals(android.os.Environment.MEDIA_MOUNTED);
        if (isSDPresent) {
            cropedImagePath = Environment.getExternalStorageDirectory().toString() + "/DCIM/avatar.jpeg";
        } else {
            cropedImagePath = "mnt/emmc/avata.jpeg";
        }
        Log.e("---------------path", cropedImagePath);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(cropedImagePath);
            thePic.compress(Bitmap.CompressFormat.JPEG, 90, out);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (Throwable ignore) {
            }
        }

        break;
    case CAMERA_CAPTURE:
        cameraImage = data.getData();
        if (cameraImage == null) {
            Log.e("CAMERA_CAPTURE", "NULL");
            return;
        }
        cropImage(cameraImage);
        break;
    default:
        break;
    }

}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);//  ww  w.  ja va 2 s. c o  m
    setActionBarColor(getResources().getColor(R.color.Actionbar_Saved_Background));
    selectedItems = new SparseBooleanArrayParcelable();
    if (savedInstanceState != null) {
        selectedItems = savedInstanceState.getParcelable(STATE_SELECTED_ITEMS);
    }
}

From source file:com.notalenthack.blaster.CommandActivity.java

protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mDevice = savedInstanceState.getParcelable(Constants.KEY_DEVICE_STATE);
}

From source file:eu.faircode.adblocker.IAB.java

public PendingIntent getBuyIntent(String sku) throws RemoteException {
    if (service == null)
        return null;
    Bundle bundle = service.getBuyIntent(IAB_VERSION, context.getPackageName(), sku, "inapp", "adblocker");
    Log.i(TAG, "getBuyIntent");
    Util.logBundle(bundle);/*w w  w . j  av  a 2  s.  c  o m*/
    int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1));
    Log.i(TAG, "Response=" + getResult(response));
    if (response != 0)
        throw new IllegalArgumentException(getResult(response));
    if (!bundle.containsKey("BUY_INTENT"))
        throw new IllegalArgumentException("BUY_INTENT missing");
    return bundle.getParcelable("BUY_INTENT");
}

From source file:com.coderstory.FTool.utils.licensesdialog.LicensesDialogFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Resources resources = getResources();

    if (savedInstanceState != null) {
        mTitleText = savedInstanceState.getString(STATE_TITLE_TEXT);
        mLicensesText = savedInstanceState.getString(STATE_LICENSES_TEXT);
        mCloseButtonText = savedInstanceState.getString(STATE_CLOSE_TEXT);
        if (savedInstanceState.containsKey(STATE_THEME_XML_ID)) {
            mThemeResourceId = savedInstanceState.getInt(STATE_THEME_XML_ID);
        }/*www .ja  va2  s.c  om*/
        if (savedInstanceState.containsKey(STATE_DIVIDER_COLOR)) {
            mDividerColor = savedInstanceState.getInt(STATE_DIVIDER_COLOR);
        }
    } else {
        mTitleText = resources.getString(R.string.notices_title);
        mCloseButtonText = resources.getString(R.string.notices_close);
        try {
            final Notices notices;
            final Bundle arguments = getArguments();
            if (arguments != null) {
                if (arguments.containsKey(ARGUMENT_NOTICES_XML_ID)) {
                    notices = NoticesXmlParser.parse(resources.openRawResource(getNoticesXmlResourceId()));
                } else if (arguments.containsKey(ARGUMENT_NOTICES)) {
                    notices = arguments.getParcelable(ARGUMENT_NOTICES);
                } else {
                    throw new IllegalStateException("Missing ARGUMENT_NOTICES_XML_ID / ARGUMENT_NOTICES");
                }
                if (arguments.getBoolean(ARGUMENT_INCLUDE_OWN_LICENSE, false)) {
                    notices.getNotices().add(LicensesDialog.LICENSES_DIALOG_NOTICE);
                }
                final boolean showFullLicenseText = arguments.getBoolean(ARGUMENT_FULL_LICENSE_TEXT, false);
                if (arguments.containsKey(ARGUMENT_THEME_XML_ID)) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        mThemeResourceId = arguments.getInt(ARGUMENT_THEME_XML_ID,
                                android.R.style.Theme_DeviceDefault_Light_Dialog);
                    } else {
                        mThemeResourceId = arguments.getInt(ARGUMENT_THEME_XML_ID);
                    }
                }
                if (arguments.containsKey(ARGUMENT_DIVIDER_COLOR)) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        mDividerColor = arguments.getInt(ARGUMENT_DIVIDER_COLOR,
                                android.R.color.holo_blue_light);
                    } else {
                        mDividerColor = arguments.getInt(ARGUMENT_DIVIDER_COLOR);
                    }
                }
                mLicensesText = NoticesHtmlBuilder.create(getActivity()).setNotices(notices)
                        .setShowFullLicenseText(showFullLicenseText).build();
            } else {
                throw new IllegalStateException("Missing arguments");
            }
        } catch (final Exception e) {
            throw new IllegalStateException(e);
        }
    }
}

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

/**
 * Gets the fragment arguments, retrieves correct
 * ThreadComment object from either ThreadList or Cache or FavouritesLog,
 * Starts the refresh from server.//from w  ww  . ja  v a 2 s .co  m
 * @param savedInstanceState The previously saved state of the Fragment.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    threadIndex = (int) bundle.getLong("id");
    isFavCom = bundle.getInt("favCom");
    thread = bundle.getParcelable("thread");
    if (locationListener == null) {
        locationListener = new LocationListenerService(getActivity());
    }
    if (prefManager == null) {
        prefManager = PreferencesManager.getInstance();
    }
    // Assign custom adapter to the thread listView.
    adapter = new ThreadViewAdapter(getActivity(), thread, getFragmentManager(), threadIndex);
    if (isFavCom != -1) {
        connectHelper = ConnectivityHelper.getInstance();
        cache = CacheManager.getInstance();
        ArrayList<Comment> comments = cache.deserializeThreadCommentById(thread.getId());
        if (comments != null) {
            thread.getBodyComment().setChildren(comments);
        }
        if (!connectHelper.isConnected()) {
            Toaster.toastShort("No network connection.");
        }
    }
}