Example usage for android.os Bundle getParcelableArrayList

List of usage examples for android.os Bundle getParcelableArrayList

Introduction

In this page you can find the example usage for android.os Bundle getParcelableArrayList.

Prototype

@Nullable
public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);/*from   w  ww . jav a  2 s.  co m*/
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    actionBar = activity.getActionBar();
    SharedPreferences settings = activity.getApiCall().settings;
    Bundle bundle = getArguments();
    if (savedInstanceState != null) {
        urls = savedInstanceState.getStringArrayList("urls");
        ids = savedInstanceState.getParcelableArrayList("ids");
        page = savedInstanceState.getInt("page");
    } else {
        urls = new ArrayList<String>();
        ids = new ArrayList<JSONParcelable>();
        page = 0;
    }
    if (bundle != null && bundle.containsKey("id"))
        isGridView = settings.getString("GalleryLayout", getString(R.string.card_view))
                .equals(getString(R.string.grid_view));
    else {
        isGridView = settings.getString("ImagesLayout", getString(R.string.grid_view))
                .equals(getString(R.string.grid_view));
    }
    if (bundle == null) {
        return;
    }
    if (bundle.containsKey("id"))
        albumId = bundle.getString("id");
    else
        albumId = null;
    if (bundle.containsKey("imageCall"))
        imageCall = bundle.getString("imageCall");
    if (bundle.containsKey("albumData")) {
        JSONParcelable dataParcel = bundle.getParcelable("albumData");
        if (dataParcel != null)
            galleryAlbumData = dataParcel.getJSONObject();
    }
}

From source file:org.site_monitor.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    dbHelper = DBHelper.getHelper(this);
    listView = this.findViewById(R.id.listView);
    connectivityAlertView = this.findViewById(R.id.connectivityAlert);
    chronometer = this.findViewById(R.id.chronometer);
    timerBannerView = this.findViewById(R.id.timerBanner);

    FragmentManager fragmentManager = getSupportFragmentManager();
    taskFragment = (TaskFragment) fragmentManager.findFragmentByTag(TAG_TASK_FRAGMENT);
    if (taskFragment == null) {
        taskFragment = new TaskFragment();
        fragmentManager.beginTransaction().add(taskFragment, TAG_TASK_FRAGMENT).commit();
    }/*from  w  w w  . ja  va2 s . com*/

    if (savedInstanceState == null || savedInstanceState.isEmpty()) {
        siteSettingsList = new ArrayList<>();
        loadDataFromDb = true;
    } else {
        siteSettingsList = savedInstanceState.getParcelableArrayList(PARCEL_SITE_LIST);
    }
    siteSettingsAdapter = new SiteSettingsAdapter(context, this, siteSettingsList);
    listView.setAdapter(siteSettingsAdapter);
    if (networkBroadcastReceiver == null) {
        networkBroadcastReceiver = new NetworkBroadcastReceiver(this);
    }
    if (alarmBroadcastReceiver == null) {
        alarmBroadcastReceiver = new AlarmBroadcastReceiver(this);
    }
    // start alarm on 1st install or if not started on system boot
    alarmUtil.startAlarmIfNeeded(this);
}

From source file:de.uni_koblenz_landau.apow.EncounterDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.encounter_detail_fragment, container, false);

    // Create UI references.
    mDateDialog = (DateDialogFragment) getFragmentManager().findFragmentByTag(DATE_DIALOG_ID);
    if (mDateDialog != null) {
        mDateDialog.setListener(this);
    }//from  w  w w . ja  v  a2  s  .  c om
    mTimeDialog = (TimeDialogFragment) getFragmentManager().findFragmentByTag(TIME_DIALOG_ID);
    if (mTimeDialog != null) {
        mTimeDialog.setListener(this);
    }
    mDateView = (TextView) view.findViewById(R.id.encounter_detail_date);
    mTimeView = (TextView) view.findViewById(R.id.encounter_detail_time);
    mTypesView = (Spinner) view.findViewById(R.id.encounter_detail_types);

    // Restore UI from saved instance or load data.
    if (savedInstanceState != null) {
        mEncounter = (Encounter) savedInstanceState.getSerializable(ARG_ENCOUNTER);
        if (mEncounter != null) {
            mTypes = savedInstanceState.getParcelableArrayList(ARG_TYPES);
            ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(),
                    android.R.layout.simple_spinner_item, mTypes);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            mTypesView.setAdapter(adapter);
        }
    } else {
        loadEncounter();
    }

    return view;
}

