List of usage examples for android.os Bundle getBundle
@Nullable
public Bundle getBundle(@Nullable String key)
From source file:com.fastbootmobile.encore.app.AlbumActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from ww w. ja v a 2 s .c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artist); mHandler = new Handler(); // Load or restore the fragment FragmentManager fm = getSupportFragmentManager(); mActiveFragment = (AlbumViewFragment) fm.findFragmentByTag(TAG_FRAGMENT); if (savedInstanceState == null) { mHero = Utils.dequeueBitmap(BITMAP_ALBUM_HERO); mInitialIntent = getIntent().getExtras(); } else { mHero = Utils.dequeueBitmap(BITMAP_ALBUM_HERO); mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT); } if (mActiveFragment == null) { mActiveFragment = new AlbumViewFragment(); fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit(); } mActiveFragment.setArguments(mHero, 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); try { 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); } } catch (IllegalStateException ignore) { // Animation was cancelled before animation mapping } } } }); } getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:net.evendanan.pushingpixels.FragmentChauffeurActivity.java
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); mIsActivityShown = true;/* w w w. ja v a2s . c o m*/ if (savedInstanceState == null) { //setting up the root of the UI. setRootFragment(createRootFragmentInstance()); //now, checking if there is a request to add a fragment on-top of this one. Bundle activityArgs = getIntent().getExtras(); if (activityArgs != null && activityArgs.containsKey(KEY_FRAGMENT_CLASS_TO_ADD)) { Class<? extends Fragment> fragmentClass = (Class<? extends Fragment>) activityArgs .get(KEY_FRAGMENT_CLASS_TO_ADD); //not sure that this is a best-practice, but I still need to remove this from the activity's args activityArgs.remove(KEY_FRAGMENT_CLASS_TO_ADD); try { Fragment fragment = fragmentClass.newInstance(); if (activityArgs.containsKey(KEY_FRAGMENT_ARGS_TO_ADD)) { fragment.setArguments(activityArgs.getBundle(KEY_FRAGMENT_ARGS_TO_ADD)); activityArgs.remove(KEY_FRAGMENT_CLASS_TO_ADD); } addFragmentToUi(fragment, FragmentUiContext.RootFragment); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:com.google.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCastConsumer = new MyCastConsumer(); Bundle bundle = getArguments(); if (null == bundle) { return;// w w w . ja v a 2 s . c o m } Bundle extras = bundle.getBundle(EXTRAS); Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA); // Retain this fragment across configuration changes. setRetainInstance(true); if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) { mOverallState = OverallState.AUTHORIZING; mMediaAuthService = mCastManager.getMediaAuthService(); handleMediaAuthTask(mMediaAuthService); showImage(Utils.getImageUri(mMediaAuthService.getMediaInfo(), 1)); } else if (null != mediaWrapper) { mOverallState = OverallState.PLAYBACK; boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START); String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA); JSONObject customData = null; if (!TextUtils.isEmpty(customDataStr)) { try { customData = new JSONObject(customDataStr); } catch (JSONException e) { LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e); } } MediaInfo info = Utils.toMediaInfo(mediaWrapper); int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0); onReady(info, shouldStartPlayback, startPoint, customData); } }
From source file:de.elanev.studip.android.app.frontend.courses.CourseViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pager);//from w w w .j a va2 s. c o m Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } mPager = (ViewPager) findViewById(R.id.pager); mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs); mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); // Get intent data if (savedInstanceState != null) { sExtras = savedInstanceState.getBundle(INTENT_EXTRAS); } else { Bundle intentExtras = getIntent().getExtras(); if (intentExtras != null) { sExtras = intentExtras; } } if (sExtras != null) { sTitle = sExtras.getString(CoursesContract.Columns.Courses.COURSE_TITLE); setTitle(sTitle); String modulesJson = sExtras.getString(CoursesContract.Columns.Courses.COURSE_MODULES); if (!TextUtils.isEmpty(modulesJson)) { mModules = Course.Modules.fromJson(modulesJson); } } else { finish(); return; } mPagerAdapter = new FragmentsAdapter(getSupportFragmentManager(), getTabs()); mPager.setAdapter(mPagerAdapter); mTabLayout.setupWithViewPager(mPager); }
From source file:com.permutassep.ui.FragmentCreatePost.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_createpost, container, false); getActivity().setTitle(R.string.app_main_toolbar_post_action); getActivity().invalidateOptionsMenu(); if (savedInstanceState != null) { mWizardModel.load(savedInstanceState.getBundle("model")); }/*from ww w .j a va 2 s . c om*/ 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 (suggestDataCompletion && mCurrentPageSequence.get(mPager.getCurrentItem()) .getKey() == PermutaSepWizardModel.CONTACT_INFO_KEY) { DialogFragment dg = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.wizard_contact_suggest_data_completion_dialog_msg) .setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { suggestDataCompletion = false; } }) .create(); } }; dg.show(getActivity().getSupportFragmentManager(), "contact_data_dialog"); } else 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 = ComplexPreferences .getComplexPreferences(getActivity(), Config.APP_PREFERENCES_NAME, Context.MODE_PRIVATE) .getObject(PrefUtils.PREF_USER_KEY, User.class); post.setUser(user); break; case PermutaSepWizardModel.CITY_FROM_KEY: State sf = p.getData().getParcelable( ProfessorCityFromPage.STATE_DATA_KEY); City cf = p.getData().getParcelable( ProfessorCityFromPage.MUNICIPALITY_DATA_KEY); Town tf = p.getData().getParcelable( ProfessorCityFromPage.LOCALITY_DATA_KEY); post.setStateFrom(sf.getId()); post.setCityFrom(Short.valueOf( String.valueOf(cf.getClaveMunicipio()))); post.setTownFrom(Short.valueOf(tf.getClave())); post.setLatFrom(tf.getLatitud()); post.setLonFrom(tf.getLongitud()); break; case PermutaSepWizardModel.CITY_TO_KEY: State st = p.getData().getParcelable( ProfessorCityToPage.STATE_TO_DATA_KEY); City ct = p.getData().getParcelable( ProfessorCityToPage.MUNICIPALITY_TO_DATA_KEY); Town tt = p.getData().getParcelable( ProfessorCityToPage.LOCALITY_TO_DATA_KEY); post.setStateTo(st.getId()); post.setCityTo(Short.valueOf( String.valueOf(ct.getClaveMunicipio()))); post.setTownTo(Short.valueOf(tt.getClave())); post.setLatTo(tt.getLatitud()); post.setLonTo(tt.getLongitud()); break; case PermutaSepWizardModel.ACADEMIC_LEVEL_KEY: post.setAcademicLevel( p.getData().getString(p.SIMPLE_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; case PermutaSepWizardModel.POST_TEXT_KEY: post.setPostText(p.getData() .getString(PostTextPage.TEXT_DATA_KEY)); break; } } showDialog(getString(R.string.wizard_post_dlg_title), getString(R.string.wizard_post_dlg_text)); GsonBuilder gsonBuilder = new GsonBuilder() // .registerTypeHierarchyAdapter(User.class, new UserTypeAdapter(getActivity())) .registerTypeHierarchyAdapter(Post.class, new PostTypeAdapter(getActivity())) .setDateFormat(Config.APP_DATE_FORMAT); Gson gson = gsonBuilder.create(); new PermutasSEPRestClient(new GsonConverter(gson)).get() .newPost(post, new Callback<Post>() { @Override public void success(Post post, retrofit.client.Response response) { replaceFragment(); hideDialog(); } @Override public void failure(RetrofitError error) { // TODO: Add the error message dialog hideDialog(); } }); } }) .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:android.support.design.internal.NavigationMenuPresenter.java
@Override public void onRestoreInstanceState(final Parcelable parcelable) { if (parcelable instanceof Bundle) { Bundle state = (Bundle) parcelable; SparseArray<Parcelable> hierarchy = state.getSparseParcelableArray(STATE_HIERARCHY); if (hierarchy != null) { mMenuView.restoreHierarchyState(hierarchy); }/*from w ww .j a v a2s . c o m*/ Bundle adapterState = state.getBundle(STATE_ADAPTER); if (adapterState != null) { mAdapter.restoreInstanceState(adapterState); } SparseArray<Parcelable> header = state.getSparseParcelableArray(STATE_HEADER); if (header != null) { mHeaderLayout.restoreHierarchyState(header); } } }
From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CId = getArguments().getInt(ARG_CID, -1); if (BuildConfig.DEBUG) Log.d(LOG_TAG, "onCreate"); // restore instance state if (savedInstanceState != null) { savedState = savedInstanceState.getBundle(SAVED_BUNDLE_TAG); //loaded = savedState.getBoolean("loaded", false); }//from w w w .j av a 2s .c o m setHasOptionsMenu(true); }
From source file:me.diskstation.ammon.gpsrunner.ui.OverviewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { ArrayList<Parcelable> parcelable = savedInstanceState.getParcelableArrayList("waypoints"); if (waypoints.size() == 0 && parcelable != null) { if (parcelable.size() > 0) { for (int i = 0; i < parcelable.size(); i++) { waypoints.add((LatLng) parcelable.get(i)); }/*from w w w .j a v a 2 s .c o m*/ updatePolyline(waypoints, waypoints.get(waypoints.size() - 1)); } } if (savedInstanceState.containsKey("run")) { Bundle run = savedInstanceState.getBundle("run"); if (run != null) { update(savedInstanceState.getBundle("run")); } } } }
From source file:android.support.v14.preference.PreferenceFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG); if (container != null) { final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (preferenceScreen != null) { preferenceScreen.restoreHierarchyState(container); }/*from w w w .j a v a2s. c o m*/ } } }
From source file:com.javielinux.tweettopics2.TweetActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); themeManager = new ThemeManager(this); themeManager.setTranslucentTheme();/* w w w . ja v a 2s .c o m*/ InfoLink infoLink = null; Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(Utils.KEY_EXTRAS_INFO)) { infoTweet = (InfoTweet) extras.getBundle(Utils.KEY_EXTRAS_INFO).getParcelable(KEY_EXTRAS_TWEET); } if (extras.containsKey(Utils.KEY_EXTRAS_INFO) && extras.getBundle(Utils.KEY_EXTRAS_INFO).containsKey(KEY_EXTRAS_LINK)) { infoLink = CacheData.getInstance() .getCacheInfoLink(extras.getBundle(Utils.KEY_EXTRAS_INFO).getString(KEY_EXTRAS_LINK)); } } if (infoTweet == null) { Utils.showMessage(this, R.string.error_general); finish(); } else { setContentView(R.layout.tweet_activity); imgAvatar = ((ImageView) findViewById(R.id.tweet_avatar)); imgAvatar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { goToLink("@" + (infoTweet.isRetweet() ? infoTweet.getUsernameRetweet() : infoTweet.getUsername())); } }); String urlAvatar = infoTweet.getUrlAvatar(); String name = infoTweet.getUsername(); String fullname = infoTweet.getFullname(); if (infoTweet.isRetweet()) { name = infoTweet.getUsernameRetweet(); urlAvatar = infoTweet.getUrlAvatarRetweet(); fullname = infoTweet.getFullnameRetweet(); } File file = Utils.getFileForSaveURL(this, urlAvatar); if (file.exists()) { imgAvatar.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath())); } else { APITweetTopics.execute(this, getSupportLoaderManager(), new APIDelegate<LoadImageWidgetResponse>() { @Override public void onResults(LoadImageWidgetResponse result) { try { imgAvatar.setImageBitmap(result.getBitmap()); } catch (Exception e) { e.printStackTrace(); } } @Override public void onError(ErrorResponse error) { } }, new LoadImageWidgetRequest(urlAvatar)); } txtUsername = ((TextView) findViewById(R.id.tweet_username)); txtUsername.setText(name + ((fullname.equals("")) ? "" : " (" + fullname + ")")); txtDate = ((TextView) findViewById(R.id.tweet_date)); txtDate.setText(Utils.timeFromTweetExtended(this, infoTweet.getDate())); txtText = ((TextView) findViewById(R.id.tweet_text)); String html = infoTweet.getTextHTMLFinal(); if (html.equals("")) html = Utils.toHTML(this, infoTweet.getText()); txtText.setText(Html.fromHtml(html)); fragmentAdapter = new TweetFragmentAdapter(this, getSupportFragmentManager(), infoTweet); pager = (ViewPager) findViewById(R.id.tweet_pager); pager.setAdapter(fragmentAdapter); indicator = (TabPageIndicator) findViewById(R.id.tweet_indicator); indicator.setViewPager(pager); (findViewById(R.id.tweet_btn_favorite)).setOnClickListener(clickFavorite); (findViewById(R.id.tweet_btn_reply)).setOnClickListener(clickReply); (findViewById(R.id.tweet_btn_retweet)).setOnClickListener(clickRetweet); (findViewById(R.id.tweet_btn_translate)).setOnClickListener(clickTranslate); (findViewById(R.id.tweet_btn_translate)).setOnLongClickListener(longClickTranslate); (findViewById(R.id.tweet_btn_original_tweet)).setOnClickListener(clickOriginalTweet); (findViewById(R.id.tweet_btn_more)).setOnClickListener(clickMore); llRoot = (FrameLayout) findViewById(R.id.tweet_ll); tweetInfoLayout = (LinearLayout) findViewById(R.id.tweet_info_ll); ivImageLarger = (ImageViewZoomTouch) findViewById(R.id.zoom_image); tweetContent = (RelativeLayout) findViewById(R.id.tweet_content); tweetActionsContainer = (LinearLayout) findViewById(R.id.tweet_actions_container); viewLoading = (LinearLayout) findViewById(R.id.tweet_text_loading); tweetContent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (imageLargerDisplayed) hideImage(); } }); popupLinks = new PopupLinks(this); popupLinks.loadPopup(llRoot); splitActionBarMenu = new SplitActionBarMenu(this); splitActionBarMenu.loadSplitActionBarMenu(llRoot); refreshTheme(); // muestra la imagen si est en versiones anteriores a HONEYCOMB if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && infoLink != null && infoLink.isExtensiveInfo() && infoLink.getType() == InfoLink.IMAGE) { showImage(infoLink); } } }