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.baruckis.nanodegree.spotifystreamer.fragments.PlayerDialogFragment.java

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

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(ARG_CONFIG_CHANGE)) {
            mIsConfigChanged = savedInstanceState.getBoolean(ARG_CONFIG_CHANGE);
        }//from  w  w w.  j a  v  a  2  s .  c  om
    } else {
        Bundle bundle = getArguments();
        if (bundle != null) {
            if (bundle.containsKey(ARG_TRACKS_LIST)) {
                mTracksList = bundle.getParcelableArrayList(ARG_TRACKS_LIST);
            }
            if (bundle.containsKey(ARG_SELECTED_TRACK_INDEX)) {
                mSelectedTrackIndex = bundle.getInt(ARG_SELECTED_TRACK_INDEX);
            }
            if (bundle.containsKey(ARG_CONFIG_CHANGE)) {
                mIsConfigChanged = bundle.getBoolean(ARG_CONFIG_CHANGE);
            }
        }
    }

    mArtistName = (TextView) view.findViewById(R.id.artist_name);
    mAlbumName = (TextView) view.findViewById(R.id.album_name);
    mAlbumImage = (ImageView) view.findViewById(R.id.album_image);
    mTrackName = (TextView) view.findViewById(R.id.track_name);
    mCurrentTime = (TextView) view.findViewById(R.id.current_time);
    mTotalTime = (TextView) view.findViewById(R.id.total_time);

    mScrubBar = (SeekBar) view.findViewById(R.id.scrub_bar);
    ImageButton previousButton = (ImageButton) view.findViewById(R.id.previous_button);
    mPlayPauseButton = (ImageButton) view.findViewById(R.id.play_pause_button);
    ImageButton nextButton = (ImageButton) view.findViewById(R.id.next_button);

    mScrubBar.setClickable(false);

    onInitService();

    // Setup player controls.
    mPlayPauseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (playbackPaused) {
                generateAction(PlayerService.ACTION_PLAY);
            } else {
                generateAction(PlayerService.ACTION_PAUSE);
            }
        }
    });

    mScrubBar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return !mScrubBar.isEnabled();
        }
    });

    mScrubBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                mCurrentTime.setText(Utils.getSecondsFromMilliseconds(progress));
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            updateSeekBar(false);
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            mPlayerService.seek(seekBar.getProgress());
            updateSeekBar(true);
        }
    });

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            generateAction(PlayerService.ACTION_NEXT);
        }
    });
    previousButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            generateAction(PlayerService.ACTION_PREVIOUS);
        }
    });

    Utils.hideSoftKeyboard(view);
}

From source file:com.amaze.filemanager.fragments.ZipViewer.java

void SetupZip(Bundle savedInstanceState) {
    if (savedInstanceState == null)
        loadlist(s);/* w  w  w .  j  a  v  a2  s  .  c  o m*/
    else {
        wholelist = savedInstanceState.getParcelableArrayList("wholelist");
        elements = savedInstanceState.getParcelableArrayList("elements");
        current = savedInstanceState.getString("path");
        f = new File(savedInstanceState.getString("file"));
        createviews(elements, current);
    }
}

From source file:com.amaze.carbonfilemanager.fragments.ZipViewer.java

void SetupZip(Bundle savedInstanceState) {
    if (savedInstanceState == null)
        loadlist(s);/*from   w  w w. ja v  a  2 s  . c  o m*/
    else {
        wholelist = savedInstanceState.getParcelableArrayList(KEY_WHOLE_LIST);
        elements = savedInstanceState.getParcelableArrayList(KEY_ELEMENTS);
        current = savedInstanceState.getString(KEY_PATH);
        f = new File(savedInstanceState.getString(KEY_FILE));
        createviews(elements, current);
    }
}

From source file:com.lloydtorres.stately.telegrams.TelegramReadActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_refreshview);

    // Either get data from intent or restore state
    if (getIntent() != null) {
        id = getIntent().getIntExtra(ID_DATA, 0);
        title = getIntent().getStringExtra(TITLE_DATA);
    }//  w  w  w  .j a  va  2 s.c om
    if (savedInstanceState != null) {
        id = savedInstanceState.getInt(ID_DATA);
        title = savedInstanceState.getString(TITLE_DATA);
        telegrams = savedInstanceState.getParcelableArrayList(TELEGRAM_DATA);
    }

    view = findViewById(R.id.refreshview_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.refreshview_toolbar);
    setToolbar(toolbar);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refreshview_refresher);
    mSwipeRefreshLayout.setEnabled(false);
    mSwipeRefreshLayout.setColorSchemeResources(SparkleHelper.refreshColours);

    // Setup recyclerview
    mRecyclerView = (RecyclerView) findViewById(R.id.refreshview_recycler);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
}

