Example usage for android.os Bundle getDouble

List of usage examples for android.os Bundle getDouble

Introduction

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

Prototype

public double getDouble(String key) 

Source Link

Document

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

Usage

From source file:net.alexjf.tmm.fragments.ImmedTransactionStatsFragment.java

@Override
public void onAsyncTaskResultSuccess(String taskId, Bundle resultData) {
    for (SimpleSeriesRenderer simpleRenderer : renderer.getSeriesRenderers()) {
        renderer.removeSeriesRenderer(simpleRenderer);
    }/* w w  w  .ja va2 s.c  o m*/

    dataSet.clear();
    catPercentageAdapter.clear();
    catPercentageAdapter.setNotifyOnChange(false);

    String currencyCode = resultData.getString(KEY_CURRENCY);
    CurrencyUnit currency;

    if (currencyCode == null) {
        currency = CurrencyUnit.EUR;
    } else {
        currency = CurrencyUnit.getInstance(currencyCode);
    }
    Category[] categories = (Category[]) resultData.getParcelableArray(KEY_CATEGORIES);
    double[] values = resultData.getDoubleArray(KEY_VALUES);
    double totalValue = resultData.getDouble(KEY_TOTALVALUE);

    for (int i = 0; i < categories.length; i++) {
        Category category = categories[i];
        double categoryTotalValue = values[i];
        int color = colors[(categories.length - i - 1) % colors.length];
        dataSet.add(category.getName(), categoryTotalValue);
        catPercentageAdapter.add(new CategoryPercentageInfo(category,
                Money.of(currency, categoryTotalValue, RoundingMode.HALF_EVEN), categoryTotalValue / totalValue,
                color));
        SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();
        seriesRenderer.setColor(color);
        renderer.addSeriesRenderer(seriesRenderer);
    }

    catPercentageAdapter.sort(new CategoryPercentageInfo.PercentageComparator(true));
    catPercentageAdapter.notifyDataSetChanged();

    if (chartView != null) {
        chartView.repaint();
    }
    categoryStatsTask = null;
    Utils.allowOrientationChanges(getActivity());
}

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

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

    Activity activity = getActivity();//from   w  ww.  j  a  v a  2s  .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:uk.org.rivernile.edinburghbustracker.android.fragments.general.BusStopMapFragment.java

