Example usage for android.os Bundle getInt

List of usage examples for android.os Bundle getInt

Introduction

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

Prototype

public int getInt(String key) 

Source Link

Document

Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.

Usage

From source file:android.support.content.TestQueryCallback.java

public void assertReceivedContent(Uri expectedUri, final int expectedPageId) {
    mReplyLatch.assertHasItem(new Matcher<Pair<Integer, Cursor>>() {
        @Override//from   www.j  a va 2 s  .c o m
        public boolean matches(Pair<Integer, Cursor> value) {
            return expectedPageId == value.first;
        }
    });
    List<Pair<Integer, Cursor>> collected = mReplyLatch.getCollected();
    Cursor cursor = null;

    for (Pair<Integer, Cursor> pair : collected) {
        if (expectedPageId == pair.first) {
            cursor = pair.second;
        }
    }

    assertEquals(0, cursor.getCount()); // we don't add any records to our test cursor.
    Bundle extras = cursor.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey(URI_KEY));
    assertEquals(extras.getParcelable(URI_KEY), expectedUri);
    assertTrue(extras.containsKey(URI_PAGE_ID));
    assertEquals(extras.getInt(URI_PAGE_ID), expectedPageId);
}

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

@Test
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);/*from   w ww  . j a  v  a2s . co m*/

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:com.openerp.addons.note.AddFollowerFragment.java

public void onStart() {
    super.onStart();
    Bundle bundle = getArguments();
    if (bundle.containsKey("res_id")) {
        record_id = bundle.getInt("res_id");
        message = bundle.getString("message");
    }//from w  ww .  j  a  v  a 2 s .com
    getPartnersFromLocal();
}

From source file:com.subzero.runners.android.AndroidLauncher.java

@Override
public void queryPurchases(Preferences pref) {
    this.pref = pref;
    try {//from  ww  w. j  a v  a  2 s.  c o m
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

            for (int i = 0; i < ownedSkus.size(); i++) {
                String name = null;

                if (ownedSkus.get(i).equals("ryan"))
                    name = "Ryan";
                else if (ownedSkus.get(i).equals("ash"))
                    name = "Ash";
                else if (ownedSkus.get(i).equals("rob"))
                    name = "Rob";
                else if (ownedSkus.get(i).equals("battle_cat"))
                    name = "BattleCat";
                else if (ownedSkus.get(i).equals("xorp"))
                    name = "Xorp";
                else if (ownedSkus.get(i).equals("rootsworth"))
                    name = "Rootsworth";
                else if (ownedSkus.get(i).equals("snap"))
                    name = "Snap";
                else if (ownedSkus.get(i).equals("metatron"))
                    name = "Metatron";
                else if (ownedSkus.get(i).equals("abaddon"))
                    name = "Abaddon";

                pref.putBoolean(name, true);
                pref.flush();
            }
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    }

}

From source file:se.anyro.tagtider.StationActivity.java

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

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.transfers);//from   w w w.  j av  a 2 s . c  om

    Bundle extras = getIntent().getExtras();

    mStationName = extras.getString("stationName");
    mStationId = extras.getInt("stationId");
    mType = extras.getString("type");

    if (!mType.equals(sLastType) || mStationId != sLastStationId) {
        sLastUpdate = 0; // Make sure we reload the data
        sLastStationId = mStationId;
        sLastType = mType;
    }

    TextView title = (TextView) findViewById(R.id.title);
    TextView place = (TextView) findViewById(R.id.place);
    if (Station.ARRIVIALS.equals(mType)) {
        title.setText(mStationName + " - Ankomster");
        mFrom = FROM_ARRIVAL;
        place.setText("Frn");
    } else {
        title.setText(mStationName + " - Avgngar");
        mFrom = FROM_DEPARTURE;
        place.setText("Till");
    }
    mEmptyView = (TextView) findViewById(android.R.id.empty);
    mProgress = findViewById(R.id.progress);
}

