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.example.julia.popularmovies.MovieGridFragment.java

@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(Config.MOVIES_KEY)) {
            mMovies = savedInstanceState.getParcelableArrayList(Config.MOVIES_KEY);
            mMovieGridAdapter.setData(mMovies);
        } else {/*from  w w w .j  a v  a  2  s.  c o m*/
            updateMovies(mSortBy);
        }
    } else {
        updateMovies(mSortBy);
    }
}

From source file:com.lloydtorres.stately.census.CensusSubFragment.java

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

    // Restore save state
    if (savedInstanceState != null) {
        censusMode = savedInstanceState.getInt(MODE_KEY);
        censusData = savedInstanceState.getParcelableArrayList(CENSUS_DATA_KEY);
        target = savedInstanceState.getString(TARGET_KEY);
    }//  w ww  .  j a  v  a2 s  . c  o m

    if (censusData != null) {
        initCensusRecycler(view);
    }

    return view;
}

From source file:org.mariotaku.twidere.fragment.support.ParcelableStatusesListFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    mStatusesRestored = false;//from   w w w  .ja v  a 2s  .  c  om
    if (savedInstanceState != null) {
        final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(EXTRA_DATA);
        if (saved != null) {
            setData(saved);
        }
    }
    super.onActivityCreated(savedInstanceState);
    mPreferences = getSharedPreferences();
}

From source file:com.dwdesign.tweetings.fragment.ParcelableStatusesListFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(INTENT_KEY_DATA);
        if (saved != null) {
            mData = new SynchronizedStateSavedList<ParcelableStatus, Long>(saved);
        }//from   w  w w . j  av a 2 s. c o m
    }
    mAdapter = new ParcelableStatusesAdapter(getActivity());
    mAdapter.setData(mData);
    super.onActivityCreated(savedInstanceState);
    mListView = getListView();
    mPreferences = getSharedPreferences();
}

From source file:de.vanita5.twittnuker.fragment.support.ParcelableStatusesListFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    mStatusesRestored = false;/*from w w  w.  ja va  2 s .  c  om*/
    if (savedInstanceState != null) {
        final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(EXTRA_DATA);
        if (saved != null) {
            setData(saved);
        }
    }
    super.onActivityCreated(savedInstanceState);
    mPreferences = getSharedPreferences();
    mIsFirstCreated = savedInstanceState == null;
}

From source file:dk.cafeanalog.OpeningsFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(OPENING_CONTENT)) {
            mOpenings = savedInstanceState.getParcelableArrayList(OPENING_CONTENT);
        }/* w  ww . ja  v  a2 s.  co  m*/
    }

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

    final SwipeRefreshLayout refresher = (SwipeRefreshLayout) view.findViewById(R.id.refresher);
    final RecyclerView listView = (RecyclerView) view.findViewById(R.id.list);
    refresher.setNestedScrollingEnabled(true);
    refresher.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            AnalogClient.getInstance().getDaysOfOpenings(new Action1<List<DayOfOpenings>>() {
                @Override
                public void call(List<DayOfOpenings> dayOfOpenings) {
                    mOpenings.clear();
                    mOpenings.addAll(dayOfOpenings);
                    listView.getAdapter().notifyDataSetChanged();
                    refresher.setRefreshing(false);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    // Ignore
                }
            });
        }
    });

    listView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    listView.setAdapter(new RecyclerView.Adapter<DayHolder>() {
        @Override
        public DayHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View day = inflater.inflate(R.layout.day, parent, false);
            return new DayHolder(day);
        }

        @Override
        public void onBindViewHolder(DayHolder holder, int position) {
            DayOfOpenings day = mOpenings.get(position);

            if (day.getMorning()) {
                holder.morning.setEnabled(true);
            } else {
                holder.morning.setEnabled(false);
            }

            if (day.getNoon()) {
                holder.noon.setEnabled(true);
            } else {
                holder.noon.setEnabled(false);
            }

            if (day.getAfternoon()) {
                holder.afternoon.setEnabled(true);
            } else {
                holder.afternoon.setEnabled(false);
            }

            holder.dayOfWeek.setText(getDayOfWeek(getActivity(), day.getDayOfWeek()));
        }

        @Override
        public int getItemCount() {
            return mOpenings.size();
        }
    });

    return view;
}

