Example usage for android.os Bundle getIntegerArrayList

List of usage examples for android.os Bundle getIntegerArrayList

Introduction

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

Prototype

@Override
@Nullable
public ArrayList<Integer> getIntegerArrayList(@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:bbct.android.common.activity.FilterCards.java

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

    // set title//from   w  w w  . j av a2 s  .  c  om
    String format = this.getString(R.string.bbct_title);
    String filterCardsTitle = this.getString(R.string.filter_cards_title);
    String title = String.format(format, filterCardsTitle);
    Activity activity = Objects.requireNonNull(getActivity());
    activity.setTitle(title);

    for (int id : CHECKBOXES) {
        View checkBox = view.findViewById(id);
        checkBox.setOnClickListener(this.onCheckBoxClick);
    }

    // restore input fields state
    if (savedInstanceState != null) {
        ArrayList<Integer> enabledFields = savedInstanceState.getIntegerArrayList(INPUT_EXTRA);
        if (enabledFields != null) {
            for (int i : enabledFields) {
                CheckBox cb = view.findViewById(CHECKBOXES[i]);
                cb.setChecked(true);
                EditText et = view.findViewById(TEXT_FIELDS[i]);
                et.setEnabled(true);
            }
        }
    }

    return view;
}

From source file:com.google.samples.apps.gameloopmanager.TestLoopsActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_loops);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    launchAllButton = (Button) findViewById(R.id.run_all);
    launchAllButton.setOnClickListener(new OnClickListener() {
        @Override//from  w ww.  ja  v a 2  s .  c o m
        public void onClick(View v) {
            startLoopFromUi();
        }
    });

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    timeout = prefs.getLong(TIMEOUT, 3 * 60 * 1000);

    if (savedInstanceState != null) {
        checkedScenarios.addAll(savedInstanceState.getIntegerArrayList(CHECKED_SCENARIOS));
        List<TestLoopGroup> savedTestLoopGroups = savedInstanceState.getParcelableArrayList(TEST_LOOP_GROUPS);
        testLoopGroups.addAll(savedTestLoopGroups);
        updateTestLoopButton();
    }

    resolveInfo = getIntent().getParcelableExtra("resolveInfo");

    adapter = new TestLoopGroupAdapter(this, checkedScenarios, testLoopGroups);
    expandableListView = (ExpandableListView) findViewById(R.id.test_loop_list);
    expandableListView.setAdapter(adapter);
    expandableListView.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            if (childPosition == 0) {
                CheckBox checkBox = (CheckBox) v;
                if (checkBox.isChecked()) {
                    for (int item : adapter.getGroup(groupPosition).getLoops()) {
                        checkedScenarios.remove(item);
                    }
                } else {
                    for (int item : adapter.getGroup(groupPosition).getLoops()) {
                        checkedScenarios.add(item);
                    }
                }
            } else {
                Integer data = adapter.getChild(groupPosition, childPosition - 1);
                if (!checkedScenarios.remove(data)) {
                    checkedScenarios.add(data);
                }
            }

            adapter.notifyDataSetChanged();
            updateTestLoopButton();
            return true;
        }
    });

}

