Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

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

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

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

Usage

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelable("imageData", imageData);
    savedInstanceState.putParcelableArrayList("commentData", commentArray);
    savedInstanceState.putBoolean("inGallery", inGallery);
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void addGeofences(CallbackContext callbackContext, JSONArray geofences) {

    final Bundle event = new Bundle();
    event.putString("name", BackgroundGeolocationService.ACTION_ADD_GEOFENCES);
    event.putBoolean("request", true);

    event.putString("geofences", geofences.toString());
    addGeofenceCallbacks.put(BackgroundGeolocationService.ACTION_ADD_GEOFENCES, callbackContext);

    postEvent(event);//from w w w.  j av  a  2  s .  c  om
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void resetOdometer(CallbackContext callbackContext) {
    SharedPreferences.Editor editor = settings.edit();
    editor.putFloat("odometer", 0);
    editor.apply();/*www .  j  a  v  a2  s  . c om*/

    if (BackgroundGeolocationService.isInstanceCreated()) {
        Bundle event = new Bundle();
        event.putString("name", BackgroundGeolocationService.ACTION_RESET_ODOMETER);
        event.putBoolean("request", true);
        postEventInBackground(event);
    }
    callbackContext.success();
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void sync(CallbackContext callbackContext) {
    syncCallback = callbackContext;//from  ww  w  .j  a va 2  s .  c o  m
    Activity activity = this.cordova.getActivity();

    EventBus eventBus = EventBus.getDefault();
    if (!eventBus.isRegistered(this)) {
        eventBus.register(this);
    }
    if (!BackgroundGeolocationService.isInstanceCreated()) {
        Intent syncIntent = new Intent(activity, BackgroundGeolocationService.class);
        syncIntent.putExtra("command", BackgroundGeolocationService.ACTION_SYNC);
        activity.startService(syncIntent);
    } else {
        final Bundle event = new Bundle();
        event.putString("name", BackgroundGeolocationService.ACTION_SYNC);
        event.putBoolean("request", true);
        postEventInBackground(event);
    }
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void insertLocation(JSONObject params, CallbackContext callbackContext) {
    if (!BackgroundGeolocationService.isInstanceCreated()) {
        Log.i(TAG,/*from   w w  w .j  ava  2 s .  com*/
                "Cannot insertLocation when the BackgroundGeolocationService is not running.  Plugin must be started first");
        return;
    }
    if (!params.has("uuid")) {
        callbackContext.error("insertLocation params must contain uuid");
        return;
    }
    if (!params.has("timestamp")) {
        callbackContext.error("insertLocation params must contain timestamp");
        return;
    }
    if (!params.has("coords")) {
        callbackContext.error("insertLocation params must contains a coords {}");
        return;
    }
    Bundle event = new Bundle();
    event.putString("name", BackgroundGeolocationService.ACTION_INSERT_LOCATION);
    event.putBoolean("request", true);

    try {
        String uuid = params.getString("uuid");
        event.putString("location", params.toString());
        insertLocationCallbacks.put(uuid, callbackContext);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    postEvent(event);
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private boolean setConfig(JSONObject config) {
    try {/*from  ww  w  .  j  av  a2  s.  c  o m*/
        JSONObject merged = new JSONObject();
        JSONObject[] objs = new JSONObject[] { mConfig, config };
        for (JSONObject obj : objs) {
            Iterator it = obj.keys();
            while (it.hasNext()) {
                String key = (String) it.next();
                merged.put(key, obj.get(key));
            }
        }
        mConfig = merged;
    } catch (JSONException e) {
        e.printStackTrace();
        return false;
    }

    cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            applyConfig();
            Bundle event = new Bundle();
            event.putString("name", BackgroundGeolocationService.ACTION_SET_CONFIG);
            event.putBoolean("request", true);
            postEvent(event);
        }
    });
    return true;
}

From source file:org.planetmono.dcuploader.SignOnGallog.java

public Runnable getMethodSignOn(final Application app, final Bundle b, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            String id, password;//w  ww.  j a  v a  2  s  .c  o m

            id = b.getString("id");
            password = b.getString("password");

            Message m = resultHandler.obtainMessage();
            Bundle bm = m.getData();

            Log.d(Application.TAG, "logging in...");

            HttpPost post = new HttpPost(SIGNON_URL);
            List<NameValuePair> vlist = new ArrayList<NameValuePair>();
            vlist.add(new BasicNameValuePair("user_id", id));
            vlist.add(new BasicNameValuePair("password", password));
            vlist.add(new BasicNameValuePair("x", "0"));
            vlist.add(new BasicNameValuePair("y", "0"));
            vlist.add(new BasicNameValuePair("s_url", "about:blank"));
            try {
                post.setEntity(new UrlEncodedFormEntity(vlist));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            post.setHeader("Origin", SIGNON_BASE_URL);
            post.setHeader("Referer", SIGNON_PAGE_URL);

            HttpResponse response = null;
            try {
                response = app.sendPostRequest(post);
            } catch (Exception e) {
                e.printStackTrace();

                bm.putBoolean("result", false);
                bm.putString("resultString", " ");
                resultHandler.sendMessage(m);
                return;
            }

            HttpEntity entity = response.getEntity();
            BufferedReader r;
            try {
                r = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));

                while (true) {
                    String line = r.readLine();
                    if (line == null)
                        break;

                    if (line.contains(" ")
                            || line.contains("?? ? ")) {
                        bm.putBoolean("result", false);
                        bm.putString("resultString", "? ");
                        resultHandler.sendMessage(m);
                        entity.consumeContent();
                        return;
                    } else if (line.contains("about:blank")) {
                        /* successful */
                        bm.putBoolean("result", true);
                        bm.putInt("method", getMethodId());
                        resultHandler.sendMessage(m);
                        entity.consumeContent();
                        return;
                    }
                }
            } catch (Exception e) {
                bm.putBoolean("result", false);
                bm.putString("resultString", " ");
                resultHandler.sendMessage(m);

                try {
                    entity.consumeContent();
                } catch (IOException e1) {
                }

                return;
            }

            try {
                entity.consumeContent();
            } catch (IOException e) {
            }

            /* abnormal status. */
            bm.putBoolean("result", false);
            bm.putString("resultString", "   .");
            resultHandler.sendMessage(m);
        }
    };
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void addGeofence(CallbackContext callbackContext, JSONObject config) {
    try {/*from   w w w  . j  a  v a2  s. c  o m*/
        String identifier = config.getString("identifier");
        final Bundle event = new Bundle();
        event.putString("name", BackgroundGeolocationService.ACTION_ADD_GEOFENCE);
        event.putBoolean("request", true);
        event.putFloat("radius", (float) config.getLong("radius"));
        event.putDouble("latitude", config.getDouble("latitude"));
        event.putDouble("longitude", config.getDouble("longitude"));
        event.putString("identifier", identifier);

        if (config.has("notifyOnEntry")) {
            event.putBoolean("notifyOnEntry", config.getBoolean("notifyOnEntry"));
        }
        if (config.has("notifyOnExit")) {
            event.putBoolean("notifyOnExit", config.getBoolean("notifyOnExit"));
        }
        if (config.has("notifyOnDwell")) {
            event.putBoolean("notifyOnDwell", config.getBoolean("notifyOnDwell"));
        }
        if (config.has("loiteringDelay")) {
            event.putInt("loiteringDelay", config.getInt("loiteringDelay"));
        }
        addGeofenceCallbacks.put(identifier, callbackContext);

        postEvent(event);

    } catch (JSONException e) {
        e.printStackTrace();
        callbackContext.error(e.getMessage());
    }
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void getCurrentPosition(CallbackContext callbackContext, JSONObject options) {
    isAcquiringCurrentPosition = true;// w ww  .ja va  2s.com
    addCurrentPositionListener(callbackContext);

    if (!isEnabled) {
        EventBus eventBus = EventBus.getDefault();
        if (!eventBus.isRegistered(this)) {
            eventBus.register(this);
        }
        if (!BackgroundGeolocationService.isInstanceCreated()) {
            Activity activity = cordova.getActivity();
            backgroundServiceIntent = new Intent(activity, BackgroundGeolocationService.class);
            backgroundServiceIntent.putExtra("command",
                    BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION);
            backgroundServiceIntent.putExtra("options", options.toString());
            startService(REQUEST_ACTION_GET_CURRENT_POSITION);
        }
    } else {
        final Bundle event = new Bundle();
        event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION);
        event.putBoolean("request", true);
        event.putString("options", options.toString());
        postEventInBackground(event);
    }
}

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

/**
 * Show SourceInfoFragment with position -1 to add new source
 *//*from  w  ww  .  java 2 s.  co m*/
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();

}