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:org.anhonesteffort.flock.SubscriptionGoogleFragment.java

private void handleRefreshDaysTillCharge() {
    if (recurringTask != null)
        return;//from  w  w w  .  j av  a 2  s.c om

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

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

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

            if (subscriptionActivity.billingService == null) {
                Log.e(TAG, "billing service is null");
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
                return result;
            }

            try {

                Bundle ownedItems = subscriptionActivity.billingService.getPurchases(3,
                        SubscriptionGoogleFragment.class.getPackage().getName(), PRODUCT_TYPE_SUBSCRIPTION,
                        null);

                ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                for (int i = 0; i < purchaseDataList.size(); ++i) {
                    JSONObject productObject = new JSONObject(purchaseDataList.get(i));
                    if (productObject.getString("productId").equals(SKU_YEARLY_SUBSCRIPTION)) {
                        long purchaseTime = productObject.getLong("purchaseTime");
                        long msSincePurchase = new Date().getTime() - purchaseTime;
                        if (msSincePurchase < 0)
                            msSincePurchase = 0;

                        daysTillNextCharge = 365 - (msSincePurchase / 1000 / 60 / 60 / 24);
                        if (daysTillNextCharge < 0)
                            daysTillNextCharge = 0;
                    }
                }

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

            } catch (RemoteException e) {
                Log.e(TAG, "error while getting owned items", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            } catch (JSONException e) {
                Log.e(TAG, "error while getting owned items", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            }

            return result;
        }

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

            if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS)
                handleUpdateUi();
            else
                ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result);
        }
    }.execute();
}

From source file:com.sababado.network.AsyncServiceCallTask.java

private Bundle parseResponse(HttpResponse result) {
    Bundle responseBundle = new Bundle();
    if (result != null) {
        if (result.getStatusLine().getStatusCode() != 200) {
            //something is wrong
            int statusCd = result.getStatusLine().getStatusCode();
            responseBundle.putString(EXTRA_ERR_MSG, "Service Failed: " + statusCd + ": "
                    + result.getStatusLine().getReasonPhrase() + ": " + mService.getUrl());
            responseBundle.putInt(EXTRA_ERR_CODE, statusCd);
            return responseBundle;
        }/* w  w  w .  java2  s .c om*/
        try {
            Bundle bundle = new Bundle();
            bundle.putSerializable(EXTRA_SERVICE_RESULT,
                    mService.parseResults(result.getEntity().getContent()));
            return bundle;
        } catch (IllegalStateException e) {
            responseBundle.putString(EXTRA_ERR_MSG, "IllegalStateException: " + e.getMessage());
            responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_PARSE_ILLEGAL_STATE);
            return responseBundle;
        } catch (IOException e) {
            responseBundle.putString(EXTRA_ERR_MSG, "IOException: " + e.getMessage());
            responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_PARSE_IOEXCEPTION);
            return responseBundle;
        } catch (XmlPullParserException e) {
            responseBundle.putString(EXTRA_ERR_MSG, "XmlPullParserException: " + e.getMessage());
            responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_XML_PULLPARSER_EXCEPTION);
            return responseBundle;
        }
    } else {
        responseBundle.putString(EXTRA_ERR_MSG, "No result from service call.");
        responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_NO_RESULTS);
        return responseBundle;
    }
}

From source file:com.zia.freshdocs.widget.CMISAdapter.java

/**
 * Download the content for the given NodeRef
 * @param ref//from   www  .j a  v a 2  s  . co  m
 * @param handler
 */
protected void downloadContent(final NodeRef ref, final Handler handler) {
    startProgressDlg(false);
    _progressDlg.setMax(Long.valueOf(ref.getContentLength()).intValue());

    _dlThread = new ChildDownloadThread(handler, new Downloadable() {
        public Object execute() {
            File f = null;

            try {
                CMISApplication app = (CMISApplication) getContext().getApplicationContext();
                URL url = new URL(ref.getContent());
                String name = ref.getName();
                long fileSize = ref.getContentLength();
                f = app.getFile(name, fileSize);

                if (f != null && f.length() != fileSize) {
                    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

                    FileOutputStream fos = new FileOutputStream(f);
                    InputStream is = _cmis.get(url.getPath());

                    byte[] buffer = new byte[BUF_SIZE];
                    int len = is.read(buffer);
                    int total = len;
                    Message msg = null;
                    Bundle b = null;

                    while (len != -1) {
                        msg = handler.obtainMessage();
                        b = new Bundle();
                        b.putInt("progress", total);
                        msg.setData(b);
                        handler.sendMessage(msg);

                        fos.write(buffer, 0, len);
                        len = is.read(buffer);
                        total += len;

                        if (Thread.interrupted()) {
                            fos.close();
                            f = null;
                            throw new InterruptedException();
                        }
                    }

                    fos.flush();
                    fos.close();
                }
            } catch (Exception e) {
                Log.e(CMISAdapter.class.getSimpleName(), "", e);
            }

            return f;
        }
    });
    _dlThread.start();
}

From source file:com.plusub.lib.service.BaseRequestService.java

/**
 * ??/*w ww. j a  va 2 s.  co m*/
 * <p>Title: transmitParams
 * <p>Description: 
 * @param map
 * @return
 */
