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:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i("OpenHABWidgetListActivity", "onCreate");
    // TODO: Make progress indicator active every time we load the page
    //      requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    //      requestWindowFeature(Window.FEATURE_PROGRESS);      
    super.onCreate(savedInstanceState);
    setContentView(R.layout.roomsettings);
    res = this.getApplicationContext().getResources();

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    openHABUsername = settings.getString("default_openhab_username", "");
    openHABPassword = settings.getString("default_openhab_password", "");
    openHABWidgetDataSource = new OpenHABWidgetDataSource();
    openHABWidgetAdapter = new OpenHABWidgetSettingsAdapter(OpenHABRoomSettingActivity.this,
            R.layout.openhabwidgetlist_genericitem, widgetList, this);
    getListView().setAdapter(openHABWidgetAdapter);
    openHABWidgetAdapter.setOpenHABUsername(openHABUsername);
    openHABWidgetAdapter.setOpenHABPassword(openHABPassword);
    //      this.getActionBar().setDisplayHomeAsUpEnabled(true);
    //      this.getActionBar().setHomeButtonEnabled(true);
    // Check if we have openHAB page url in saved instance state?
    if (savedInstanceState != null) {
        pageStack = savedInstanceState.getParcelableArrayList("pageStack");
        displayPageUrl = savedInstanceState.getString("displayPageUrl");
        openHABBaseUrl = savedInstanceState.getString("openHABBaseUrl");
        sitemapRootUrl = savedInstanceState.getString("sitemapRootUrl");
        openHABWidgetAdapter.setOpenHABBaseUrl(openHABBaseUrl);
    }/*from  w ww. ja v  a2s . co  m*/
    // If yes, then just show it
    if (displayPageUrl.length() > 0) {
        Log.i(TAG, "displayPageUrl = " + displayPageUrl);
        showPage(displayPageUrl, false);
        // Else check if we got openHAB base url through launch intent?
    } else {
        openHABBaseUrl = getIntent().getExtras().getString("baseURL");
        if (openHABBaseUrl != null) {
            openHABWidgetAdapter.setOpenHABBaseUrl(openHABBaseUrl);
            selectSitemap(openHABBaseUrl, false);
        } else {
            Log.i(TAG, "No base URL!");
        }
    }

    initUI();

}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

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

    /* Set up ActionBar */
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_the_hub);
    setSupportActionBar(toolbar);//  ww  w .  j  ava 2s.c  o  m

    /* Set up Navigation Drawer */
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.hub_drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);

    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    generateDrawerGreeting(navigationView);

    /* Set up recycler and Card View */
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        rvContent = savedInstanceState.getParcelableArrayList(AppConstants.RESTORED_USER_FLOWS);
        manager = savedInstanceState.getParcelable(AppConstants.RESTORED_DATA_MANAGER);
    } else {
        rvContent = new ArrayList<>();
        manager = new AppDataManager(this);
    }

    menuState = AppConstants.MENU_ITEMS_NATIVE;

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Drive.API).addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
}

From source file:mn.today.TheHubActivity.java

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

    /* Set up ActionBar */
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_the_hub);
    setSupportActionBar(toolbar);/*from w w  w . j av  a2  s  .  c om*/

    /* Set up Navigation Drawer */
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.hub_drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);

    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    generateDrawerGreeting(navigationView);

    /* Set up recycler and Card View */
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        rvContent = savedInstanceState.getParcelableArrayList(AppConstants.RESTORED_USER_FLOWS);
        manager = savedInstanceState.getParcelable(AppConstants.RESTORED_DATA_MANAGER);
    } else {
        rvContent = new ArrayList<>();
        manager = new AppDataManager(this);
    }

    menuState = AppConstants.MENU_ITEMS_NATIVE;

    // ATTENTION: This "addApi(AppIndex.API)"was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    //        mGoogleApiClient = new GoogleApiClient.Builder(this)
    //                .addApi(Drive.API)
    //                .addScope(Drive.SCOPE_FILE)
    //                .addConnectionCallbacks(this)
    //                .addOnConnectionFailedListener(this)
    //                .addApi(AppIndex.API).build();
}

From source file:com.filemanager.free.fragments.Main.java