/**
 * {@inheritDoc}//from  www  .j  a  v a  2 s . c o 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:com.rappsantiago.weighttracker.profile.setup.ProfileSetupSummaryFragment.java

public void refreshProfileData(Bundle profileData) {
    if (profileData.containsKey(NameBirthdayGenderFragment.KEY_NAME)) {
        mName.setText(profileData.getString(NameBirthdayGenderFragment.KEY_NAME));
    }/*from w  w  w.j  a v a 2 s .  c o  m*/

    if (profileData.containsKey(NameBirthdayGenderFragment.KEY_BIRTHDAY)) {
        long birthdayInMillis = profileData.getLong(NameBirthdayGenderFragment.KEY_BIRTHDAY);
        mBirthday.setText(DisplayUtil.getReadableDate(birthdayInMillis));
    }

    if (profileData.containsKey(NameBirthdayGenderFragment.KEY_GENDER)) {
        String gender = profileData.getString(NameBirthdayGenderFragment.KEY_GENDER);
        mGender.setText(DisplayUtil.getReadableGender(getContext(), gender));
    }

    if (profileData.containsKey(WeightHeightFragment.KEY_WEIGHT)
            && profileData.containsKey(WeightHeightFragment.KEY_WEIGHT_UNIT)) {

        String weightUnit = profileData.getString(WeightHeightFragment.KEY_WEIGHT_UNIT);
        double weight = profileData.getDouble(WeightHeightFragment.KEY_WEIGHT);
        mWeight.setText(DisplayUtil.getFormattedWeight(getContext(), weight, weightUnit));
    }

    if (profileData.containsKey(WeightHeightFragment.KEY_BODY_FAT_INDEX)) {
        double bodyFatIndex = profileData.getDouble(WeightHeightFragment.KEY_BODY_FAT_INDEX);
        mBodyFatIndex.setText(bodyFatIndex + "%");
    }

    if (profileData.containsKey(WeightHeightFragment.KEY_HEIGHT)
            && profileData.containsKey(WeightHeightFragment.KEY_HEIGHT_UNIT)) {

        double height = profileData.getDouble(WeightHeightFragment.KEY_HEIGHT);
        String heightUnit = profileData.getString(WeightHeightFragment.KEY_HEIGHT_UNIT);
        double heightInches = 0.0;

        if (profileData.containsKey(WeightHeightFragment.KEY_HEIGHT_INCHES)) {
            heightInches = profileData.getDouble(WeightHeightFragment.KEY_HEIGHT_INCHES);
        }

        mHeight.setText(DisplayUtil.getFormattedHeight(getContext(), height, heightInches, heightUnit));
    }

    if (profileData.containsKey(SetGoalsFragment.KEY_TARGET_WEIGHT)) {
        String weightUnit = profileData.getString(WeightHeightFragment.KEY_WEIGHT_UNIT);
        double targetWeight = profileData.getDouble(SetGoalsFragment.KEY_TARGET_WEIGHT);
        mTargetWeight.setText(DisplayUtil.getFormattedWeight(getContext(), targetWeight, weightUnit));
    }

    if (profileData.containsKey(SetGoalsFragment.KEY_TARGET_BODY_FAT_INDEX)) {
        double targetBodyFatIndex = profileData.getDouble(SetGoalsFragment.KEY_TARGET_BODY_FAT_INDEX);
        mTargetBodyFatIndex.setText(targetBodyFatIndex + "%");
    }

    if (profileData.containsKey(SetGoalsFragment.KEY_DUE_DATE)) {
        long dueDateInMillis = profileData.getLong(SetGoalsFragment.KEY_DUE_DATE);

        if (0 < dueDateInMillis) {
            mDueDate.setText(DisplayUtil.getReadableDate(dueDateInMillis));
        } else {
            mDueDate.setText(R.string.not_applicable);
        }
    }
}

From source file:org.xbmc.kore.ui.AlbumDetailsFragment.java

@TargetApi(21)
@Override//from  w ww . j av a 2 s. co m
protected View createView(LayoutInflater inflater, ViewGroup container) {
    albumId = getArguments().getInt(BUNDLE_KEY_ALBUMID, -1);

    if ((container == null) || (albumId == -1)) {
        // We're not being shown or there's nothing to show
        return null;
    }

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_album_details, container, false);
    ButterKnife.inject(this, root);

    hostManager = HostManager.getInstance(getActivity());
    hostInfo = hostManager.getHostInfo();

    // Setup dim the fanart when scroll changes. Full dim on 4 * iconSize dp
    Resources resources = getActivity().getResources();
    final int pixelsToTransparent = 4 * resources.getDimensionPixelSize(R.dimen.default_icon_size);
    mediaPanel.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            float y = mediaPanel.getScrollY();
            float newAlpha = Math.min(1, Math.max(0, 1 - (y / pixelsToTransparent)));
            mediaArt.setAlpha(newAlpha);
        }
    });

    FloatingActionButton fab = (FloatingActionButton) fabButton;
    fab.attachToScrollView((ObservableScrollView) mediaPanel);

    Bundle bundle = getArguments();

    if (Utils.isLollipopOrLater()) {
        mediaPoster.setTransitionName(bundle.getString(POSTER_TRANS_NAME));
    }

    mediaTitle.setText(bundle.getString(BUNDLE_KEY_ALBUMTITLE));
    mediaUndertitle.setText(bundle.getString(BUNDLE_KEY_ALBUMARTIST));
    setMediaYear(bundle.getString(BUNDLE_KEY_ALBUMGENRE), bundle.getInt(BUNDLE_KEY_ALBUMYEAR));
    setMediaRating(bundle.getDouble(BUNDLE_KEY_ALBUMRATING));

    // Pad main content view to overlap with bottom system bar
    //        UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true);
    //        mediaPanel.setClipToPadding(false);

    return root;
}

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;
        }//ww w.java2  s .  c  o  m

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

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

From source file:com.aegiswallet.actions.MainActivity.java

