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.wjh1119.bestnews.ui.fragment.DetailFragment.java

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

    //??//from www  .j  a v  a  2s  .  co  m
    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        mTransitionAnimation = arguments.getBoolean(DetailFragment.DETAIL_TRANSITION_ANIMATION, false);
    }

    View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);

    //?reviewFragment?
    Fragment reviewFragment = getChildFragmentManager().findFragmentByTag(REVIEWFRAGMENT_TAG);
    if (reviewFragment == null) {
        Logger.i(LOG_TAG, "add new reviewFragment !!");
        Bundle args = new Bundle();
        args.putParcelable(ReviewFragment.REVIEW_URI, mUri);

        reviewFragment = new ReviewFragment();
        reviewFragment.setArguments(args);

        FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.container_review, reviewFragment, REVIEWFRAGMENT_TAG).commit();
    } else {
        Logger.i(LOG_TAG, "found existing reviewFragment, no need to add it again !!");
    }

    //view
    ButterKnife.bind(this, rootView);

    imageManager = ImageManager.getSingleton(getContext());

    return rootView;
}

From source file:palamarchuk.smartlife.app.fragments.ProfileFragment.java

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

    ((FragmentHolderActivity) parentActivity).updateTitle("");

    dialogAttachCard = new DialogAttachCard(getActivity(), true);
    dialogAttachCard.setObtainResultListener(cardNumberResult);

    View rootView = inflater.inflate(R.layout.profile, null);

    Bundle bundle = getArguments();
    UserInfo userInfo = bundle.getParcelable(UserInfo.PARCELABLE_KEY);

    ((TextView) rootView.findViewById(R.id.profile_name))
            .setText(userInfo.getFirst_name() + " " + userInfo.getLastName());
    ((TextView) rootView.findViewById(R.id.profile_email)).setText(userInfo.getEmail());
    ((TextView) rootView.findViewById(R.id.profile_phone)).setText(userInfo.getPhone());
    ((TextView) rootView.findViewById(R.id.profile_birth_date)).setText(userInfo.getBirthdate());
    userPoints = (TextView) rootView.findViewById(R.id.profile_points);
    userPoints.setText(userInfo.getPoints());

    rootView.findViewById(R.id.profile_setting).setOnClickListener(this);
    rootView.findViewById(R.id.profile_feedback).setOnClickListener(this);
    rootView.findViewById(R.id.profile_edit_favorite).setOnClickListener(this);
    rootView.findViewById(R.id.profile_history).setOnClickListener(this);
    rootView.findViewById(R.id.profile_rules).setOnClickListener(this);
    rootView.findViewById(R.id.profileGiveBonuses).setOnClickListener(this);
    rootView.findViewById(R.id.profileReopenInitialNavigation).setOnClickListener(this);
    rootView.findViewById(R.id.profileShowMyCards).setOnClickListener(this);

    rootView.findViewById(R.id.profileAttachCard).setOnClickListener(this);

    return rootView;
}

From source file:com.paymaya.sdk.android.checkout.PayMayaCheckoutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.paymaya_checkout_activity);

    Intent intent = getIntent();/*  w  w w  .jav  a2  s  .  com*/
    Preconditions.checkNotNull(intent, "Missing intent.");

    Bundle bundle = intent.getBundleExtra(EXTRAS_CHECKOUT_BUNDLE);
    Preconditions.checkNotNull(bundle, "Missing bundle.");

    mCheckout = bundle.getParcelable(EXTRAS_CHECKOUT);
    Preconditions.checkNotNull(mCheckout, "Missing checkout object.");

    mClientKey = intent.getStringExtra(EXTRAS_CLIENT_KEY);
    Preconditions.checkNotNull(mClientKey, "Missing client key.");

    initialize();
    requestCreateCheckout();
}

