Example usage for android.os Bundle putStringArray

List of usage examples for android.os Bundle putStringArray

Introduction

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

Prototype

public void putStringArray(@Nullable String key, @Nullable String[] value) 

Source Link

Document

Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java

private void persistActionModeState(Bundle outState) {
    if (outState != null && mActionModeStarted && mSelectedItemData != null) {
        outState.putStringArray(STATE_ACTION_MODE,
                new String[] { mSelectedItemData.get(BlocksQuery.STARRED_SESSION_ID),
                        mSelectedItemData.get(BlocksQuery.STARRED_SESSION_TITLE),
                        mSelectedItemData.get(BlocksQuery.STARRED_SESSION_HASHTAGS),
                        mSelectedItemData.get(BlocksQuery.STARRED_SESSION_URL),
                        mSelectedItemData.get(BlocksQuery.STARRED_SESSION_ROOM_ID), });
    }//from   ww  w.  j ava 2 s  . c  o  m
}

From source file:net.reichholf.dreamdroid.fragment.MovieListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable("movie", mMovie);

    String[] selectedTags;//from  w  ww . j  a  va 2 s. c  om
    if (mSelectedTags != null) {
        selectedTags = new String[mSelectedTags.size()];
        mSelectedTags.toArray(selectedTags);
    } else {
        selectedTags = new String[0];
    }
    outState.putStringArray("selectedTags", selectedTags);

    String[] oldTags;
    if (mOldTags != null) {
        oldTags = new String[mOldTags.size()];
        mOldTags.toArray(oldTags);
    } else {
        oldTags = new String[0];
    }
    outState.putStringArray("oldTags", oldTags);
    outState.putString("currentLocation", mCurrentLocation);
    outState.putInt("selectedLocationPosition", mSelectedLocationPosition);

    super.onSaveInstanceState(outState);
}

From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putCharSequence(SAVE_STATE_TITLE, mDialogTitle);
    outState.putCharSequence(SAVE_STATE_MESSAGE, mDialogMessage);
    outState.putBoolean(SAVE_STATE_IS_MULTI, mMulti);
    outState.putCharSequenceArray(SAVE_STATE_ENTRIES, mEntries);
    outState.putCharSequenceArray(SAVE_STATE_ENTRY_VALUES, mEntryValues);
    if (mMulti) {
        outState.putStringArray(SAVE_STATE_INITIAL_SELECTIONS,
                mInitialSelections.toArray(new String[mInitialSelections.size()]));
    } else {/*from w ww  .  j  a v  a2 s. c o  m*/
        outState.putString(SAVE_STATE_INITIAL_SELECTION, mInitialSelection);
    }
}

From source file:com.fbbackup.MyFriendFragmentActivity.java

@SuppressLint("NewApi")
public void setLisetner() {

    // Tag//from  www.  j  a  v a2  s.  c  o  m
    btn_tag_me.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Fragment newFragment = new TagMeImageGridFragment();

            Bundle args = new Bundle();
            args.putString("token", token);
            args.putStringArray("tagMePicture", tagMePicture);
            args.putString("userName", friendsName[0]);

            newFragment.setArguments(args);

            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.rl_user_photo, newFragment, "first");
            ft.addToBackStack(null);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

            ft.commit();

            controlPanelHandler.sendEmptyMessage(HIDE_CONTROL_PANEL);
        }

    });

    btn_cancel_download.setOnClickListener(new ImageButton.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            downloadTask.cancel(true);
            downloadTaskNoUI.cancel(true);
            rl_prb_download.setVisibility(View.GONE);
            hasCancel = true;
        }

    });

    // Photo
    btn_photo.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Fragment newFragment = new MyFriendFragment();

            Bundle args = new Bundle();
            args.putStringArray("friendPic", friendsPicture);
            args.putStringArray("friendName", friendsName);
            args.putStringArray("friendID", friendsID);
            args.putString("token", token);

            newFragment.setArguments(args);

            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.rl_user_photo, newFragment, "first");

            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

            ft.commit();

        }
    });

    btn_logout.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads()
                        .detectDiskWrites().detectNetwork() // or
                        // .detectAll()
                        // for
                        // all
                        // detectable
                        // problems
                        .penaltyLog().build());
                StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects()
                        .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());

            }

            try {
                facebook.logout(MyFriendFragmentActivity.this);

                Toast.makeText(MyFriendFragmentActivity.this, "FB logout", Toast.LENGTH_LONG).show();

            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            SharedPreferences mPrefs = getSharedPreferences(MainActivity.FIRST_LOGIN_PREFERENCE, MODE_PRIVATE);

            Log.w("Ryan", "S:" + mPrefs.getBoolean(MainActivity.FIRST_LOGIN, true));

            SharedPreferences.Editor editor = mPrefs.edit();
            editor.putBoolean(MainActivity.FIRST_LOGIN, true);
            editor.commit();

            Log.w("Ryan", "F:" + mPrefs.getBoolean(MainActivity.FIRST_LOGIN, true));

            Intent it = new Intent();
            it.setClass(MyFriendFragmentActivity.this, MainActivity.class);
            startActivity(it);
            finish();

        }

    });
}

