Example usage for android.os Bundle putDouble

List of usage examples for android.os Bundle putDouble

Introduction

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

Prototype

public void putDouble(@Nullable String key, double value) 

Source Link

Document

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

Usage

From source file:com.mina.breathitout.AnalyzeActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putDouble("dtRMS", dtRMS);
    savedInstanceState.putDouble("dtRMSFromFT", dtRMSFromFT);
    savedInstanceState.putDouble("maxAmpDB", maxAmpDB);
    savedInstanceState.putDouble("maxAmpFreq", maxAmpFreq);
    savedInstanceState.putDouble("dtRMSFromFT_Log", dtRMSFromFT_Log);
    savedInstanceState.putInt("breathCount", breathCount);
    savedInstanceState.putBoolean("isBreathing", isBreathing);
    savedInstanceState.putBoolean("isInhaling", isInhaling);
    savedInstanceState.putInt("lastMaxTime", lastMaxTime);

    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.google.firebase.quickstart.analytics.webview.AnalyticsWebInterface.java

private Bundle bundleFromJson(String json) {
    // [START_EXCLUDE]
    if (TextUtils.isEmpty(json)) {
        return new Bundle();
    }/*from  www. ja  v  a2  s.c o m*/

    Bundle result = new Bundle();
    try {
        JSONObject jsonObject = new JSONObject(json);
        Iterator<String> keys = jsonObject.keys();

        while (keys.hasNext()) {
            String key = keys.next();
            Object value = jsonObject.get(key);

            if (value instanceof String) {
                result.putString(key, (String) value);
            } else if (value instanceof Integer) {
                result.putInt(key, (Integer) value);
            } else if (value instanceof Double) {
                result.putDouble(key, (Double) value);
            } else {
                Log.w(TAG, "Value for key " + key + " not one of [String, Integer, Double]");
            }
        }
    } catch (JSONException e) {
        Log.w(TAG, "Failed to parse JSON, returning empty Bundle.", e);
        return new Bundle();
    }

    return result;
    // [END_EXCLUDE]
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(ParamIntent.BUNDLE_SAVE, true);
    if (getModelActivity().getNearResp() != null) {
        outState.putParcelable(ParamIntent.NEAR_RESP, getModelActivity().getNearResp());
    } else {/*from  w  ww . j  ava 2  s .  c om*/
        outState.putBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST, getModelActivity().isForceResearch());
    }
    if (getModelActivity().getLocalisation() != null) {
        outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE,
                getModelActivity().getLocalisation().getLatitude());
        outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE,
                getModelActivity().getLocalisation().getLongitude());
    }
    outState.putString(ParamIntent.ACTIVITY_SEARCH_THEATER_ID, getModelActivity().getFavTheaterId());
    outState.putInt(ParamIntent.ACTIVITY_SEARCH_DAY, getModelActivity().getDay());
    outState.putString(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName());
    outState.putString(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME, getModelActivity().getMovieName());
    outState.putIntegerArrayList(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND,
            new ArrayList<Integer>(getModelActivity().getGroupExpanded()));
    super.onSaveInstanceState(outState);
}

From source file:org.croudtrip.gcm.GcmIntentService.java

