Example usage for android.os Bundle getBundle

List of usage examples for android.os Bundle getBundle

Introduction

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

Prototype

@Nullable
public Bundle getBundle(@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:android.support.car.ui.CarNavExtender.java

/**
 * Reconstruct a CarNavExtender from an existing notification. Can be used to retrieve values.
 *
 * @param notification The notification to retrieve the values from.
 *//*from   www . ja  v  a2  s. c  o m*/
public CarNavExtender(@NonNull Notification notification) {
    Bundle extras = NotificationCompat.getExtras(notification);
    if (extras == null) {
        return;
    }
    Bundle b = extras.getBundle(EXTRA_CAR_EXTENDER);
    if (b == null) {
        return;
    }

    mIsExtended = b.getBoolean(EXTRA_IS_EXTENDED);
    mContentId = (Long) b.getSerializable(EXTRA_CONTENT_ID);
    // The ternary guarantees that we return either TYPE_HERO or TYPE_NORMAL.
    mType = (b.getInt(EXTRA_TYPE, TYPE_NORMAL) == TYPE_HERO) ? TYPE_HERO : TYPE_NORMAL;
    mContentTitle = b.getCharSequence(Notification.EXTRA_TITLE);
    mContentText = b.getCharSequence(Notification.EXTRA_TEXT);
    mSubText = b.getCharSequence(EXTRA_SUB_TEXT);
    mLargeIcon = b.getParcelable(Notification.EXTRA_LARGE_ICON);
    mActionIcon = b.getInt(EXTRA_ACTION_ICON);
    mContentIntent = b.getParcelable(EXTRA_CONTENT_INTENT);
    mColor = b.getInt(EXTRA_COLOR, Notification.COLOR_DEFAULT);
    mNightColor = b.getInt(EXTRA_NIGHT_COLOR, Notification.COLOR_DEFAULT);
    mShowInStream = b.getBoolean(EXTRA_STREAM_VISIBILITY, true);
    mShowAsHeadsUp = b.getBoolean(EXTRA_HEADS_UP_VISIBILITY);
    mIgnoreInStream = b.getBoolean(EXTRA_IGNORE_IN_STREAM);
}

From source file:com.checktipsplitter.ui.FragmentAddBill.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_createpost, container, false);
    mWizardModel = new WizardModel(getActivity());

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }/*from  w w  w .ja v a2 s  .c o  m*/

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());
    mPager = (ViewPager) rootView.findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) rootView.findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) rootView.findViewById(R.id.next_button);
    mPrevButton = (Button) rootView.findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                DialogFragment dg = new DialogFragment() {
                    @Override
                    public Dialog onCreateDialog(Bundle savedInstanceState) {
                        return new AlertDialog.Builder(getActivity())
                                .setMessage(R.string.submit_confirm_message)
                                .setPositiveButton(R.string.submit_confirm_button,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                getActivity().finish();
                                            }
                                        })
                                .setNegativeButton(android.R.string.cancel, null).create();
                    }
                };
                dg.show(getActivity().getSupportFragmentManager(), "place_order_dialog");
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();

    return rootView;
}

From source file:dev.dworks.libs.awizard.WizardActivity.java

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

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
        mDataChanged = savedInstanceState.getBoolean("dataChanged");
    }//from w  ww  . j  a  v a2  s  .co m
}