From source file:de.wikilab.android.friendica01.FileUploadService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.i("Andfrnd/UploadFile", "onHandleIntent exec");

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    //Instantiate the Notification:
    CharSequence tickerText = "Uploading...";
    Notification notification = new Notification(R.drawable.arrow_up, tickerText, System.currentTimeMillis());
    notification.flags |= Notification.FLAG_ONGOING_EVENT;

    //Define the Notification's expanded message and Intent:
    Context context = getApplicationContext();
    PendingIntent nullIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
    notification.setLatestEventInfo(context, "Upload in progress...", "You are notified here when it completes",
            nullIntent);/*from  w  w  w  .java2s .c  om*/

    //Pass the Notification to the NotificationManager:
    mNotificationManager.notify(UPLOAD_PROGRESS_ID, notification);
    /*
    final TwLogin login = new TwLogin();
    login.initialize(FileUploadService.this);
    login.doLogin(FileUploadService.this, null, false);
            
    if (!login.isLoginOK()) {
       showFailMsg(FileUploadService.this, "Invalid login data or no network connection");
       return;
    }
    */
    Bundle intentPara = intent.getExtras();
    fileToUpload = (Uri) intentPara.getParcelable(Intent.EXTRA_STREAM);
    descText = intentPara.getString(EXTRA_DESCTEXT);
    subject = intentPara.getString(Intent.EXTRA_SUBJECT);

    if (targetFilename == null || targetFilename.equals(""))
        targetFilename = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".txt";

    String fileSpec = Max.getRealPathFromURI(FileUploadService.this, fileToUpload);

    String tempFile = Max.IMG_CACHE_DIR + "/imgUploadTemp_" + System.currentTimeMillis() + ".jpg";
    Max.resizeImage(fileSpec, tempFile, 1024, 768);

    try {
        Log.i("Andfrnd/UploadFile", "before uploadFile");
        final TwAjax uploader = new TwAjax(FileUploadService.this, true, true);
        uploader.addPostFile(new TwAjax.PostFile("media", targetFilename, tempFile));
        uploader.addPostData("status", descText);
        uploader.addPostData("title", subject);
        uploader.addPostData("source",
                "<a href='http://friendica-for-android.wiki-lab.net'>Friendica for Android</a>");
        uploader.uploadFile(Max.getServer(this) + "/api/statuses/update", null);
        Log.i("Andfrnd/UploadFile", "after uploadFile");
        Log.i("Andfrnd/UploadFile", "isSuccess() = " + uploader.isSuccess());
        Log.i("Andfrnd/UploadFile", "getError() = " + uploader.getError());

        mNotificationManager.cancel(UPLOAD_PROGRESS_ID);
        if (uploader.isSuccess() && uploader.getError() == null) {
            JSONObject result = null;
            try {
                Log.i("Andfrnd/UploadFile", "JSON RESULT: " + uploader.getHttpCode());
                result = (JSONObject) uploader.getJsonResult();

                String postedText = result.getString("text");
                showSuccessMsg(FileUploadService.this);

            } catch (Exception e) {
                String errMes = e.getMessage() + " | " + uploader.getResult();
                if (result != null)
                    try {
                        errMes = result.getString("error");
                    } catch (JSONException fuuuuJava) {
                    }

                showFailMsg(FileUploadService.this, errMes);

                e.printStackTrace();
            }
        } else if (uploader.getError() != null) {
            showFailMsg(FileUploadService.this, uploader.getError().toString());
        } else {
            showFailMsg(FileUploadService.this, uploader.getResult());
        }

    } finally {
        new File(tempFile).delete();
    }
}

From source file:net.kourlas.voipms_sms.Billing.java

private void showDonationDialog(Activity sourceActivity) {
    try {/*ww w. jav a 2s  . c  om*/
        Bundle buyIntentBundle = billingService.getBuyIntent(3, applicationContext.getPackageName(),
                applicationContext.getString(R.string.billing_pid_donation), "inapp", null);
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        sourceActivity.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0);
    } catch (Exception ex) {
        Utils.showInfoDialog(sourceActivity, applicationContext.getString(R.string.billing_failure));
    }
}

From source file:com.cerema.cloud2.ui.preview.FileDownloadFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    setFile((OCFile) args.getParcelable(ARG_FILE));
    // TODO better in super, but needs to check ALL the class extending FileFragment; not right now

    mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
    mAccount = args.getParcelable(ARG_ACCOUNT);
}

