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.github.jobs.ui.fragment.EditTemplateFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mTemplateServices = new ArrayList<TemplateService>();
    if (savedInstanceState != null) {
        ArrayList<Parcelable> list = savedInstanceState.getParcelableArrayList(KEY_TEMPLATE_SERVICES);
        if (list != null) {
            for (Parcelable parcelable : list) {
                mTemplateServices.add((TemplateService) parcelable);
            }/*from w w  w . j  av a 2 s .c  o m*/
        }
    }
    return inflater.inflate(R.layout.edit_template, null, false);
}

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 a  v a 2  s  . com
    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.bilibili.boxing.AbsBoxingViewFragment.java

@Nullable
private ArrayList<BaseMedia> parseSelectedMedias(Bundle savedInstanceState, Bundle argument) {
    ArrayList<BaseMedia> selectedMedias = null;
    if (savedInstanceState != null) {
        selectedMedias = savedInstanceState.getParcelableArrayList(Boxing.EXTRA_SELECTED_MEDIA);
    } else if (argument != null) {
        selectedMedias = argument.getParcelableArrayList(Boxing.EXTRA_SELECTED_MEDIA);
    }//w  w w. j a va  2  s .  c o m
    return selectedMedias;
}

From source file:com.poepoemyintswe.popularmovies.ui.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    ButterKnife.bind(this, view);
    initUI();/* ww w.  ja va2 s  . c om*/

    if (savedInstanceState == null || !savedInstanceState.containsKey(MOVIE)) {
        getMovies();
    } else {
        resultList = savedInstanceState.getParcelableArrayList(MOVIE);
        movieAdapter.setItems(resultList);
        mProgressWheel.setVisibility(View.GONE);
        mRecyclerView.setVisibility(View.VISIBLE);
    }

    return view;
}

From source file:com.coincollection.ReorderCollections.java

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

    // If the screen rotated and our view got destroyed/recreated,
    // grab the list of collections from the old view (that we stored
    // in the bundle.)
    if (savedInstanceState != null) {
        mItems = savedInstanceState.getParcelableArrayList("mItems");
        mUnsavedChanges = savedInstanceState.getBoolean("mUnsavedChanges");
    }/* w  w  w .j  a v a  2s .c  om*/

    RecyclerView mRecyclerView = (RecyclerView) view.findViewById(R.id.reorder_collections_recycler_view);

    mRecyclerView.setBackgroundColor(Color.BLACK);

    // Indicate that the contents do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(true);

    // Use a linear layout manager
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    // Set up the adapter that provides the collection entries
    ReorderAdapter mAdapter = new ReorderAdapter(mItems, this);
    mRecyclerView.setAdapter(mAdapter);

    // Register the ItemTouchHelper Callback so that we can allow reordering
    // collections when the user drags the coin images or long presses and then
    // drags.
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(mAdapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(mRecyclerView);

    // Register a callback so we can know when the list has been reordered
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
            super.onItemRangeMoved(fromPosition, toPosition, itemCount);

            Log.d("onItemRangeMoved", String.valueOf(fromPosition) + " " + String.valueOf(toPosition) + " "
                    + String.valueOf(itemCount));

            ReorderCollections fragment = (ReorderCollections) getFragmentManager()
                    .findFragmentByTag("ReorderFragment");

            fragment.setUnsavedChanges(true);
            fragment.showUnsavedTextView();
        }
    });

    if (mUnsavedChanges) {
        showUnsavedTextView();
    }

    //http://stackoverflow.com/questions/7992216/android-fragment-handle-back-button-press
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
                if (mUnsavedChanges) {
                    showUnsavedChangesMessage();
                } else {
                    closeFragment();
                }
                return true;
            }
            return false;
        }
    });
}

From source file:com.android.managedprovisioning.DeviceOwnerProvisioningActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG)/*from ww w.j av  a2s .c  om*/
        ProvisionLogger.logd("Device owner provisioning activity ONCREATE");

    if (savedInstanceState != null) {
        mCancelDialogShown = savedInstanceState.getBoolean(KEY_CANCEL_DIALOG_SHOWN, false);
        mPendingProvisioningIntents = savedInstanceState.getParcelableArrayList(KEY_PENDING_INTENTS);
    }

    // Setup the UI.
    initializeLayoutParams(R.layout.progress, R.string.setup_work_device, true);
    configureNavigationButtons(NEXT_BUTTON_EMPTY_LABEL, View.INVISIBLE, View.VISIBLE);
    setTitle(R.string.setup_device_progress);

    mProgressTextView = (TextView) findViewById(R.id.prog_text);
    if (mCancelDialogShown)
        showCancelResetDialog();

    // Setup broadcast receiver for feedback from service.
    mServiceMessageReceiver = new ServiceMessageReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(DeviceOwnerProvisioningService.ACTION_PROVISIONING_SUCCESS);
    filter.addAction(DeviceOwnerProvisioningService.ACTION_PROVISIONING_ERROR);
    filter.addAction(DeviceOwnerProvisioningService.ACTION_PROGRESS_UPDATE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mServiceMessageReceiver, filter);

    // Load the ProvisioningParams (from message in Intent).
    mParams = (ProvisioningParams) getIntent().getParcelableExtra(ProvisioningParams.EXTRA_PROVISIONING_PARAMS);
    if (mParams != null) {
        maybeSetLogoAndMainColor(mParams.mainColor);
    }
    startDeviceOwnerProvisioningService();
}