From source file:com.ayuget.redface.ui.fragment.PostsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable final Bundle savedInstanceState) {
    Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) -> onCreateView(page=%d)",
            System.identityHashCode(this), currentPage, currentPage));

    final View rootView = inflateRootView(R.layout.fragment_posts, inflater, container);

    // Default view is the loading indicator
    showLoadingIndicator();//from   w  w w .j a  v  a2s. co  m

    // Restore the list of posts when the fragment is recreated by the framework
    restoredPosts = false;

    if (savedInstanceState != null) {
        Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) -> trying to restore state",
                System.identityHashCode(this), currentPage));
        displayedPosts = savedInstanceState.getParcelableArrayList(ARG_POST_LIST);
        if (displayedPosts != null) {
            Log.i(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) -> Restored %d posts to fragment",
                    System.identityHashCode(this), displayedPosts.size(), currentPage));

            topicPageView.setTopic(topic);
            topicPageView.setPage(currentPage);
            topicPageView.setPosts(displayedPosts);

            restoredPosts = displayedPosts.size() > 0;
            showPosts();
        }
    }

    if (displayedPosts == null) {
        displayedPosts = new ArrayList<>();
    }

    // Implement swipe to refresh
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            savePageScrollPosition();
            Log.d(LOG_TAG, String.format("Refreshing topic page '%d' for topic %s", currentPage, topic));
            loadPage(currentPage);
        }
    });
    swipeRefreshLayout.setColorSchemeResources(R.color.theme_primary, R.color.theme_primary_dark);

    if (errorReloadButton != null) {
        errorReloadButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(LOG_TAG, String.format("Refreshing topic page '%d' for topic %s", currentPage, topic));
                showLoadingIndicator();
                loadPage(currentPage);
            }
        });
    }

    replyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Joiner joiner = Joiner.on("\n");
            startReplyActivity(joiner.join(quotedMessages.values()));
        }
    });

    topicPageView.setOnScrollListener(new TopicPageView.OnScrollListener() {
        @Override
        public void onScrolled(int dx, int dy) {
            if (dy < 0) {
                hideReplyButton();
            } else {
                showReplyButton();
            }
        }
    });

    topicPageView.setOnPageLoadedListener(new TopicPageView.OnPageLoadedListener() {
        @Override
        public void onPageLoaded() {
            if (currentScrollPosition > 0) {
                restorePageScrollPosition();
            }
        }
    });

    topicPageView.setOnMultiQuoteModeListener(new TopicPageView.OnMultiQuoteModeListener() {
        @Override
        public void onMultiQuoteModeToggled(boolean active) {
            if (active) {
                quotedMessages.clear();
            }

            Fragment parent = getParentFragment();

            if (parent != null) {
                // Multi-quote event is forwarded to parent fragment as a batch operation
                ((TopicFragment) parent).onBatchOperation(active);
            }
        }

        @Override
        public void onPostAdded(final long postId) {
            subscribe(quoteHandler.load(postId,
                    mdService.getQuote(userManager.getActiveUser(), topic, (int) postId),
                    new EndlessObserver<String>() {
                        @Override
                        public void onNext(String quoteBBCode) {
                            quotedMessages.put(postId, quoteBBCode);
                        }

                        @Override
                        public void onError(Throwable throwable) {
                            Log.e(LOG_TAG, "Failed to add post to quoted list", throwable);
                            Toast.makeText(getActivity(), R.string.post_failed_to_quote, Toast.LENGTH_SHORT)
                                    .show();
                        }
                    }));
        }

        @Override
        public void onPostRemoved(long postId) {
            quotedMessages.remove(postId);
        }

        @Override
        public void onQuote() {
            Joiner joiner = Joiner.on("\n");
            topicPageView.disableBatchActions();
            startReplyActivity(joiner.join(quotedMessages.values()));
        }
    });

    if (userManager.getActiveUser().isGuest()) {
        replyButton.setVisibility(View.INVISIBLE);
    }

    return rootView;
}

From source file:de.msal.shoutemo.fragments.OnlineUsersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_onlineusers, container, false);

    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.onlineusers_swipe);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.autemo_pink, R.color.autemo_yellow_bright,
            R.color.autemo_green_secondary, R.color.autemo_blue);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override//from   w  w w.j a  v  a2  s . c om
        public void onRefresh() {
            refreshTriggeredBySwipe = true;
            new GetOnlineUsersTask().execute();
        }
    });

    mAdapter = new OnlineUsersAdapter(getActivity(), new LinkedList<Author>());
    mAdapter.setOnUserClickListener(new OnlineUseresClickListener());
    RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(mAdapter);

    if (savedInstanceState != null) {
        mTitle = savedInstanceState.getCharSequence(INSTANCESTATE_TITLE);
        mAuthors = savedInstanceState.getParcelableArrayList(INSTANCESTATE_AUTHORS);
        mAdapter.addAll(mAuthors);
    } else {
        new GetOnlineUsersTask().execute();
    }

    getActivity().setTitle(mTitle);
    return view;
}

From source file:ru.yandex.subtitles.ui.activity.QuestionnaireActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*  www. j av a  2 s  .c  o m*/
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_questionnaire);

    final Toolbar toolbar = findView(R.id.toolbar);
    if (ApplicationUtils.hasLollipop()) {
        toolbar.setElevation(0.f);
    }
    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDefaultDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
    }

    getSupportFragmentManager().addOnBackStackChangedListener(this);

    if (savedInstanceState == null) {
        mTotalQuestions = 4;

        final Question impairmentQuestion = new Question();
        impairmentQuestion.setTitle(R.string.question_impairment);
        impairmentQuestion.setOptions(R.array.questionnaire_impairment);

        showFragmentNoAnimate(QuestionFragment.newInstance(impairmentQuestion), QuestionFragment.TAG);

    } else {
        mTotalQuestions = savedInstanceState.getInt(KEY_TOTAL_QUESTIONS);
        mAnswered = savedInstanceState.getParcelableArrayList(KEY_ANSWERED);
    }
}