private void handleRequestDeclined(Intent intent) {
    Timber.d("REQUEST_DECLINED");

    // extract join request and offer from message
    long joinTripRequestId = Long.parseLong(intent.getExtras().getString(GcmConstants.GCM_MSG_JOIN_REQUEST_ID));
    long offerId = Long.parseLong(intent.getExtras().getString(GcmConstants.GCM_MSG_JOIN_REQUEST_OFFER_ID));

    // download the join trip request
    tripsResource.getJoinRequest(joinTripRequestId).observeOn(Schedulers.io())
            .subscribeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<JoinTripRequest>() {
                @Override//from   w  ww.j av  a2s .  c o  m
                public void call(JoinTripRequest joinTripRequest) {

                    //Check the two starting positions. If they are the same, this was the declined message from the first driver
                    RouteLocation r1 = joinTripRequest.getSuperTrip().getQuery().getStartLocation();
                    RouteLocation r2 = joinTripRequest.getSubQuery().getStartLocation();
                    boolean firstDriver = r1.equals(r2);

                    //save the canceled waiting status only if the first driver canceled
                    if (firstDriver) {
                        final SharedPreferences prefs = getApplicationContext().getSharedPreferences(
                                Constants.SHARED_PREF_FILE_PREFERENCES, Context.MODE_PRIVATE);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.putBoolean(Constants.SHARED_PREF_KEY_SEARCHING, true);
                        editor.putBoolean(Constants.SHARED_PREF_KEY_WAITING, false);
                        editor.apply();

                        tripsResource.cancelSuperTrip(joinTripRequest.getSuperTrip().getId())
                                .observeOn(Schedulers.io()).subscribeOn(AndroidSchedulers.mainThread())
                                .subscribe(new Action1<SuperTrip>() {
                                    @Override
                                    public void call(SuperTrip superTrip) {
                                        Timber.d("Cancelled your super trip");
                                    }
                                }, new Action1<Throwable>() {
                                    @Override
                                    public void call(Throwable throwable) {
                                        Timber.e("Could not cancel your trip: " + throwable.getMessage());
                                    }
                                });

                    }

                    Bundle extras = new Bundle();
                    TripQuery query = joinTripRequest.getSuperTrip().getQuery();
                    extras.putDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LATITUDE,
                            query.getStartLocation().getLat());
                    extras.putDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LONGITUDE,
                            query.getStartLocation().getLng());
                    extras.putDouble(JoinDispatchFragment.KEY_DESTINATION_LATITUDE,
                            query.getDestinationLocation().getLat());
                    extras.putDouble(JoinDispatchFragment.KEY_DESTINATION_LONGITUDE,
                            query.getDestinationLocation().getLng());
                    extras.putInt(JoinDispatchFragment.KEY_MAX_WAITING_TIME,
                            (int) query.getMaxWaitingTimeInSeconds());

                    if (LifecycleHandler.isApplicationInForeground()) {
                        //go back to search UI only if the first driver canceled
                        if (firstDriver) {
                            //Toast.makeText(getApplicationContext(), getString(R.string.join_request_declined_msg), Toast.LENGTH_SHORT).show();
                            Intent startingIntent = new Intent(Constants.EVENT_CHANGE_JOIN_UI);
                            startingIntent.putExtras(extras);
                            LocalBroadcastManager.getInstance(getApplicationContext())
                                    .sendBroadcast(startingIntent);
                        } else {
                            Intent startingIntent = new Intent(Constants.EVENT_SECONDARY_DRIVER_DECLINED);
                            startingIntent.putExtras(extras);
                            LocalBroadcastManager.getInstance(getApplicationContext())
                                    .sendBroadcast(startingIntent);
                        }
                    } else {
                        // create notification for the user
                        Intent startingIntent = new Intent(getApplicationContext(), MainActivity.class);
                        startingIntent.putExtras(extras);
                        PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0,
                                startingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                        createNotification(getString(R.string.join_request_declined_title),
                                getString(R.string.join_request_declined_msg),
                                GcmConstants.GCM_NOTIFICATION_REQUEST_DECLINED_ID, contentIntent);
                    }

                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    Timber.e("Something went wrong when downloading join request: " + throwable.getMessage());
                }
            });
}

From source file:us.socialgoodworking.mocklocation.MockLocationActivity.java

@Override
protected void onSaveInstanceState(Bundle saveState) {
    saveState.putInt("mode", currentMode);
    saveState.putDouble("currentLat", currentLatLng.latitude);
    saveState.putDouble("currentLng", currentLatLng.longitude);
    saveState.putDouble("previousLat", currentLatLng.latitude);
    saveState.putDouble("previousLng", currentLatLng.longitude);
    saveState.putString("currentRoute", currentRoute);
    saveState.putBoolean("started", bStarted);

    if (currentRoute != null && !currentRoute.isEmpty()) {
        saveState.putInt("index", routeList.getCurrentIndex(currentRoute));
    }//from  www.j  av  a2  s  .  co  m

    super.onSaveInstanceState(saveState);
}

