Example usage for android.os Bundle putShort

List of usage examples for android.os Bundle putShort

Introduction

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

Prototype

@Override
public void putShort(@Nullable String key, short value) 

Source Link

Document

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

Usage

From source file:com.facebook.LegacyTokenCacheTest.java

private static void putShort(String key, Bundle bundle) {
    bundle.putShort(key, (short) random.nextInt());
}

From source file:com.scooter1556.sms.android.utils.MediaUtils.java

public static MediaDescriptionCompat getMediaDescription(@NonNull MediaElement element) {
    String mediaId = getMediaIDFromMediaElement(element);

    if (mediaId == null) {
        return null;
    }/*from w w w .j a  v  a  2  s  . com*/

    Bundle extras = new Bundle();
    if (element.getYear() != null) {
        extras.putShort("Year", element.getYear());
    }
    if (element.getDuration() != null) {
        extras.putDouble("Duration", element.getDuration());
    }
    if (element.getTrackNumber() != null) {
        extras.putShort("TrackNumber", element.getTrackNumber());
    }
    if (element.getDiscNumber() != null) {
        extras.putShort("DiscNumber", element.getDiscNumber());
    }
    if (element.getDiscSubtitle() != null) {
        extras.putString("DiscSubtitle", element.getDiscSubtitle());
    }
    if (element.getGenre() != null) {
        extras.putString("Genre", element.getGenre());
    }
    if (element.getRating() != null) {
        extras.putFloat("Rating", element.getRating());
    }
    if (element.getCertificate() != null) {
        extras.putString("Certificate", element.getCertificate());
    }
    if (element.getTagline() != null) {
        extras.putString("Tagline", element.getTagline());
    }

    MediaDescriptionCompat description = new MediaDescriptionCompat.Builder().setMediaId(mediaId)
            .setTitle(element.getTitle() == null ? "" : element.getTitle()).setSubtitle(getSubtitle(element))
            .setDescription(element.getDescription() == null ? "" : element.getDescription()).setExtras(extras)
            .setIconUri(
                    Uri.parse(RESTService.getInstance().getAddress() + "/image/" + element.getID() + "/cover"))
            .build();

    return description;
}

From source file:com.facebook.internal.BundleJSONConverterTests.java

@SmallTest
public void testUnsupportedValues() throws JSONException {
    Bundle b = new Bundle();
    b.putShort("shortValue", (short) 7);

    boolean exceptionCaught = false;
    try {/*  ww  w.java2  s .co  m*/
        BundleJSONConverter.convertToJSON(b);
    } catch (IllegalArgumentException a) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);

    JSONArray jsonArray = new JSONArray();
    jsonArray.put(10);
    JSONObject json = new JSONObject();
    json.put("arrayValue", jsonArray);

    exceptionCaught = false;
    try {
        BundleJSONConverter.convertToBundle(json);
    } catch (IllegalArgumentException a) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
}

From source file:com.facebook.internal.BundleJSONConverterTest.java

@Test
public void testUnsupportedValues() throws JSONException {
    Bundle b = new Bundle();
    b.putShort("shortValue", (short) 7);

    boolean exceptionCaught = false;
    try {//from   w w  w .  j a  v a2  s. c o  m
        BundleJSONConverter.convertToJSON(b);
    } catch (IllegalArgumentException a) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);

    JSONArray jsonArray = new JSONArray();
    jsonArray.put(10);
    JSONObject json = new JSONObject();
    json.put("arrayValue", jsonArray);

    exceptionCaught = false;
    try {
        BundleJSONConverter.convertToBundle(json);
    } catch (IllegalArgumentException a) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
}

From source file:com.nextgis.maplibui.CreateRemoteTMSLayerDialog.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString(KEY_TITLE, mTitle);
    outState.putShort(KEY_ID, mGroupLayer.getId());
    outState.putString(KEY_NAME, mInput.getText().toString());
    outState.putString(KEY_URL, mUrl.getText().toString());
    outState.putInt(KEY_POSITION, mSpinner.getSelectedItemPosition());
    outState.putString(KEY_LOGIN, mLogin.getText().toString());
    outState.putString(KEY_PASSWORD, mPassword.getText().toString());

    super.onSaveInstanceState(outState);
}