From source file:de.azapps.mirakel.settings.SettingsActivity.java

@Override
protected void onRestoreInstanceState(@NonNull final Bundle state) {
    super.onRestoreInstanceState(state);

    //Retrieve our saved header list and last clicked position and ensure we switch to the proper header.
    headers = state.getParcelableArrayList(STATE_HEADERS_LIST);
    currentFragment = FRAGMENTS.values()[state.getInt(STATE_CUR_HEADER_POS)];
    if (headers != null) {
        currentFragment.restoreFragment(this);
    }//  w w w  . j a v a2 s. c o  m
}

From source file:com.berniesanders.fieldthebern.MainActivity.java

private History getHistory(Bundle savedInstanceState, GsonParceler parceler) {
    if (savedInstanceState != null && savedInstanceState.getParcelableArrayList("ENTRIES") != null) {
        return History.from(savedInstanceState, parceler);
    }/*w  w w .  jav a  2s  .  c  o m*/
    return History.single(initialScreen.get());
}

From source file:com.example.maxuan.photoutils.ViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_viewpager);
    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    cancelBtn = (ImageView) findViewById(R.id.selectCancel);
    cancelBtn.setOnClickListener(this);
    selectCheckBox = (CheckBox) findViewById(R.id.checkbox);
    selectCheckBox.setOnClickListener(this);
    completeBtn = (Button) findViewById(R.id.completeBtn);
    completeBtn.setOnClickListener(this);
    photos = new ArrayList<>();
    posArray = new SparseIntArray(10);
    adapter = new PhotoPagerAdapter(this, photos);
    mViewPager.setAdapter(adapter);/* ww  w. j a v  a  2  s . c o m*/
    mViewPager.addOnPageChangeListener(this);
    Intent intent = getIntent();
    if (intent != null) {
        Bundle bundle = intent.getBundleExtra("data");
        if (bundle == null)
            return;
        selectedPhotoArray = bundle.getSparseParcelableArray("selectedPhotos");
        completeBtn.setText(String.format(format, selectedPhotoArray.size()));
        List<Photo> list = bundle.getParcelableArrayList("photos");
        if (list != null)
            photos.addAll(list);
        for (int i = 0; i < photos.size(); ++i) {
            posArray.put(photos.get(i).id, i);
        }
        position = bundle.getInt("position", 0);
        maxCount = bundle.getInt("maxCount", 9);
        adapter.notifyDataSetChanged();
        mViewPager.setCurrentItem(position);
        selectCheckBox.setChecked(selectedPhotoArray.indexOfKey(photos.get(position).id) >= 0);
    }

    selectedPhotoAdapter = new SelectedPhotoAdapter(this);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    layoutManager.setReverseLayout(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(selectedPhotoAdapter);
    recyclerView.setVisibility(selectedPhotoArray.size() > 0 ? View.VISIBLE : View.GONE);
    if (savedInstanceState != null) {
        boolean isLocked = savedInstanceState.getBoolean(ISLOCKED_ARG, false);
        ((HackyViewPager) mViewPager).setLocked(isLocked);
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
        return;
    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

}

From source file:com.todoroo.astrid.tags.TagsControlSet.java

@Nullable
@Override//from   ww  w.  j a  va2s  .com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    ArrayList<String> newTags;
    if (savedInstanceState != null) {
        selectedTags = savedInstanceState.getParcelableArrayList(EXTRA_SELECTED_TAGS);
        newTags = savedInstanceState.getStringArrayList(EXTRA_NEW_TAGS);
    } else {
        selectedTags = tagService.getTagDataForTask(taskId);
        newTags = newArrayList();
    }
    allTags = tagService.getTagList();
    dialogView = inflater.inflate(R.layout.control_set_tag_list, null);
    newTagLayout = (LinearLayout) dialogView.findViewById(R.id.newTags);
    tagListView = (ListView) dialogView.findViewById(R.id.existingTags);
    tagListView.setAdapter(new ArrayAdapter<TagData>(getActivity(),
            R.layout.simple_list_item_multiple_choice_themed, allTags) {
        @NonNull
        @SuppressLint("NewApi")
        @Override
        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
            CheckedTextView view = (CheckedTextView) super.getView(position, convertView, parent);
            TagData tagData = allTags.get(position);
            ThemeColor themeColor = themeCache.getThemeColor(tagData.getColor() >= 0 ? tagData.getColor() : 19);
            view.setText(tagData.getName());
            Drawable original = ContextCompat.getDrawable(getContext(), R.drawable.ic_label_24dp);
            Drawable wrapped = DrawableCompat.wrap(original.mutate());
            DrawableCompat.setTint(wrapped, themeColor.getPrimaryColor());
            if (atLeastJellybeanMR1()) {
                view.setCompoundDrawablesRelativeWithIntrinsicBounds(wrapped, null, null, null);
            } else {
                view.setCompoundDrawablesWithIntrinsicBounds(wrapped, null, null, null);
            }
            return view;
        }
    });
    for (String newTag : newTags) {
        addTag(newTag);
    }
    addTag("");
    for (TagData tag : selectedTags) {
        setTagSelected(tag);
    }
    refreshDisplayView();
    return view;
}