private Bundle transmitParams(Map map) {
    String keys;
    if (map != null && map.size() > 0) {
        Bundle bd = new Bundle();
        for (Object key : map.keySet()) {
            //String
            if (key instanceof String) {
                keys = (String) key;
                //
                Object obj = map.get(key);
                if (obj instanceof String) {
                    bd.putString(keys, (String) obj);
                } else if (obj instanceof Integer) {
                    bd.putInt(keys, (Integer) obj);
                } else if (obj instanceof Boolean) {
                    bd.putBoolean(keys, (Boolean) obj);
                } else if (obj instanceof Serializable) {
                    bd.putSerializable(keys, (Serializable) obj);
                } else if (obj instanceof Character) {
                    bd.putChar(keys, (Character) obj);
                } else if (obj instanceof Double) {
                    bd.putDouble(keys, (Double) obj);
                } else if (obj instanceof Float) {
                    bd.putFloat(keys, (Float) obj);
                } else {
                    Logger.e("[MainService] : unknow map values type ! keys:" + keys);
                }
            }
        }
        return bd;
    }
    return null;
}

From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java

private void showTrialFragment(final boolean expired, int numDaysRemaining) {

    //Load the trial fragment into the activity.
    TrialFragment fragment = new TrialFragment();
    Bundle bundle = new Bundle();
    bundle.putInt("NUM_DAYS_REMAINING", numDaysRemaining);
    bundle.putBoolean("EXPIRED", expired);
    fragment.setArguments(bundle);/*from  w  ww  .ja va2s  .  c  o m*/

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.launcher_root_view, fragment, "trialFragment");
    transaction.commit();

}

From source file:com.hackensack.umc.activity.ProfileSelfieActivityCustomeCam.java

private void startRegistrationActivity(DataForAutoRegistration dataTosend) {
    Intent intent = new Intent(ProfileSelfieActivityCustomeCam.this, RegistrationDetailsActivity.class);
    Bundle b = new Bundle();
    b.putSerializable(Constant.REG_REQUIRED_DATA, dataTosend);
    b.putInt(Constant.REGISTRATION_MODE, Constant.AUTO);
    b = putUrlValuesInBundle(b);/*from ww  w. j av  a  2  s. co m*/
    intent.putExtra(Constant.BUNDLE, b);
    startActivity(intent);
}

From source file:de.da_sense.moses.client.FormFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    // save the formID for the future
    outState.putInt(Form.KEY_FORM_ID, mFormID);
    outState.putString(InstalledExternalApplication.KEY_APK_ID, mAPKID);
    outState.putBoolean(KEY_IS_FIRST, mIsFirst);
    outState.putBoolean(KEY_IS_LAST, mIsLast);
    outState.putInt(KEY_POSITION, mPosition);
    super.onSaveInstanceState(outState);
}

From source file:com.nextgis.firereporter.GetFiresService.java

protected void SendScanexItem(ScanexSubscriptionItem item) {
    if (mScanexReceiver == null)
        return;//from   ww  w  .  j  a  v  a2s .c o  m
    Bundle b = new Bundle();
    b.putLong(SUBSCRIPTION_ID, item.GetId());
    b.putInt(TYPE, SCANEX_SUBSCRIPTION);
    b.putParcelable(ITEM, item);
    mScanexReceiver.send(SERVICE_SCANEXDATA, b);
}

From source file:com.facebook.android.friendsmash.GameFragment.java

void setLives(int lives) {
    this.lives = lives;

    if (getActivity() != null) {
        // Update the livesContainer
        livesContainer.removeAllViews();
        for (int i = 0; i < lives; i++) {
            ImageView heartImageView = new ImageView(getActivity());
            heartImageView.setImageResource(R.drawable.heart_red);
            livesContainer.addView(heartImageView);
        }/*from ww  w .j  a  va2  s.co  m*/

        if (lives <= 0) {
            // User has no lives left, so end the game, passing back the score
            Bundle bundle = new Bundle();
            bundle.putInt("score", getScore());

            Intent i = new Intent();
            i.putExtras(bundle);

            getActivity().setResult(Activity.RESULT_OK, i);
            getActivity().finish();
        }
    }
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

private static Bundle getBundleWithAllOptionsSet() {
    Bundle bundle = new Bundle();

    bundle.putString("title", "Test H");
    bundle.putString("alert", "Test B");
    bundle.putString("bgn", "1");
    bundle.putString("vis", "0");
    bundle.putString("bgac", "FF0000FF");
    bundle.putString("from", "703322744261");
    bundle.putString("ledc", "FFFFFF00");
    bundle.putString("bicon", "big_picture");
    bundle.putString("licon", "large_icon");
    bundle.putString("sicon", "small_icon");
    bundle.putString("sound", "test_sound");
    bundle.putString("grp_msg", "You test $[notif_count] MSGs!");
    bundle.putString("collapse_key", "a_key"); // GCM sets this to 'do_not_collapse' when not set.
    bundle.putString("bg_img",
            "{\"img\": \"test_image_url\"," + "\"tc\": \"FF000000\"," + "\"bc\": \"FFFFFFFF\"}");

    bundle.putInt("pri", 10);
    bundle.putString("custom", "{\"a\": {" + "        \"myKey\": \"myValue\","
            + "        \"nested\": {\"nKey\": \"nValue\"},"
            + "        \"actionButtons\": [{\"id\": \"id1\", \"text\": \"button1\", \"icon\": \"ic_menu_share\"},"
            + "                            {\"id\": \"id2\", \"text\": \"button2\", \"icon\": \"ic_menu_send\"}"
            + "        ]," + "         \"actionSelected\": \"__DEFAULT__\"" + "      },"
            + "\"u\":\"http://google.com\"," + "\"i\":\"9764eaeb-10ce-45b1-a66d-8f95938aaa51\"" + "}");

    return bundle;
}