Example usage for android.os Bundle getFloat

List of usage examples for android.os Bundle getFloat

Introduction

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

Prototype

@Override
public float getFloat(String key) 

Source Link

Document

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

Usage

From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameScoreFragment.java

private void initCurrentScoreDisplayed(Bundle savedBundle) {
    if (savedBundle != null) {
        mCurrentFinalScore = savedBundle.getFloat(BUNDLE_CURRENT_FINAL_SCORE);
        mCurrentExpEarned = savedBundle.getFloat(BUNDLE_CURRENT_EXP_EARNED);
        mCurrentExpEarned = savedBundle.getFloat(BUNDLE_CURRENT_EXP_BAR);
    } else {//from   www .ja  v  a 2  s. c  o  m
        mCurrentFinalScore = 0;
        mCurrentExpEarned = 0;
        mCurrentExpBar = 0;
    }
}

From source file:nl.atcomputing.spacetravelagency.fragments.PlaceOrderFragment.java

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

    Activity activity = getActivity();/*w  ww.  j  a v a 2  s. co m*/

    StateSingleton state = StateSingleton.getInstance();
    Order order = state.getOrder();
    if (HttpCommunicator.isOnline(activity)) {
        if (order == null) {
            order = createOrder();
            state.setOrder(order);
            placeOrder();
            hideMapFragment();
        } else if (!order.isComplete()) {
            state.setOrder(order);
            placeOrder();
            hideMapFragment();
        }
    }

    if (savedInstanceState != null) {
        this.zoom = savedInstanceState.getFloat(BUNDLE_KEY_ZOOM);
        this.cameraPosition = new LatLng(savedInstanceState.getDouble(BUNDLE_KEY_POSITION_LAT),
                savedInstanceState.getDouble(BUNDLE_KEY_POSITION_LNG));
    }

    if (MapsInitializer.initialize(activity) == ConnectionResult.SUCCESS) {
        this.mapInitialized = true;
    } else {
        this.mapInitialized = false;
    }

    updateView();
}

From source file:com.dabay6.android.apps.carlog.ui.fuel.fragments.FuelHistoryDetailFragment.java

/**
 * {@inheritDoc}/*w ww . java2  s .com*/
 */
@SuppressWarnings("unchecked")
@Override
protected void createListItems(final Cursor cursor) {
    if (DataUtils.hasData(cursor)) {
        final Bundle bundle = getArguments();
        final FuelHistoryDTO history = FuelHistoryDTO.newInstance(cursor);
        final NumberFormat currency = NumberFormat.getCurrencyInstance();
        final String purchaseDate;

        purchaseDate = DateUtils.getUserLocaleFormattedDate(getActivity(), history.getPurchaseDate(),
                DateFormats.Medium);

        setTitle(string.fuel_history_details);
        setSubtitle(history.getName());

        if (isDualPane()) {
            adapter.clear();
        }

        adapter.add(createDetailItem(Columns.PURCHASE_DATE, purchaseDate));
        adapter.add(createDetailItem(Columns.ODOMETER_READING,
                getString(R.string.fuel_history_miles, history.getOdometerReading())));

        if (bundle != null && bundle.containsKey(PARAMS_MPG)) {
            final float mpg = bundle.getFloat(PARAMS_MPG);

            adapter.add(getString(string.fuel_history_mpg),
                    String.format(getString(string.miles_per_gallon), mpg));
        }

        currency.setMaximumFractionDigits(2);
        adapter.add(createDetailItem(Columns.TOTAL_COST, currency.format(history.getTotalCost())));

        adapter.add(createDetailItem(Columns.FUEL_AMOUNT, history.getFuelAmount().toString()));

        currency.setMaximumFractionDigits(3);
        adapter.add(createDetailItem(Columns.COST_PER_UNIT, currency.format(history.getCostPerUnit())));

        getActivity().supportInvalidateOptionsMenu();
    }
}

From source file:com.aimfire.gallery.service.MovieProcessor.java