From source file:com.appniche.android.sunshine.app.DetailFragment.java

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

    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        mTransitionAnimation = arguments.getBoolean(DetailFragment.DETAIL_TRANSITION_ANIMATION, false);
    }//from ww  w  .j a  v a  2s  .  com

    View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);
    mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
    mDateView = (TextView) rootView.findViewById(R.id.detail_date_textview);
    mDescriptionView = (TextView) rootView.findViewById(R.id.detail_forecast_textview);
    mHighTempView = (TextView) rootView.findViewById(R.id.detail_high_textview);
    mLowTempView = (TextView) rootView.findViewById(R.id.detail_low_textview);
    mHumidityView = (TextView) rootView.findViewById(R.id.detail_humidity_textview);
    mHumidityLabelView = (TextView) rootView.findViewById(R.id.detail_humidity_label_textview);
    mWindView = (TextView) rootView.findViewById(R.id.detail_wind_textview);
    mWindLabelView = (TextView) rootView.findViewById(R.id.detail_wind_label_textview);
    mPressureView = (TextView) rootView.findViewById(R.id.detail_pressure_textview);
    mPressureLabelView = (TextView) rootView.findViewById(R.id.detail_pressure_label_textview);
    return rootView;
}

From source file:com.creativechaitu.castremotedisplay.CastRemoteDisplayActivity.java

/**
 * Initialization of the Activity after it is first created. Must at least
 * call {@link android.app.Activity#setContentView setContentView()} to
 * describe what is to be displayed in the screen.
 *///from  w  w w. j  av a  2  s  .c o  m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.second_screen_layout);
    setFullScreen();
    setupActionBar();

    // Local UI
    final Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Change the remote display animation color when the button is clicked
            PresentationService presentationService = (PresentationService) CastRemoteDisplayLocalService
                    .getInstance();
            if (presentationService != null) {
                presentationService.changeColor();
            }
        }
    });

    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(CastMediaControlIntent.categoryForCast(getString(R.string.app_id))).build();
    if (isRemoteDisplaying()) {
        // The Activity has been recreated and we have an active remote display session,
        // so we need to set the selected device instance
        CastDevice castDevice = CastDevice.getFromBundle(mMediaRouter.getSelectedRoute().getExtras());
        mCastDevice = castDevice;
    } else {
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            mCastDevice = extras.getParcelable(MainActivity.INTENT_EXTRA_CAST_DEVICE);
        }
    }

    mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
            MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}

From source file:ar.com.martineo14.spotifystreamer2.ui.fragment.TrackPlayerActivityFragment.java

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

    artistNameTextView = (TextView) rootView.findViewById(R.id.player_artist_name);
    artistAlbumNameTextView = (TextView) rootView.findViewById(R.id.player_album_name);
    trackAlbumImage = (ImageView) rootView.findViewById(R.id.player_album_artwork);
    trackNameTextView = (TextView) rootView.findViewById(R.id.player_track_name);
    seekBar = (SeekBar) rootView.findViewById(R.id.player_seekbar);
    trackDuration = (TextView) rootView.findViewById(R.id.player_track_duration);
    addListenerOnButton(rootView);/* www  .  j a v  a  2 s  .c om*/
    Bundle bundle = getArguments();
    createMediaPlayer();
    if (savedInstanceState == null) {
        trackModel = bundle.getParcelable(Constants.TRACK_MODEL);
    } else {
        trackModel = savedInstanceState.getParcelable(Constants.TRACK_MODEL);
        mActualTrackPosition = savedInstanceState.getInt(Constants.ACTUAL_POSITION);
    }

    displayTrack(trackModel);
    return rootView;
}

From source file:biz.wiz.android.wallet.util.ViewPagerTabs.java

@Override
public void onRestoreInstanceState(final Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        pagePosition = bundle.getInt("page_position");
        pageOffset = bundle.getFloat("page_offset");
        super.onRestoreInstanceState(bundle.getParcelable("super_state"));
        return;/*from w w w  .j a v a2 s  .  co m*/
    }

    super.onRestoreInstanceState(state);
}