void retrieveFromSavedInstance(final Bundle savedInstanceState) {

    Bundle b = new Bundle();
    String cur = savedInstanceState.getString("CURRENT_PATH");
    if (cur != null) {
        b.putInt("index", savedInstanceState.getInt("index"));
        b.putInt("top", savedInstanceState.getInt("top"));
        scrolls.put(cur, b);/*from ww w.j av a 2 s. c  o  m*/

        openMode = savedInstanceState.getInt("openMode", 0);
        if (openMode == 1)
            smbPath = savedInstanceState.getString("SmbPath");
        LIST_ELEMENTS = savedInstanceState.getParcelableArrayList("list");
        CURRENT_PATH = cur;
        folder_count = savedInstanceState.getInt("folder_count", 0);
        file_count = savedInstanceState.getInt("file_count", 0);
        results = savedInstanceState.getBoolean("results");

        MAIN_ACTIVITY.updatePath(CURRENT_PATH, results, openMode, folder_count, file_count);
        createViews(LIST_ELEMENTS, true, (CURRENT_PATH), openMode, results, !IS_LIST);
        if (savedInstanceState.getBoolean("selection")) {

            for (int i : savedInstanceState.getIntegerArrayList("position")) {
                adapter.toggleChecked(i);
            }
        }
    }
}

From source file:com.igniva.filemanager.fragments.Main.java

void retrieveFromSavedInstance(final Bundle savedInstanceState) {

    Bundle b = new Bundle();
    String cur = savedInstanceState.getString("CURRENT_PATH");
    if (cur != null) {
        b.putInt("index", savedInstanceState.getInt("index"));
        b.putInt("top", savedInstanceState.getInt("top"));
        scrolls.put(cur, b);//from   w  ww .  j a  v  a 2s.c  o m

        openMode = savedInstanceState.getInt("openMode", 0);
        if (openMode == 1)
            smbPath = savedInstanceState.getString("SmbPath");
        LIST_ELEMENTS = savedInstanceState.getParcelableArrayList("list");
        CURRENT_PATH = cur;
        folder_count = savedInstanceState.getInt("folder_count", 0);
        file_count = savedInstanceState.getInt("file_count", 0);
        results = savedInstanceState.getBoolean("results");
        MAIN_ACTIVITY.updatePath(CURRENT_PATH, results, openMode, folder_count, file_count);
        createViews(LIST_ELEMENTS, true, (CURRENT_PATH), openMode, results, !IS_LIST);
        if (savedInstanceState.getBoolean("selection")) {

            for (int i : savedInstanceState.getIntegerArrayList("position")) {
                adapter.toggleChecked(i, null);
            }
        }
    }
}

From source file:com.fbartnitzek.tasteemall.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(LOG_TAG, "onCreate, hashCode=" + this.hashCode() + ", " + "savedInstanceState = ["
            + savedInstanceState + "]");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  ww  w.j a  v a  2s.  co m*/
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(false);
        supportActionBar.setHomeButtonEnabled(false);
        supportActionBar.setDisplayShowTitleEnabled(false);
    }

    Log.v(LOG_TAG, "onCreate, hashCode=" + this.hashCode() + ", " + "savedInstanceState = ["
            + savedInstanceState + "]");

    //        mSearchPattern = null;
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(STATE_SEARCH_PATTERN)) {
            mSearchPattern = savedInstanceState.getString(STATE_SEARCH_PATTERN);
            mReloaded = true;
        }
        if (savedInstanceState.containsKey(STATE_PRODUCERS_TO_GEOCODE)) {
            mProducerLocationUris = savedInstanceState.getParcelableArrayList(STATE_PRODUCERS_TO_GEOCODE);
        }
        if (savedInstanceState.containsKey(STATE_REVIEW_LOCATIONS_TO_GEOCODE)) {
            mReviewLocationUris = savedInstanceState.getParcelableArrayList(STATE_REVIEW_LOCATIONS_TO_GEOCODE);
        }
        if (savedInstanceState.containsKey(STATE_PAGER_POSITION)) {
            mPagerPosition = savedInstanceState.getInt(STATE_PAGER_POSITION);
        }
    }

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setPageTransformer(true, new ZoomOutPageTransformer());

    mViewPager.setCurrentItem(mPagerPosition < 0 ? 0 : mPagerPosition);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            //                Log.v(LOG_TAG, "onPageSelected, hashCode=" + this.hashCode() + ", " + "position = [" + position + "]");
            mPagerPosition = position;
            getFragment(position).fragmentBecameVisible();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    createSpinner();

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_add);
    fab.setOnClickListener(this);

}