From source file:net.lp.actionbarpoirot.helpers.FragmentHelperHoneycomb.java

@Override
public void onLoadInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState == null)
        return;//from  ww w.j  a  v  a2s.c o m

    final String lastSelectedPositionUriString = savedInstanceState.getString(STATE_LAST_SELECTED_POSITION_URI);
    lastSelectedPositionUri = lastSelectedPositionUriString == null ? null
            : Uri.parse(lastSelectedPositionUriString);
    mSelectedPositionsUris = new LinkedHashSet<Uri>((ArrayList<? extends Uri>) savedInstanceState
            .getParcelableArrayList(STATE_SELECTED_POSITIONS_URIS));
}

From source file:fr.cph.chicago.activity.MainActivity.java

@Override
public final boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        if (mCurrentPosition != POSITION_DIVVY && mCurrentPosition != POSITION_NEARBY
                && mCurrentPosition != POSITION_ALERTS) {
            MenuItem menuItem = item;
            menuItem.setActionView(R.layout.progressbar);
            menuItem.expandActionView();

            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
            boolean loadTrain = sharedPref.getBoolean("cta_train", true);
            boolean loadBus = sharedPref.getBoolean("cta_bus", true);
            boolean loadBike = sharedPref.getBoolean("divvy_bike", true);
            boolean loadAlert = sharedPref.getBoolean("cta_alert", true);

            MultiMap<String, String> params = new MultiValueMap<String, String>();
            List<Integer> trainFavorites = Preferences
                    .getTrainFavorites(ChicagoTracker.PREFERENCE_FAVORITES_TRAIN);
            for (Integer fav : trainFavorites) {
                params.put("mapid", String.valueOf(fav));
            }//from w  ww  . ja  va2  s. c om
            MultiMap<String, String> params2 = new MultiValueMap<String, String>();
            List<String> busFavorites = Preferences.getBusFavorites(ChicagoTracker.PREFERENCE_FAVORITES_BUS);
            for (String str : busFavorites) {
                String[] fav = Util.decodeBusFavorite(str);
                params2.put("rt", fav[0]);
                params2.put("stpid", fav[1]);
            }
            GlobalConnectTask task;
            try {
                task = new GlobalConnectTask(mFavoritesFragment, FavoritesFragment.class,
                        CtaRequestType.TRAIN_ARRIVALS, params, CtaRequestType.BUS_ARRIVALS, params2, loadTrain,
                        loadBus, loadBike);
                task.execute((Void) null);
            } catch (ParserException e) {
                ChicagoTracker.displayError(this, e);
                return true;
            }
            // Google analytics
            if (loadTrain) {
                Util.trackAction(MainActivity.this, R.string.analytics_category_req,
                        R.string.analytics_action_get_train, R.string.analytics_action_get_train_arrivals, 0);
            }
            if (loadBus) {
                Util.trackAction(MainActivity.this, R.string.analytics_category_req,
                        R.string.analytics_action_get_bus, R.string.analytics_action_get_bus_arrival, 0);
            }
            if (loadBike) {
                Util.trackAction(MainActivity.this, R.string.analytics_category_req,
                        R.string.analytics_action_get_divvy, R.string.analytics_action_get_divvy_all, 0);
            }
            // Check if bus/bike or alert data are not loaded. If not, load them.
            // Can happen when the app has been loaded without any data connection
            boolean loadData = false;
            DataHolder dataHolder = DataHolder.getInstance();

            BusData busData = dataHolder.getBusData();
            AlertData alertData = dataHolder.getAlertData();

            Bundle bundle = getIntent().getExtras();
            List<BikeStation> bikeStations = bundle.getParcelableArrayList("bikeStations");

            if (loadBus && busData.getRoutes() != null && busData.getRoutes().size() == 0) {
                loadData = true;
            }
            if (!loadData && loadAlert && alertData.getAlerts() != null && alertData.getAlerts().size() == 0) {
                loadData = true;
            }
            if (!loadData && loadBike && bikeStations == null) {
                loadData = true;
            }
            if (loadData) {
                startRefreshAnimation();
                new LoadData().execute();
            }
            Util.trackAction(this, R.string.analytics_category_ui, R.string.analytics_action_press,
                    R.string.analytics_action_refresh_fav, 0);
        } else if (mCurrentPosition == POSITION_NEARBY) {
            mNearbyFragment.reloadData();
            Util.trackAction(this, R.string.analytics_category_ui, R.string.analytics_action_press,
                    R.string.analytics_action_refresh_nearby, 0);
        }
        return false;
    case R.id.action_search:
        Util.trackAction(this, R.string.analytics_category_ui, R.string.analytics_action_press,
                R.string.analytics_action_search, 0);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.yolosec.upckeygen.ui.NetworkFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments().containsKey(NETWORK_ID)) {
        wifiNetwork = getArguments().getParcelable(NETWORK_ID);
        restoreMissingKeygens();//w ww .j a v  a  2s  .c  o m
        thread = new KeygenThread(wifiNetwork);
    }
    if (savedInstanceState != null) {
        final ArrayList<Parcelable> arList = savedInstanceState.getParcelableArrayList(PASSWORD_LIST);
        if (arList != null) {
            for (Parcelable p : arList) {
                if (p instanceof WiFiKey) {
                    final WiFiKey key = (WiFiKey) p;
                    passwordList.add(key);
                }
            }
        }
    }
    setHasOptionsMenu(true);
}

