Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@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.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java

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

    if (getArguments() != null) {
        mAlert = (Alert) getArguments().getSerializable(ARG_ALERT_OBJECT);
    }/* ww w .j av  a2 s  . c o m*/

    if (savedInstanceState != null) {
        mAlert = (Alert) savedInstanceState.getSerializable(ARG_ALERT_OBJECT);
    }

    FabricUtils.logAlertContentView(mAlert);
}

From source file:edu.umd.umiacs.newsstand.imageview.ImagePagerActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_pager);

    Bundle bundle = getIntent().getExtras();

    mTitle = bundle.getString(MainActivity.TITLE);

    String[] imageUrls = bundle.getStringArray(IMAGE_URLS);
    int pagerPosition = bundle.getInt(IMAGE_POSITION, 0);
    mImages = (ArrayList<Image>) bundle.getSerializable(IMAGES);

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }/*from   w  w w .  jav a 2 s  .c  o m*/

    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_image_stub)
            .showImageOnFail(R.drawable.ic_image_stub).resetViewBeforeLoading().cacheOnDisc()
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
            .memoryCacheExtraOptions(3000, 3000).build();
    imageLoader.getInstance().init(config);

    String[] captions = new String[mImages.size()];
    int i = 0;
    for (Image currentImage : mImages) {
        captions[i] = currentImage.getCaption();
        i++;
    }
    pager = (DeactivableViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(imageUrls, captions));
    pager.setCurrentItem(pagerPosition);

    setupActionBar();
}

From source file:com.mobilesolutionworks.android.twitter.TwitterPluginFragment.java

protected Task<AccessToken> doGetAccessToken(final Twitter instance, Bundle bundle) {
    final Task<AccessToken>.TaskCompletionSource source = Task.create();

    new AsyncTask<Bundle, Void, Object>() {

        @Override//from  ww  w.java 2s.c o  m
        protected Object doInBackground(Bundle... params) {
            try {
                Bundle result = params[0];

                RequestToken token = (RequestToken) result.getSerializable("request_token");
                String verifier = result.getString("oauth_verifier");

                AccessToken accessToken = instance.getOAuthAccessToken(token, verifier);
                Log.d(BuildConfig.DEBUG_TAG, "accessToken.getScreenName() = " + accessToken.getScreenName());
                Log.d(BuildConfig.DEBUG_TAG, "accessToken.getUserId() = " + accessToken.getUserId());
                Log.d(BuildConfig.DEBUG_TAG, "accessToken.getToken() = " + accessToken.getToken());
                Log.d(BuildConfig.DEBUG_TAG, "accessToken.getTokenSecret() = " + accessToken.getTokenSecret());

                return accessToken;
            } catch (TwitterException e) {
                return e;
            }
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);
            if (o instanceof AccessToken) {
                source.trySetResult((AccessToken) o);
            } else {
                source.trySetError((Exception) o);
            }

        }
    }.execute(bundle);
    return source.getTask();
}

From source file:com.pickr.fragments.PhotoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_photo, null);
    mImageView = (ImageView) view.findViewById(R.id.photoImageView);
    mProgressBar = (ProgressBar) view.findViewById(R.id.photoLoadingProgressBar);

    mImageView.setOnClickListener(this);
    mProgressBar.setVisibility(View.VISIBLE);

    if (savedInstanceState != null) {
        mPhoto = (Photo) savedInstanceState.getSerializable(PARAM_PHOTO);
        mPhotoUrl = (URL) savedInstanceState.getSerializable(PARAM_PHOTO_URL);
    }//from   www  . ja v a  2  s  .  co  m

    new PhotoLoader(mImageView, getPhoto(), mHandler, getActivity()).execute();

    return view;
}

From source file:com.cw.litenote.note_add.Note_addText.java

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

    System.out.println("Note_addText / _onCreate");

    // get row Id from saved instance
    rowId = (savedInstanceState == null) ? null
            : (Long) savedInstanceState.getSerializable(DB_page.KEY_NOTE_ID);
}

From source file:com.kaliturin.blacklist.fragments.AddContactsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();
    if (arguments != null) {
        contactType = arguments.getInt(CONTACT_TYPE);
        sourceType = (ContactSourceType) arguments.getSerializable(SOURCE_TYPE);
        singleNumberMode = arguments.getBoolean(SINGLE_NUMBER_MODE);
    }//  ww  w .  j a v  a 2s.  c  o  m

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_add_contacts, container, false);
}

From source file:de.grobox.liberario.locations.LocationView.java

