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.allwinner.theatreplayer.launcher.activity.LaunchActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putInt(Key_Int, mViewPageIndex);

}

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

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

    String[] selectedTags;/*from  ww w .j av  a 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:com.googlecode.android_scripting.facade.AndroidFacade.java

@Rpc(description = "Get list of constants (static final fields) for a class")
public Bundle getConstants(
        @RpcParameter(name = "classname", description = "Class to get constants from") String classname)
        throws Exception {
    Bundle result = new Bundle();
    int flags = Modifier.FINAL | Modifier.PUBLIC | Modifier.STATIC;
    Class<?> clazz = Class.forName(classname);
    for (Field field : clazz.getFields()) {
        if ((field.getModifiers() & flags) == flags) {
            Class<?> type = field.getType();
            String name = field.getName();
            if (type == int.class) {
                result.putInt(name, field.getInt(null));
            } else if (type == long.class) {
                result.putLong(name, field.getLong(null));
            } else if (type == double.class) {
                result.putDouble(name, field.getDouble(null));
            } else if (type == char.class) {
                result.putChar(name, field.getChar(null));
            } else if (type instanceof Object) {
                result.putString(name, field.get(null).toString());
            }/*from w  w w  .j a v a2  s.  c  om*/
        }
    }
    return result;
}

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

/**
 * Show SourceInfoFragment with position -1 to add new source
 *///  w  w  w.  j av a  2  s.  com
private void showSourceAddFragment() {
    final SourceInfoFragment sourceInfoFragment = new SourceInfoFragment();
    Bundle arguments = new Bundle();
    arguments.putInt("position", -1);
    arguments.putString("type", AppSettings.WEBSITE);
    arguments.putString("title", "");
    arguments.putString("data", "");
    arguments.putString("num", "");
    arguments.putBoolean("use", true);
    arguments.putBoolean("preview", true);
    arguments.putBoolean("use_time", false);
    arguments.putString("time", "00:00 - 00:00");
    sourceInfoFragment.setArguments(arguments);

    getFragmentManager().beginTransaction().add(R.id.content_frame, sourceInfoFragment, "source_info_fragment")
            .addToBackStack(null).setTransition(FragmentTransaction.TRANSIT_NONE).commit();

}

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

/**
  * //w  ww .j a  va2  s. c o  m
  */
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle item selection
    switch (item.getItemId()) {

    case R.id.deleteWaypointsMenuItem:

        // clear all waypoints with confirmation dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.are_you_sure).setCancelable(true)
                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {

                        Waypoints.deleteAll(app.getDatabase());

                        updateWaypointsArray();// cursor.requery();

                        waypointsArrayAdapter.setItems(waypoints);
                        waypointsArrayAdapter.notifyDataSetChanged();

                        Toast.makeText(WaypointsListActivity.this, R.string.all_waypoints_deleted,
                                Toast.LENGTH_SHORT).show();

                    }

                }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();

        alert.show();

        return true;

    // import waypoints from external file
    case R.id.importMenuItem:

        // this.importFromTextFile();

        this.importFromXMLFile();

        return true;

    case R.id.exportMenuItem:

        exportWaypoints();

        return true;

    case R.id.showMapMenuItem:

        // startActivity(new Intent(this, WaypointsMapActivity.class));

        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_ALL_WAYPOINTS);

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

        return true;

    default:

        return super.onOptionsItemSelected(item);

    }

}

From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java

