List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:com.permutassep.presentation.view.wizard.ui.ProfessorCityToFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_page_professor_place_selector, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); spnState = ((Spinner) rootView.findViewById(R.id.spnState)); spnMunicipality = ((Spinner) rootView.findViewById(R.id.spnMunicipality)); spnLocality = ((Spinner) rootView.findViewById(R.id.spnLocality)); if (savedInstanceState != null) { mStates = savedInstanceState.getParcelableArrayList(STATES_TO_KEY); mCities = savedInstanceState.getParcelableArrayList(CITIES_TO_KEY); mTowns = savedInstanceState.getParcelableArrayList(TOWNS_TO_KEY); stateSelectedPosition = savedInstanceState.getInt(STATE_TO_SELECTED_KEY); citySelectedPosition = savedInstanceState.getInt(CITY_TO_SELECTED_KEY); townSelectedPosition = savedInstanceState.getInt(TOWN_TO_SELECTED_KEY); if (mStates.size() > 0) { spnState.setAdapter(new PlaceSpinnerBaseAdapter(getActivity(), mStates)); spnState.setSelection(stateSelectedPosition, false); }/*w w w. j a va2 s. co m*/ if (mCities.size() > 0) { spnMunicipality.setAdapter(new PlaceSpinnerBaseAdapter(getActivity(), mCities)); spnMunicipality.setSelection(citySelectedPosition, false); } if (mTowns.size() > 0) { spnLocality.setAdapter(new PlaceSpinnerBaseAdapter(getActivity(), mTowns)); spnLocality.setSelection(townSelectedPosition, false); } } setupSpinners(); return rootView; }
From source file:com.open.file.manager.MainActivity.java
/** * If an operation was not completed, restart it * /*from www.j a v a2 s. c o m*/ * @param savedInstanceState */ private boolean restoreOperations(Bundle savedInstanceState) { boolean restoreconflicts = false; if (savedInstanceState != null) { if (savedInstanceState.containsKey("conflicts")) { Log.d("reload", "conflicts"); FileOperations.conflicts = savedInstanceState.getParcelableArrayList("conflicts"); restoreconflicts = !FileOperations.conflicts.isEmpty(); } FileOperations.currentaction = savedInstanceState.getInt("operation"); if (savedInstanceState.containsKey("oldqueue")) { List<String> filequeue = savedInstanceState.getStringArrayList("oldqueue"); for (String curfile : filequeue) { FileOperations.operationqueue.add(new File(curfile)); } } if (savedInstanceState.containsKey("currentpath")) { FileOperations.currentpath = savedInstanceState.getString("currentpath"); } operator.restoreOp(); } return restoreconflicts; }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { ArrayList<PendingAction> savedActions = savedInstanceState .getParcelableArrayList(EXTRA_PENDING_ACTIONS); mPendingActions.addAll(savedActions); }// w w w .j av a2 s. co m mProgressBar = (ProgressBar) getActivity().findViewById(R.id.card_list_loading); RecyclerView cardListView = (RecyclerView) getActivity().findViewById(R.id.card_list); mAdapter = new PendingActionCardAdapter(getActivity(), mPendingActions); cardListView.setHasFixedSize(true); cardListView.setAdapter(mAdapter); DragSwipeItemTouchCallback itemTouchCallback = new DragSwipeItemTouchCallback(this); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback); itemTouchHelper.attachToRecyclerView(cardListView); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); cardListView.setLayoutManager(llm); AddFloatingActionButton fabFlashZip = (AddFloatingActionButton) getActivity() .findViewById(R.id.fab_add_zip); fabFlashZip.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // Show file chooser Intent intent = FileUtils.getFileOpenIntent(getActivity()); startActivityForResult(intent, ACTIVITY_REQUEST_FILE); } }); if (savedInstanceState != null) { mSelectedFile = savedInstanceState.getString(EXTRA_SELECTED_FILE); mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID); mZipRomId = savedInstanceState.getString(EXTRA_ZIP_ROM_ID); mTaskIdVerifyZip = savedInstanceState.getInt(EXTRA_TASK_ID_VERIFY_ZIP); } try { mActivityCallback = (OnReadyStateChangedListener) getActivity(); } catch (ClassCastException e) { throw new ClassCastException(getActivity().toString() + " must implement OnReadyStateChangedListener"); } mActivityCallback.onReady(!mPendingActions.isEmpty()); mPrefs = getActivity().getSharedPreferences("settings", 0); if (savedInstanceState == null) { boolean shouldShow = mPrefs.getBoolean(PREF_SHOW_FIRST_USE_DIALOG, true); if (shouldShow) { FirstUseDialog d = FirstUseDialog.newInstance(this, R.string.zip_flashing_title, R.string.zip_flashing_dialog_first_use); d.show(getFragmentManager(), CONFIRM_DIALOG_FIRST_USE); } } getActivity().getLoaderManager().initLoader(0, null, this); }
From source file:com.ovrhere.android.currencyconverter.ui.fragments.MainFragment.java
/** Processes the save state for rates, requesting if there are none. * Requires asyncModel to be valid. */ @SuppressWarnings("unchecked") public void processStateForRates(Bundle savedInstanceState) { if (savedInstanceState == null) { requestFreshExchangeRates(false); ;// w w w . j ava 2 s .co m } else { currentlyUpdating = savedInstanceState.getBoolean(KEY_CURRENTLY_UPDATING); ArrayList<Parcelable> list = savedInstanceState.getParcelableArrayList(KEY_CURRENCY_LIST); synchronized (currencyList) { if (list != null) { currencyList.clear(); try { currencyList.addAll((Collection<? extends CurrencyData>) list); } catch (ClassCastException e) { Log.e(LOGTAG, "Current data invalid: " + e); } } if (currencyList.isEmpty()) { requestFreshExchangeRates(false); } } } }
From source file:com.example.android.wizardpager.wizard.ui.ProfessorCityFromFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_page_professor_city_from, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); spnState = ((Spinner) rootView.findViewById(R.id.spn_your_state)); spnMunicipality = ((Spinner) rootView.findViewById(R.id.spn_your_municipality)); spnLocality = ((Spinner) rootView.findViewById(R.id.spn_your_locality)); if (savedInstanceState != null) { mStates = savedInstanceState.getParcelableArrayList(STATES_FROM_KEY); mCities = savedInstanceState.getParcelableArrayList(CITIES_FROM_KEY); mTowns = savedInstanceState.getParcelableArrayList(TOWNS_FROM_KEY); stateSelectedPosition = savedInstanceState.getInt(STATE_FROM_SELECTED_KEY); citySelectedPosition = savedInstanceState.getInt(CITY_FROM_SELECTED_KEY); townSelectedPosition = savedInstanceState.getInt(TOWN_FROM_SELECTED_KEY); if (mStates.size() > 0) { spnState.setAdapter(new StateSpinnerBaseAdapter(getActivity(), mStates)); spnState.setSelection(stateSelectedPosition, false); }/* w ww . j a v a 2s.co m*/ if (mCities.size() > 0) { spnMunicipality.setAdapter(new CitySpinnerBaseAdapter(getActivity(), mCities)); spnMunicipality.setSelection(citySelectedPosition, false); } if (mTowns.size() > 0) { spnLocality.setAdapter(new TownSpinnerBaseAdapter(getActivity(), mTowns)); spnLocality.setSelection(townSelectedPosition, false); } } setupSpinners(); return rootView; }
From source file:com.trogdan.nanospotify.service.MusicService.java
void processAddRequest(Intent intent) { if (mState == State.Playing) { processPauseRequest();/* w w w .j a v a2 s . com*/ } if (mState == State.Paused || mState == State.Stopped) { final Bundle args = intent.getExtras(); // We explay a play request to come momentarily, there shouldn't be a way for the user // to unpause before that mNextTrack = args.getInt(PlayerFragment.PLAYERPLAYTRACK_ARG); final ArrayList nextList = args.getParcelableArrayList(PlayerFragment.PLAYERTRACKS_ARG); if (nextList != null) { mState = State.Stopped; relaxResources(true); mTrackList = nextList; mCurrentTrack = mNextTrack; } else if (mNextTrack != mCurrentTrack) { // Let's say we're stopped, so that the expected play operation will play the new track mState = State.Stopped; mCurrentTrack = mNextTrack; } } }
From source file:org.sleepydragon.rgbclient.MainFragment.java
@Override public void onCreate(Bundle savedInstanceState) { LOG.v("onCreate()"); super.onCreate(savedInstanceState); mHandler = new Handler(new MainHandlerCallback()); if (savedInstanceState == null) { mColorState = new ColorState(); } else {//from w w w. j a v a 2 s . co m mColorState = savedInstanceState.getParcelable(KEY_COLOR_STATE); final ArrayList<ColorCommand> commandQueue = savedInstanceState .getParcelableArrayList(KEY_COMMAND_QUEUE); synchronized (mCommandQueue) { mCommandQueue.addAll(commandQueue); } } mColorState.setEventHandler(mHandler); }
From source file:com.bangz.smartmute.LocationsMapFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getMapAsync(this); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API) .addOnConnectionFailedListener(this).addConnectionCallbacks(this).build(); mGoogleApiClient.connect();/*from w w w.ja v a 2 s .c o m*/ if (savedInstanceState == null) { mLastLocation = PrefUtils.getLastLatLng(getActivity()); mapInitState = 0; } else { // When subclass from MapFragment, do not use outState to save you state data which is // parcelable object, if you do, when in onCreate, onCreateView, onActivityCreated , // saveInstance.getParcelable will get Class not found when unmarshalling from // java.lang.ClassNotFoundException. The cause may be google play service clean class // info in his saveInstance. to workaround this ,you add your all date to a new Bundle // and save this Bundle to outState in onSaveInstanceState method. // http://stackoverflow.com/a/15973603/1036923 // in above site, the best answer is suggest use setArguments() when CTO new Bundle, // then onSaveInstanceState use getArguments() Bundle mybundle = savedInstanceState.getBundle(KEY_STATE_MYARGUMENT); mSavedMarkerExInfos = mybundle.getParcelableArrayList(KEY_STATE_MARKERS); mapInitState = mybundle.getInt(KEY_STATE_MAPINIT, 0); bLocationUpdated = mybundle.getBoolean(KEY_STATE_LOCATION_UPDATED, false); mLocationUpdateType = mybundle.getInt(KEY_STATE_LOCATION_UPDATE_TYPE); meiSelected = mybundle.getParcelable(KEY_STATE_SELECT_MARKER); } }
From source file:org.bienvenidoainternet.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ThemeManager tm = new ThemeManager(this); this.setTheme(tm.getThemeForMainActivity()); if (savedInstanceState != null) { currentThemeId = savedInstanceState.getInt("currentThemeId"); boardList = savedInstanceState.getParcelableArrayList("boardList"); }/*from w w w . ja v a 2 s . c o m*/ SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); if (settings.getString("pref_password", "").isEmpty()) { SharedPreferences.Editor edit = settings.edit(); edit.putString("pref_password", makePassword()); edit.commit(); } setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("Bievenido a internet"); this.setSupportActionBar(toolbar); fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (pager.getCurrentItem() == 0) { if (!mainFragment.getMode() && mainFragment.currentBoard != null) { Intent in = new Intent(getApplicationContext(), ResponseActivity.class); Bundle b = new Bundle(); BoardItem temp = new BoardItem(); temp.setParentBoard(mainFragment.currentBoard); b.putParcelable("theReply", temp); b.putBoolean("quoting", false); b.putBoolean("newthread", true); in.putExtras(b); startActivity(in); } } else { if (childFragment.currentBoard != null) { if (!childFragment.boardItems.isEmpty()) { try { Intent in = new Intent(getApplicationContext(), ResponseActivity.class); Bundle b = new Bundle(); BoardItem reply = childFragment.boardItems.get(0); if (!reply.isLocked) { b.putParcelable("theReply", reply); b.putBoolean("quoting", false); b.putBoolean("newthread", false); in.putExtras(b); startActivity(in); } else { Toast.makeText(getApplicationContext(), "Error: Este hilo est cerrado", Toast.LENGTH_LONG).show(); } } catch (Exception e) { e.printStackTrace(); } } } } } }); fab.setVisibility(View.GONE); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); if (savedInstanceState != null) { mainFragment = (FragmentBoardItemList) getSupportFragmentManager().getFragment(savedInstanceState, "mainFragment"); childFragment = (FragmentBoardItemList) getSupportFragmentManager().getFragment(savedInstanceState, "childFragment"); } else { mainFragment = FragmentBoardItemList.newInstance(true, null, null); childFragment = FragmentBoardItemList.newInstance(false, null, null); } this.pager = (ViewPager) findViewById(R.id.pager); this.pagerAdapter = new CustomFragmentPagerAdapter(getSupportFragmentManager()); pagerAdapter.addFragment(mainFragment); pagerAdapter.addFragment(childFragment); this.pager.setAdapter(pagerAdapter); pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { if (position == 0) { fab.setImageResource(R.drawable.ic_action_add); if (mainFragment.currentBoard != null) { toolbar.setTitle("Catlogo"); toolbar.setSubtitle(mainFragment.currentBoard.getBoardName()); } if (mainFragment.getMode()) { toolbar.setTitle("Post recientes"); toolbar.setSubtitle(""); } if (mainFragment.getMode()) { fab.hide(); } else { fab.show(); } } else if (position == 1) { fab.setImageResource(R.drawable.ic_edit); if (childFragment.currentBoard != null) { toolbar.setTitle(childFragment.currentBoard.getBoardName()); if (!childFragment.boardItems.isEmpty()) { toolbar.setSubtitle(childFragment.boardItems.get(0).getSubject()); } fab.show(); } } } @Override public void onPageScrollStateChanged(int state) { } }); if (boardList.isEmpty()) { getBoardList(); } else { Menu menu = navigationView.getMenu(); SubMenu sub = menu.addSubMenu("Lista de Boards"); for (Board b : boardList) { sub.add(b.getBoardName()); } refreshNavigator(); } if (tm.isDarkTheme()) { navigationView.setBackgroundColor(0xFF888888); } }
From source file:com.wglxy.example.dashL.SearchActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); setTitleFromActivityLabel(R.id.title_text); showLogginLogout(findViewById(R.id.btn_login_logout)); initUI();/*from w w w . ja v a 2 s . c o m*/ if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH_QUERY) && savedInstanceState.containsKey(KEY_USER_OBJ)) { searchStr = savedInstanceState.getString(KEY_SEARCH_QUERY); data = savedInstanceState.getParcelableArrayList(KEY_USER_OBJ); } try { Bundle args = getIntent().getExtras(); searchStr = args.getString(Constants.KEY_SEARCH_ARGS); Log.e(LOG_TAG, "search query: " + searchStr); doSearch(searchStr); } catch (Exception ex) { Log.e(LOG_TAG, "no search args", ex.getCause()); searchBar.setVisibility(View.VISIBLE); edt_search.requestFocus(); } }