Example usage for android.os Bundle getDoubleArray

List of usage examples for android.os Bundle getDoubleArray

Introduction

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

Prototype

@Nullable
public double[] getDoubleArray(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.ibm.mf.geofence.demo.MapsActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState != null) {
        double[] loc = savedInstanceState.getDoubleArray("currentLocation");
        if (loc != null) {
            currentLocation = new Location(LocationManager.NETWORK_PROVIDER);
            currentLocation.setLatitude(loc[0]);
            currentLocation.setLongitude(loc[1]);
            currentLocation.setTime(System.currentTimeMillis());
        }//w w w . ja v a  2s. c  om
        currentZoom = savedInstanceState.getFloat("zoom", -1f);
        //log.debug(String.format("restored currentLocation=%s; currentZoom=%f", currentLocation, currentZoom));
    }
}

From source file:com.nextgis.mobile.InputPointActivity.java

@Override
protected void onRestoreInstanceState(Bundle outState) {
    super.onRestoreInstanceState(outState);

    m_sCat = outState.getString("cat");
    m_sSubCat = outState.getString("subcat");
    m_fAzimuth = outState.getFloat("az");
    m_fDist = outState.getFloat("dist");
    m_sNote = outState.getString("note");
    image_lst = outState.getStringArrayList("photos");
    double[] adfAz = outState.getDoubleArray("photos_az");
    for (int i = 0; i < adfAz.length; i++) {
        image_rotation.add(adfAz[i]);/*w  w w . j a v a2s.  com*/
    }
}

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);
    }//from ww w  .ja v  a2  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:com.ibm.mf.geofence.demo.MapsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    log.debug("***************************************************************************************");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps_activity);
    mapCrossHair = (ImageView) findViewById(R.id.map_cross_hair);
    log.debug("in onCreate() tracking is " + (trackingEnabled ? "enabled" : "disabled"));
    addFenceButton = (Button) findViewById(R.id.addFenceButton);
    addFenceButton.setOnClickListener(new View.OnClickListener() {
        @Override//from   w ww .  j av a 2 s .c  om
        public void onClick(View v) {
            switchMode();
        }
    });
    if (savedInstanceState != null) {
        double[] loc = savedInstanceState.getDoubleArray("currentLocation");
        if (loc != null) {
            currentLocation = new Location(LocationManager.NETWORK_PROVIDER);
            currentLocation.setLatitude(loc[0]);
            currentLocation.setLongitude(loc[1]);
            currentLocation.setTime(System.currentTimeMillis());
        }
        currentZoom = savedInstanceState.getFloat("zoom", -1f);
        log.debug(String.format("restored currentLocation=%s; currentZoom=%f", currentLocation, currentZoom));
    }
    if (currentLocation == null) {
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        currentLocation = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }
    log.debug("onCreate() : init of geofencing service");
    /*
    if (!dbDeleted) {
    dbDeleted = true;
    DemoUtils.deleteGeofenceDB(this);
    }
    */
    initManager();
    /*
    // testing the loading from a zip resource
    manager.loadGeofencesFromResource("com/ibm/pisdk/geofencing/geofence_2016-03-18_14_38_04.zip");
    */
    customHttpService = new CustomHttpService(manager, this, SERVER_URL, USER, PWD);
    try {
        startSimulation(geofenceHolder.getFences());
    } catch (Exception e) {
        log.error("error in startSimulation()", e);
    }
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindFragmentArgument(Fragment receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//  ww  w. j a va2 s .c o  m
        FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class);
        if (fragmentArgument != null) {
            try {
                Bundle bundle = receiver.getArguments();
                if (bundle != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, bundle.getBoolean(fragmentArgument.value()));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, bundle.getByte(fragmentArgument.value()));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, bundle.getChar(fragmentArgument.value()));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, bundle.getDouble(fragmentArgument.value()));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, bundle.getFloat(fragmentArgument.value()));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, bundle.getInt(fragmentArgument.value()));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, bundle.getLong(fragmentArgument.value()));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, bundle.getShort(fragmentArgument.value()));
                    } else if (type == String.class) {
                        field.set(receiver, bundle.getString(fragmentArgument.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, bundle.getBooleanArray(fragmentArgument.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, bundle.getByteArray(fragmentArgument.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, bundle.getCharArray(fragmentArgument.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, bundle.getDoubleArray(fragmentArgument.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, bundle.getFloatArray(fragmentArgument.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, bundle.getIntArray(fragmentArgument.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, bundle.getLongArray(fragmentArgument.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, bundle.getShortArray(fragmentArgument.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, bundle.getStringArray(fragmentArgument.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, bundle.getSerializable(fragmentArgument.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, bundle.getBundle(fragmentArgument.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.nekomeshi312.whiteboardcorrection.WhiteBoardCheckFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    if (MyDebug.DEBUG)
        Log.i(LOG_TAG, "onCreateView");
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_white_board_check, container, false);
    final Bundle args = getArguments();
    mArgsOK = true;/*from   w w  w .  j  ava  2 s . c  o  m*/
    if (args == null) {
        mArgsOK = false;
    } else {
        mMyTag = args.getString(TAG_FRAGMENT);
        mFilePath = args.getString(TAG_FILE_PATH);
        mFileName = args.getString(TAG_FILE_NAME);
        mPicWidth = args.getInt(TAG_WIDTH, -1);
        mPicHeight = args.getInt(TAG_HEIGHT, -1);
        mPrevWidth = args.getInt(TAG_PREV_WIDTH, -1);
        mPrevHeight = args.getInt(TAG_PREV_HEIGHT, -1);
        mPreviewPoints = args.getDoubleArray(TAG_WB_POS);
        mIsCaptured = args.getBoolean(TAG_IS_CAPTURED, true);
        if (mFilePath == null) {
            Log.w(LOG_TAG, "Invalid picture path");
            mArgsOK = false;
        }
        if (mFileName == null) {
            Log.w(LOG_TAG, "Invalid picture name");
            mArgsOK = false;
        }
        if (mPicWidth < 0) {
            Log.w(LOG_TAG, "Invalid picture width(" + mPicWidth + ")");
            mArgsOK = false;
        }
        if (mPicHeight < 0) {
            Log.w(LOG_TAG, "Invalid picture height(" + mPicHeight + ")");
            mArgsOK = false;
        }
        if (mPrevWidth < 0) {
            Log.w(LOG_TAG, "Invalid preview width(" + mPrevWidth + ")");
            mArgsOK = false;
        }
        if (mPrevHeight < 0) {
            Log.w(LOG_TAG, "Invalid preview height(" + mPrevHeight + ")");
            mArgsOK = false;
        }

        if (MyDebug.DEBUG) {
            Log.d(LOG_TAG, "FilePath = " + mFilePath);
            Log.d(LOG_TAG, "FileName = " + mFileName);
            Log.d(LOG_TAG, "PicWidth = " + mPicWidth);
            Log.d(LOG_TAG, "PicHeight = " + mPicHeight);
            Log.d(LOG_TAG, "PreviewWidth = " + mPrevWidth);
            Log.d(LOG_TAG, "PreviewHeight = " + mPrevHeight);
            if (mPreviewPoints == null) {
                Log.d(LOG_TAG, "mPreviewPoints = null");
            } else {
                for (int i = 0; i < 4; i++) {
                    Log.d(LOG_TAG, "PrevPoints(" + i + ") = " + mPreviewPoints[i * 2] + ":"
                            + mPreviewPoints[i * 2 + 1]);
                }
            }
        }
    }
    ActionBar actionBar = ((SherlockFragmentActivity) mParentActivity).getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    mCapturedImageView = (ImageView) root.findViewById(R.id.captured_image);
    mWBCorrectionView = (WhiteBoardAreaView) root.findViewById(R.id.whiteboard_area_correction_view);
    mWBCorrectionView.setDraggable(true);
    mWBCheckViewBase = (FrameLayout) root.findViewById(R.id.area_check_view_base);
    mWBCheckViewBase.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {//?view?????????
            // TODO Auto-generated method stub
            if (mIsFirstOnGlobalLayout) {
                //jpeg?WB???
                mIsFirstOnGlobalLayout = false;
                LoadJpegFileAsyncTask loadJpegTask = new LoadJpegFileAsyncTask();
                loadJpegTask.execute();
            }
        }

    });
    return root;
}

From source file:com.facebook.LegacyTokenCacheTest.java

@Test
public void testAllTypes() {
    Bundle originalBundle = new Bundle();

    putBoolean(BOOLEAN_KEY, originalBundle);
    putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle);
    putByte(BYTE_KEY, originalBundle);/*  w w w.  jav a  2s.  c  om*/
    putByteArray(BYTE_ARRAY_KEY, originalBundle);
    putShort(SHORT_KEY, originalBundle);
    putShortArray(SHORT_ARRAY_KEY, originalBundle);
    putInt(INT_KEY, originalBundle);
    putIntArray(INT_ARRAY_KEY, originalBundle);
    putLong(LONG_KEY, originalBundle);
    putLongArray(LONG_ARRAY_KEY, originalBundle);
    putFloat(FLOAT_KEY, originalBundle);
    putFloatArray(FLOAT_ARRAY_KEY, originalBundle);
    putDouble(DOUBLE_KEY, originalBundle);
    putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle);
    putChar(CHAR_KEY, originalBundle);
    putCharArray(CHAR_ARRAY_KEY, originalBundle);
    putString(STRING_KEY, originalBundle);
    putStringList(STRING_LIST_KEY, originalBundle);
    originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB);

    ensureApplicationContext();

    LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application);
    cache.save(originalBundle);

    LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application);
    Bundle cachedBundle = cache2.load();

    assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY));
    assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY),
            cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY));
    assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY));
    assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY));
    assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY));
    assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY),
            cachedBundle.getShortArray(SHORT_ARRAY_KEY));
    assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY));
    assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY));
    assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY));
    assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY));
    assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY),
            TestUtils.DOUBLE_EQUALS_DELTA);
    assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY),
            cachedBundle.getFloatArray(FLOAT_ARRAY_KEY));
    assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY),
            TestUtils.DOUBLE_EQUALS_DELTA);
    assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY),
            cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY));
    assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY));
    assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY));
    assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY));
    assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY),
            cachedBundle.getStringArrayList(STRING_LIST_KEY));
    assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY),
            cachedBundle.getSerializable(SERIALIZABLE_KEY));
}