From source file:com.veniosg.dir.android.fragment.FileListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Set auto refresh on preference change.
    getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(preferenceListener);

    // Set list properties
    getListView().requestFocus();/*ww  w . jav a 2  s . c  o m*/
    getListView().requestFocusFromTouch();

    mFlipper = (WaitingViewFlipper) view.findViewById(R.id.flipper);
    view.findViewById(R.id.empty_img).setOnClickListener(mEmptyViewClickListener);
    view.findViewById(R.id.permissions_button).setOnClickListener(mRequestPermissionsListener);

    // Get arguments
    boolean needsLoading = true;
    if (savedInstanceState == null) {
        setPath(new File(getArguments().getString(EXTRA_DIR_PATH)));
        mFilename = getArguments().getString(EXTRA_FILENAME);
    } else {
        setPath(new File(savedInstanceState.getString(INSTANCE_STATE_PATH)));
        mFiles = savedInstanceState.getParcelableArrayList(INSTANCE_STATE_FILES);
        needsLoading = savedInstanceState.getInt(INSTANCE_STATE_NEEDS_LOADING) != 0;
    }
    pathCheckAndFix();

    if (needsLoading) {
        refresh();
    }

    mAdapter = new FileHolderListAdapter(mFiles);
    setListAdapter(mAdapter);
}

From source file:com.ultramegasoft.flavordex2.fragment.EditCatFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState == null) {
        if (mCatId > 0) {
            getLoaderManager().initLoader(0, null, this).forceLoad();
        } else {/*from  ww w  .j a  va  2 s .  co m*/
            createFlavor();
            hideLoadingIndicator(false);
            if (mTxtTitle != null) {
                mTxtTitle.requestFocus();
            }
        }
    } else {
        final ArrayList<Field> extraFields = savedInstanceState.getParcelableArrayList(STATE_EXTRA_FIELDS);
        if (extraFields != null) {
            mExtraFields = extraFields;
        }
        final ArrayList<Field> flavorFields = savedInstanceState.getParcelableArrayList(STATE_FLAVOR_FIELDS);
        if (flavorFields != null) {
            mFlavorFields = flavorFields;
        }
        populateFields();
        hideLoadingIndicator(false);
    }
}

From source file:com.github.jobs.ui.fragment.SOUserPickerFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);/*from  w ww  .  j a  v a 2s.c  o m*/
    FragmentManager fm = getFragmentManager();
    mSOUserFetcherReceiver = (SOUserFetcherReceiver) fm.findFragmentByTag(ReceiverFragment.TAG);
    if (mSOUserFetcherReceiver == null) {
        mSOUserFetcherReceiver = new SOUserFetcherReceiver();
        fm.beginTransaction().add(mSOUserFetcherReceiver, ReceiverFragment.TAG).commitAllowingStateLoss();
    }

    mUserSearch = (EditText) getView().findViewById(R.id.edit_user_search);
    mUserSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                executeSearch(mUserSearch.getText().toString().trim());
                return true;
            }
            return false;
        }
    });
    ListView userList = (ListView) getView().findViewById(R.id.users_list);
    mAdapter = new SOUsersAdapter(getActivity());
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_USERS)) {
        ArrayList<Parcelable> items = savedInstanceState.getParcelableArrayList(KEY_USERS);
        ArrayList<SOUser> users = new ArrayList<SOUser>();
        for (Parcelable item : items) {
            users.add((SOUser) item);
        }
        mAdapter.updateItems(users);
    }
    userList.setOnItemClickListener(this);
    userList.setAdapter(mAdapter);

    String search = getActivity().getIntent().getStringExtra(SOUserPickerActivity.EXTRA_SEARCH);
    if (search == null) {
        if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH)) {
            search = savedInstanceState.getString(KEY_SEARCH);
            mUserSearch.setText(search);
            mUserSearch.setSelection(search.length());
        } else {
            search = "";
        }
    }

    mUserSearch.setText(search);
    mUserSearch.setSelection(search.length());

    if (savedInstanceState == null) {
        // this will execute search only the first time the activity is open
        executeSearch(search);
    }
}

From source file:org.sufficientlysecure.keychain.ui.DecryptListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Bundle args = savedInstanceState != null ? savedInstanceState : getArguments();

    ArrayList<Uri> inputUris = getArguments().getParcelableArrayList(ARG_INPUT_URIS);
    ArrayList<Uri> cancelledUris = args.getParcelableArrayList(ARG_CANCELLED_URIS);
    ParcelableHashMap<Uri, InputDataResult> results = args.getParcelable(ARG_RESULTS);

    mCanDelete = args.getBoolean(ARG_CAN_DELETE, false);

    displayInputUris(inputUris, cancelledUris, results != null ? results.getMap() : null);
}