From source file:com.dsi.ant.antplus.pluginsampler.fitnessequipment.Dialog_ConfigSettings.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Settings Configuration");
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View detailsView = inflater.inflate(R.layout.dialog_fe_settings, null);

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(detailsView);//  w  ww  .  j a va  2  s  .  c om

    // Add action buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent i = new Intent(Dialog_ConfigSettings.this.getActivity(),
                    Activity_FitnessEquipmentSampler.class);
            Bundle b = new Bundle();
            b.putString(SETTINGS_NAME, et_friendlyName.getText().toString());
            b.putShort(SETTINGS_AGE, Short.parseShort(et_age.getText().toString()));
            b.putFloat(SETTINGS_HEIGHT, Float.parseFloat(et_height.getText().toString()) / 100f); // Convert to m
            b.putFloat(SETTINGS_WEIGHT, Float.parseFloat(et_weight.getText().toString()));
            b.putBoolean(SETTINGS_GENDER, rb_male.isChecked());
            b.putBoolean(INCLUDE_WORKOUT, cb_workout.isChecked());
            i.putExtras(b);
            startActivity(i);
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Let dialog dismiss
        }
    });

    et_friendlyName = (EditText) detailsView.findViewById(R.id.editText_FriendlyName);
    et_age = (EditText) detailsView.findViewById(R.id.editText_Age);
    et_height = (EditText) detailsView.findViewById(R.id.editText_Height);
    et_weight = (EditText) detailsView.findViewById(R.id.editText_Weight);
    rb_female = (RadioButton) detailsView.findViewById(R.id.radioButton_Female);
    rb_male = (RadioButton) detailsView.findViewById(R.id.radioButton_Male);
    cb_workout = (CheckBox) detailsView.findViewById(R.id.checkBox_Workout);

    return builder.create();
}

From source file:com.nextgis.maplibui.SelectNGWResourceDialog.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString(KEY_TITLE, mTitle);
    outState.putInt(KEY_MASK, mTypeMask);
    outState.putShort(KEY_ID, mGroupLayer.getId());
    outState.putInt(KEY_RESOURCEID, mListAdapter.getCurrentResourceId());
    outState.putParcelable(KEY_CONNECTIONS, mListAdapter.getConnections());
    outState.putParcelableArrayList(KEY_STATES,
            (ArrayList<? extends android.os.Parcelable>) mListAdapter.getCheckState());
    super.onSaveInstanceState(outState);
}

From source file:com.ecoplayer.beta.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (album != null)
        outState.putParcelable(EXTRA_ALBUM, album);
    outState.putShort(EXTRA_FRAGMENT_ID, currentFragment);
    super.onSaveInstanceState(outState);
}

From source file:com.untappedkegg.rally.home.ActivityMain.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putShort("pos", curPosition);
    super.onSaveInstanceState(outState);
}

From source file:info.wncwaterfalls.app.ResultsActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putShort(SearchActivity.EXTRA_SEARCH_MODE, mSearchMode);
    savedInstanceState.putString(SearchActivity.EXTRA_SEARCH_TERM, searchTerm);
    savedInstanceState.putShort(SearchActivity.EXTRA_SEARCH_TRAIL_LENGTH, searchTrailLength);
    savedInstanceState.putShort(SearchActivity.EXTRA_SEARCH_TRAIL_DIFFICULTY, searchTrailDifficulty);
    savedInstanceState.putShort(SearchActivity.EXTRA_SEARCH_TRAIL_CLIMB, searchTrailClimb);
    savedInstanceState.putShort(SearchActivity.EXTRA_SEARCH_LOCATION_DISTANCE, searchLocationDistance);
    savedInstanceState.putString(SearchActivity.EXTRA_SEARCH_LOCATION_RELTO, searchLocationRelto);
    savedInstanceState.putString(SearchActivity.EXTRA_SEARCH_LOCATION_RELTO_TXT, searchLocationReltoTxt);
    savedInstanceState.putBoolean(SearchActivity.EXTRA_ONLY_SHARED, searchOnlyShared);
    super.onSaveInstanceState(savedInstanceState);
}