From source file:com.fastbootmobile.encore.app.PlaylistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    setContentView(R.layout.activity_playlist);

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (PlaylistViewFragment) fm.findFragmentByTag(TAG_FRAGMENT);
    if (savedInstance == null) {
        mInitialIntent = getIntent().getExtras();
    } else {/*from  w  w  w  . ja v  a  2 s.  co  m*/
        mInitialIntent = savedInstance.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new PlaylistViewFragment();
        fm.beginTransaction().add(R.id.playlist_container, mActiveFragment, TAG_FRAGMENT).commit();
        mActiveFragment.setArguments(mInitialIntent);
    }

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View imageHeader = mActiveFragment.getHeroImageView();
                if (imageHeader != null) {
                    sharedElements.put("itemImage", imageHeader);
                }

                View albumName = mActiveFragment.findViewById(R.id.tvAlbumName);
                if (albumName != null) {
                    final int cx = albumName.getMeasuredWidth() / 4;
                    final int cy = albumName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(albumName, cx, cy);

                    if (albumName.isAttachedToWindow()) {
                        if (mIsEntering) {
                            albumName.setVisibility(View.INVISIBLE);
                            Utils.animateCircleReveal(albumName, cx, cy, 0, radius, duration, 300);
                        } else {
                            albumName.setVisibility(View.VISIBLE);
                            Utils.animateCircleReveal(albumName, cx, cy, radius, 0, duration, 0);
                        }
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:org.jboss.aerogear.android.authentication.impl.loader.AuthenticationModuleAdapter.java

@Override
public Loader<HeaderAndBody> onCreateLoader(int id, Bundle bundle) {
    AuthenticationModuleAdapter.Methods method = (AuthenticationModuleAdapter.Methods) bundle.get(METHOD);
    Callback callback = (Callback) bundle.get(CALLBACK);
    Loader loader = null;/*  www.  j  a  va2 s  .com*/
    switch (method) {
    case LOGIN: {
        Bundle loginBundle = bundle.getBundle(PARAMS);
        Map<String, String> loginParams = new HashMap<String, String>(loginBundle.size());
        for (String key : loginBundle.keySet()) {
            loginParams.put(key, loginBundle.getString(key));
        }
        loader = new LoginLoader(applicationContext, callback, module, loginParams);
    }
        break;
    case LOGOUT: {
        loader = new LogoutLoader(applicationContext, callback, module);
    }
        break;
    case ENROLL: {
        Map<String, String> params = (Map<String, String>) bundle.getSerializable(PARAMS);
        loader = new EnrollLoader(applicationContext, callback, module, params);
    }
        break;
    }
    return loader;
}

From source file:pl.openrnd.managers.fragmentsswapper.FragmentDescriptorImpl.java

/**
 * Method must be called in onCreate() method of holding fragment.
 *
 * @see android.support.v4.app.Fragment/*  ww w. j av a 2s .c  o  m*/
 *
 * @param savedInstanceState Bundle object containing saved state.
 */
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(DATA_REQUEST_CODE)) {
            mResultCode = savedInstanceState.getInt(DATA_REQUEST_CODE, RESULT_CANCELED);
        }

        if (savedInstanceState.containsKey(DATA_RESULT_BUNDLE)) {
            mResultData = savedInstanceState.getBundle(DATA_RESULT_BUNDLE);
        }
    }
}

From source file:com.firebase.jobdispatcher.GooglePlayReceiver.java

@Nullable
private JobParameters prepareJob(Intent intent) {
    Bundle data = intent.getExtras();
    if (data == null) {
        Log.e(TAG, ERROR_NO_DATA);/*from  www.j a  v a2  s .co  m*/
        return null;
    }

    // get the callback first. If we don't have this we can't talk back to the backend.
    JobCallback callback = callbackExtractor.extractCallback(data);
    if (callback == null) {
        Log.i(TAG, "no callback found");
        return null;
    }

    Bundle extras = data.getBundle(GooglePlayJobWriter.REQUEST_PARAM_EXTRAS);
    if (extras == null) {
        Log.i(TAG, "no 'extras' bundle found");
        sendResultSafely(callback, JobService.RESULT_FAIL_NORETRY);
        return null;
    }

    JobInvocation job = prefixedCoder.decode(extras);
    if (job == null) {
        Log.i(TAG, "unable to decode job from extras");
        sendResultSafely(callback, JobService.RESULT_FAIL_NORETRY);
        return null;
    }

    // repack the extras
    job.getExtras().putAll(extras);

    synchronized (this) {
        SimpleArrayMap<String, JobCallback> map = callbacks.get(job.getService());
        if (map == null) {
            map = new SimpleArrayMap<>(1);
            callbacks.put(job.getService(), map);
        }

        map.put(job.getTag(), callback);
    }

    return job;
}

