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:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java

@Override
public void onInflate(Activity a, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(a, attrs, savedInstanceState);
    TypedArray array = a.obtainStyledAttributes(attrs, R.styleable.SprocketsPreferenceFragment);
    Bundle args = Fragments.arguments(this);
    args.putInt(PREFS, array.getResourceId(R.styleable.SprocketsPreferenceFragment_preferences, 0));
    args.putBoolean(TRACK_CHANGES,//from  w ww.  j  a  va  2  s .co  m
            array.getBoolean(R.styleable.SprocketsPreferenceFragment_trackChanges, false));
    array.recycle();
}

From source file:org.anhonesteffort.flock.registration.model.FlockAccount.java

public Bundle toBundle() throws JsonProcessingException {
    Bundle bundle = new Bundle();

    bundle.putString(KEY_ACCOUNT_ID, id);
    bundle.putInt(KEY_VERSION, version);
    bundle.putString(KEY_STRIPE_CUSTOMER_ID, stripeCustomerId);
    bundle.putString(KEY_PASSWORD_SHA512, passwordSha512);
    bundle.putLong(KEY_CREATE_DATE, createDate.getTime());
    bundle.putBoolean(KEY_LAST_STRIPE_CHARGE_FAILED, lastStripeChargeFailed);
    bundle.putBoolean(KEY_AUTO_RENEW_ENABLED, autoRenewEnabled);
    bundle.putInt(KEY_SUBSCRIPTION_PLAN_TYPE, subscriptionPlan.getPlanType());
    bundle.putString(KEY_SUBSCRIPTION_PLAN, subscriptionPlan.serialize());

    return bundle;
}

From source file:de.tu_berlin.snet.probe.FacebookProbe.java