From source file:in.codehex.facilis.ViewBidItemsFragment.java

/**
 * Implement and manipulate the objects.
 *///from   w w  w  .  j  a v a 2s.c o m
private void prepareObjects() {
    Bundle bundle = getArguments();
    // TODO: handle null value of arguments
    if (bundle != null) {
        mOrderId = bundle.getInt(Config.KEY_BUNDLE_ORDER_ID);
        mBidId = bundle.getInt(Config.KEY_BUNDLE_BID_ID);
    }

    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mRefreshLayout.setColorSchemeColors(R.color.primary, R.color.primary_dark, R.color.accent);
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mRefreshLayout.setRefreshing(true);
            processBidItems();
        }
    });
    mRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            mRefreshLayout.setRefreshing(true);
            processBidItems();
        }
    });
}

From source file:com.tangrainc.inappbilling.InAppBillingHelper.java

public ListenableFuture<JSONObject[]> getProducts() {
    return _executor.submit(new Callable<JSONObject[]>() {
        @Override//  w  w w  .j a va  2 s. co  m
        public JSONObject[] call() throws Exception {
            // Wait for the service to be initialized (if call too soon after constructor)
            int loop = 0;
            while (_service == null || loop < 20) {
                Thread.sleep(500);
                loop++;
            }
            if (_service == null) {
                throw new Exception(
                        "Billing service could not be connected for 10 secs! May be running on an emulator w/o Google Service?");
            }

            Bundle queryProducts = new Bundle();
            queryProducts.putStringArrayList("ITEM_ID_LIST",
                    new ArrayList<>(Arrays.asList(_productIdentifiers)));

            Bundle productDetails = _service.getSkuDetails(3, _context.getPackageName(), "inapp",
                    queryProducts);
            ArrayList<JSONObject> result = new ArrayList<>();

            int response = productDetails.getInt("RESPONSE_CODE");
            if (response == 0) {
                ArrayList<String> responseList = productDetails.getStringArrayList("DETAILS_LIST");

                for (String thisResponse : responseList) {
                    result.add(new JSONObject(thisResponse));
                }

                return result.toArray(new JSONObject[0]);
            } else {
                throw new Exception("Response from service: " + response);
            }
        }
    });
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.MbtoolTaskOutputFragment.java

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

    if (savedInstanceState != null) {
        mTaskId = savedInstanceState.getInt(EXTRA_TASK_ID);
    }//  w w w .ja  v  a  2s .  com
}

From source file:net.olejon.mdapp.DonateActivity.java

private void resetDonations() {
    try {/*from w  w  w.  j  a  va2  s . c  o  m*/
        Bundle bundle = mIInAppBillingService.getPurchases(3, getPackageName(), "inapp", null);

        int responseCode = bundle.getInt("RESPONSE_CODE");

        if (responseCode == 0) {
            ArrayList<String> purchaseDataArrayList = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");

            for (String purchaseData : purchaseDataArrayList) {
                JSONObject purchaseDataJsonObject = new JSONObject(purchaseData);

                consumeDonation(purchaseDataJsonObject.getString("purchaseToken"));
            }

            mTools.showToast(getString(R.string.donate_reset_successful), 0);
        } else {
            new MaterialDialog.Builder(mContext).title(getString(R.string.device_not_supported_dialog_title))
                    .content(getString(R.string.device_not_supported_dialog_message))
                    .positiveText(getString(R.string.device_not_supported_dialog_positive_button))
                    .contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show();
        }
    } catch (Exception e) {
        new MaterialDialog.Builder(mContext).title(getString(R.string.device_not_supported_dialog_title))
                .content(getString(R.string.device_not_supported_dialog_message))
                .positiveText(getString(R.string.device_not_supported_dialog_positive_button))
                .contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show();
    }
}

From source file:edu.csh.coursebrowser.SectionInfoActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    // Restore the previously serialized current tab position.
    if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
        getActionBar().setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
    }/*from  w  w w.j a  va 2 s .com*/
}