private void initiateHandlers(final TextView wallet_balance) {
    balanceHandler = new Handler() {
        @Override//from   www.ja va2  s .c o  m
        public void handleMessage(Message msg) {

            final long now = System.currentTimeMillis();
            boolean shouldNotify = false;

            //If the last view update time is less than one second ago we don't do anything.
            //This is to stop the app from crashing.
            if (now - lastViewUpdateTime.get() < 1500) {
                shouldNotify = false;
            } else
                shouldNotify = true;

            Bundle data = msg.getData();

            int status = data.getInt("status");
            switch (status) {
            case Constants.WALLET_UPDATE_COINS_RECEIVED:
                Double amountReceived = data.getDouble("amount");
                notifyCoinsReceivedOrSent(amountReceived, true);
                if (shouldNotify) {
                    updateMainViews();
                }
                break;
            case Constants.WALLET_UPDATE_COINS_SENT:
                Double amountSent = data.getDouble("amount");
                notifyCoinsReceivedOrSent(amountSent, false);
                if (shouldNotify)
                    updateMainViews();
                break;
            case Constants.WALLET_UPDATE_REORGANIZED:
                //Do something upon reorg?
                //updateMainViews();
                if (shouldNotify)
                    updateMainViews();
                break;
            case Constants.WALLET_UPDATE_TRANS_CONFIDENCE:
                if (shouldNotify) {
                    updateMainViews();
                }
                break;
            case Constants.WALLET_UPDATE_CHANGED:
                //Do something upon change?
                if (shouldNotify) {
                    checkWalletEncryptionStatus();
                    updateMainViews();
                }
                break;
            case Constants.WALLET_UPDATE_KEYS_ADDED:
                if (shouldNotify) {
                    updateMainViews();
                }
                break;
            default:
                break;
            }
        }
    };
}

From source file:com.hro.museapp.map.ClusteringMapActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cluster_map);

    listType = getIntent().getIntExtra("type", TYPE_ALL);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    FragmentManager fm = getSupportFragmentManager();
    SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map);
    map = f.getExtendedMap();/*from  www .  j  ava2  s .com*/

    gps = new GPSTracker(ClusteringMapActivity.this);
    //gps = PlacesLoader.getGPS();

    // mapView = (MapView) this.findViewById(R.id.map);

    float cameraZoom = 8;
    LatLng cameraLatLng = new LatLng(52.281602, 5.503235);
    if (savedInstanceState != null) {
        double savedLat = savedInstanceState.getDouble("lat");
        double savedLng = savedInstanceState.getDouble("lng");
        cameraLatLng = new LatLng(savedLat, savedLng);

        cameraZoom = savedInstanceState.getFloat("zoom", 12);
    }
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, cameraZoom));

    map.setClustering(new ClusteringSettings().iconDataProvider(new DemoIconProvider(getResources()))
            .addMarkersDynamically(true));
    map.setMyLocationEnabled(true);

    map.setInfoWindowAdapter(new InfoWindowAdapter() {

        private TextView tv;
        {
            tv = new TextView(ClusteringMapActivity.this);
            tv.setTextColor(Color.BLACK);
        }

        private Collator collator = Collator.getInstance();
        private Comparator<Marker> comparator = new Comparator<Marker>() {
            public int compare(Marker lhs, Marker rhs) {
                String leftTitle = lhs.getTitle();
                String rightTitle = rhs.getTitle();
                if (leftTitle == null && rightTitle == null) {
                    return 0;
                }
                if (leftTitle == null) {
                    return 1;
                }
                if (rightTitle == null) {
                    return -1;
                }
                return collator.compare(leftTitle, rightTitle);
            }
        };

        @Override
        public View getInfoWindow(Marker marker) {
            return null;
        }

        @Override
        public View getInfoContents(Marker marker) {
            if (marker.isCluster()) {
                List<Marker> markers = marker.getMarkers();
                int i = 0;
                String text = "";
                while (i < 3 && markers.size() > 0) {
                    Marker m = Collections.min(markers, comparator);
                    String title = m.getTitle();
                    if (title == null) {
                        break;
                    }
                    text += title + "\n";
                    markers.remove(m);
                    i++;
                }
                if (text.length() == 0) {
                    text = "Markers with mutable data";
                } else if (markers.size() > 0) {
                    text += "and " + markers.size() + " more...";
                } else {
                    text = text.substring(0, text.length() - 1);
                }
                tv.setText(text);
                return tv;
            } else {
                String title = marker.getTitle();
                tv.setText(title);
                return tv;
            }
        }
    });

    map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker marker) {
            if (marker.isCluster()) {
                List<Marker> markers = marker.getMarkers();
                Builder builder = LatLngBounds.builder();
                for (Marker m : markers) {
                    builder.include(m.getPosition());
                }
                LatLngBounds bounds = builder.build();
                map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,
                        getResources().getDimensionPixelSize(R.dimen.padding)));
            } else {
                // String title = marker.getTitle();
                // String mid = MarkerGenerator.mapPlaceToId.get(title);
                String mid = (String) marker.getData();

                Intent in = new Intent(getApplicationContext(), ShowPlaceActivity.class);
                // sending mid to next activity
                in.putExtra(MarkerGenerator.TAG_MID, mid);

                // starting new activity and expecting some response back
                startActivityForResult(in, 100);
            }
        }
    });

    // MarkerGenerator.addMarkers(map);
    new AddMarkersInBackground().execute();

}

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

