List of usage examples for android.os Bundle getSerializable
@Override
@Nullable
public Serializable getSerializable(@Nullable String key)
From source file:com.davemorrissey.labs.subscaleview.sample.PageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.page, container, false); ImageViewState imageViewState = null; if (savedInstanceState != null) { if (asset == null && savedInstanceState.containsKey(BUNDLE_ASSET)) { asset = savedInstanceState.getString(BUNDLE_ASSET); }//from w w w. jav a2 s . com if (savedInstanceState.containsKey(BUNDLE_STATE)) { imageViewState = (ImageViewState) savedInstanceState.getSerializable(BUNDLE_STATE); orientation = imageViewState.getOrientation(); } } rootView.findViewById(id.rotate).setOnClickListener(this); if (asset != null) { SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) rootView.findViewById(id.imageView); imageView.setImageAsset(asset, imageViewState); imageView.setOnClickListener(this); imageView.setOnLongClickListener(this); } return rootView; }
From source file:com.microsoft.rightsmanagement.sampleapp.TextEditorFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { if (args.containsKey(KEY_EDITOR_MODE)) { mTextEditorMode = TextEditorMode.values()[args.getInt(KEY_EDITOR_MODE)]; }// w w w .j a v a 2s . c o m if (args.containsKey(KEY_USER_POLICY)) { Serializable userPolicyCandidate = (Serializable) args.getSerializable(KEY_USER_POLICY); try { mUserPolicy = (UserPolicy) userPolicyCandidate; } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); throw ex; } } } setHasOptionsMenu(true); }
From source file:com.esri.arcgisruntime.sample.blendrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState/*from w w w . ja v a2 s . c o m*/ * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle blendParameters = getArguments(); if (blendParameters != null) { mAltitude = blendParameters.getInt("altitude"); mAzimuth = blendParameters.getInt("azimuth"); mSlopeType = (SlopeType) blendParameters.getSerializable("slope_type"); mColorRampType = (ColorRamp.PresetType) blendParameters.getSerializable("color_ramp_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.dialog_title); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mAltitude, mAzimuth, mSlopeType, mColorRampType); } }); mCurrAltitudeTextView = (TextView) dialogView.findViewById(R.id.curr_altitude_text); SeekBar altitudeSeekBar = (SeekBar) dialogView.findViewById(R.id.altitude_seek_bar); altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90 //set initial altitude value updateAltitudeSeekBar(altitudeSeekBar); altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAltitude = progress; updateAltitudeSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mCurrAzimuthTextView = (TextView) dialogView.findViewById(R.id.curr_azimuth_text); SeekBar azimuthSeekBar = (SeekBar) dialogView.findViewById(R.id.azimuth_seek_bar); azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360 //set initial azimuth value updateAzimuthSeekBar(azimuthSeekBar); azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAzimuth = progress; updateAzimuthSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); List<String> slopeTypeArray = new ArrayList<>(); slopeTypeArray.add("None"); //ordinals:0 slopeTypeArray.add("Degree"); //1 slopeTypeArray.add("Percent rise"); //2 slopeTypeArray.add("Scaled"); //3 ArrayAdapter<String> slopeTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, slopeTypeArray); Spinner slopeTypeSpinner = (Spinner) dialogView.findViewById(R.id.slope_type_spinner); slopeTypeSpinner.setAdapter(slopeTypeSpinnerAdapter); slopeTypeSpinner.setSelection(mSlopeType.ordinal()); slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mSlopeType = SlopeType.NONE; break; case 1: mSlopeType = SlopeType.DEGREE; break; case 2: mSlopeType = SlopeType.PERCENT_RISE; break; case 3: mSlopeType = SlopeType.SCALED; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); List<String> colorRampTypeArray = new ArrayList<>(); colorRampTypeArray.add("None"); //ordinals:0 colorRampTypeArray.add("Elevation"); //1 colorRampTypeArray.add("DEM screen"); //2 colorRampTypeArray.add("DEM light"); //3 ArrayAdapter<String> colorRampSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, colorRampTypeArray); Spinner colorRampSpinner = (Spinner) dialogView.findViewById(R.id.color_ramp_spinner); colorRampSpinner.setAdapter(colorRampSpinnerAdapter); colorRampSpinner.setSelection(mColorRampType.ordinal()); colorRampSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mColorRampType = ColorRamp.PresetType.NONE; break; case 1: mColorRampType = ColorRamp.PresetType.ELEVATION; break; case 2: mColorRampType = ColorRamp.PresetType.DEM_SCREEN; break; case 3: mColorRampType = ColorRamp.PresetType.DEM_LIGHT; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:com.rubengees.introduction.IntroductionActivity.java
private void getFieldsFromBundle() { Bundle bundle = getIntent().getExtras(); if (bundle == null) { bundle = new Bundle(); }/*from w w w .ja va2 s . c o m*/ slides = bundle.getParcelableArrayList(BUNDLE_SLIDES); style = (Style) bundle.getSerializable(BUNDLE_STYLE); orientation = bundle.getInt(BUNDLE_ORIENTATION, ORIENTATION_BOTH); showPreviousButton = bundle.getBoolean(BUNDLE_SHOW_PREVIOUS_BUTTON, true); showIndicator = bundle.getBoolean(BUNDLE_SHOW_INDICATOR, true); skipText = bundle.getString(BUNDLE_SKIP_STRING); allowBackPress = bundle.getBoolean(BUNDLE_ALLOW_BACK_PRESS, false); if (slides == null) { slides = new ArrayList<>(); } if (skipText == null) { int skipResource = bundle.getInt(BUNDLE_SKIP_RESOURCE, 0); if (skipResource != 0) { skipText = this.getString(skipResource); } } }
From source file:de.egore911.drilog.ShowActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); String[] intentChannels = getIntent().getStringArrayExtra(Constants.INTENT_CHANNELS); if (intentChannels == null) { channels = Arrays.asList(Constants.DEFAULT_CHANNELS); } else {//from w w w . j a v a 2 s . com channels = Arrays.asList(intentChannels); } DbOpenHelper.instance = new DbOpenHelper(this); mWatchesDao = new WatchesDao(); mWatchesDao.open(); setContentView(R.layout.activity_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, channels)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Bundle extras = getIntent().getExtras(); if (extras != null) { setAnchor(extras.getString("anchor")); if (extras.containsKey(Constants.STATE_DATE)) { mSelectedDate = (SimpleDate) extras.getSerializable(Constants.STATE_DATE); } if (extras.containsKey("channel")) { setPosition(channels.indexOf(extras.getString("channel"))); } } // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(channels.get(mPosition)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(R.string.app_name); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); setPosition(mPosition); if (savedInstanceState == null) { loadData(); } }
From source file:de.grobox.liberario.ui.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);/* w ww. j av a 2 s. c o m*/ } else if (text != null && text.length() > 0) { ui.location.setText(text); ui.clear.setVisibility(View.VISIBLE); // load the auto-completion results again as they seem to get lost during restart Loader loader = loaderManager.getLoader(getId()); if (loader != null) loader.onContentChanged(); } int position = bundle.getInt(TEXT_POSITION); ui.location.setSelection(position); changingHome = bundle.getBoolean(CHANGING_HOME); if (changingHome) { // re-set OnHomeChangedListener if home picker is shown 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.whamads.nativecamera.NativeCameraLauncher.java
@Override public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) { this.callbackContext = callbackContext; this.mQuality = state.getInt("mQuality"); this.targetWidth = state.getInt("targetWidth"); this.targetHeight = state.getInt("targetHeight"); this.imageUri = state.getParcelable("imageUri"); this.photo = (File) state.getSerializable("photo"); this.date = state.getString("date"); super.onRestoreStateForActivityResult(state, callbackContext); }
From source file:com.deliciousdroid.activity.BrowseBookmarks.java
public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (findViewById(R.id.maincontent) != null) { lastSelected = (Bookmark) savedInstanceState.getSerializable(STATE_LASTBOOKMARK); lastViewType = (BookmarkViewType) savedInstanceState.getSerializable(STATE_LASTVIEWTYPE); setBookmarkView(lastSelected, lastViewType); }/*w w w .ja v a2s .c o m*/ }
From source file:com.cjc.activity.carManagement.CarDisassemblyTypeActivity.java
@Override protected void setData() { Bundle bundle = getIntent().getExtras(); if (bundle != null) { if (bundle.containsKey(Config.Extras.CarItem)) { carListItem = (CarListItem) bundle.getSerializable(Config.Extras.CarItem); if (carListItem != null) { setDataView();//from ww w. j av a 2 s. c om loadData(); } } if (bundle.containsKey(Config.Extras.IsCarOUt)) { isCarOut = bundle.getBoolean(Config.Extras.IsCarOUt); } if (isCarOut) { btnCarOut.setVisibility(View.VISIBLE); ll1.setVisibility(View.GONE); ll2.setVisibility(View.GONE); mCommonTitle.setTitle(""); } else { btnCarOut.setVisibility(View.GONE); ll1.setVisibility(View.VISIBLE); ll2.setVisibility(View.VISIBLE); mCommonTitle.setTitle("?"); } } carDisassemblyTypeAdapter = new CarDisassemblyTypeAdapter(context, dismantlePhotoBeanList); gvImage.setAdapter(carDisassemblyTypeAdapter); }
From source file:com.github.hobbe.android.openkarotz.fragment.RadioTabFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab_radio, container, false); if (savedInstanceState == null) { this.group = (RadioGroupModel) getArguments().getSerializable(KEY_GROUP); } else {// www . jav a 2 s . c o m this.group = (RadioGroupModel) savedInstanceState.getSerializable(KEY_GROUP); } initializeView(view); disableFields(); Log.v(LOG_TAG, "onCreateView: " + (group == null ? "no group" : group.getName())); return view; }