public void onClick(DialogInterface di, int whichButton) {
    // get strings from edittext boxes, then insert them into database
    ContentValues values = new ContentValues(DatabaseHelper.CONTENT_VALUE_COUNT);
    ContentValues drugInteractionValues = new ContentValues(4);
    Dialog dlg = (Dialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    TimePicker tp = (TimePicker) dlg.findViewById(R.id.timePicker);
    Spinner mySpinner = (Spinner) dlg.findViewById(R.id.spinner);
    String fre = mySpinner.getSelectedItem().toString();
    EditText dosage = (EditText) dlg.findViewById(R.id.dosage);
    EditText instruction = (EditText) dlg.findViewById(R.id.instruction);
    RadioGroup radioButtonGroup = (RadioGroup) dlg.findViewById(R.id.radioGroup);
    int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
    View radioButton = radioButtonGroup.findViewById(radioButtonID);
    int shape = radioButtonGroup.indexOfChild(radioButton) / 2;
    int Fre;//from  w  w w .j  a v a 2  s.c o m
    //int day = 0;
    int monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0, sunday = 0;

    // clear array list
    drug_interaction_list.clear();
    curr_drug_interaction_list.clear();

    // loop through database
    crsInteractions.moveToPosition(-1);
    while (crsInteractions.moveToNext()) {
        // drug names
        drugName = crsInteractions.getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_NAMES));

        // corresponding interacted drugs/foods
        interactionName = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_INTERACTIONS));

        // interaction result
        interactionResult = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_INTERACTION_RESULT));

        // medication name entered by user
        medNameFieldTxt = textView.getText().toString();

        // check if newly entered medication name matches current drug name
        if (drugName.equals(medNameFieldTxt)) {
            /**if found, check if the corresponding interaction
             * drug in the list of all added drugs by user
             */
            if (db.isNameExitOnDB(interactionName)) {
                // interaction found
                Log.d("myinteraction", "Found Interaction");

                String interaction_result = medNameFieldTxt + "/" + interactionName + "\n";

                // only insert new drug interactions if they have not yet exist
                if (!dbInteraction.isDrugInteractionExist(medNameFieldTxt, interactionName)) {
                    // insert the drug interaction into our new dynamic drug interaction db
                    drugInteractionValues.put(DatabaseInteractionHelper.USR_NAME,
                            ParseUser.getCurrentUser().getUsername());
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_NAME, medNameFieldTxt);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION, interactionName);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION_SHOW,
                            DatabaseInteractionHelper.DRUG_INTERACTION_SHOW_TRUE);

                    dbInteraction.getWritableDatabase().insert(DatabaseInteractionHelper.TABLE,
                            DatabaseInteractionHelper.DRUG_NAME, drugInteractionValues);
                }

                drug_interaction_list.add(interaction_result);
                curr_drug_interaction_list.add(interactionName);
            }
        }
    }

    Log.d("mydatabase3", DatabaseUtils.dumpCursorToString(dbInteraction.getCursor()));

    // display all iteractions in pop window if there is any
    String interaction_results = "\n";
    for (int i = 0; i < curr_drug_interaction_list.size(); i++) {
        String interaction = medNameFieldTxt + " & " + curr_drug_interaction_list.get(i) + "\n\n";
        interaction_results = interaction_results.concat(interaction);
    }

    if (drug_interaction_list.size() != 0) {
        // inflate a dialog to display the drug interactions warning
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View resultView = inflater.inflate(R.layout.drug_interaction_result, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder.setTitle(R.string.drug_interaction_result_title).setView(resultView)
                // go to drug interaction list button
                .setNegativeButton(R.string.drug_interaction_list, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // drug interaction page
                        DrugInteractions drugInterac = new DrugInteractions();
                        FragmentTransaction transaction;
                        transaction = getFragmentManager().beginTransaction();
                        transaction.replace(R.id.fragmentContainer, drugInterac);
                        transaction.addToBackStack(null);
                        // Commit the transaction
                        transaction.commit();
                    }
                })

                // ok button
                .setPositiveButton(R.string.dismiss, null).show();

        TextView interactionResultView = (TextView) resultView.findViewById(R.id.resultView);

        // add warning message into the pop up window
        interaction_results = interaction_results.concat(getString(R.string.interaction_warning));

        // display on pop up window
        interactionResultView.setText(interaction_results);
    }

    // write the list of drug interactions into file
    Helpers.writeToFile(getContext(), drug_interaction_list, "drug_interaction_list");

    Log.d("mydatabase", DatabaseUtils.dumpCursorToString(db.getCursor()));

    if (fre == "Ten Times a Day") {
        Fre = 10;
    } else if (fre == "Twice a Day") {
        Fre = 2;
    } else if (fre == "Three Times a Day") {
        Fre = 3;
    } else if (fre == "Four Times a Day") {
        Fre = 4;
    } else if (fre == "Five Times a Day") {
        Fre = 5;
    } else if (fre == "Six Times a Day") {
        Fre = 6;
    } else if (fre == "Seven Times a Day") {
        Fre = 7;
    } else if (fre == "Eight Times a Day") {
        Fre = 8;
    } else if (fre == "Nine Times a Day") {
        Fre = 9;
    } else {
        Fre = 1;
    }

    if (((CheckBox) dlg.findViewById(R.id.MonCheck)).isChecked()) {
        monday = monday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.TueCheck)).isChecked()) {
        tuesday = tuesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.WedCheck)).isChecked()) {
        wednesday = wednesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.ThuCheck)).isChecked()) {
        thursday = thursday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.FriCheck)).isChecked()) {
        friday = friday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SatCheck)).isChecked()) {
        saturday = saturday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SunCheck)).isChecked()) {
        sunday = sunday + 1;
    }

    // clear focus before retrieving the min and hr
    tp.clearFocus();

    int tpMinute = tp.getCurrentMinute();
    int tpHour = tp.getCurrentHour();
    // an order number to order the list view items
    int orderNum = tpHour * 60 + tpMinute;
    tp.setIs24HourView(true);

    String titleStr = title.getText().toString();
    String timeHStr = Helpers.StringFormatter(tpHour, "00");
    String timeMStr = Helpers.StringFormatter(tpMinute, "00");
    String dosageStr = dosage.getText().toString();
    String instructionStr = instruction.getText().toString();

    Log.d("mytime", Integer.toString(tpHour));
    Log.d("mytime", Integer.toString(tpMinute));

    values.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    values.put(DatabaseHelper.TITLE, titleStr);
    values.put(DatabaseHelper.TIME_H, timeHStr);
    values.put(DatabaseHelper.TIME_M, timeMStr);
    values.put(DatabaseHelper.FREQUENCY, Fre);
    //values.put(DatabaseHelper.DAY, day);

    values.put(DatabaseHelper.MONDAY, monday);
    values.put(DatabaseHelper.TUESDAY, tuesday);
    values.put(DatabaseHelper.WEDNESDAY, wednesday);
    values.put(DatabaseHelper.THURSDAY, thursday);
    values.put(DatabaseHelper.FRIDAY, friday);
    values.put(DatabaseHelper.SATURDAY, saturday);
    values.put(DatabaseHelper.SUNDAY, sunday);

    values.put(DatabaseHelper.DOSAGE, dosageStr);
    values.put(DatabaseHelper.INSTRUCTION, instructionStr);
    values.put(DatabaseHelper.SHAPE, shape);
    values.put(DatabaseHelper.ORDER_NUM, orderNum);

    Bundle bundle = new Bundle();
    // add extras here..
    bundle.putString(DatabaseHelper.TITLE, title.getText().toString());
    bundle.putString(DatabaseHelper.TIME_H, timeHStr);
    bundle.putString(DatabaseHelper.TIME_M, timeMStr);
    bundle.putInt(DatabaseHelper.FREQUENCY, Fre);
    //bundle.putInt(DatabaseHelper.DAY, day);

    bundle.putInt(DatabaseHelper.MONDAY, monday);
    bundle.putInt(DatabaseHelper.TUESDAY, tuesday);
    bundle.putInt(DatabaseHelper.WEDNESDAY, wednesday);
    bundle.putInt(DatabaseHelper.THURSDAY, thursday);
    bundle.putInt(DatabaseHelper.FRIDAY, friday);
    bundle.putInt(DatabaseHelper.SATURDAY, saturday);
    bundle.putInt(DatabaseHelper.SUNDAY, sunday);

    bundle.putString(DatabaseHelper.DOSAGE, dosageStr);
    bundle.putString(DatabaseHelper.INSTRUCTION, instructionStr);
    bundle.putInt(DatabaseHelper.SHAPE, shape);
    bundle.putInt(DatabaseHelper.ORDER_NUM, orderNum);
    //Alarm alarm = new Alarm(getActivity().getApplicationContext(), bundle);

    // get unique notifyId for each alarm
    int length = title.length();
    for (int i = 0; i < length; i++) {
        notifyId = (int) titleStr.charAt(i) + notifyId;
    }
    notifyId = Integer.parseInt(timeHStr + timeMStr);

    // saving it into parse.com
    ParseObject parseObject = new ParseObject(Helpers.PARSE_OBJECT);
    parseObject.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    parseObject.put(DatabaseHelper.TITLE, titleStr);
    parseObject.put(DatabaseHelper.TIME_H, timeHStr);
    parseObject.put(DatabaseHelper.TIME_M, timeMStr);
    parseObject.put(DatabaseHelper.FREQUENCY, Fre);
    //parseObject.put(DatabaseHelper.DAY, day);

    parseObject.put(DatabaseHelper.MONDAY, monday);
    parseObject.put(DatabaseHelper.TUESDAY, tuesday);
    parseObject.put(DatabaseHelper.WEDNESDAY, wednesday);
    parseObject.put(DatabaseHelper.THURSDAY, thursday);
    parseObject.put(DatabaseHelper.FRIDAY, friday);
    parseObject.put(DatabaseHelper.SATURDAY, saturday);
    parseObject.put(DatabaseHelper.SUNDAY, sunday);

    parseObject.put(DatabaseHelper.DOSAGE, dosageStr);
    parseObject.put(DatabaseHelper.INSTRUCTION, instructionStr);
    parseObject.put(DatabaseHelper.SHAPE, shape);
    parseObject.put(DatabaseHelper.NOFITY_ID, notifyId);
    parseObject.put(DatabaseHelper.ORDER_NUM, orderNum);
    parseObject.saveInBackground();

    task = new InsertTask().execute(values);
}