From source file:ru.moscow.tuzlukov.sergey.weatherlog.MainActivity.java

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

    preferences = getSharedPreferences("preferences", MODE_PRIVATE);
    cityId = preferences.getInt(NetworkQuery.Params.ID, NetworkQuery.Defaults.CITY_ID);
    cachingTimestamp = preferences.getLong(CACHE_TIMESTAMP, 0L);

    tvTemperatureLimit1 = (TextView) findViewById(R.id.tvTemperatureLimit1);
    tvTemperatureLimit2 = (TextView) findViewById(R.id.tvTemperatureLimit2);
    tvTime1Limit1 = (TextView) findViewById(R.id.tvTime1Limit1);
    tvTime1Limit2 = (TextView) findViewById(R.id.tvTime1Limit2);
    tvTime2Limit1 = (TextView) findViewById(R.id.tvTime2Limit1);
    tvTime2Limit2 = (TextView) findViewById(R.id.tvTime2Limit2);
    tvDayTemperatureSpan = (TextView) findViewById(R.id.tvDayTemperatureSpan);
    tvDayAverageTemperature = (TextView) findViewById(R.id.tvDayAverageTemperature);
    tvDayMedianTemperature = (TextView) findViewById(R.id.tvDayMedianTemperature);
    graphView = (GraphView) findViewById(R.id.graph);
    llLoader = (LinearLayout) findViewById(R.id.llLoader);
    ptrLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);

    resetValues();/*w w w .  j a  v a2 s.  c  om*/

    ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(new OnRefreshListener() {
        @Override
        public void onRefreshStarted(View view) {
            networkQuery.cancelAllRequests(MainActivity.this);
            refreshWeatherData();
        }
    }).setup(ptrLayout);

    String appId = preferences.getString(NetworkQuery.Params.APPID, "");
    networkQuery = NetworkQuery.getInstance(getApplicationContext());
    networkQuery.setAppId(appId);

    registerDialog = new SettingsActivity.RegisterDialog(this, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String appId = registerDialog.getEtAppId().getText().toString().trim();
            networkQuery.setAppId(appId);
            preferences.edit().putString(NetworkQuery.Params.APPID, appId).apply();
            cachingTimestamp = 0;
            refreshWeatherData();
        }
    });

    if (savedInstanceState == null) {
        refreshWeatherData();
        if (preferences.getBoolean(IS_FIRST_LAUNCH, true)) {
            registerDialog.show();
            preferences.edit().putBoolean(IS_FIRST_LAUNCH, false).apply();
        }
    } else {
        currentTime = savedInstanceState.getLong(SAVED_CURRENT_TIME);
        currentTimeMinus12h = savedInstanceState.getLong(SAVED_CURRENT_TIME_MINUS_12);
        currentTimeMinus24h = savedInstanceState.getLong(SAVED_CURRENT_TIME_MINUS_24);
        currentIsGained = savedInstanceState.getBoolean(SAVED_CURRENT_GAINED);
        historyIsGained = savedInstanceState.getBoolean(SAVED_HISTORY_GAINED);
        long[] timeArray = savedInstanceState.getLongArray(SAVED_TIME_ARRAY);
        double[] tempArray = savedInstanceState.getDoubleArray(SAVED_TEMP_ARRAY);
        boolean refreshWasRun = savedInstanceState.getBoolean(SAVED_LOADER_VISIBILITY) || refreshWasCancelled;
        if (refreshWasRun || (timeArray == null || tempArray == null))
            refreshWeatherData();
        else {
            temperatureMap.clear();
            for (int i = 0; i < timeArray.length && i < tempArray.length; i++)
                temperatureMap.put(timeArray[i], tempArray[i]);
            processValues(true);
        }
        if (savedInstanceState.getBoolean(SAVED_DIALOG_VISIBILITY)) {
            registerDialog.getEtAppId().setText(savedInstanceState.getString(SAVED_DIALOG_APPID));
            registerDialog.show();
        }
    }
}