List of usage examples for android.os Bundle putDoubleArray
public void putDoubleArray(@Nullable String key, @Nullable double[] value)
From source file:com.facebook.LegacyTokenCacheTest.java
private static void putDoubleArray(String key, Bundle bundle) { int length = random.nextInt(50); double[] array = new double[length]; for (int i = 0; i < length; i++) { array[i] = random.nextDouble();/*w w w . j a v a 2s . com*/ } bundle.putDoubleArray(key, array); }
From source file:Main.java
@SuppressWarnings("unchecked") private static void putArray(String key, ArrayList arrayList, Bundle bundle) { if (arrayList.size() == 0) { bundle.putBooleanArray(key, new boolean[] {}); } else {//from w ww .ja va 2 s. c o m verifyArrayListIsSingleType(arrayList); if (arrayList.get(0) instanceof String) { bundle.putStringArray(key, toStringArray((ArrayList<String>) arrayList)); } else if (arrayList.get(0) instanceof Integer) { bundle.putIntArray(key, toIntArray((ArrayList<Integer>) arrayList)); } else if (arrayList.get(0) instanceof Float) { bundle.putFloatArray(key, toFloatArray((ArrayList<Float>) arrayList)); } else if (arrayList.get(0) instanceof Double) { bundle.putDoubleArray(key, toDoubleArray((ArrayList<Double>) arrayList)); } else if (arrayList.get(0) instanceof Boolean) { bundle.putBooleanArray(key, toBooleanArray((ArrayList<Boolean>) arrayList)); } else if (arrayList.get(0) instanceof HashMap) { bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList)); } else if (arrayList.get(0) instanceof ArrayList) { Log.w("RNNavigation", "Arrays of arrays passed in props are converted to dictionaries with indexes as keys"); Bundle innerArray = new Bundle(); for (int i = 0; i < arrayList.size(); i++) { putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray); } bundle.putParcelable(key, innerArray); } } }
From source file:com.money.manager.ex.home.DashboardFragment.java
private void showChartIncomeVsExpensesCurrentMonth(Cursor cursor) { // move to first if (!cursor.moveToFirst()) return;//from ww w . j a v a 2s . c o m // arrays double[] incomes = new double[3]; double[] expenses = new double[3]; String[] titles = new String[3]; // incomes and expenses incomes[1] = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income)); expenses[1] = Math.abs(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses))); // titles int year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR)); int month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month)); // format month // Calendar calendar = Calendar.getInstance(); // calendar.set(year, month - 1, 1); MmxDate dateTime = new MmxDate(year, month - 1, 1); // titles // titles[1] = Integer.toString(year) + "-" + new SimpleDateFormat("MMM").format(calendar.getTime()); titles[1] = Integer.toString(year) + "-" + dateTime.toString("MMM"); // compose bundle for arguments Bundle args = new Bundle(); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_EXPENSES_VALUES, expenses); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_INCOME_VALUES, incomes); args.putStringArray(IncomeVsExpensesChartFragment.KEY_XTITLES, titles); args.putString(IncomeVsExpensesChartFragment.KEY_TITLE, getString(R.string.income_vs_expenses_current_month)); args.putBoolean(IncomeVsExpensesChartFragment.KEY_DISPLAY_AS_UP_ENABLED, false); // get fragment manager FragmentManager fragmentManager = getChildFragmentManager(); if (fragmentManager != null) { IncomeVsExpensesChartFragment fragment; fragment = new IncomeVsExpensesChartFragment(); fragment.setChartArguments(args); if (fragment.isVisible()) fragment.onResume(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.linearLayoutScreen1, fragment, IncomeVsExpensesChartFragment.class.getSimpleName()); fragmentTransaction.commit(); } }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
private void showChartInternal() { // take a adapter and cursor IncomeVsExpensesAdapter adapter = ((IncomeVsExpensesAdapter) getListAdapter()); if (adapter == null) return;/*from w w w . ja va 2 s .c o m*/ Cursor cursor = adapter.getCursor(); if (cursor == null) return; // Move to the first record. if (cursor.getCount() <= 0) return; // arrays ArrayList<Double> incomes = new ArrayList<>(); ArrayList<Double> expenses = new ArrayList<>(); ArrayList<String> titles = new ArrayList<>(); // Reset cursor to initial position. cursor.moveToPosition(-1); // cycle cursor while (cursor.moveToNext()) { int month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month)); // check if not subtotal if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) { // incomes and expenses incomes.add(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income))); expenses.add( Math.abs(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)))); // titles int year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR)); // format month Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, 1); // titles titles.add(Integer.toString(year) + "-" + new SimpleDateFormat("MMM").format(calendar.getTime())); } } //compose bundle for arguments Bundle args = new Bundle(); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_EXPENSES_VALUES, ArrayUtils.toPrimitive(expenses.toArray(new Double[0]))); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_INCOME_VALUES, ArrayUtils.toPrimitive(incomes.toArray(new Double[0]))); args.putStringArray(IncomeVsExpensesChartFragment.KEY_XTITLES, titles.toArray(new String[titles.size()])); //get fragment manager FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); if (fragmentManager != null) { IncomeVsExpensesChartFragment fragment; fragment = (IncomeVsExpensesChartFragment) fragmentManager .findFragmentByTag(IncomeVsExpensesChartFragment.class.getSimpleName()); if (fragment == null) { fragment = new IncomeVsExpensesChartFragment(); } fragment.setChartArguments(args); fragment.setDisplayHomeAsUpEnabled(true); if (fragment.isVisible()) fragment.onResume(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (((IncomeVsExpensesActivity) getActivity()).mIsDualPanel) { fragmentTransaction.replace(R.id.fragmentChart, fragment, IncomeVsExpensesChartFragment.class.getSimpleName()); } else { fragmentTransaction.replace(R.id.fragmentMain, fragment, IncomeVsExpensesChartFragment.class.getSimpleName()); fragmentTransaction.addToBackStack(null); } fragmentTransaction.commit(); } }
From source file:com.ibm.mf.geofence.demo.MapsActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (currentLocation != null) { outState.putDoubleArray("currentLocation", new double[] { currentLocation.getLatitude(), currentLocation.getLongitude() }); }// w w w . j av a2s.c o m if (googleMap != null) { outState.putFloat("zoom", googleMap.getCameraPosition().zoom); } //log.debug("onSaveInstanceState()"); }
From source file:com.softminds.matrixcalculator.base_activities.FillingMatrix.java
public void MakeType(Type type) { switch (type) { case Null:/*w ww. ja v a 2 s.c o m*/ for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { EditText editText = findViewById(i * 10 + j); editText.setText(String.valueOf(0.0)); } double variable[][] = GetIntoFloat(); Bundle bundle = new Bundle(); bundle.putAll(getIntent().getExtras()); //bundle.putSerializable("VALUES",variable); bundle.putDoubleArray("VALUES", MatrixV2.flattenValues(variable, getIntent().getIntExtra("ROW", -1), getIntent().getIntExtra("COL", -1))); Intent intnt = new Intent(); intnt.putExtras(bundle); setResult(0, intnt); finish(); break; case Diagonal: for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { EditText editText = findViewById(i * 10 + j); if (i != j) { editText.setText(String.valueOf(0.0)); } } break; case Identity: for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { EditText editText = findViewById(i * 10 + j); if (i == j) editText.setText(String.valueOf(1.0)); else editText.setText(String.valueOf(0.0)); } double vari[][] = GetIntoFloat(); Bundle bundle2 = new Bundle(); bundle2.putAll(getIntent().getExtras()); //bundle2.putSerializable("VALUES",vari); bundle2.putDoubleArray("VALUES", MatrixV2.flattenValues(vari, getIntent().getIntExtra("ROW", -1), getIntent().getIntExtra("COL", -1))); Intent intn = new Intent(); intn.putExtras(bundle2); setResult(0, intn); finish(); break; } }
From source file:com.softminds.matrixcalculator.base_activities.FillingMatrix.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.ConfirmCreate: if (!MatrixError()) { double variable[][] = GetIntoFloat(); Bundle bundle = new Bundle(); bundle.putAll(getIntent().getExtras()); //bundle.putSerializable("VALUES",variable); bundle.putDoubleArray("VALUES", MatrixV2.flattenValues(variable, getIntent().getIntExtra("ROW", -1), getIntent().getIntExtra("COL", -1))); Intent intnt = new Intent(); intnt.putExtras(bundle);//from w ww. j a v a2 s . co m setResult(0, intnt); finish(); return true; } else break; case R.id.Input1Empty: EmptyInput(1); return true; case R.id.ClearAll: ClearAllValues(); return true; case R.id.FillAllZero: EmptyInput(0); return true; case R.id.InputRandom: InputRandomInt(); return true; case R.id.InputRandomFloat: if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("DECIMAL_USE", true)) Toast.makeText(getApplicationContext(), R.string.AllowDecimals, Toast.LENGTH_SHORT).show(); else InputRandomFloat(); return true; case R.id.FillCustom: startActivityForResult(new Intent(getApplicationContext(), CustomValueFiller.class), RESULT); return true; } return super.onOptionsItemSelected(item); }
From source file:com.nekomeshi312.whiteboardcorrection.WhiteBoardCheckFragment.java
public static WhiteBoardCheckFragment newInstance(String tag, WhiteBoardCheckInfo checkInfo) { WhiteBoardCheckFragment frag = new WhiteBoardCheckFragment(); Bundle args = new Bundle(); args.putString(TAG_FRAGMENT, tag);//from w w w .j av a 2s.com args.putString(TAG_FILE_PATH, checkInfo.mFilePath); args.putString(TAG_FILE_NAME, checkInfo.mFileName); args.putInt(TAG_WIDTH, checkInfo.mPicWidth); args.putInt(TAG_HEIGHT, checkInfo.mPicHeight); args.putInt(TAG_PREV_WIDTH, checkInfo.mPrevWidth); args.putInt(TAG_PREV_HEIGHT, checkInfo.mPrevHeight); args.putBoolean(TAG_IS_CAPTURED, checkInfo.mIsCaptured); if (checkInfo.mDetectedPoints != null) { double[] points = new double[8]; for (int i = 0; i < 4; i++) { points[i * 2 + 0] = checkInfo.mDetectedPoints.get(i).x; points[i * 2 + 1] = checkInfo.mDetectedPoints.get(i).y; } args.putDoubleArray(TAG_WB_POS, points); } frag.setArguments(args); return frag; }
From source file:me.xiaopan.android.inject.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView = new ListView(getBaseContext()); setContentView(listView);/*from w ww . ja v a 2 s . c om*/ // SharedPreferences? PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true); PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f); PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000); PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000); PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String"); Set<String> stringSet = new HashSet<String>(); stringSet.add("String Set 1"); stringSet.add("String Set 2"); stringSet.add("String Set 3"); stringSet.add("String Set 4"); PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet); MyBean bean2 = new MyBean(); bean2.setEmail("sky@xiaopan.me2"); bean2.setName("?2"); bean2.setSex("2"); PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2); PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name()); // ?? String[] items = new String[] { "", "?", "FragmentDialog", "InjectAdapter", "InjectExpandableListAdapter" }; listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, android.R.id.text1, items)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= 2) { Bundle bundle = new Bundle(); bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true); bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true }); bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110); bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 }); bundle.putChar(MainActivity.PARAM_CHAR, 'R'); bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' }); bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence"); bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY, new CharSequence[] { "Char", " ", "Sequence" }); bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d); bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d }); bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f); bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f }); bundle.putInt(MainActivity.PARAM_INT, 120); bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, }); bundle.putLong(MainActivity.PARAM_LONG, 12345); bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 }); bundle.putShort(MainActivity.PARAM_SHORT, (short) 2); bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 }); bundle.putString(MainActivity.PARAM_STRING, "String"); bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY, new String[] { "String1", "String2", "String3" }); // ??JSONBundle MyBean bean = new MyBean(); bean.setEmail("sky@xiaopan.me"); bean.setName("?"); bean.setSex(""); bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean)); bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name()); // ArrayList<String> stringList = new ArrayList<String>(); stringList.add("ArrayList String 1"); stringList.add("ArrayList String 2"); stringList.add("ArrayList String 3"); bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList); switch (position) { case 0: Second.SECOND_CHRONOGRAPH.lap(); Intent intent = new Intent(getBaseContext(), InjectTestActivity.class); intent.putExtras(bundle); startActivity(intent); break; case 1: Second.SECOND_CHRONOGRAPH.lap(); Intent intent2 = new Intent(getBaseContext(), NormalActivity.class); intent2.putExtras(bundle); startActivity(intent2); break; case 2: Second.SECOND_CHRONOGRAPH.lap(); new TestDialogFragment().show(getSupportFragmentManager(), ""); break; } } else { Class<?> targetClass = null; if (position == 3) { targetClass = InjectAdapterActivity.class; } else if (position == 4) { targetClass = InjectExpandableListAdapterActivity.class; } if (targetClass != null) { startActivity(new Intent(getBaseContext(), targetClass)); } } } }); }
From source file:com.nextgis.mobile.InputPointActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (descriptfrag != null) descriptfrag.onStoreValues();//from w w w. j av a 2 s . co m if (positionfrag != null) positionfrag.onStoreValues(); if (camfrag != null) camfrag.onStoreValues(); if (notefrag != null) notefrag.onStoreValues(); outState.putString("cat", m_sCat); outState.putString("subcat", m_sSubCat); outState.putFloat("az", m_fAzimuth); outState.putFloat("dist", m_fDist); outState.putString("note", m_sNote); outState.putStringArrayList("photos", image_lst); int nAzArraySize = image_rotation.size(); double[] adfAz = new double[nAzArraySize]; for (int i = 0; i < nAzArraySize; i++) adfAz[i] = image_rotation.get(i); outState.putDoubleArray("photos_az", adfAz); }