From source file:csci310.parkhere.ui.activities.RenterActivity.java

public void onReservationSelected(int resPosition, boolean ifNotPassed) {
    System.out.println("RenterActivity onReservationSelected for: " + resPosition);
    if (clientController.renterReservations.size() == 0) {
        System.out.println("RenterActivity: error - no renterReservations to select");
        return;//from ww  w  .j a  v  a  2 s .c  o  m
    }
    Reservation selectedRes = clientController.renterReservations.get(resPosition);
    if (selectedRes == null) {
        System.out.println("Selected parking spot is null");
        return;
    }
    RenterReservationDetailFragment resDetailfragment = new RenterReservationDetailFragment();
    Bundle args = new Bundle();
    args.putDouble("LAT", selectedRes.getSpot().getLat());
    args.putDouble("LONG", selectedRes.getSpot().getLon());
    args.putString("ADDRESS", selectedRes.getSpot().getStreetAddr());

    Time startTime = selectedRes.getReserveTimeInterval().startTime;
    Time endTime = selectedRes.getReserveTimeInterval().endTime;

    Time displayStartTime = new Time(startTime.year, startTime.month, startTime.dayOfMonth, startTime.hourOfDay,
            startTime.minute, startTime.second);
    Time displayEndTime = new Time(endTime.year, endTime.month, endTime.dayOfMonth, endTime.hourOfDay,
            endTime.minute, endTime.second);

    displayStartTime.month += 1;
    displayEndTime.month += 1;

    Log.d("STARTTime: ", displayStartTime.toString());
    Log.d("ENDTime: ", displayEndTime.toString());

    args.putString("START_TIME", displayStartTime.toString());
    args.putString("END_TIME", displayEndTime.toString());
    args.putLong("PROVIDER", selectedRes.getSpot().getOwner());
    args.putLong("RES_ID", selectedRes.getReservationID());

    if (selectedRes.review == null && !ifNotPassed) {
        args.putBoolean("IF_CANREVIEW", true);
    } else {
        args.putBoolean("IF_CANREVIEW", false);
    }
    args.putBoolean("IF_CANCANCEL", ifNotPassed);
    args.putBoolean("IF_ISPAID", selectedRes.isPaid());
    resDetailfragment.setArguments(args);

    try {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragContainer, resDetailfragment).commit();
    } catch (Exception e) {
        System.out.println("RenterActivity onReservationSelected exception");
    }
}

From source file:com.binomed.showtime.android.screen.widget.results.CineShowTimeResultsWidgetActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (getModelActivity().getNearResp() != null) {
        outState.putBoolean(ParamIntent.BUNDLE_SAVE, true);
        if (getModelActivity().getNearResp() != null) {
            outState.putParcelable(ParamIntent.NEAR_RESP, getModelActivity().getNearResp());
        } else {//from  w ww . j  a va 2  s.  co m
            outState.putBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST,
                    getModelActivity().isForceResearch());
        }
        if (getModelActivity().getLocalisation() != null) {
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE,
                    getModelActivity().getLocalisation().getLatitude());
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE,
                    getModelActivity().getLocalisation().getLongitude());
        }
        outState.putString(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName());
    }
    super.onSaveInstanceState(outState);
}

From source file:nuclei.task.TaskScheduler.java