From source file:org.odk.collect.android.activities.GoogleDriveActivity.java

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

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setProgressBarVisibility(true);//w  w  w  .j a v  a2 s  .com
    setContentView(R.layout.drive_layout);
    listView = (ListView) findViewById(android.R.id.list);
    listView.setOnItemClickListener(this);
    emptyView = (TextView) findViewById(android.R.id.empty);

    initToolbar();

    parentId = null;
    alertShowing = false;
    toDownload = new ArrayList<>();

    if (savedInstanceState != null && savedInstanceState.containsKey(MY_DRIVE_KEY)) {
        // recover state on rotate
        myDrive = savedInstanceState.getBoolean(MY_DRIVE_KEY);
        String[] patharray = savedInstanceState.getStringArray(PATH_KEY);
        currentPath = buildPath(patharray);

        parentId = savedInstanceState.getString(PARENT_KEY);
        alertMsg = savedInstanceState.getString(ALERT_MSG_KEY);
        alertShowing = savedInstanceState.getBoolean(ALERT_SHOWING_KEY);

        ArrayList<DriveListItem> dl = savedInstanceState.getParcelableArrayList(DRIVE_ITEMS_KEY);
        adapter = new FileArrayAdapter(GoogleDriveActivity.this, R.layout.two_item_image, dl);
        listView.setAdapter(adapter);
        adapter.setEnabled(true);
    } else {
        // new
        myDrive = false;

        if (!isDeviceOnline()) {
            createAlertDialog(getString(R.string.no_connection));
        }
    }

    // restore any task state
    if (getLastCustomNonConfigurationInstance() instanceof RetrieveDriveFileContentsAsyncTask) {
        retrieveDriveFileContentsAsyncTask = (RetrieveDriveFileContentsAsyncTask) getLastNonConfigurationInstance();
        setProgressBarIndeterminateVisibility(true);
    } else {
        getFileTask = (GetFileTask) getLastNonConfigurationInstance();
        if (getFileTask != null) {
            getFileTask.setGoogleDriveFormDownloadListener(this);
        }
    }
    if (getFileTask != null && getFileTask.getStatus() == AsyncTask.Status.FINISHED) {
        try {
            dismissDialog(PROGRESS_DIALOG);
        } catch (Exception e) {
            Timber.i("Exception was thrown while dismissing a dialog.");
        }
    }
    if (alertShowing) {
        try {
            dismissDialog(PROGRESS_DIALOG);
        } catch (Exception e) {
            // don't care...
            Timber.i("Exception was thrown while dismissing a dialog.");
        }
        createAlertDialog(alertMsg);
    }

    rootButton = (Button) findViewById(R.id.root_button);
    if (myDrive) {
        rootButton.setText(getString(R.string.go_shared));
    } else {
        rootButton.setText(getString(R.string.go_drive));
    }
    rootButton.setOnClickListener(this);

    backButton = (Button) findViewById(R.id.back_button);
    backButton.setEnabled(parentId != null);
    backButton.setOnClickListener(this);

    downloadButton = (Button) findViewById(R.id.download_button);
    downloadButton.setOnClickListener(this);

    searchText = (EditText) findViewById(R.id.search_text);
    searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                executeSearch();
                return true;
            }
            return false;
        }
    });
    searchButton = (ImageButton) findViewById(R.id.search_button);
    searchButton.setOnClickListener(this);

    // Initialize credentials and service object.
    credential = GoogleAccountCredential
            .usingOAuth2(getApplicationContext(), Collections.singletonList(DriveScopes.DRIVE))
            .setBackOff(new ExponentialBackOff());

    HttpTransport transport = AndroidHttp.newCompatibleTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    driveService = new com.google.api.services.drive.Drive.Builder(transport, jsonFactory, credential)
            .setApplicationName("ODK-Collect").build();

    getResultsFromApi();
}

