Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

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

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(),
            AccessToken.getCurrentAccessToken().getToken());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED
            : AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_places_picked", (getSelection() != null) ? 1 : 0);

    logger.logSdkEvent(AnalyticsEvents.EVENT_PLACE_PICKER_USAGE, null, parameters);
}

From source file:org.anhonesteffort.flock.SubscriptionStripeFragment.java

private void handleCancelSubscription() {
    if (asyncTask != null)
        return;//  w ww . j a va  2s .c o m

    asyncTask = new AsyncTask<Void, Void, Bundle>() {

        @Override
        protected void onPreExecute() {
            Log.d(TAG, "handleCancelSubscription()");
            subscriptionActivity.setProgressBarIndeterminateVisibility(true);
            subscriptionActivity.setProgressBarVisibility(true);
        }

        @Override
        protected Bundle doInBackground(Void... params) {
            Bundle result = new Bundle();
            RegistrationApi registrationApi = new RegistrationApi(subscriptionActivity);

            try {

                registrationApi.cancelSubscription(subscriptionActivity.davAccount);

                AccountStore.setLastChargeFailed(subscriptionActivity, false);
                AccountStore.setSubscriptionPlan(subscriptionActivity, SubscriptionPlan.PLAN_NONE);
                AccountStore.setAutoRenew(subscriptionActivity, false);

                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS);

            } catch (RegistrationApiException e) {
                ErrorToaster.handleBundleError(e, result);
            } catch (JsonProcessingException e) {
                ErrorToaster.handleBundleError(e, result);
            } catch (IOException e) {
                ErrorToaster.handleBundleError(e, result);
            }

            return result;
        }

        @Override
        protected void onPostExecute(Bundle result) {
            asyncTask = null;
            subscriptionActivity.setProgressBarIndeterminateVisibility(false);
            subscriptionActivity.setProgressBarVisibility(false);

            if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS) {
                new AccountSyncScheduler(subscriptionActivity).requestSync();
                Toast.makeText(subscriptionActivity, R.string.subscription_canceled, Toast.LENGTH_SHORT).show();
                subscriptionActivity.updateFragmentWithPlanType(SubscriptionPlan.PLAN_TYPE_NONE);
            }

            else {
                ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result);
                handleUpdateUi();
            }
        }
    }.execute();
}

From source file:cw.kop.autobackground.sources.SourceInfoFragment.java

private void showImageFragment(boolean setPath, String viewPath, int position, boolean use) {
    LocalImageFragment localImageFragment = new LocalImageFragment();
    Bundle arguments = new Bundle();
    arguments.putBoolean("set_path", setPath);
    arguments.putString("view_path", viewPath);
    arguments.putInt("position", position);
    arguments.putBoolean("use", use);
    localImageFragment.setArguments(arguments);
    localImageFragment.setTargetFragment(this, -1);

    getFragmentManager().beginTransaction().add(R.id.content_frame, localImageFragment, "image_fragment")
            .addToBackStack(null).commit();
}

From source file:org.elasticdroid.SshConnectorView.java

/**
 * Save state of the activity on destroy/stop.
 * Saves:/*w  w w  .j a v a 2s.co m*/
 * <ul>
 * <li></li>
 * </ul>
 */
@Override
public void onSaveInstanceState(Bundle saveState) {
    // if a dialog is displayed when this happens, dismiss it
    if (alertDialogDisplayed) {
        alertDialogBox.dismiss();
    }
    //save the info as to whether dialog is displayed
    saveState.putBoolean("alertDialogDisplayed", alertDialogDisplayed);
    //save the dialog msg
    saveState.putString("alertDialogMessage", alertDialogMessage);

    //save the list of open ports 
    if (openPorts != null) {
        saveState.putSerializable("openPorts", openPorts);
        saveState.putInt("selectedPortPos",
                ((Spinner) findViewById(R.id.sshConnectorPortSpinner)).getSelectedItemPosition());
    }
    //save if progress dialog is being displayed.
    saveState.putBoolean("progressDialogDisplayed", progressDialogDisplayed);

    //save the username entered if it is not the default user name
    String curUsername = ((EditText) findViewById(R.id.sshConnectorUsernameEditTextView)).getText().toString();
    if (!curUsername.equals(this.getString(R.string.ssh_defaultuser))) {
        saveState.putString("sshUsername", curUsername);
    }

    //save the state of the checkbox that specifies whether pubkey auth should be used or not
    saveState.putBoolean("usePubkeyAuth",
            ((CheckBox) findViewById(R.id.sshConnectorUsePublicKeyAuth)).isChecked());
}

From source file:fr.cph.chicago.core.activity.BusBoundActivity.java