From source file:com.example.com.benasque2014.mercurio.AddRecorridoActivity.java

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

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }// w  ww. j  a va2s  . co  m

    PuntosInfoFragment.points = new ArrayList<LatLng>();
    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) findViewById(R.id.next_button);
    mPrevButton = (Button) findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                if (Utils.isOnline(getApplicationContext())) {
                    DialogFragment dg = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            return new AlertDialog.Builder(getActivity())
                                    .setMessage(R.string.submit_confirm_message)
                                    .setPositiveButton(R.string.submit_confirm_button, new OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            guardarRuta();
                                        }
                                    }).setNegativeButton(android.R.string.cancel, null).create();
                        }
                    };
                    dg.show(getSupportFragmentManager(), "place_order_dialog");
                } else {
                    Toast.makeText(getApplicationContext(), "No internet.", Toast.LENGTH_SHORT).show();
                }
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();
}

From source file:com.example.android.wizardpager.MainActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);/*from www  . j a v  a2  s.co  m*/

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) findViewById(R.id.next_button);
    mPrevButton = (Button) findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                DialogFragment dg = new DialogFragment() {
                    @Override
                    public Dialog onCreateDialog(Bundle savedInstanceState) {
                        return new AlertDialog.Builder(getActivity())
                                .setMessage(R.string.submit_confirm_message)
                                .setPositiveButton(R.string.submit_confirm_button, null)
                                .setNegativeButton(android.R.string.cancel, null).create();
                    }
                };
                dg.show(getSupportFragmentManager(), "place_order_dialog");
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();
}

From source file:com.example.android.wizardpager.MainFragment.java

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

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }/*from  ww w. j a  va  2 s  .co  m*/

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());
    mPager = (ViewPager) rootView.findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) rootView.findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) rootView.findViewById(R.id.next_button);
    mPrevButton = (Button) rootView.findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                DialogFragment dg = new DialogFragment() {
                    @Override
                    public Dialog onCreateDialog(Bundle savedInstanceState) {
                        return new AlertDialog.Builder(getActivity())
                                .setMessage(R.string.submit_confirm_message)
                                .setPositiveButton(R.string.submit_confirm_button,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {

                                                Post post = new Post();
                                                post.setPostDate(new Date());

                                                for (Page p : mWizardModel.getCurrentPageSequence()) {
                                                    switch (p.getKey()) {
                                                    case PermutaSepWizardModel.CONTACT_INFO_KEY:
                                                        User user = new User(
                                                                p.getData().getString(
                                                                        ProfessorContactInfoPage.NAME_DATA_KEY),
                                                                p.getData().getString(
                                                                        ProfessorContactInfoPage.EMAIL_DATA_KEY),
                                                                p.getData().getString(
                                                                        ProfessorContactInfoPage.PHONE_DATA_KEY));
                                                        post.setUser(user);
                                                        break;
                                                    case PermutaSepWizardModel.CITY_FROM_KEY:
                                                        post.setStateFrom((State) p.getData().getParcelable(
                                                                ProfessorCityFromPage.STATE_DATA_KEY));
                                                        post.setCityFrom((City) p.getData().getParcelable(
                                                                ProfessorCityFromPage.MUNICIPALITY_DATA_KEY));
                                                        post.setTownFrom((Town) p.getData().getParcelable(
                                                                ProfessorCityFromPage.LOCALITY_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.CITY_TO_KEY:
                                                        post.setStateTo((State) p.getData().getParcelable(
                                                                ProfessorCityToPage.STATE_TO_DATA_KEY));
                                                        post.setCityTo((City) p.getData().getParcelable(
                                                                ProfessorCityToPage.MUNICIPALITY_TO_DATA_KEY));
                                                        post.setTownTo((Town) p.getData().getParcelable(
                                                                ProfessorCityToPage.LOCALITY_TO_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.POSITION_TYPE_KEY:
                                                        post.setPositionType(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.WORKDAY_TYPE_KEY:
                                                        post.setWorkdayType(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.TEACHING_CAREER_KEY:
                                                        post.setIsTeachingCareer(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY)
                                                                        .equals("Si") ? true : false);
                                                        break;
                                                    }
                                                }

                                            }
                                        })
                                .setNegativeButton(android.R.string.cancel, null).create();
                    }
                };
                dg.show(getActivity().getSupportFragmentManager(), "place_order_dialog");
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();

    return rootView;
}