@Override
protected void onHandleIntent(Intent intent) {
    /*//from  w w w .j a va  2  s.c  o  m
     * Obtain the FirebaseAnalytics instance.
     */
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    boolean[] result = new boolean[] { false, false };
    String previewPath = null;
    String thumbPath = null;
    String configPath = null;
    String convertFilePath = null;

    String exportL = MainConsts.MEDIA_3D_RAW_PATH + "L.png";
    String exportR = MainConsts.MEDIA_3D_RAW_PATH + "R.png";

    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

    Bundle extras = intent.getExtras();
    if (extras == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onHandleIntent: error, wrong parameter");
        FirebaseCrash.report(new Exception("onHandleIntent: error, wrong parameter"));
        return;
    }

    String filePathL = extras.getString("lname");
    String filePathR = extras.getString("rname");
    String cvrNameNoExt = MediaScanner.getProcessedCvrName((new File(filePathL)).getName());

    if (BuildConfig.DEBUG)
        Log.d(TAG, "onHandleIntent:left file=" + filePathL + ", right file=" + filePathR);

    String creatorName = extras.getString("creator");
    String creatorPhotoUrl = extras.getString("photo");

    float scale = extras.getFloat(MainConsts.EXTRA_SCALE);

    /*
     * if left/right videos were taken using front facing camera,
     * they need to be swapped when generating sbs 
     */
    int facing = extras.getInt(MainConsts.EXTRA_FACING);
    boolean isFrontCamera = (facing == Camera.CameraInfo.CAMERA_FACING_FRONT) ? true : false;

    MediaMetadataRetriever retriever = new MediaMetadataRetriever();

    Bitmap bitmapL = null;
    Bitmap bitmapR = null;

    long frameTime = FIRST_KEYFRAME_TIME_US;
    if (BuildConfig.DEBUG)
        Log.d(TAG, "extract frame from left at " + frameTime / 1000 + "ms");

    try {
        long startUs = SystemClock.elapsedRealtimeNanos() / 1000;

        FileInputStream inputStreamL = new FileInputStream(filePathL);
        retriever.setDataSource(inputStreamL.getFD());
        inputStreamL.close();

        bitmapL = retriever.getFrameAtTime(frameTime, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);

        FileInputStream inputStreamR = new FileInputStream(filePathR);
        retriever.setDataSource(inputStreamR.getFD());
        inputStreamR.close();

        bitmapR = retriever.getFrameAtTime(frameTime, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);

        retriever.release();

        long stopUs = SystemClock.elapsedRealtimeNanos() / 1000;
        if (BuildConfig.DEBUG)
            Log.d(TAG, "retrieving preview frames took " + (stopUs - startUs) / 1000 + "ms");

        if ((bitmapL != null) && (bitmapR != null)) {
            saveFrame(bitmapL, exportL);
            saveFrame(bitmapR, exportR);
        } else {
            reportError(MediaScanner.getProcessedCvrPath((new File(filePathL)).getName()),
                    ERROR_EXTRACT_SYNC_FRAME_ERROR);
            return;
        }

        previewPath = MainConsts.MEDIA_3D_THUMB_PATH + cvrNameNoExt + ".jpeg";

        result = p.getInstance().f1(exportL, exportR, previewPath, scale, isFrontCamera);
    } catch (Exception ex) {
        retriever.release();
        reportError(MediaScanner.getProcessedCvrPath((new File(filePathL)).getName()),
                ERROR_EXTRACT_SYNC_FRAME_EXCEPTION);
        return;
    }

    if (!result[0]) {
        reportError(MediaScanner.getProcessedCvrPath((new File(filePathL)).getName()),
                ERROR_EXTRACT_SIMILARITY_MATRIX);

        File leftFrom = (new File(filePathL));
        File rightFrom = (new File(filePathR));
        File leftExportFrom = (new File(exportL));
        File rightExportFrom = (new File(exportR));

        if (!BuildConfig.DEBUG) {
            leftFrom.delete();
            rightFrom.delete();

            leftExportFrom.delete();
            rightExportFrom.delete();
        } else {
            File leftTo = new File(MainConsts.MEDIA_3D_DEBUG_PATH + leftFrom.getName());
            File rightTo = new File(MainConsts.MEDIA_3D_DEBUG_PATH + rightFrom.getName());

            leftFrom.renameTo(leftTo);
            rightFrom.renameTo(rightTo);

            File leftExportTo = new File(MainConsts.MEDIA_3D_DEBUG_PATH + leftExportFrom.getName());
            File rightExportTo = new File(MainConsts.MEDIA_3D_DEBUG_PATH + rightExportFrom.getName());

            leftExportFrom.renameTo(leftExportTo);
            rightExportFrom.renameTo(rightExportTo);
        }
    } else {
        double[] similarityMat = p.getInstance().g();

        String configData = similarityMat[0] + " " + similarityMat[1] + " " + similarityMat[2] + " "
                + similarityMat[3] + " " + similarityMat[4] + " " + similarityMat[5];

        if (result[1]) {
            convertFilePath = filePathR;
        } else {
            convertFilePath = filePathL;
        }

        configPath = createConfigFile(convertFilePath, configData);

        /*
         * save the thumbnail
         */
        if (bitmapL != null) {
            thumbPath = MainConsts.MEDIA_3D_THUMB_PATH + cvrNameNoExt + ".jpg";
            saveThumbnail(bitmapL, thumbPath);

            MediaScanner.insertExifInfo(thumbPath, "name=" + creatorName + "photourl=" + creatorPhotoUrl);
        }

        createZipFile(filePathL, filePathR, configPath, thumbPath, previewPath);

        /*
         * let CamcorderActivity know we are done.
         */
        reportResult(MediaScanner.getProcessedCvrPath((new File(filePathL)).getName()));
    }

    /*
     * paranoia
     */
    if (bitmapL != null) {
        bitmapL.recycle();
    }
    if (bitmapR != null) {
        bitmapR.recycle();
    }

    (new File(exportL)).delete();
    (new File(exportR)).delete();
}