@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.checkBusData(this);
    if (!this.isFinishing()) {
        setContentView(R.layout.activity_bus_bound);
        ButterKnife.bind(this);

        if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) {
            final Bundle extras = getIntent().getExtras();
            busRouteId = extras.getString(bundleBusRouteId);
            busRouteName = extras.getString(bundleBusRouteName);
            bound = extras.getString(bundleBusBound);
            boundTitle = extras.getString(bundleBusBoundTitle);
        }// w w  w.ja v a 2  s  .c  om
        busBoundAdapter = new BusBoundAdapter();
        setListAdapter(busBoundAdapter);
        getListView().setOnItemClickListener((adapterView, view, position, id) -> {
            final BusStop busStop = (BusStop) busBoundAdapter.getItem(position);
            final Intent intent = new Intent(getApplicationContext(), BusActivity.class);

            final Bundle extras = new Bundle();
            extras.putInt(bundleBusStopId, busStop.getId());
            extras.putString(bundleBusStopName, busStop.getName());
            extras.putString(bundleBusRouteId, busRouteId);
            extras.putString(bundleBusRouteName, busRouteName);
            extras.putString(bundleBusBound, bound);
            extras.putString(bundleBusBoundTitle, boundTitle);
            extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude());
            extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude());

            intent.putExtras(extras);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        });

        filter.addTextChangedListener(new TextWatcher() {
            private List<BusStop> busStopsFiltered;

            @Override
            public void beforeTextChanged(final CharSequence s, final int start, final int count,
                    final int after) {
                busStopsFiltered = new ArrayList<>();
            }

            @Override
            public void onTextChanged(final CharSequence s, final int start, final int before,
                    final int count) {
                if (busStops != null) {
                    Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s))
                            .forEach(busStopsFiltered::add);
                }
            }

            @Override
            public void afterTextChanged(final Editable s) {
                busBoundAdapter.update(busStopsFiltered);
                busBoundAdapter.notifyDataSetChanged();
            }
        });

        Util.setWindowsColor(this, toolbar, TrainLine.NA);
        toolbar.setTitle(busRouteId + " - " + boundTitle);

        toolbar.setNavigationIcon(arrowBackWhite);
        toolbar.setOnClickListener(v -> finish());

        ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound)
                .subscribe(onNext -> {
                    busStops = onNext;
                    busBoundAdapter.update(onNext);
                    busBoundAdapter.notifyDataSetChanged();
                }, onError -> {
                    Log.e(TAG, onError.getMessage(), onError);
                    Util.showOopsSomethingWentWrong(getListView());
                });

        Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus,
                BUSES_STOP_URL, 0);

        // Preventing keyboard from moving background when showing up
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }
}

From source file:it.scoppelletti.mobilepower.app.data.DatabaseConnectionManager.java

/**
 * Esegue l&rsquo;eventuale aggiornamento del database.
 *//* w ww .j  av  a 2s .  com*/
public void run() {
    int ver, stepCount;
    Bundle params;
    ProgressDialogFragment dlg;
    FragmentManager fragmentMgr;

    if (myDb != null) {
        throw new IllegalStateException("Database already open.");
    }

    myDb = myActivity.asActivity().openOrCreateDatabase(myDbName, Context.MODE_PRIVATE, null);
    ver = myDb.getVersion();
    if (ver >= myVersion) {
        onPostExecute(0, null, false);
        return;
    }

    stepCount = myVersion - ver;
    fragmentMgr = myActivity.getSupportFragmentManager();
    dlg = ProgressDialogFragment.newInstance(R.string.lbl_databaseUpgrading, stepCount, true);
    dlg.setOnCancelListener(this);
    dlg.show(fragmentMgr, ProgressDialogFragment.TAG);

    myUpgradeTask = new DatabaseUpgradeTask(myDb, myUpgrader, stepCount, this);
    params = new Bundle();
    params.putInt(DatabaseUpgradeTask.PARAM_CURRENTVERSION, ver);
    params.putInt(DatabaseUpgradeTask.PARAM_TARGETVERSION, myVersion);
    myUpgradeTask.execute(params);
}

From source file:com.nearnotes.NoteEdit.java

/**
 * Populates the checkboxes on the side by analyzing the current text from
 * the body of the note./*from ww w.  j a v a  2s .c o m*/
 * 
 * @param currentString
 *            the current body of the note.
 * 
 */