From source file:me.willowcheng.makerthings.ui.OpenHABWidgetListFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    Log.d(TAG, "onSaveInstanceState");
    Log.d(TAG, "isAdded = " + isAdded());
    Log.d(TAG, String.format("onSave current selected item = %d", getListView().getCheckedItemPosition()));
    savedInstanceState.putString("displayPageUrl", displayPageUrl);
    savedInstanceState.putString("openHABBaseUrl", openHABBaseUrl);
    savedInstanceState.putString("sitemapRootUrl", sitemapRootUrl);
    savedInstanceState.putString("openHABUsername", openHABUsername);
    savedInstanceState.putString("openHABPassword", openHABPassword);
    savedInstanceState.putInt("currentSelectedItem", getListView().getCheckedItemPosition());
    savedInstanceState.putInt("position", mPosition);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    // If there's an animation in progress, end it immediately to ensure the state is
    // up-to-date before it is serialized.
    if (mCurrentAnimator != null) {
        mCurrentAnimator.end();//w w w  . j a  v  a 2s . co  m
    }

    super.onSaveInstanceState(outState);

    outState.putInt(KEY_CURRENT_STATE, mCurrentState.ordinal());
    outState.putString(KEY_CURRENT_EXPRESSION, mInputEditText.getText().toString());
}

From source file:com.markupartist.sthlmtraveling.PlannerFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putInt("level", mStackLevel);
    if (mStartPoint != null)
        outState.putParcelable("startPoint", mStartPoint);
    if (mEndPoint != null)
        outState.putParcelable("endPoint", mEndPoint);
    if (mViaPoint != null)
        outState.putParcelable("viaPoint", mViaPoint);

    super.onSaveInstanceState(outState);
}