From source file:paulscode.android.mupen64plusae.jni.CoreService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        Bundle extras = intent.getExtras();

        mRomGoodName = extras.getString(ActivityHelper.Keys.ROM_GOOD_NAME);
        mRomPath = extras.getString(ActivityHelper.Keys.ROM_PATH);
        mCheatOptions = extras.getString(ActivityHelper.Keys.CHEAT_ARGS);
        mIsRestarting = extras.getBoolean(ActivityHelper.Keys.DO_RESTART, false);
        mSaveToLoad = extras.getString(ActivityHelper.Keys.SAVE_TO_LOAD);
        mCoreLib = extras.getString(ActivityHelper.Keys.CORE_LIB);
        mUseHighPriorityThread = extras.getBoolean(ActivityHelper.Keys.HIGH_PRIORITY_THREAD, false);

        mPakType = extras.getIntegerArrayList(ActivityHelper.Keys.PAK_TYPE_ARRAY);

        boolean[] isPluggedArray = extras.getBooleanArray(ActivityHelper.Keys.IS_PLUGGED_ARRAY);
        mIsPlugged = new ArrayList<>();

        for (Boolean isPlugged : isPluggedArray) {
            mIsPlugged.add(isPlugged);/*from  ww  w . j ava2 s. c  om*/
        }

        mIsFrameLimiterEnabled = extras.getBoolean(ActivityHelper.Keys.IS_FPS_LIMIT_ENABLED, true);
        mCoreUserDataDir = extras.getString(ActivityHelper.Keys.CORE_USER_DATA_DIR);
        mCoreUserCacheDir = extras.getString(ActivityHelper.Keys.CORE_USER_CACHE_DIR);
        mCoreUserConfigDir = extras.getString(ActivityHelper.Keys.CORE_USER_CONFIG_DIR);
        mUserSaveDir = extras.getString(ActivityHelper.Keys.USER_SAVE_DIR);

        mArtPath = extras.getString(ActivityHelper.Keys.ROM_ART_PATH);

        String libsDir = extras.getString(ActivityHelper.Keys.LIBS_DIR);
        // Load the native libraries, this must be done outside the thread to prevent race conditions
        // that depend on the libraries being loaded after this call is made
        NativeExports.loadLibraries(libsDir, Build.VERSION.SDK_INT);

        mIsServiceRunning = true;

        updateNotification();
    }

    mStartId = startId;

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:org.rm3l.ddwrt.fragments.DDWRTBaseFragment.java

/**
 * Called to do initial creation of a fragment.  This is called after
 * {@link #onAttach(android.app.Activity)}} and before
 * {@link #onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)}.
 * <p/>/* w w w.j  a v  a 2  s. c o  m*/
 * <p>Note that this can be called while the fragment's activity is
 * still in the process of being created.  As such, you can not rely
 * on things like the activity's content view hierarchy being initialized
 * at this point.  If you want to do work once the activity itself is
 * created, see {@link #onActivityCreated(android.os.Bundle)}.
 *
 * @param savedInstanceState If the fragment is being re-created from
 *                           a previous saved state, this is the state.
 */
@Override
public final void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setHasOptionsMenu(true);

    this.router = RouterManagementActivity.getDao(this.getActivity())
            .getRouter(getArguments().getString(ROUTER_CONNECTION_INFO));
    Log.d(LOG_TAG, "onCreate() loaderIdsInUse: " + loaderIdsInUse);
    if (savedInstanceState != null) {
        final ArrayList<Integer> loaderIdsSaved = savedInstanceState.getIntegerArrayList(STATE_LOADER_IDS);
        Log.d(LOG_TAG, "onCreate() loaderIdsSaved: " + loaderIdsSaved);
        if (loaderIdsSaved != null) {
            //Destroy existing IDs, if any, as new loaders will get created in onResume()
            final LoaderManager loaderManager = getLoaderManager();
            for (final Integer loaderId : loaderIdsSaved) {
                if (loaderId == null) {
                    continue;
                }
                loaderManager.destroyLoader(loaderId);
            }
        }
    }
    this.loaderIdsInUse.clear();
    viewGroup = (ScrollView) getSherlockActivity().getLayoutInflater()
            .inflate(R.layout.base_tiles_container_scrollview, null);

    this.fragmentTiles = this.getTiles(savedInstanceState);
}

From source file:io.github.hidroh.materialistic.widget.StoryRecyclerViewAdapter.java