/**
 * Move the camera to the initial location. The initial location is
 * determined by the following order;/*from   www .  ja va2s  .com*/
 * 
 * - If the args contains a stopCode, go there.
 * - If the args contains a latitude AND a longitude, go there.
 * - If the SharedPreferences have mappings for a previous location, then
 *   go there.
 * - Otherwise, go to the default map location, as defined by
 *   {@link #DEFAULT_LAT} and {@link #DEFAULT_LONG) at
 *   {@link #DEFAULT_ZOOM}.
 */
private void moveCameraToInitialLocation() {
    final Bundle args = getArguments();

    if (args != null && args.containsKey(ARG_STOPCODE)) {
        moveCameraToBusStop(args.getString(ARG_STOPCODE));
        args.remove(ARG_STOPCODE);
    } else if (args != null && args.containsKey(ARG_LATITUDE) && args.containsKey(ARG_LONGITUDE)) {
        moveCameraToLocation(new LatLng(args.getDouble(ARG_LATITUDE), args.getDouble(ARG_LONGITUDE)),
                DEFAULT_SEARCH_ZOOM, false);
        args.remove(ARG_LATITUDE);
        args.remove(ARG_LONGITUDE);
    } else if (map != null) {
        // The Lat/Lons have to be treated as Strings because
        // SharedPreferences has no support for doubles.
        final String latitude = sp.getString(PreferencesActivity.PREF_MAP_LAST_LATITUDE,
                String.valueOf(DEFAULT_LAT));
        final String longitude = sp.getString(PreferencesActivity.PREF_MAP_LAST_LONGITUDE,
                String.valueOf(DEFAULT_LONG));
        final float zoom = sp.getFloat(PreferencesActivity.PREF_MAP_LAST_ZOOM, DEFAULT_ZOOM);

        try {
            moveCameraToLocation(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude)), zoom,
                    false);
        } catch (NumberFormatException e) {
            moveCameraToLocation(new LatLng(DEFAULT_LAT, DEFAULT_LONG), DEFAULT_ZOOM, false);
        }
    }
}

From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java

private void executeState(Bundle bundle) {
    if (bundle == null) {
        return;// w  w  w  .j a va  2 s . c o m
    }

    mHeightFull = bundle.getBoolean(Extra.MAP_HEIGHT_FULL, false);

    boolean doRequest = false;
    boolean doCenter = false;
    GeoPoint centerPoint = null;
    int zoom = 0;

    if (bundle.containsKey(Extra.REQUEST)) {
        doRequest = true;
    }

    if (bundle.containsKey(Extra.CENTER_MAP)) {
        double lat = bundle.getDouble(Extra.LATITUDE);
        double lon = bundle.getDouble(Extra.LONGITUDE);
        zoom = bundle.getInt(Extra.ZOOM_MAP, MAP_ZOOM_DEFAULT);
        centerPoint = new GeoPoint(lat, lon);
        doCenter = true;
    }

    if (doCenter || doRequest) {
        executeMapDeferred(centerPoint, zoom, doCenter, doRequest);
    }
}