List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:de.uni_koblenz_landau.apow.ObsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.obs_list_fragment, container, false); // Create UI references. mListView = (ListView) view.findViewById(R.id.obs_list_fragment_listview); mListView.setEmptyView(view.findViewById(android.R.id.empty)); mListView.getEmptyView().setVisibility(ListView.GONE); mListView.setOnItemClickListener(new OnItemClickListener() { @Override// www . j a v a 2s. co m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ListViewItem item = (ListViewItem) parent.getItemAtPosition(position); Intent intent = new Intent(getActivity(), ObsDetailActivity.class); intent.putExtra(ObsDetailFragment.ARG_OBS_ID, (int) id); intent.putExtra(ObsDetailFragment.ARG_ENCOUNTER_ID, mEncounterID); intent.putExtra(ObsDetailFragment.ARG_TITLE, item.getField1()); getActivity().startActivity(intent); } }); // Restore UI from saved instance or load data. if (savedInstanceState != null) { mDeleteDialog = (DeleteDialogFragment) getFragmentManager().findFragmentByTag(DELETE_DIALOG_ID); if (mDeleteDialog != null) { mDeleteDialog.setListener(this); } mTitle = savedInstanceState.getString(ARG_TITLE); getActivity().setTitle(mTitle); mObs = savedInstanceState.getParcelableArrayList(ARG_OBS); ObsAdapter adapter = new ObsAdapter(this.getActivity(), mObs); mListView.setAdapter(adapter); } else { mTitle = getArguments().getString(ARG_TITLE); loadObs(mTitle); } return view; }
From source file:com.krayzk9s.imgurholo.ui.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.account_layout, container, false); LinearLayout headerLayout = (LinearLayout) view.findViewById(R.id.header); headerLayout.setVisibility(View.GONE); errorText = (TextView) view.findViewById(R.id.error); mDrawerList = (ListView) view.findViewById(R.id.account_list); ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); SharedPreferences settings = activity.getApiCall().settings; if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) commentsAdapter = new MessageAdapter(activity, R.layout.comment_layout); else//from w ww. j ava2 s . co m commentsAdapter = new MessageAdapter(activity, R.layout.comment_layout_dark); String[] mMenuList = getResources().getStringArray(R.array.emptyList); ArrayAdapter<String> tempAdapter; if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) tempAdapter = new ArrayAdapter<String>(activity, R.layout.comment_layout, mMenuList); else tempAdapter = new ArrayAdapter<String>(activity, R.layout.comment_layout_dark, mMenuList); mDrawerList.setAdapter(tempAdapter); if (savedInstanceState == null) { getComments(); } else { commentDataArray = savedInstanceState.getParcelableArrayList("content"); commentsAdapter.addAll(commentDataArray); mDrawerList.setAdapter(commentsAdapter); commentsAdapter.notifyDataSetChanged(); } return view; }
From source file:com.dmitrymalkovich.android.popularmoviesapp.details.MovieDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.movie_detail, container, false); ButterKnife.bind(this, rootView); mMovieTitleView.setText(mMovie.getTitle()); mMovieOverviewView.setText(mMovie.getOverview()); mMovieReleaseDateView.setText(mMovie.getReleaseDate(getContext())); Picasso.with(getContext()).load(mMovie.getPosterUrl(getContext())).config(Bitmap.Config.RGB_565) .into(mMoviePosterView);/*from www. ja v a 2s . c o m*/ updateRatingBar(); updateFavoriteButtons(); // For horizontal list of trailers LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); mRecyclerViewForTrailers.setLayoutManager(layoutManager); mTrailerListAdapter = new TrailerListAdapter(new ArrayList<Trailer>(), this); mRecyclerViewForTrailers.setAdapter(mTrailerListAdapter); mRecyclerViewForTrailers.setNestedScrollingEnabled(false); // For vertical list of reviews mReviewListAdapter = new ReviewListAdapter(new ArrayList<Review>(), this); mRecyclerViewForReviews.setAdapter(mReviewListAdapter); // Fetch trailers only if savedInstanceState == null if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_TRAILERS)) { List<Trailer> trailers = savedInstanceState.getParcelableArrayList(EXTRA_TRAILERS); mTrailerListAdapter.add(trailers); mButtonWatchTrailer.setEnabled(true); } else { fetchTrailers(); } // Fetch reviews only if savedInstanceState == null if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_REVIEWS)) { List<Review> reviews = savedInstanceState.getParcelableArrayList(EXTRA_REVIEWS); mReviewListAdapter.add(reviews); } else { fetchReviews(); } return rootView; }
From source file:ufms.br.com.ufmsapp.fragment.EventosFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/*from w ww . j a v a2 s . co m*/ view = inflater.inflate(R.layout.fragment_eventos_layout, container, false); //getActivity().invalidateOptionsMenu(); listEventosProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar_list_eventos); eventos = new ArrayList<>(); mRecyclerEventos = (RecyclerView) view.findViewById(R.id.recycler_eventos); messageConnectionError = (TextView) view.findViewById(R.id.txt_volley_error); iconConnectionError = (ImageView) view.findViewById(R.id.no_connection_icon); iconConnectionError.setColorFilter(ContextCompat.getColor(getActivity(), R.color.no_connection_msg)); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_eventos); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.green, R.color.blue, R.color.yellow); // if (OrientationUtils.isPortrait(getResources().getConfiguration())) { mRecyclerEventos.setLayoutManager(new LinearLayoutManager(getActivity())); // } else { // mRecyclerEventos.setLayoutManager(new GridLayoutManager(getActivity(), 2)); // } adapter = new EventosAdapter(getActivity()); if (savedInstanceState != null) { eventos = savedInstanceState.getParcelableArrayList(STATE_EVENTOS); adapter.setEventosList(eventos); } else { UserSessionPreference prefs = new UserSessionPreference(getActivity()); ArrayList<Disciplina> disciplinas = new ArrayList<>(); if (!prefs.isFirstTime()) { disciplinas = MyApplication.getWritableDatabase().listarDisciplinas( MyApplication.getWritableDatabase().alunoByEmail(prefs.getEmail()).getAlunoIdServidor()); } for (int i = 0; i < disciplinas.size(); i++) { eventos.addAll(MyApplication.getWritableDatabase() .listarEventos(disciplinas.get(i).getIdDisciplinaServidor())); } adapter.setEventosList(eventos); if (eventos.isEmpty()) { if (ConnectionUtils.hasConnection(getActivity())) { mTask = new TaskLoadEventos(this, listEventosProgressBar, false, messageConnectionError, iconConnectionError); mTask.execute(); } else { showConnectionErrorMessage(); } } } updateList(); return view; }
From source file:ufms.br.com.ufmsapp.fragment.DisciplinasFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);//from w w w . j a v a2 s. co m view = inflater.inflate(R.layout.fragment_disciplina_layout, container, false); listDisciplinasProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar_list_disciplinas); mRecyclerDisciplinas = (RecyclerView) view.findViewById(R.id.recycler_disciplinas); mRecyclerDisciplinas.setLayoutManager(new LinearLayoutManager(getActivity())); txtEmptyList = (TextView) view.findViewById(R.id.txt_no_disciplina); imgEmptyView = (ImageView) view.findViewById(R.id.disciplina_no_item); imgEmptyView.setColorFilter(ContextCompat.getColor(getActivity(), R.color.no_connection_msg)); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_disciplinas); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.green, R.color.blue, R.color.yellow); listDisciplinas = new ArrayList<>(); //if (OrientationUtils.isPortrait(getResources().getConfiguration())) { mRecyclerDisciplinas.setLayoutManager(new LinearLayoutManager(getActivity())); //} else { // mRecyclerDisciplinas.setLayoutManager(new GridLayoutManager(getActivity(), 2)); // } adapter = new DisciplinasAdapter(getActivity()); if (savedInstanceState != null) { listDisciplinas = savedInstanceState.getParcelableArrayList(STATE_DISCIPLINAS); adapter.setDisciplinasList(listDisciplinas); } else { UserSessionPreference prefs = new UserSessionPreference(getActivity()); if (!prefs.isFirstTime()) { // Aluno ID como parmetro listDisciplinas = MyApplication.getWritableDatabase().listarDisciplinas( MyApplication.getWritableDatabase().alunoByEmail(prefs.getEmail()).getAlunoIdServidor()); } adapter.setDisciplinasList(listDisciplinas); if (listDisciplinas.isEmpty()) { if (ConnectionUtils.hasConnection(getActivity())) { //new TaskLoadMatriculas().execute(); mTaskDisciplinas = new TaskLoadDisciplinas(this, listDisciplinasProgressBar, false, txtEmptyList, imgEmptyView); mTaskDisciplinas.execute(); } else { showConnectionErrorMessage(); } } } updateList(); return view; }
From source file:de.uni_koblenz_landau.apow.PatientListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.patient_list_fragment, container, false); // Create UI references. mFormView = view.findViewById(R.id.patient_list_fragment_form); mStatusView = view.findViewById(R.id.patient_list_fragment_status); mStatusMessageView = (TextView) view.findViewById(R.id.patient_list_fragment_status_message); mListView = (ExpandableListView) view.findViewById(R.id.patient_list_fragment_listview); mListView.setEmptyView(view.findViewById(android.R.id.empty)); mListView.getEmptyView().setVisibility(ListView.GONE); mListView.setOnGroupExpandListener(new OnGroupExpandListener() { @Override/*from ww w . java 2 s . c om*/ public void onGroupExpand(int groupPosition) { if (mLastExpandedPosition != -1 && groupPosition != mLastExpandedPosition) { mListView.collapseGroup(mLastExpandedPosition); } mLastExpandedPosition = groupPosition; } }); mListView.setOnGroupCollapseListener(new OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { mLastExpandedPosition = -1; } }); // Restore UI from saved instance or load data. if (savedInstanceState != null) { mLastExpandedPosition = savedInstanceState.getInt(ARG_LAST_EXPANDED, -1); mPatients = savedInstanceState.getParcelableArrayList(ARG_PATIENTS); PatientAdapter adapter = new PatientAdapter(this.getActivity(), mPatients); mProgress = savedInstanceState.getBoolean(ARG_PROGRESS); mListView.setAdapter(adapter); if (mLastExpandedPosition != -1) { mListView.expandGroup(mLastExpandedPosition); } } else { mProgress = false; mLastExpandedPosition = -1; searchPatients("", false); } showProgress(mProgress); return view; }
From source file:com.zns.comicdroid.activity.Add.java
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_add); super.onCreate(savedInstanceState); mEtISBN = (EditText) findViewById(R.id.etISBN); mSpGroup = (Spinner) findViewById(R.id.add_spGroup); mCbIsRead = (CheckBox) findViewById(R.id.add_cbIsRead); ListView lvComics = (ListView) findViewById(R.id.add_lvComics); ImageView ivGroupAdd = (ImageView) findViewById(R.id.add_ivGroupAdd); mBtnScan = (Button) findViewById(R.id.btnScan); mBtnSearch = (Button) findViewById(R.id.btnSearch); //Spinner groups List<Group> groups = getDBHelper().getGroups(); if (groups == null) groups = new ArrayList<Group>(); groups.add(0, new Group(0, getResources().getString(R.string.common_nogroup), null, 0, 0, 0, 0, 0)); adapterGroups = new ArrayAdapter<Group>(this, android.R.layout.simple_spinner_item, groups); adapterGroups.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpGroup.setAdapter(adapterGroups);//from w ww . j ava 2 s .c o m //Dialog ivGroupAdd.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment dialogAddGroup = new GroupDialogFragment(); dialogAddGroup.show(getSupportFragmentManager(), "GROUPADD"); } }); ArrayList<Comic> comics = new ArrayList<Comic>(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_COMICS)) { comics = savedInstanceState.getParcelableArrayList(STATE_COMICS); } mAdapter = new ComicArrayAdapter(this, comics, getImagePath(true)); lvComics.setAdapter(mAdapter); }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mission_planner); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_mission_planner); if (savedInstanceState == null) { // Load saved missionData if available. try {//from w w w .jav a2 s. c o m FileInputStream inStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "MissionData"); ObjectInputStream objectInStream = new ObjectInputStream(inStream); int count = objectInStream.readInt(); for (int i = 0; i < count; i++) missionData.add((MissionData) objectInStream.readObject()); objectInStream.close(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the list is empty, add the default planet if (missionData.size() == 0) { missionData = setFirstMissionData(); } } else { missionData = savedInstanceState.getParcelableArrayList("key"); } mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground); mListView = (ListView) findViewById(R.id.list); tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV); mAdapter = new StableArrayAdapter(this, missionData, mTouchListener); // add the newDestination button as a footer below the listview ImageView newDestination = new ImageView(this); newDestination.setImageResource(R.drawable.ic_plus); mListView.addFooterView(newDestination); newDestination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use if (missionData.size() < 1) { possibleIconState = 1; } Intent intent = new Intent(MissionPlanner.this, MissionDestination.class); intent.putExtra("possibleIconState", possibleIconState); intent.putExtra("isNewItem", true); // Places the result as a new item in the listview startActivityForResult(intent, 0); } }); mListView.setAdapter(mAdapter); }
From source file:com.google.android.apps.flexbox.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initializeStringResources();//www . j a v a 2 s. c om mFlexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); if (drawer != null) { drawer.addDrawerListener(toggle); } toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); if (navigationView != null) { navigationView.setNavigationItemSelectedListener(this); Menu navigationMenu = navigationView.getMenu(); initializeFlexDirectionSpinner(navigationMenu); initializeFlexWrapSpinner(navigationMenu); initializeJustifyContentSpinner(navigationMenu); initializeAlignItemsSpinner(navigationMenu); initializeAlignContentSpinner(navigationMenu); } if (savedInstanceState != null) { ArrayList<FlexItem> flexItems = savedInstanceState.getParcelableArrayList(FLEX_ITEMS_KEY); assert flexItems != null; mFlexboxLayout.removeAllViews(); for (int i = 0; i < flexItems.size(); i++) { FlexItem flexItem = flexItems.get(i); FlexboxLayout.LayoutParams lp = flexItem.toLayoutParams(this); TextView textView = createBaseFlexItemTextView(i); ViewCompat.setPaddingRelative(textView, flexItem.paddingStart, flexItem.paddingTop, flexItem.paddingEnd, flexItem.paddingBottom); textView.setLayoutParams(lp); mFlexboxLayout.addView(textView); } } for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) { mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i)); } FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab); if (addFab != null) { addFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int viewIndex = mFlexboxLayout.getChildCount(); // index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1]) // exist. TextView textView = createBaseFlexItemTextView(viewIndex); textView.setLayoutParams(createDefaultLayoutParams()); textView.setOnClickListener(new FlexItemClickListener(viewIndex)); mFlexboxLayout.addView(textView); } }); } FloatingActionButton removeFab = (FloatingActionButton) findViewById(R.id.remove_fab); if (removeFab != null) { removeFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mFlexboxLayout.getChildCount() == 0) { return; } mFlexboxLayout.removeViewAt(mFlexboxLayout.getChildCount() - 1); } }); } }
From source file:com.amaze.filemanager.fragments.Main.java
void retrieveFromSavedInstance(final Bundle savedInstanceState) { Bundle b = new Bundle(); String cur = savedInstanceState.getString("CURRENT_PATH"); if (cur != null) { b.putInt("index", savedInstanceState.getInt("index")); b.putInt("top", savedInstanceState.getInt("top")); scrolls.put(cur, b);/*from w w w .ja v a2 s .c o m*/ openMode = savedInstanceState.getInt("openMode", 0); if (openMode == 1) smbPath = savedInstanceState.getString("SmbPath"); LIST_ELEMENTS = savedInstanceState.getParcelableArrayList("list"); folder_count = savedInstanceState.getInt("folder_count", 0); file_count = savedInstanceState.getInt("file_count", 0); results = savedInstanceState.getBoolean("results"); adapter = (Recycleradapter) savedInstanceState.getParcelable("adapter"); createViews(LIST_ELEMENTS, true, (CURRENT_PATH), openMode, true, !IS_LIST); if (savedInstanceState.getBoolean("selection")) { for (int i : savedInstanceState.getIntegerArrayList("position")) { adapter.toggleChecked(i); } } } }