From source file:me.lizheng.deckviewsample.DeckViewSampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_deck_view_sample);

    //noinspection unchecked
    mDeckView = (DeckView) findViewById(R.id.deckview);
    mDefaultThumbnail = BitmapFactory.decodeResource(getResources(), R.drawable.default_thumbnail);
    mDefaultHeaderIcon = ContextCompat.getDrawable(getApplicationContext(), R.drawable.default_header_icon);

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(CURRENT_LIST)) {
            mEntries = savedInstanceState.getParcelableArrayList(CURRENT_LIST);
        }/*from  w  w w .  j a v  a2  s .com*/

        if (savedInstanceState.containsKey(CURRENT_SCROLL)) {
            scrollToChildIndex = savedInstanceState.getInt(CURRENT_SCROLL);
        }
    }

    if (mEntries == null) {
        mEntries = new ArrayList<>();

        for (int i = 1; i < 100; i++) {
            CardDataModel cardDataModel = new CardDataModel();
            cardDataModel.id = generateUniqueKey();
            cardDataModel.title = "Image ID " + cardDataModel.id;
            mEntries.add(cardDataModel);
        }
    }

    // Callback implementation
    DeckView.Callback<CardDataModel> deckViewCallback = new DeckView.Callback<CardDataModel>() {
        @Override
        public ArrayList<CardDataModel> getData() {
            return mEntries;
        }

        @Override
        public void loadViewData(WeakReference<DeckChildView<CardDataModel>> dcv, CardDataModel item) {
            if (dcv.get() != null) {
                dcv.get().onDataLoaded(item, mDefaultThumbnail, mDefaultHeaderIcon, item.title, Color.DKGRAY);
            }
        }

        @Override
        public void unloadViewData(CardDataModel item) {
        }

        @Override
        public void onViewDismissed(CardDataModel item) {
            mEntries.remove(item);
            mDeckView.notifyDataSetChanged();
        }

        @Override
        public void onItemClick(CardDataModel item) {
            Toast.makeText(DeckViewSampleActivity.this, "Item with title: '" + item.title + "' clicked",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNoViewsToDeck() {
            Toast.makeText(DeckViewSampleActivity.this, "No views to show", Toast.LENGTH_SHORT).show();
        }
    };

    mDeckView.initialize(deckViewCallback);

    if (scrollToChildIndex != -1) {
        mDeckView.post(new Runnable() {
            @Override
            public void run() {
                // Restore scroll position
                mDeckView.scrollToChild(scrollToChildIndex);
            }
        });
    }
}

From source file:com.example.android.wizardpager.wizard.ui.ProfessorCityToFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_page_professor_city_to, 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 StateSpinnerBaseAdapter(getActivity(), mStates));
            spnState.setSelection(stateSelectedPosition, false);
        }//from  www. j  ava 2s.  c o  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.permutassep.presentation.view.wizard.ui.ProfessorCityFromFragment.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_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 PlaceSpinnerBaseAdapter(getActivity(), mStates));
            spnState.setSelection(stateSelectedPosition, false);
        }/*from   ww w  . j  ava  2 s .c  o  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;
}