From source file:com.yekertech.tvbarsetting.dialog.DialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.v("DialogFragment", "onCreate");
    super.onCreate(savedInstanceState);
    Bundle state = (savedInstanceState != null) ? savedInstanceState : getArguments();
    if (mTitle == null) {
        mTitle = state.getString(EXTRA_CONTENT_TITLE);
    }/*from   ww  w. j a  va2s.c  om*/
    if (mBreadcrumb == null) {
        mBreadcrumb = state.getString(EXTRA_CONTENT_BREADCRUMB);
    }
    if (mDescription == null) {
        mDescription = state.getString(EXTRA_CONTENT_DESCRIPTION);
    }
    if (mIconResourceId == 0) {
        mIconResourceId = state.getInt(EXTRA_CONTENT_ICON_RESOURCE_ID, 0);
    }
    if (mIconUri == null) {
        mIconUri = state.getParcelable(EXTRA_CONTENT_ICON_URI);
    }
    if (mIconBitmap == null) {
        mIconBitmap = state.getParcelable(EXTRA_CONTENT_ICON_BITMAP);
    }
    if (mIconBackgroundColor == Color.TRANSPARENT) {
        mIconBackgroundColor = state.getInt(EXTRA_CONTENT_ICON_BACKGROUND, Color.TRANSPARENT);
    }
    if (mActions == null) {
        mActions = state.getParcelableArrayList(EXTRA_ACTION_ACTIONS);
    }
    if (mName == null) {
        mName = state.getString(EXTRA_ACTION_NAME);
    }
    if (mSelectedIndex == -1) {
        mSelectedIndex = state.getInt(EXTRA_ACTION_SELECTED_INDEX, -1);
    }
    mEntryTransitionPerformed = state.getBoolean(EXTRA_ENTRY_TRANSITION_PERFORMED, false);
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    android.util.Log.v("DialogFragment", "onCreate");
    super.onCreate(savedInstanceState);
    Bundle state = (savedInstanceState != null) ? savedInstanceState : getArguments();
    if (mTitle == null) {
        mTitle = state.getString(EXTRA_CONTENT_TITLE);
    }/*from ww  w.  ja va2  s .  co m*/
    if (mBreadcrumb == null) {
        mBreadcrumb = state.getString(EXTRA_CONTENT_BREADCRUMB);
    }
    if (mDescription == null) {
        mDescription = state.getString(EXTRA_CONTENT_DESCRIPTION);
    }
    if (mIconResourceId == 0) {
        mIconResourceId = state.getInt(EXTRA_CONTENT_ICON_RESOURCE_ID, 0);
    }
    if (mIconUri == null) {
        mIconUri = state.getParcelable(EXTRA_CONTENT_ICON_URI);
    }
    if (mIconBitmap == null) {
        mIconBitmap = state.getParcelable(EXTRA_CONTENT_ICON_BITMAP);
    }
    if (mIconBackgroundColor == Color.TRANSPARENT) {
        mIconBackgroundColor = state.getInt(EXTRA_CONTENT_ICON_BACKGROUND, Color.TRANSPARENT);
    }
    if (mActions == null) {
        mActions = state.getParcelableArrayList(EXTRA_ACTION_ACTIONS);
    }
    if (mName == null) {
        mName = state.getString(EXTRA_ACTION_NAME);
    }
    if (mSelectedIndex == -1) {
        mSelectedIndex = state.getInt(EXTRA_ACTION_SELECTED_INDEX, -1);
    }
    mEntryTransitionPerformed = state.getBoolean(EXTRA_ENTRY_TRANSITION_PERFORMED, false);
}

From source file:org.lunci.dumbthing.fragment.MainDisplayFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAdapter = new DumbItemSimpleAdapter(getActivity(), R.layout.dumb_display_item_simple);
    mDetector = new GestureDetectorCompat(getActivity(), new GestureDetector.OnGestureListener() {
        private static final float ThresholdDistance = 50;
        private static final float ThresholdVelocity = 1000;

        @Override//from  w w  w .j  a v  a2s . c  om
        public boolean onDown(MotionEvent e) {
            return false;
        }

        @Override
        public void onShowPress(MotionEvent e) {

        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        @Override
        public void onLongPress(MotionEvent e) {

        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (e1 == null || e2 == null)
                return false;
            final float distanceX = e1.getRawX() - e2.getRawX();
            if (distanceX < -ThresholdDistance && velocityX > ThresholdVelocity) {
                return mViewHolder.showPrevious();
            } else if (distanceX > ThresholdDistance && velocityX < -ThresholdVelocity) {
                return mViewHolder.showNext();
            }
            return true;
        }
    });
    if (savedInstanceState != null) {
        savedInstanceState.setClassLoader(DumbModel.class.getClassLoader());
        final ArrayList<Parcelable> list = savedInstanceState.getParcelableArrayList(EXTRA_ITEMS);
        for (Parcelable p : list) {
            mAdapter.add((DumbModel) p);
        }
    }
}