From source file:io.forward.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Crashlytics(), new Twitter(authConfig), new TweetComposer());
    setContentView(io.forward.R.layout.activity_main);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SEND);
    plotter = new Plotter(this);
    gpsReceiver = new GPSReceiver(this, plotter);
    magnetoReceiver = new MagnetoReceiver(this, plotter);
    broadcastManager = LocalBroadcastManager.getInstance(this);
    broadcastManager.registerReceiver(gpsReceiver, filter);
    broadcastManager.registerReceiver(magnetoReceiver, filter);

    // Start the dim service
    startService(new Intent(this, GPSService.class));
    startService(new Intent(this, MagnetoService.class));
    startOfflineMaps();//  w  w w.  j a  v  a2  s  . c o  m

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(INTENT_EXTRA_HEADING)) {
            plotter.updateHeading(savedInstanceState.getFloat(INTENT_EXTRA_HEADING));
        }

        if (savedInstanceState.containsKey(INTENT_EXTRA_LATITUDE)
                && savedInstanceState.containsKey(INTENT_EXTRA_LONGITUDE)) {
            plotter.updateGPS(savedInstanceState.getFloat(INTENT_EXTRA_LATITUDE),
                    savedInstanceState.getFloat(INTENT_EXTRA_LONGITUDE));
        }
    }
}

From source file:com.glanznig.beepme.view.ExportActivity.java

@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    setContentView(R.layout.export_data);

    exporter = new DataExporter(ExportActivity.this);
    densityFactors = new ArrayList<Integer>();

    if (savedState != null) {
        rawExport = savedState.getBoolean("rawExport");
        photoExport = savedState.getBoolean("photoExport");

        if (savedState.getInt("postActionItem") != 0) {
            postActionItem = savedState.getInt("postActionItem") - 1;
        }/*  w ww  . ja  v a2 s . c  om*/

        if (savedState.getInt("densityItem") != 0) {
            densityItem = savedState.getInt("densityItem") - 1;
        }

        photoAvgSize = savedState.getDouble("photoAvgSize");
        photoAvgDensity = savedState.getFloat("photoAvgDensity");
    }
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.BusStopMapFragment.java

/**
 * {@inheritDoc}/*from  w w  w .  j a  v  a 2  s  .  co m*/
 */
@Override
public Loader onCreateLoader(final int i, final Bundle bundle) {
    switch (i) {
    case LOADER_ID_BUS_STOPS:
        if (bundle.containsKey(LOADER_ARG_FILTERED_SERVICES)) {
            return new BusStopMarkerLoader(getActivity(), bundle.getDouble(LOADER_ARG_MIN_X),
                    bundle.getDouble(LOADER_ARG_MIN_Y), bundle.getDouble(LOADER_ARG_MAX_X),
                    bundle.getDouble(LOADER_ARG_MAX_Y), bundle.getFloat(LOADER_ARG_ZOOM),
                    bundle.getStringArray(LOADER_ARG_FILTERED_SERVICES));
        } else {
            return new BusStopMarkerLoader(getActivity(), bundle.getDouble(LOADER_ARG_MIN_X),
                    bundle.getDouble(LOADER_ARG_MIN_Y), bundle.getDouble(LOADER_ARG_MAX_X),
                    bundle.getDouble(LOADER_ARG_MAX_Y), bundle.getFloat(LOADER_ARG_ZOOM));
        }
    case LOADER_ID_GEO_SEARCH:
        String query = bundle.getString(LOADER_ARG_QUERY);
        // Make sure the query arg is not null.
        if (query == null) {
            query = "";
        }

        return new GeoSearchLoader(getActivity(), query);
    case LOADER_ID_ROUTE_LINES:
        return new RouteLineLoader(getActivity(), bundle.getStringArray(LOADER_ARG_FILTERED_SERVICES));
    default:
        return null;
    }
}