@Override
public void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;/*from  w ww .  j  a  va  2s .com*/
    }
    super.restoreState(savedState);
    ArrayList<Item> savedItems = savedState.getParcelableArrayList(STATE_ITEMS);
    setItemsInternal(savedItems);
    mUpdated = savedState.getParcelableArrayList(STATE_UPDATED);
    if (mUpdated != null) {
        for (int i = 0; i < mUpdated.size(); i++) {
            mUpdatedPositions.put(mUpdated.get(i).getLongId(), i);
        }
    }
    ArrayList<String> promotedKey = savedState.getStringArrayList(STATE_PROMOTED_KEY);
    ArrayList<Integer> promotedValue = savedState.getIntegerArrayList(STATE_PROMOTED_VALUE);
    mPromoted.clear();
    //noinspection ConstantConditions
    for (int i = 0; i < promotedKey.size(); i++) {
        //noinspection ConstantConditions
        mPromoted.put(promotedKey.get(i), promotedValue.get(i));
    }
    mShowAll = savedState.getBoolean(STATE_SHOW_ALL, true);
    mHighlightUpdated = savedState.getBoolean(STATE_HIGHLIGHT_UPDATED, true);
    mFavoriteRevision = savedState.getInt(STATE_FAVORITE_REVISION);
    mUsername = savedState.getString(STATE_USERNAME);
}

From source file:net.xisberto.phonetodesktop.ui.LinkListActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }//from  w ww  .  j a  va  2s .co  m
    setContentView(R.layout.activity_link_list);

    selectedItems = new SparseArrayCompat<>();

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    list_view = (ListView) findViewById(android.R.id.list);
    list_view.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    if ((savedInstanceState != null) && savedInstanceState.containsKey(Utils.EXTRA_TITLES)) {
        taskList = savedInstanceState.getParcelable(Utils.EXTRA_TITLES);
        boolean updating = savedInstanceState.getBoolean(Utils.EXTRA_UPDATING, false);
        swipeRefreshLayout.setRefreshing(updating);
        ArrayList<Integer> selection = savedInstanceState.getIntegerArrayList(SELECTED_ITEMS);

        if (list_view.getAdapter() == null) {
            adapter = new TasksArrayAdapter(this, taskList.items, this);
            list_view.setAdapter(adapter);
        } else {
            adapter = (TasksArrayAdapter) list_view.getAdapter();
        }
        if (selection != null) {
            Log.w("LinkList", String.format("Read selection with %s items", selection.size()));
            for (int i = 0; i < selection.size(); i++) {
                selectedItems.put(selection.get(i), adapter.getItem(i).getId());
                adapter.setChecked(selectedItems.keyAt(i), true);
                onItemChecked(selectedItems.keyAt(i), true);
            }
            adapter.notifyDataSetChanged();
        }

    } else {
        taskList = new TaskList();
        refreshTasks();
    }
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherListFragment.java

/**
 * {@inheritDoc}//from  w  ww .ja  v a 2s  .  c o m
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        mTaskIdGetRomsState = savedInstanceState.getInt(EXTRA_TASK_ID_GET_ROMS_STATE);
        mTaskIdSwitchRom = savedInstanceState.getInt(EXTRA_TASK_ID_SWITCH_ROM);
        mTaskIdSetKernel = savedInstanceState.getInt(EXTRA_TASK_ID_SET_KERNEL);
        mTaskIdsToRemove = savedInstanceState.getIntegerArrayList(EXTRA_TASK_IDS_TO_REMOVE);

        mPerformingAction = savedInstanceState.getBoolean(EXTRA_PERFORMING_ACTION);

        mSelectedRom = savedInstanceState.getParcelable(EXTRA_SELECTED_ROM);
        mActiveRomId = savedInstanceState.getString(EXTRA_ACTIVE_ROM_ID);

        mShowedSetKernelWarning = savedInstanceState.getBoolean(EXTRA_SHOWED_SET_KERNEL_WARNING);
        mHavePermissionsResult = savedInstanceState.getBoolean(EXTRA_HAVE_PERMISSIONS_RESULT);

        mIsLoading = savedInstanceState.getBoolean(EXTRA_IS_LOADING);
    }

    mFabFlashZip = (FloatingActionButton) getActivity().findViewById(R.id.fab_flash_zip);
    mFabFlashZip.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), InAppFlashingActivity.class);
            startActivityForResult(intent, REQUEST_FLASH_ZIP);
        }
    });

    mSwipeRefresh = (SwipeRefreshLayoutWorkaround) getActivity().findViewById(R.id.swiperefreshroms);
    mSwipeRefresh.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            reloadRomsState();
        }
    });

    mSwipeRefresh.setColorSchemeResources(R.color.swipe_refresh_color1, R.color.swipe_refresh_color2,
            R.color.swipe_refresh_color3, R.color.swipe_refresh_color4);

    initErrorCard();
    initCardList();
    setErrorVisibility(false);

    mIsInitialStart = savedInstanceState == null;
}

From source file:de.frank_durr.ble_v_monitor.MainActivity.java

/**
 * Restore the data model from saved instance state.
 * It is save to call this method with empty or partial state only containing portions
 * of the data model.//w  w w  . j  a v a 2  s.  com
 *
 * @param savedInstanceState the instance state containing portions of the data model
 */
