List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.artemchep.horario.ui.fragments.details.MooDetailsFragment.java
@Override public void onCreate(@Nullable Bundle savedState) { super.onCreate(savedState); Bundle args = getArguments();/*from www .ja v a 2s. c om*/ mArgsTimetablePath = args.getString(ModelFragment.EXTRA_TIMETABLE_PATH); mArgsEditable = args.getBoolean(ModelFragment.EXTRA_EDITABLE); // Load extras if (savedState != null) { // Model must not be null here! //noinspection ConstantConditions mModel = savedState.getParcelable(EXTRA_MODEL); } else { mModel = args.getParcelable(EXTRA_MODEL); assert mModel != null; //noinspection unchecked mModel = (T) mModel.clone(); } if (mModel != null) { mDatabaseRef = FirebaseDatabase.getInstance().getReference(getPath()).child(mModel.key); } }
From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { final Uri uri = args.getParcelable(EXTRA_URI); /*//from w w w.j a va2 s . c o m * Some apps, f.e. Google Drive allow to select file that is not on the device. There is no "_data" column handled by that provider. Let's try to obtain all columns and than check * which columns are present. */ //final String[] projection = new String[] { MediaStore.MediaColumns.DISPLAY_NAME, MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.DATA }; return new CursorLoader(this, uri, null /*all columns, instead of projection*/, null, null, null); }
From source file:com.jetheis.android.makeitrain.billing.googleplay.GooglePlayBillingWrapper.java
public void requestVipStatus() { Bundle response; try {//w ww . j a va 2 s . co m response = mBoundService.makeGooglePlayPurchaseRequest(Constants.GOOGLE_PLAY_PRODUCT_ID); } catch (RemoteException e) { Log.e(Constants.TAG, "RemoteException: " + e.getLocalizedMessage()); return; } if (response.getInt(Constants.GOOGLE_PLAY_BUNDLE_KEY_RESPONSE_CODE) != GooglePlayResponseCode.RESULT_OK .ordinal()) { return; } PendingIntent pendingIntent = response.getParcelable(Constants.GOOGLE_PLAY_BUNDLE_KEY_PURCHASE_INTENT); try { mContext.startIntentSender(pendingIntent.getIntentSender(), new Intent(), 0, 0, 0); } catch (SendIntentException e) { Log.e(Constants.TAG, "SendIntentException: " + e.getLocalizedMessage()); } }
From source file:com.chao.facebookzc.UiLifecycleHelper.java
/** * To be called from an Activity or Fragment's onCreate method. * * @param savedInstanceState the previously saved state */// w w w . j ava 2 s . com public void onCreate(Bundle savedInstanceState) { Session session = Session.getActiveSession(); if (session == null) { if (savedInstanceState != null) { session = Session.restoreSession(activity, null, callback, savedInstanceState); } if (session == null) { session = new Session(activity); } Session.setActiveSession(session); } if (savedInstanceState != null) { pendingFacebookDialogCall = savedInstanceState.getParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY); } }
From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(App.theme.theme);// w ww . j ava2 s . c om super.onCreate(savedInstanceState); setContentView(R.layout.activity_preferences); getSupportActionBar().setDisplayHomeAsUpEnabled(true); Bundle b = getIntent().getExtras(); if (b == null) { finish(); return; } int index = PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_SORT_TYPE, 0); preferenceSortType = PreferenceSortType.values()[index]; mViewPager = (ViewPager) findViewById(R.id.pager); mLoadingView = findViewById(R.id.loadingView); mEmptyView = findViewById(R.id.emptyView); iconUri = b.getParcelable(KEY_ICON_URI); packageName = b.getString(EXTRA_PACKAGE_NAME); title = b.getString(EXTRA_TITLE); launchedFromShortcut = b.getBoolean(EXTRA_SHORTCUT, false); getSupportActionBar().setTitle(Ui.applyCustomTypeFace(title, this)); getSupportActionBar().setSubtitle(Ui.applyCustomTypeFace(packageName, this)); Picasso.with(this).load(iconUri).error(R.drawable.ic_launcher) .into((android.widget.ImageView) findViewById(android.R.id.home)); if (savedInstanceState == null) { findFilesAndBackupsTask = new FindFilesAndBackupsTask(packageName); findFilesAndBackupsTask.execute(); } else { try { ArrayList<String> tmp = new ArrayList<String>(); JSONArray array = new JSONArray(savedInstanceState.getString(KEY_FILES)); for (int i = 0; i < array.length(); i++) { tmp.add(array.getString(i)); } updateFindFiles(tmp); updateFindBackups(Utils.getBackups(getApplicationContext(), packageName)); } catch (Exception e) { findFilesAndBackupsTask = new FindFilesAndBackupsTask(packageName); findFilesAndBackupsTask.execute(); } } }
From source file:com.binomed.showtime.android.screen.results.tablet.CineShowTimeResultsTabletActivity.java
@Override protected void onPreRestoreBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { boolean saved = savedInstanceState.getBoolean(ParamIntent.BUNDLE_SAVE, false); if (saved) { // Restore results getModelActivity().setNearResp((NearResp) savedInstanceState.getParcelable(ParamIntent.NEAR_RESP)); intentResult = new Intent(); getModelActivity().setForceResearch( savedInstanceState.getBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, false)); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, getModelActivity().isForceResearch()); getModelActivity().setCityName(savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_CITY)); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName()); getModelActivity()/*from w w w . j a v a 2 s .c o m*/ .setMovieName(savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME)); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME, getModelActivity().getMovieName()); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_THEATER_ID, savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_THEATER_ID)); getModelActivity().setDay(savedInstanceState.getInt(ParamIntent.ACTIVITY_SEARCH_DAY, 0)); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_DAY, getModelActivity().getDay()); ArrayList<Integer> expandGroup = savedInstanceState .getIntegerArrayList(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND); getModelActivity().setGroupExpanded(new HashSet<Integer>(expandGroup)); intentResult.putIntegerArrayListExtra(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND, expandGroup); // We manage expand Groups if ((expandGroup != null) && (expandGroup.size() > 0) && (getModelActivity().getNearResp() .getTheaterList().size() < expandGroup.get(expandGroup.size() - 1))) { movieList = new ArrayList<MovieBean>(); theater = getModelActivity().getNearResp().getTheaterList() .get(expandGroup.get(expandGroup.size() - 1)); for (String movieId : theater.getMovieMap().keySet()) { movieList.add(getModelActivity().getNearResp().getMapMovies().get(movieId)); } } Double latitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE, 0); Double longitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, 0); if ((latitude != 0) && (longitude != 0)) { intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LATITUDE, latitude); intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, longitude); } // Restore movie MovieBean movie = savedInstanceState.getParcelable(ParamIntent.MOVIE); if (movie != null) { TheaterBean theater = savedInstanceState.getParcelable(ParamIntent.THEATER); latitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_MOVIE_LATITUDE, -1); longitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_MOVIE_LONGITUDE, -1); intentStartMovieActivity = new Intent(this, CineShowTimeMovieActivity.class); intentStartMovieActivity.putExtra(ParamIntent.MOVIE_ID, movie.getId()); intentStartMovieActivity.putExtra(ParamIntent.MOVIE, movie); intentStartMovieActivity.putExtra(ParamIntent.THEATER_ID, theater.getId()); intentStartMovieActivity.putExtra(ParamIntent.THEATER, theater); intentStartMovieActivity.putExtra(ParamIntent.ACTIVITY_MOVIE_LATITUDE, latitude != -1 ? latitude : null); intentStartMovieActivity.putExtra(ParamIntent.ACTIVITY_MOVIE_LONGITUDE, longitude != -1 ? longitude : null); StringBuilder place = new StringBuilder(); if (theater != null) { if (theater.getPlace() != null) { if ((theater.getPlace().getCityName() != null // ) && (theater.getPlace().getCityName().length() > 0)) { place.append(theater.getPlace().getCityName()); } if ((theater.getPlace().getPostalCityNumber() != null // ) && (theater.getPlace().getPostalCityNumber().length() > 0)) { place.append(" ").append(theater.getPlace().getPostalCityNumber()); } if ((theater.getPlace().getCountryNameCode() != null // ) && (theater.getPlace().getCountryNameCode().length() > 0 // ) && (place.length() > 0)) { place.append(", ").append(theater.getPlace().getCountryNameCode()); //$NON-NLS-1$ } if (place.length() == 0) { place.append(theater.getPlace().getSearchQuery()); } } } intentStartMovieActivity.putExtra(ParamIntent.ACTIVITY_MOVIE_NEAR, place.toString()); Fragment fragmentRecycle = getSupportFragmentManager().findFragmentById(R.id.fragmentInfo); if ((fragmentRecycle != null) && (fragmentRecycle.getClass() == CineShowTimeMovieFragment.class)) { fragmentMovie = (CineShowTimeMovieFragment) fragmentRecycle; } else { fragmentMovie = new CineShowTimeMovieFragment(); } if ((fragmentRecycle != null) && !fragmentMovie.equals(fragmentRecycle)) { getSupportFragmentManager().beginTransaction().replace(R.id.fragmentInfo, fragmentMovie) .commit(); } } } } }
From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri movieUri = getActivity().getIntent().getData(); if (movieUri != null) { return new CursorLoader(context, movieUri, null, null, null, null); } else {//from w ww .j a va2 s .com Bundle arguments = getArguments(); movieUri = arguments.getParcelable("movie"); return new CursorLoader(context, movieUri, null, null, null, null); } }
From source file:com.burhan.udacity.popularmovies.ui.fragment.MovieFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); trySetupToolbar();//from w w w. j av a 2 s . c o m mScrollView.setScrollViewCallbacks(this); if (savedInstanceState != null) { mVideos = savedInstanceState.getParcelableArrayList(STATE_VIDEOS); mReviews = savedInstanceState.getParcelableArrayList(STATE_REVIEWS); mScrollView.onRestoreInstanceState(savedInstanceState.getParcelable(STATE_SCROLL_VIEW)); } }
From source file:com.yschi.castscreen.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mResultCode = savedInstanceState.getInt(STATE_RESULT_CODE); mResultData = savedInstanceState.getParcelable(STATE_RESULT_DATA); }//from ww w . j av a 2 s . c o m mContext = this; mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); mDiscoverdMap = new HashMap<>(); mDiscoverListView = (ListView) findViewById(R.id.discover_listview); mDiscoverAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); mDiscoverAdapter.addAll(mDiscoverdMap.keySet()); mDiscoverListView.setAdapter(mDiscoverAdapter); mDiscoverListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name = mDiscoverAdapter.getItem(i); String ip = mDiscoverdMap.get(name); Log.d(TAG, "Select receiver name: " + name + ", ip: " + ip); mReceiverIp = ip; updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } }); // add server mode option mDiscoverAdapter.add(mContext.getString(R.string.server_mode)); mDiscoverdMap.put(mContext.getString(R.string.server_mode), ""); mReceiverTextView = (TextView) findViewById(R.id.receiver_textview); final EditText ipEditText = (EditText) findViewById(R.id.ip_edittext); final Button selectButton = (Button) findViewById(R.id.select_button); selectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ipEditText.getText().length() > 0) { mReceiverIp = ipEditText.getText().toString(); Log.d(TAG, "Using ip: " + mReceiverIp); updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit() .putString(PREF_KEY_INPUT_RECEIVER, mReceiverIp).commit(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } } }); ipEditText.setText(mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_INPUT_RECEIVER, "")); Spinner formatSpinner = (Spinner) findViewById(R.id.format_spinner); ArrayAdapter<CharSequence> formatAdapter = ArrayAdapter.createFromResource(this, R.array.format_options, android.R.layout.simple_spinner_item); formatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); formatSpinner.setAdapter(formatAdapter); formatSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedFormat = FORMAT_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedFormat = FORMAT_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, 0).commit(); } }); formatSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_FORMAT, 0)); Spinner resolutionSpinner = (Spinner) findViewById(R.id.resolution_spinner); ArrayAdapter<CharSequence> resolutionAdapter = ArrayAdapter.createFromResource(this, R.array.resolution_options, android.R.layout.simple_spinner_item); resolutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); resolutionSpinner.setAdapter(resolutionAdapter); resolutionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedWidth = RESOLUTION_OPTIONS[i][0]; mSelectedHeight = RESOLUTION_OPTIONS[i][1]; mSelectedDpi = RESOLUTION_OPTIONS[i][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedWidth = RESOLUTION_OPTIONS[0][0]; mSelectedHeight = RESOLUTION_OPTIONS[0][1]; mSelectedDpi = RESOLUTION_OPTIONS[0][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, 0).commit(); } }); resolutionSpinner .setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_RESOLUTION, 0)); Spinner bitrateSpinner = (Spinner) findViewById(R.id.bitrate_spinner); ArrayAdapter<CharSequence> bitrateAdapter = ArrayAdapter.createFromResource(this, R.array.bitrate_options, android.R.layout.simple_spinner_item); bitrateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bitrateSpinner.setAdapter(bitrateAdapter); bitrateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedBitrate = BITRATE_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedBitrate = BITRATE_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, 0).commit(); } }); bitrateSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_BITRATE, 0)); mReceiverIp = mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_RECEIVER, ""); updateReceiverStatus(); startService(); }
From source file:com.andrada.sitracker.ui.fragment.RemoteAuthorsFragment.java
public void reloadFromArguments(Bundle arguments) { // Load new arguments if (arguments == null) { arguments = new Bundle(); } else {/* w w w . j av a2s . com*/ // since we might make changes, don't meddle with caller's copy arguments = (Bundle) arguments.clone(); } // save arguments so we can reuse it when reloading from content observer events mArguments = arguments; LOGD(TAG, "SessionsFragment reloading from arguments: " + arguments); mCurrentUri = arguments.getParcelable("_uri"); LOGD(TAG, "SessionsFragment reloading, uri=" + mCurrentUri); reloadSearchData(); }