@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) { // implicit null check
        Bundle bundle = (Bundle) state;
        Location loc = (Location) bundle.getSerializable(LOCATION);
        String text = bundle.getString(TEXT);
        if (loc != null) {
            setLocation(loc);/*from   w  w w .  j  av  a2 s  .  com*/
        } else if (text != null && text.length() > 0) {
            ui.location.setText(text);
            ui.clear.setVisibility(View.VISIBLE);
        }
        int position = bundle.getInt(TEXT_POSITION);
        ui.location.setSelection(position);

        changingHome = bundle.getBoolean(CHANGING_HOME);
        if (changingHome) {
            Fragment homePicker = activity.getSupportFragmentManager()
                    .findFragmentByTag(HomePickerDialogFragment.TAG);
            if (homePicker != null && homePicker.isAdded()) {
                ((HomePickerDialogFragment) homePicker).setOnHomeChangedListener(this);
            }
        }

        // replace state by super state
        state = bundle.getParcelable(SUPER_STATE);
    }
    super.onRestoreInstanceState(state);
}

From source file:com.commonsware.android.camcon.CameraContentDemoActivity.java

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

    Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    if (savedInstanceState == null) {
        output = new File(new File(getFilesDir(), PHOTOS), FILENAME);

        if (output.exists()) {
            output.delete();/*from   www .j  av  a  2  s  .c o m*/
        } else {
            output.getParentFile().mkdirs();
        }
    } else {
        output = (File) savedInstanceState.getSerializable(EXTRA_FILENAME);
    }

    outputUri = FileProvider.getUriForFile(this, AUTHORITY, output);

    if (savedInstanceState == null) {
        i.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            ClipData clip = ClipData.newUri(getContentResolver(), "A photo", outputUri);

            i.setClipData(clip);
            i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        } else {
            List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(i,
                    PackageManager.MATCH_DEFAULT_ONLY);

            for (ResolveInfo resolveInfo : resInfoList) {
                String packageName = resolveInfo.activityInfo.packageName;
                grantUriPermission(packageName, outputUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            }
        }

        startActivityForResult(i, CONTENT_REQUEST);
    }
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@Override
public void debugProgram() {
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.getSerializable(CompileManager.EXTRA_FILE) != null) {
        mFilePath = ((File) extras.getSerializable(CompileManager.EXTRA_FILE)).getPath();
        if (mFilePath.isEmpty())
            return;
        File file = new File(mFilePath);
        if (!file.exists()) {
            finish();/*from  w w w . j a va2  s . com*/
            return;
        }
        String code = null;
        try {
            code = IOUtils.toString(new FileReader(file));
        } catch (IOException e) {
            e.printStackTrace();
            finish();
            return;
        }
        mCodeView.setTextHighlighted(code);
        mCodeView.highlightAll();

        setTitle(file.getName());
        mEnded.set(false);
        setEnableDebug(true); //disable DEBUG
        createAndRunProgram(mFilePath); //execute file
    } else {
        finish();
    }
}

From source file:com.google.android.gms.nearby.messages.samples.nearbybackgroundbeacons.MainActivityFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);

    if (savedInstanceState != null) {
        mSubState = (SubState) savedInstanceState.getSerializable(KEY_SUB_STATE);
        mResolvingError = savedInstanceState.getBoolean((KEY_RESOLVING_ERROR));
    }//from w ww .  j  a  va 2 s .  com
    mNearbyMessagesList = Utils.getCachedMessages(getActivity());

    final ListView nearbyMessagesListView = (ListView) view.findViewById(R.id.nearby_messages_list_view);
    mNearbyMessagesArrayAdapter = new ArrayAdapter<>(getActivity().getApplicationContext(),
            android.R.layout.simple_list_item_1, mNearbyMessagesList);
    nearbyMessagesListView.setAdapter(mNearbyMessagesArrayAdapter);

    mSubscriptionImageButton = (ImageButton) view.findViewById(R.id.subscription_image_button);
    mSubscriptionImageButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            switch (mSubState) {
            case NOT_SUBSCRIBING:
            case ATTEMPTING_TO_UNSUBSCRIBE:
                mSubState = SubState.ATTEMPTING_TO_SUBSCRIBE;
                subscribe();
                break;
            case SUBSCRIBING:
            case ATTEMPTING_TO_SUBSCRIBE:
                mSubState = SubState.ATTEMPTING_TO_UNSUBSCRIBE;
                unsubscribe();
                break;
            }
            updateUI();
        }
    });
    mSubscriptionProgressBar = (ProgressBar) view.findViewById(R.id.subscription_progress_bar);
    return view;
}