private void restoreDataModel(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        return;
    }

    // There is some data to be restored.
    if (savedInstanceState.containsKey(BUNDLE_KEY_CURRENT_VOLTAGE)) {
        DataModel.theModel.setCurrentVoltage(savedInstanceState.getInt(BUNDLE_KEY_CURRENT_VOLTAGE));
    }

    ArrayList<Integer> values = savedInstanceState.getIntegerArrayList(BUNDLE_KEY_HISTORY_MINUTELY);
    if (values != null) {
        DataModel.theModel.setMinutelyHistory(values);
    }

    values = savedInstanceState.getIntegerArrayList(BUNDLE_KEY_HISTORY_HOURLY);
    if (values != null) {
        DataModel.theModel.setHourlyHistory(values);
    }

    values = savedInstanceState.getIntegerArrayList(BUNDLE_KEY_HISTORY_DAILY);
    if (values != null) {
        DataModel.theModel.setDailyHistory(values);
    }
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsActivity.java

@Override
protected void onPreRestoreBundle(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        boolean saved = savedInstanceState.getBoolean(ParamIntent.BUNDLE_SAVE, false);
        if (saved) {
            getModelActivity().setNearResp((NearResp) savedInstanceState.getParcelable(ParamIntent.NEAR_RESP));
            intentResult = new Intent();
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST,
                    savedInstanceState.getBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, false));
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_CITY,
                    savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_CITY));
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME,
                    savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME));
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_THEATER_ID,
                    savedInstanceState.getString(ParamIntent.ACTIVITY_SEARCH_THEATER_ID));
            intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_DAY,
                    savedInstanceState.getInt(ParamIntent.ACTIVITY_SEARCH_DAY, 0));
            intentResult.putIntegerArrayListExtra(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND,
                    savedInstanceState.getIntegerArrayList(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND));
            Double latitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE, -1);
            Double longitude = savedInstanceState.getDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, -1);
            if ((latitude != -1) && (longitude != -1)) {
                intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LATITUDE, latitude);
                intentResult.putExtra(ParamIntent.ACTIVITY_SEARCH_LONGITUDE, longitude);
            }/*from w w  w.  j av  a2 s. c  o m*/
        }

    }
}