From source file:se.toxbee.sleepfighter.challenge.shake.ShakeChallenge.java

@Override
public void start(Activity activity, ChallengeResolvedParams params, Bundle state) {
    super.start(activity, params);

    this.activity().setContentView(R.layout.challenge_shake);

    // Get view references
    this.progressBar = (ProgressBar) this.activity().findViewById(R.id.progressBar);
    this.progressText = (TextView) this.activity().findViewById(R.id.progressText);

    // Check if required sensor is available
    boolean hasAccelerometer = activity.getPackageManager()
            .hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);
    if (!hasAccelerometer) {
        // Complete right away, for now. Checking if device has required
        // hardware could perhaps be done before the challenge is started.
        Log.e(TAG, "Device lacks required sensor for ShakeChallenge");
        this.complete();
        return;//from w  ww. ja v a2  s.c  o m
    }

    // Register to get acceleration events
    this.sensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
    this.accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    // Get last progress from bundle, if it exists
    if (state != null) {
        this.progress = state.getFloat(KEY_PROGRESS_FLOAT);
    }
    updateProgress();
}

From source file:com.dgmltn.ranger.internal.AbsRangeBar.java

@Override
public void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {

        Bundle bundle = (Bundle) state;

        mBarWeight = bundle.getFloat("BAR_WEIGHT");
        mBarColor = bundle.getInt("BAR_COLOR");

        mTickCount = bundle.getInt("TICK_COUNT");
        mTickColor = bundle.getInt("TICK_COLOR");
        mTickSize = bundle.getFloat("TICK_SIZE");

        mConnectingLineWeight = bundle.getFloat("CONNECTING_LINE_WEIGHT");
        mFirstConnectingLineColor = bundle.getInt("FIRST_CONNECTING_LINE_COLOR");
        mSecondConnectingLineColor = bundle.getInt("SECOND_CONNECTING_LINE_COLOR");

        mSelectorSize = bundle.getFloat("SELECTOR_SIZE");
        mFirstSelectorColor = bundle.getInt("FIRST_SELECTOR_COLOR");
        mSecondSelectorColor = bundle.getInt("SECOND_SELECTOR_COLOR");

        mPinRadius = bundle.getFloat("PIN_RADIUS");
        mExpandedPinRadius = bundle.getFloat("EXPANDED_PIN_RADIUS");
        mPinPadding = bundle.getFloat("PIN_PADDING");
        mIsRangeBar = bundle.getBoolean("IS_RANGE_BAR");
        mArePinsTemporary = bundle.getBoolean("ARE_PINS_TEMPORARY");

        int firstPinIndex = bundle.getInt("FIRST_PIN_INDEX");
        int secondPinIndex = bundle.getInt("SECOND_PIN_INDEX");
        setPinIndices(firstPinIndex, secondPinIndex);

        mMinPinFont = bundle.getFloat("MIN_PIN_FONT");
        mMaxPinFont = bundle.getFloat("MAX_PIN_FONT");

        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
    } else {//www  . j a  v  a  2  s .c  o m
        super.onRestoreInstanceState(state);
    }
}

From source file:de.j4velin.mapsmeasure.Map.java

@Override
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {//  w w  w . ja  v  a 2 s .  co  m
        metric = savedInstanceState.getBoolean("metric");
        @SuppressWarnings("unchecked")
        // Casting to Stack<LatLng> apparently results in
        // "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack"
        // on some devices
        List<LatLng> tmp = (List<LatLng>) savedInstanceState.getSerializable("trace");
        Iterator<LatLng> it = tmp.iterator();
        while (it.hasNext()) {
            addPoint(it.next());
        }
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(savedInstanceState.getDouble("position-lat"),
                        savedInstanceState.getDouble("position-lon")),
                savedInstanceState.getFloat("position-zoom")));
    } catch (Exception e) {
        e.printStackTrace();
    }
}