private void fetchFacebook() {
    try {/*  w  w w .  j a v  a 2 s  .c  om*/
        SharedPreferences prefs = getContext().getSharedPreferences("default", Context.MODE_MULTI_PROCESS);
        Session session = Session.getActiveSession();
        List<Request> requests = new ArrayList<Request>();

        if (session == null) {
            Log.d(TAG, "Facebook Probe not activated.");
            return;
        }

        // default is Tue, 01 Jan 2008 00:00:00 GMT
        int since = prefs.getInt("facebook.since", 1199145600);
        int until = (int) (System.currentTimeMillis() / 1000);

        Bundle params = new Bundle();
        params.putInt("since", since);
        params.putInt("until", until);
        params.putInt("limit", 5000);

        for (final String requestId : REQUEST_IDS) {
            requests.add(new Request(session, requestId, params, null, new Request.Callback() {

                public void onCompleted(Response response) {
                    GraphObject graphObject = response.getGraphObject();
                    FacebookRequestError error = response.getError();

                    if (graphObject != null) {
                        JSONObject orig = graphObject.getInnerJSONObject();
                        JsonObject data = new JsonObject();

                        anonymizeData(orig);
                        data.addProperty(response.getRequest().getGraphPath(), orig.toString());
                        sendData(data);

                    } else if (error != null) {
                        Log.e(TAG, "Error: " + error.getErrorMessage());
                    }
                }

                private Set<String> sensitiveSet = new HashSet<String>(Arrays.asList(SENSITIVE));

                private void anonymizeData(Object o) {
                    try {
                        if (o instanceof JSONObject) {
                            JSONObject obj = (JSONObject) o;

                            // not needed, may contain sensitive data
                            obj.remove("paging");
                            obj.remove("actions");

                            for (Iterator<?> iter = obj.keys(); iter.hasNext();) {
                                String key = (String) iter.next();
                                Object val = obj.get(key);

                                if (!(val instanceof String))
                                    anonymizeData(val);

                                if (sensitiveSet.contains(key))
                                    obj.put(key, sensitiveData((String) val));
                            }
                        } else if (o instanceof JSONArray) {
                            JSONArray arr = (JSONArray) o;

                            for (int i = 0; i < arr.length(); i++)
                                anonymizeData(arr.get(i));
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }));
        }
        boolean error = false;
        for (Response r : Request.executeBatchAndWait(requests)) {
            if (r.getError() != null)
                error = true;
        }
        if (!error)
            prefs.edit().putInt("facebook.since", until + 1).commit();

    } catch (Exception e) {
        e.printStackTrace();
    }
    stop();
}

From source file:at.wada811.android.library.demos.loader.LoaderListFragment.java

/**
 * URL???//from   www  . j a  va 2s.  co  m
 * 
 * @param url ?URL
 */
private void searchImageWithUrl(String url) {
    LogUtils.i(url);
    Loader<Object> currentLoader = getLoaderManager().getLoader(mLoaderListAdapter.getCount());
    if (currentLoader != null && currentLoader.isStarted()) {
        // ?
        LogUtils.i("canceled!");
        return;
    }
    Bundle args = new Bundle();
    args.putInt(LoaderListFragment.KEY_START_INDEX, mLoaderListAdapter.getCount());
    args.putString(LoaderListFragment.KEY_SEARCH_URL, url);
    getLoaderManager().restartLoader(mLoaderListAdapter.getCount(), args, new LoaderCallbacks<Void>() {
        @Override
        public Loader<Void> onCreateLoader(int id, Bundle args) {
            LogUtils.i("LoaderId: " + id);
            return new AsyncImageSearchLoader(getActivity(), args, new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, JSONObject response) {
                    super.onSuccess(statusCode, response);
                    LogUtils.d("statusCode: " + statusCode);
                    try {
                        int responseStatus = response.getInt("responseStatus");
                        LogUtils.d("responseStatus: " + responseStatus);
                        if (responseStatus != 200) {
                            return;
                        }
                        JSONObject responseData = response.getJSONObject("responseData");
                        JSONArray results = responseData.getJSONArray("results");
                        ArrayList<LoaderListItem> resultsList = new ArrayList<LoaderListItem>(results.length());
                        for (int i = 0; i < results.length(); i++) {
                            JSONObject result = results.getJSONObject(i);
                            LoaderListItem item = new LoaderListItem();
                            item.setImageUrl(result.getString("unescapedUrl"));
                            item.setThumbnailUrl(result.getString("tbUrl"));
                            item.setImageTitle(result.getString("titleNoFormatting"));
                            item.setImageWidth(Integer.valueOf(result.getString("width")));
                            item.setImageHeight(Integer.valueOf(result.getString("height")));
                            resultsList.add(item);
                        }
                        if (mLoaderListAdapter.getCount() == 0) {
                            setListShown(true);
                        }
                        if (resultsList.size() > 0) {
                            mLoaderListAdapter.addAll(resultsList);
                            getListView().invalidateViews();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                        LogUtils.e(e);
                    }
                }

                @Override
                public void onFailure(int statusCode, Throwable e, JSONObject errorResponse) {
                    super.onFailure(statusCode, e, errorResponse);
                    LogUtils.e("statusCode: " + statusCode);
                    LogUtils.e(e);
                }
            });
        }

        @Override
        public void onLoadFinished(Loader<Void> loader, Void data) {
            LogUtils.i("LoaderId: " + loader.getId());
        }

        @Override
        public void onLoaderReset(Loader<Void> loader) {
            LogUtils.i();
        }
    });
}

From source file:com.sawyer.advadapters.app.adapters.jsonadapter.JSONAdapterFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(STATE_LIST, getListAdapter().getJSONArray().toString());
    outState.putInt(STATE_CAB_CHECKED_COUNT, mCheckedCount);
}

From source file:net.carlh.toast.State.java

private void changed(int p) {
    for (Handler h : handlers) {
        Message m = Message.obtain();// w w  w.  ja  va 2  s.  c o  m
        Bundle b = new Bundle();
        b.putInt("property", p);
        m.setData(b);
        h.sendMessage(m);
    }
}

From source file:it.scoppelletti.mobilepower.preference.ColorPreference.java

protected void onSaveInstanceState(Bundle outState) {
    outState.putInt(ColorPreference.STATE_VALUE, myValue);
}

From source file:com.brodev.socialapp.view.BlogDetail.java

/** Called when the activity is first created. */
@Override// w  w  w  . j  ava 2  s .  c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blog_content_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    blog = (Blog) bundle.get("blog");

    user = (User) getApplicationContext();
    colorView = new ColorView(getApplicationContext());
    this.imageGetter = new ImageGetter(getApplicationContext());

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    if (blog.getTime_stamp().equals("0")) {
        this.getBlogAdapter();
    }

    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "blog");
    comment.putInt("itemId", blog.getBlog_id());
    comment.putInt("totalComment", blog.getTotal_comment());
    comment.putInt("total_like", blog.getTotal_like());
    comment.putBoolean("no_share", blog.getShare());
    comment.putBoolean("is_liked", blog.getIs_like());
    comment.putBoolean("can_post_comment", blog.isCanPostComment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();
}

From source file:com.amazon.adobepass.auth.AdobepassAuthentication.java

/**
 * Bundle to be sent on authorization failure
 *
 * @param statusCode status code of failure
 * @param bundle     Bundle to populate//from  ww  w.j  a  va 2s.com
 * @param throwable  throwable thrown
 */
private void populateAuthorizationFailureBundle(int statusCode, Bundle bundle, Throwable throwable) {

    bundle.putInt(ResponseHandler.STATUS_CODE, statusCode);
    bundle.putString(AuthenticationConstants.ERROR_CATEGORY,
            AuthenticationConstants.AUTHORIZATION_ERROR_CATEGORY);
    bundle.putSerializable(AuthenticationConstants.ERROR_CAUSE, throwable);
}

From source file:com.amazon.adobepass.auth.AdobepassAuthentication.java

/**
 * Bundle to be sent on authentication failure
 *
 * @param statusCode status code of failure
 * @param bundle     Bundle to populate/*w  w w .  ja va 2s.co m*/
 * @param throwable  throwable thrown
 */
private void populateAuthenticationFailureBundle(int statusCode, Bundle bundle, Throwable throwable) {

    bundle.putInt(ResponseHandler.STATUS_CODE, statusCode);
    bundle.putString(AuthenticationConstants.ERROR_CATEGORY,
            AuthenticationConstants.AUTHENTICATION_ERROR_CATEGORY);
    bundle.putSerializable(AuthenticationConstants.ERROR_CAUSE, throwable);
}