From source file:edu.cnu.PowerTutor.ui.PowerViewer.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean("collecting", collecting);
    outState.putStringArray("componentNames", componentNames);
    outState.putInt("noUidMask", noUidMask);
}

From source file:it.angrydroids.epub3reader.EpubReaderMain.java

public void chooseLanguage(BookEnum which) {

    String[] languages;/*www . ja  v  a2 s .  co m*/
    if (which == BookEnum.first) {
        languages = navigator.getLanguagesBook1();
    } else {
        languages = navigator.getLanguagesBook2();
    }
    if (languages.length > 0) {
        Bundle bundle = new Bundle();
        bundle.putString(getString(R.string.tome), which.toString());
        bundle.putStringArray(getString(R.string.lang), languages);

        LanguageChooser langChooser = new LanguageChooser();
        langChooser.setArguments(bundle);
        langChooser.show(getFragmentManager(), "");
    } else {
        errorMessage(getString(R.string.error_noOtherLanguages));
    }
}

From source file:com.group7.dragonwars.MapSelectActivity.java

@Override
public final void onItemClick(final AdapterView<?> parent, final View v, final int position, final long id) {
    if (position < mapInfo.size()) {
        Intent intent = new Intent(this, PlayerSelectActivity.class);
        Bundle b = new Bundle();
        b.putString("mapFileName", mapInfo.get(position).getPath());
        b.putString("mapName", mapInfo.get(position).getName());

        int numPlayers = mapInfo.get(position).getPlayers();
        b.putBooleanArray("isAi", new boolean[numPlayers]);
        // boolean defaults to false, what could possibly go wrong?
        b.putInt("numPlayers", numPlayers);

        /* Make a fake player list for now, again */
        String[] playerNames = new String[numPlayers];

        for (Integer i = 0; i < numPlayers; ++i) {
            playerNames[i] = ("Player " + (i + 1));
        }// w  w  w.j ava  2s  . co m

        b.putStringArray("playerNames", playerNames);

        intent.putExtras(b);
        startActivity(intent);
    }
}