private void onSchedulePreL(Context context) {
    Task.Builder builder;//  w w w. j  a  v a2 s  .  com

    switch (mBuilder.mTaskType) {
    case TASK_ONE_OFF:
        OneoffTask.Builder oneOffBuilder = new OneoffTask.Builder();
        builder = oneOffBuilder;
        if (mBuilder.mWindowStartDelaySecondsSet || mBuilder.mWindowEndDelaySecondsSet)
            oneOffBuilder.setExecutionWindow(mBuilder.mWindowStartDelaySeconds,
                    mBuilder.mWindowEndDelaySeconds);
        break;
    case TASK_PERIODIC:
        builder = new PeriodicTask.Builder().setFlex(mBuilder.mFlexInSeconds)
                .setPeriod(mBuilder.mPeriodInSeconds);
        break;
    default:
        throw new IllegalArgumentException();
    }

    ArrayMap<String, Object> map = new ArrayMap<>();
    mBuilder.mTask.serialize(map);
    Bundle extras = new Bundle();
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        Object v = entry.getValue();
        if (v == null)
            continue;
        if (v instanceof Integer)
            extras.putInt(entry.getKey(), (int) v);
        else if (v instanceof Double)
            extras.putDouble(entry.getKey(), (double) v);
        else if (v instanceof Long)
            extras.putLong(entry.getKey(), (long) v);
        else if (v instanceof String)
            extras.putString(entry.getKey(), (String) v);
        else if (v instanceof String[])
            extras.putStringArray(entry.getKey(), (String[]) v);
        else if (v instanceof boolean[])
            extras.putBooleanArray(entry.getKey(), (boolean[]) v);
        else if (v instanceof double[])
            extras.putDoubleArray(entry.getKey(), (double[]) v);
        else if (v instanceof long[])
            extras.putLongArray(entry.getKey(), (long[]) v);
        else if (v instanceof int[])
            extras.putIntArray(entry.getKey(), (int[]) v);
        else if (v instanceof Parcelable)
            extras.putParcelable(entry.getKey(), (Parcelable) v);
        else if (v instanceof Serializable)
            extras.putSerializable(entry.getKey(), (Serializable) v);
        else
            throw new IllegalArgumentException("Invalid Type: " + entry.getKey());
    }
    extras.putString(TASK_NAME, mBuilder.mTask.getClass().getName());

    builder.setExtras(extras).setPersisted(mBuilder.mPersisted).setRequiresCharging(mBuilder.mRequiresCharging)
            .setService(TaskGcmService.class).setTag(mBuilder.mTask.getTaskTag())
            .setUpdateCurrent(mBuilder.mUpdateCurrent);

    switch (mBuilder.mNetworkState) {
    case NETWORK_STATE_ANY:
        builder.setRequiredNetwork(Task.NETWORK_STATE_ANY);
        break;
    case NETWORK_STATE_CONNECTED:
        builder.setRequiredNetwork(Task.NETWORK_STATE_CONNECTED);
        break;
    case NETWORK_STATE_UNMETERED:
        builder.setRequiredNetwork(Task.NETWORK_STATE_UNMETERED);
        break;
    }

    GcmNetworkManager.getInstance(context).schedule(builder.build());
}

From source file:fr.cph.chicago.core.activity.BusActivity.java

@Override
public void onSaveInstanceState(final Bundle savedInstanceState) {
    savedInstanceState.putInt(bundleBusStopId, busStopId);
    savedInstanceState.putString(bundleBusRouteId, busRouteId);
    savedInstanceState.putString(bundleBusBound, bound);
    savedInstanceState.putString(bundleBusBoundTitle, boundTitle);
    savedInstanceState.putString(bundleBusStopName, busStopName);
    savedInstanceState.putString(bundleBusRouteName, busRouteName);
    savedInstanceState.putDouble(bundleBusLatitude, latitude);
    savedInstanceState.putDouble(bundleBusLongitude, longitude);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:fr.cph.chicago.activity.BusActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putInt("busStopId", mBusStopId);
    savedInstanceState.putString("busRouteId", mBusRouteId);
    savedInstanceState.putString("bound", mBound);
    savedInstanceState.putString("busStopName", mBusStopName);
    savedInstanceState.putString("busRouteName", mBusRouteName);
    savedInstanceState.putDouble("latitude", mLatitude);
    savedInstanceState.putDouble("longitude", mLongitude);
    super.onSaveInstanceState(savedInstanceState);
}