From source file:com.m2team.phuotstory.activity.DirectionActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction);
    ButterKnife.bind(this);
    final ArrayList<LatLng> latLngs = new ArrayList<>();
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.getUiSettings().setCompassEnabled(true);
    mMap.getUiSettings().setZoomControlsEnabled(true);

    textProgress = (TextView) findViewById(R.id.textProgress);
    textProgress.setVisibility(View.GONE);

    buttonAnimate.setColorNormalResId(R.color.white);
    buttonAnimate.setIcon(R.drawable.ic_action_direction);
    buttonAnimate.setTitle(getString(R.string.animation));
    buttonAnimate.setSize(FloatingActionButton.SIZE_NORMAL);
    buttonAnimate.setEnabled(false);/*from   w  w  w .  ja v  a 2s.c  o m*/
    buttonAnimate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            gd.animateDirection(mMap, latLngs, GoogleDirection.SPEED_VERY_FAST, true, false, true, true,
                    new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_motor2)), false,
                    true, null);
        }
    });
    totalDistance = 0;

    if (getIntent() != null && getIntent().getExtras() != null) {
        Bundle extras = getIntent().getExtras();
        locations = extras.getParcelableArrayList(Constant.ARRAY_LOCATION);
        if (locations != null && locations.size() > 0) {
            index = 0;
            final int locSize = locations.size();
            gd = new GoogleDirection(this);

            mMap.clear();
            MyLocation sLoc = locations.get(0);
            MyLocation eLoc = locations.get(locations.size() - 1);
            if (eLoc.equals(sLoc)) {
                eLoc = locations.get(locations.size() - 2);
            }
            mMap.addMarker(new MarkerOptions().position(newLatLong(sLoc))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_start)));

            mMap.addMarker(new MarkerOptions().position(newLatLong(eLoc))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action)));

            MyLocation temp1, temp2;
            for (int i = 0; i < locations.size() - 1; i++) {
                temp1 = locations.get(i);
                temp2 = locations.get(i + 1);
                latLngs.add(newLatLong(temp1));
                gd.request(newLatLong(temp1), newLatLong(temp2), GoogleDirection.MODE_DRIVING);
                /*if (i > 0 && i < locations.size() - 1)
                mMap.addMarker(new MarkerOptions().position(newLatLong(temp1))
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_between)));*/
            }
            latLngs.add(newLatLong(eLoc));
            latLngs.add(newLatLong(sLoc));
            //request from last to first location
            gd.request(newLatLong(eLoc), newLatLong(sLoc), GoogleDirection.MODE_DRIVING);

            final ArrayList<String> addressList = new ArrayList<>();

            gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {
                public void onResponse(String status, Document doc, GoogleDirection gd) {
                    index++;
                    String startAddress = gd.getStartAddress(doc);

                    if (!addressList.contains(startAddress))
                        addressList.add(startAddress);
                    totalDistance += gd.getTotalDistanceValue(doc);
                    mMap.addPolyline(gd.getPolyline(doc, 5, R.color.md_blue_600));
                    if (index == locSize) {
                        buttonAnimate.setEnabled(true);
                        tv_start_address.setText(TextUtils.join("->", addressList));
                        tv_distance.setText("Total distance: " + (totalDistance / 1000) + " km");
                        LatLngBounds.Builder builder = new LatLngBounds.Builder();
                        for (LatLng latLng : latLngs) {
                            builder.include(latLng);
                        }
                        LatLngBounds bounds = builder.build();
                        mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 300));
                        //clusterMarker(mMap, locations);
                    }
                }
            });

            gd.setOnAnimateListener(new OnAnimateListener() {
                public void onStart() {
                    textProgress.setVisibility(View.VISIBLE);
                }

                public void onProgress(int progress, int total) {
                    textProgress.setText(progress + " / " + total);
                }

                public void onFinish() {
                    buttonAnimate.setEnabled(true);
                    textProgress.setVisibility(View.GONE);
                }
            });

        } else {
            Toast.makeText(this, getString(R.string.fail_data), Toast.LENGTH_SHORT).show();
        }
    } else {
        Toast.makeText(this, getString(R.string.fail_data), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.ubimobitech.spotifystreamer.PlaybackFragment.java

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

    ButterKnife.inject(this, view);

    Bundle args = getArguments();

    if (args != null) {
        mTrackInfo = args.getParcelableArrayList(TRACKS_ARGS);
        mCurrentPosition = args.getInt(POSITION_ARGS);

        updatePlaybackScreen(mCurrentPosition);
    }//  ww w. j a  va2s  . c o m

    mPlayPause.setOnClickListener(this);
    mNext.setOnClickListener(this);
    mPrevious.setOnClickListener(this);

    return view;
}

From source file:com.example.run_tracker.MyRunsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.v(TAG, "onActivityCreated");

    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        mTracks = savedInstanceState.getParcelableArrayList("tracklist");
    }/* ww w . j  a va2s .c o  m*/
}

From source file:eu.thedarken.rootvalidator.ValidatorFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey("data")) {
            ArrayList<TestInfo> theData = savedInstanceState.getParcelableArrayList("data");
            mAdapter = new RVAdapter(theData);

        }//from   ww w.jav a 2  s .  c om
    }
    super.onCreate(savedInstanceState);
}