From source file:org.opendatakit.survey.android.fragments.InstanceUploaderListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    String[] selectedArray = new String[mSelected.size()];
    for (int i = 0; i < mSelected.size(); i++)
        selectedArray[i] = mSelected.get(i);
    outState.putStringArray(BUNDLE_SELECTED_ITEMS_KEY, selectedArray);
    outState.putBoolean(BUNDLE_TOGGLED_KEY, mToggled);
    outState.putString(DIALOG_TITLE, mAlertTitle);
    outState.putString(DIALOG_MSG, mAlertMsg);
    outState.putString(DIALOG_STATE, mDialogState.name());
    outState.putBoolean(SHOW_UNSENT, mShowUnsent);
    if (mUrl != null) {
        outState.putString(URL, mUrl.toString());
    }//from  w w  w. j av a2  s . c  o m
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) {
    holder.stationNameTextView.setText(busRoute.getId());
    holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp);

    final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>();

    final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData
            .getBusArrivalsMapped(busRoute.getId());
    for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) {
        // Build data for button outside of the loop
        final String stopName = entry.getKey();
        final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName);
        final Map<String, List<BusArrival>> value = entry.getValue();
        for (final String key2 : value.keySet()) {
            final BusArrival busArrival = value.get(key2).get(0);
            final String boundTitle = busArrival.getRouteDirection();
            final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum
                    .fromString(boundTitle);
            final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId())
                    .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle)
                    .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName())
                    .stopName(stopName).build();
            busDetailsDTOs.add(busDetails);
        }/*from   w  w  w. jav a 2  s  . c  o  m*/

        boolean newLine = true;
        int i = 0;

        for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) {
            final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParams);

            // Left
            final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParams);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context,
                    TrainLine.NA);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase();
            final String leftString = stopNameTrimmed + " " + bound;
            final SpannableString destinationSpannable = new SpannableString(leftString);
            destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(),
                    leftString.length(), 0); // set size
            destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color

            final TextView boundCustomTextView = new TextView(context);
            boundCustomTextView.setText(destinationSpannable);
            boundCustomTextView.setSingleLine(true);
            boundCustomTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(boundCustomTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final List<BusArrival> buses = entry2.getValue();
            final StringBuilder currentEtas = new StringBuilder();
            for (final BusArrival arri : buses) {
                currentEtas.append(" ").append(arri.getTimeLeftDueDelay());
            }
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    }

    holder.mapButton.setText(activity.getString(R.string.favorites_view_buses));
    holder.detailsButton
            .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound)
                    .collect(Collectors.toSet());
            final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class);
            final Bundle extras = new Bundle();
            extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId());
            extras.putStringArray(activity.getString(R.string.bundle_bus_bounds),
                    bounds.toArray(new String[bounds.size()]));
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });
}

From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java

private void showChartInternal() {
    // take a adapter and cursor
    IncomeVsExpensesAdapter adapter = ((IncomeVsExpensesAdapter) getListAdapter());
    if (adapter == null)
        return;/*from www  .j  a va 2 s  .  com*/
    Cursor cursor = adapter.getCursor();
    if (cursor == null)
        return;
    // Move to the first record.
    if (cursor.getCount() <= 0)
        return;

    // arrays
    ArrayList<Double> incomes = new ArrayList<>();
    ArrayList<Double> expenses = new ArrayList<>();
    ArrayList<String> titles = new ArrayList<>();

    // Reset cursor to initial position.
    cursor.moveToPosition(-1);
    // cycle cursor
    while (cursor.moveToNext()) {
        int month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month));
        // check if not subtotal
        if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) {
            // incomes and expenses
            incomes.add(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income)));
            expenses.add(
                    Math.abs(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses))));
            // titles
            int year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR));

            // format month
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, month - 1, 1);
            // titles
            titles.add(Integer.toString(year) + "-" + new SimpleDateFormat("MMM").format(calendar.getTime()));
        }
    }
    //compose bundle for arguments
    Bundle args = new Bundle();
    args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_EXPENSES_VALUES,
            ArrayUtils.toPrimitive(expenses.toArray(new Double[0])));
    args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_INCOME_VALUES,
            ArrayUtils.toPrimitive(incomes.toArray(new Double[0])));
    args.putStringArray(IncomeVsExpensesChartFragment.KEY_XTITLES, titles.toArray(new String[titles.size()]));
    //get fragment manager
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    if (fragmentManager != null) {
        IncomeVsExpensesChartFragment fragment;
        fragment = (IncomeVsExpensesChartFragment) fragmentManager
                .findFragmentByTag(IncomeVsExpensesChartFragment.class.getSimpleName());
        if (fragment == null) {
            fragment = new IncomeVsExpensesChartFragment();
        }
        fragment.setChartArguments(args);
        fragment.setDisplayHomeAsUpEnabled(true);

        if (fragment.isVisible())
            fragment.onResume();

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (((IncomeVsExpensesActivity) getActivity()).mIsDualPanel) {
            fragmentTransaction.replace(R.id.fragmentChart, fragment,
                    IncomeVsExpensesChartFragment.class.getSimpleName());
        } else {
            fragmentTransaction.replace(R.id.fragmentMain, fragment,
                    IncomeVsExpensesChartFragment.class.getSimpleName());
            fragmentTransaction.addToBackStack(null);
        }
        fragmentTransaction.commit();
    }
}