From source file:com.fa.mastodon.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        View view = this.getWindow().getDecorView();
        view.setBackgroundColor(Color.parseColor("#EEEEEE"));
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        View view = this.getWindow().getDecorView();
        view.setBackgroundColor(Color.parseColor("#000000"));
    }//  w w  w  .  j  av  a  2s .  c o  m
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pageHistory = new Stack<>();
    if (savedInstanceState != null) {
        List<Integer> restoredHistory = savedInstanceState.getIntegerArrayList("pageHistory");
        if (restoredHistory != null) {
            pageHistory.addAll(restoredHistory);
        }
    }

    ButterKnife.bind(this);

    floatingBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSheetLayout.expandFab();
        }
    });

    TypedArray array = getTheme().obtainStyledAttributes(new int[] { android.R.attr.colorBackground, });
    int backgroundColor = array.getColor(0, 0xFF00FF);
    array.recycle();

    mSheetLayout.setFab(floatingBtn);
    mSheetLayout.setFabAnimationEndListener(this);
    mSheetLayout.setColor(backgroundColor);

    setupDrawer();
    setupSearchView();

    /* Fetch user info while we're doing other things. This has to be after setting up the
     * drawer, though, because its callback touches the header in the drawer. */
    fetchUserInfo();

    // Setup the tabs and timeline pager.
    TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager());

    int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
    viewPager.setPageMargin(pageMargin);
    Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable,
            R.drawable.tab_page_margin_dark);
    viewPager.setPageMarginDrawable(pageMarginDrawable);
    viewPager.setAdapter(adapter);

    int[] tabIcons = { R.drawable.ic_home_24dp, R.drawable.ic_notifications_24dp, R.drawable.ic_local_24dp,
            R.drawable.ic_public_24dp, };
    String[] pageTitles = { getString(R.string.title_home), getString(R.string.title_notifications),
            getString(R.string.title_public_local), getString(R.string.title_public_federated), };

    Intent intent = getIntent();

    bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);

    AHBottomNavigationItem item1 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_timeline_black_36dp, R.color.colorPrimaryDark);
    AHBottomNavigationItem item2 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_notifications_24dp, R.color.colorPrimaryDark);
    AHBottomNavigationItem item3 = new AHBottomNavigationItem(R.string.app_name, R.drawable.ic_face_black_36dp,
            R.color.colorPrimaryDark);
    AHBottomNavigationItem item4 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_language_black_36dp, R.color.colorPrimaryDark);

    bottomNavigation.addItem(item1);
    bottomNavigation.addItem(item2);
    bottomNavigation.addItem(item3);
    bottomNavigation.addItem(item4);

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#FFFFFF"));
        bottomNavigation.setInactiveColor(Color.parseColor("#727272"));
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#000000"));
        bottomNavigation.setInactiveColor(Color.parseColor("#DDDDDD"));
    } else {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#363c4b"));
        bottomNavigation.setInactiveColor(Color.parseColor("#68738f"));
    }

    bottomNavigation.setBehaviorTranslationEnabled(false);

    bottomNavigation.setAccentColor(Color.parseColor("#2b90d9"));

    bottomNavigation.setForceTint(true);

    bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_HIDE);

    bottomNavigation.setColored(false);
    bottomNavigation.setUseElevation(true);

    bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
        @Override
        public boolean onTabSelected(int position, boolean wasSelected) {
            viewPager.setCurrentItem(position);

            if (pageHistory.isEmpty()) {
                pageHistory.push(0);
            }

            if (pageHistory.contains(position)) {
                pageHistory.remove(pageHistory.indexOf(position));
            }

            pageHistory.push(position);
            return true;
        }
    });

    bottomNavigation.setCurrentItem(0);

    int tabSelected = 0;
    if (intent != null) {
        int tabPosition = intent.getIntExtra("tab_position", 0);
        if (tabPosition != 0) {
            if (bottomNavigation.getItem(tabPosition) != null) {
                bottomNavigation.setCurrentItem(tabPosition);
            }
        }
    }

    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            bottomNavigation.setCurrentItem(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    // Setup push notifications
    if (arePushNotificationsEnabled()) {
        enablePushNotifications();
    } else {
        disablePushNotifications();
    }

    composeButton = floatingBtn;

    if (!DonateActivity.isPlus(this)) {
        // Initialize the Mobile Ads SDK.
        MobileAds.initialize(this, "ca-app-pub-8245120186869512~8307608980");

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-8245120186869512/2261075384");

        requestNewInterstitial();

        mInterstitialAd.setAdListener(new AdListener() {
            public void onAdLoaded() {
                mInterstitialAd.show();
            }
        });
    }
}