public ArrayList<NoteRow> populateBoxes(String currentString) {

    // Load ArrayList<String> mLines with the current bodytext seperated into seperate lines.
    mLines = Arrays.asList(currentString.split(System.getProperty("line.separator")));

    // row counter to determine what the current line number is for the for loop
    int row = 0;

    // realRow counter to determine what line of text in the actual display we are on
    // used to get the number of characters on each line
    int realRow = 0;
    int activeRow = 0;
    int finishedCount = 0;

    ArrayList<NoteRow> tempRealRow = new ArrayList<NoteRow>();
    for (String line : mLines) {
        NoteRow temp = new NoteRow(0, 1, row); // Create a note row object with rowType of 0 (invisible), lineSize of 1 and the current row number

        if (!line.isEmpty()) {
            activeRow++;
            temp.setType(1); // Set the NoteRow object to 1 (visible)

            // Determine how many lines the note takes up
            int internalCounter = 0;
            try {
                float lineLength = (float) line.length();
                for (int k = 0; (lineLength
                        / (getFloatLineEnd(realRow + k) - getFloatLineEnd(realRow - 1))) > 1; k++) {
                    internalCounter++;
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

            // Detemine if the note is supposed to be checked and set the NoteRow object to 2 (Checked)
            if (line.startsWith("[X]")) {
                finishedCount++;
                int spanstart = 0;
                StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
                Spannable spannable = (Spannable) mBodyText.getText();
                // TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);

                for (int j = 0; j < row; j++) {
                    spanstart += mLines.get(j).length() + 1;
                }

                Object spansToRemove[] = spannable.getSpans(spanstart, spanstart + mLines.get(row).length(),
                        Object.class);
                for (Object span : spansToRemove) {
                    if (span instanceof CharacterStyle)
                        spannable.removeSpan(span);
                }

                spannable.setSpan(STRIKE_THROUGH_SPAN, spanstart, spanstart + mLines.get(row).length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                temp.setType(2);
            }

            temp.setSize(1 + internalCounter); // Set the amount of rows the note takes up
            realRow = realRow + internalCounter; // Determine the real line on the display text we are on
        }

        tempRealRow.add(temp); // NoteRow object has been finalized - add to the ListArray<NoteRow>
        realRow++; // Increase the noteRow and the displayRow for the next line
        row++;
    }

    if (finishedCount == activeRow && finishedCount != 0) {

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        boolean useListPref = sharedPref.getBoolean("pref_key_use_checklist_default", false);
        String stringlistPref = sharedPref.getString("pref_key_checklist_listPref", "2");
        int listPref = Integer.parseInt(stringlistPref);

        ChecklistDialog newFragment = new ChecklistDialog();
        if (mRowId == null) {
            saveState();
        }
        Bundle args = new Bundle();
        args.putLong("_id", mRowId);
        args.putBoolean("useDefault", useListPref);
        args.putInt("listPref", listPref);
        newFragment.setArguments(args);
        if (listPref == 2 && useListPref) {
            return tempRealRow;
        }
        if (getFragmentManager().findFragmentByTag("MyDialog") == null) {
            newFragment.show(getFragmentManager(), "MyDialog");
        }

    }

    return tempRealRow;
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Show current waypoint on map//from   ww w .ja  va 2  s  .  c o m
 * 
 * @param waypointId
 *            Id of the requested waypoint
 */
protected void showOnMap(long waypointId) {

    com.balakrish.gpstracker.db.Waypoint wp = Waypoints.get(app.getDatabase(), waypointId);

    Intent i = new Intent(this, MyMapActivity.class);

    // using Bundle to pass track id into new activity
    Bundle b = new Bundle();

    b.putInt("mode", Constants.SHOW_WAYPOINT);
    b.putInt("latE6", wp.getLatE6());
    b.putInt("lngE6", wp.getLngE6());

    i.putExtras(b);
    startActivity(i);

}

From source file:com.facebook.GraphRequest.java

/**
 * Creates a new Request that is configured to perform a search for places near a specified
 * location via the Graph API. At least one of location or searchText must be specified.
 *
 * @param accessToken    the access token to use, or null
 * @param location       the location around which to search; only the latitude and longitude
 *                       components of the location are meaningful
 * @param radiusInMeters the radius around the location to search, specified in meters; this is
 *                       ignored if no location is specified
 * @param resultsLimit   the maximum number of results to return
 * @param searchText     optional text to search for as part of the name or type of an object
 * @param callback       a callback that will be called when the request is completed to handle
 *                       success or error conditions
 * @return a Request that is ready to execute
 * @throws FacebookException If neither location nor searchText is specified
 *///from   w  w  w  .j a  v a2 s  .  c om
public static GraphRequest newPlacesSearchRequest(AccessToken accessToken, Location location,
        int radiusInMeters, int resultsLimit, String searchText, final GraphJSONArrayCallback callback) {
    if (location == null && Utility.isNullOrEmpty(searchText)) {
        throw new FacebookException("Either location or searchText must be specified.");
    }

    Bundle parameters = new Bundle(5);
    parameters.putString("type", "place");
    parameters.putInt("limit", resultsLimit);
    if (location != null) {
        parameters.putString("center",
                String.format(Locale.US, "%f,%f", location.getLatitude(), location.getLongitude()));
        parameters.putInt("distance", radiusInMeters);
    }
    if (!Utility.isNullOrEmpty(searchText)) {
        parameters.putString("q", searchText);
    }

    Callback wrapper = new Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            if (callback != null) {
                JSONObject result = response.getJSONObject();
                JSONArray data = result != null ? result.optJSONArray("data") : null;
                callback.onCompleted(data, response);
            }
        }
    };

    return new GraphRequest(accessToken, SEARCH, parameters, HttpMethod.GET, wrapper);
}

From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java

public boolean onContextItemSelected(MenuItem item) {
    if (item.getMenuInfo() != null) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        selectedPosition = info.position;
    }// ww  w  . j  a  v  a  2 s.  c o  m
    Cursor c = mAdapter.getCursor();
    c.moveToPosition(selectedPosition);
    Channel chan = cursorToChannel(c);
    Timer timer;
    switch (item.getItemId()) {
    case R.id.menuTimer:
        timer = cursorToTimer(c);
        if (UIUtils.isTablet(getActivity())) {
            TimerDetails timerdetails = TimerDetails.newInstance();
            Bundle args = new Bundle();
            args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle());
            args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
            args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
            args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime());
            args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime());
            timerdetails.setArguments(args);
            timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName());
        } else {
            Intent timerIntent = new Intent(getActivity(), TimerDetailsActivity.class);
            timerIntent.putExtra(TimerDetails.EXTRA_TITLE, timer.getTitle());
            timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
            timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
            timerIntent.putExtra(TimerDetails.EXTRA_START, timer.getStart().getTime());
            timerIntent.putExtra(TimerDetails.EXTRA_END, timer.getEnd().getTime());
            startActivity(timerIntent);
        }
        return true;
    case R.id.menuStream:
        if (UIUtils.isTablet(getActivity())) {
            StreamConfig cfg = StreamConfig.newInstance();
            Bundle arguments = new Bundle();
            arguments.putInt(StreamConfig.EXTRA_FILE_ID, chan.getPosition());
            arguments.putInt(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE);
            arguments.putInt(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig);
            cfg.setArguments(arguments);
            cfg.show(getSherlockActivity().getSupportFragmentManager(), StreamConfig.class.getName());
        } else {
            Intent streamConfig = new Intent(getActivity(), StreamConfigActivity.class);
            streamConfig.putExtra(StreamConfig.EXTRA_FILE_ID, chan.getPosition());
            streamConfig.putExtra(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE);
            streamConfig.putExtra(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig);
            startActivity(streamConfig);
        }
        return true;
    case R.id.menuSwitch:
        String switchRequest = ServerConsts.URL_SWITCH_COMMAND + chan.getPosition();
        DVBViewerCommand command = new DVBViewerCommand(switchRequest);
        Thread exexuterTHread = new Thread(command);
        exexuterTHread.start();
        return true;
    case R.id.menuRecord:
        timer = cursorToTimer(c);
        String url = timer.getId() <= 0l ? ServerConsts.URL_TIMER_CREATE : ServerConsts.URL_TIMER_EDIT;
        String title = timer.getTitle();
        String days = String.valueOf(DateUtils.getDaysSinceDelphiNull(timer.getStart()));
        String start = String.valueOf(DateUtils.getMinutesOfDay(timer.getStart()));
        String stop = String.valueOf(DateUtils.getMinutesOfDay(timer.getEnd()));
        String endAction = String.valueOf(timer.getTimerAction());
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("ch", String.valueOf(timer.getChannelId())));
        params.add(new BasicNameValuePair("dor", days));
        params.add(new BasicNameValuePair("encoding", "255"));
        params.add(new BasicNameValuePair("enable", "1"));
        params.add(new BasicNameValuePair("start", start));
        params.add(new BasicNameValuePair("stop", stop));
        params.add(new BasicNameValuePair("title", title));
        params.add(new BasicNameValuePair("endact", endAction));
        if (timer.getId() > 0) {
            params.add(new BasicNameValuePair("id", String.valueOf(timer.getId())));
        }

        String query = URLEncodedUtils.format(params, "utf-8");
        String request = url + query;
        RecordingServiceGet rsGet = new RecordingServiceGet(request);
        Thread executionThread = new Thread(rsGet);
        executionThread.start();
        return true;

    default:
        break;
    }
    return false;
}