Java Code Examples for android.os.Bundle.putIntArray()

The following are Jave code examples for showing how to use putIntArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: SubwayTooter   File: ColorPickerDialog.java   View Source Code Vote up 6 votes
/**
 * Create the {@link ColorPickerDialog} instance.
 *
 * @return A new {@link ColorPickerDialog}.
 * @see #show(Activity)
 */
public ColorPickerDialog create() {
  ColorPickerDialog dialog = new ColorPickerDialog();
  Bundle args = new Bundle();
  args.putInt(ARG_ID, dialogId);
  args.putInt(ARG_TYPE, dialogType);
  args.putInt(ARG_COLOR, color);
  args.putIntArray(ARG_PRESETS, presets);
  args.putBoolean(ARG_ALPHA, showAlphaSlider);
  args.putBoolean(ARG_ALLOW_CUSTOM, allowCustom);
  args.putBoolean(ARG_ALLOW_PRESETS, allowPresets);
  args.putInt(ARG_DIALOG_TITLE, dialogTitle);
  args.putBoolean(ARG_SHOW_COLOR_SHADES, showColorShades);
  args.putInt(ARG_COLOR_SHAPE, colorShape);
  dialog.setArguments(args);
  return dialog;
}
 
Example 2
Project: boohee_v5.6   File: FragmentActivity.java   View Source Code Vote up 6 votes
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Parcelable p = this.mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    if (this.mPendingFragmentActivityResults.size() > 0) {
        outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, this.mNextCandidateRequestIndex);
        int[] requestCodes = new int[this.mPendingFragmentActivityResults.size()];
        String[] fragmentWhos = new String[this.mPendingFragmentActivityResults.size()];
        for (int i = 0; i < this.mPendingFragmentActivityResults.size(); i++) {
            requestCodes[i] = this.mPendingFragmentActivityResults.keyAt(i);
            fragmentWhos[i] = (String) this.mPendingFragmentActivityResults.valueAt(i);
        }
        outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
        outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
    }
}
 
Example 3
Project: letv   File: FragmentActivity.java   View Source Code Vote up 6 votes
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Parcelable p = this.mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    if (this.mPendingFragmentActivityResults.size() > 0) {
        outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, this.mNextCandidateRequestIndex);
        int[] requestCodes = new int[this.mPendingFragmentActivityResults.size()];
        String[] fragmentWhos = new String[this.mPendingFragmentActivityResults.size()];
        for (int i = 0; i < this.mPendingFragmentActivityResults.size(); i++) {
            requestCodes[i] = this.mPendingFragmentActivityResults.keyAt(i);
            fragmentWhos[i] = (String) this.mPendingFragmentActivityResults.valueAt(i);
        }
        outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
        outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
    }
}
 
Example 4
Project: TripleTap   File: GameFragment.java   View Source Code Vote up 6 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // Get the SetGame
    SetGame game = mActionsListener.getSetGame();

    SparseBooleanArray checkedItemPositions = getCheckedItemPositions();
    int positionIndex = 0;
    // Loop through SparseBooleanArray and grab the positions that are checked
    for (int i = 0; i < checkedItemPositions.size(); i++) {
        if (checkedItemPositions.valueAt(i)) {
            mCheckedPositions[positionIndex] = checkedItemPositions.keyAt(i);
            positionIndex++;
        }
    }

    // Bundle objects
    outState.putParcelable(getString(R.string.bundle_key_game), Parcels.wrap(game));
    outState.putIntArray(getString(R.string.bundle_key_checked_positions), mCheckedPositions);
    outState.putInt(getString(R.string.bundle_key_checked_count), mCheckedCount);
}
 
Example 5
Project: ChromeLikeTabSwitcher   File: TabSwitcherModel.java   View Source Code Vote up 6 votes
@Override
public final void saveInstanceState(@NonNull final Bundle outState) {
    outState.putSerializable(LOG_LEVEL_EXTRA, logLevel);
    outState.putParcelableArrayList(TABS_EXTRA, tabs);
    outState.putBoolean(SWITCHER_SHOWN_EXTRA, switcherShown);
    outState.putInt(SELECTED_TAB_INDEX_EXTRA, selectedTab != null ? indexOf(selectedTab) : -1);
    outState.putIntArray(PADDING_EXTRA, padding);
    outState.putBoolean(APPLY_PADDING_TO_TABS_EXTRA, applyPaddingToTabs);
    outState.putInt(TAB_ICON_ID_EXTRA, tabIconId);
    outState.putParcelable(TAB_ICON_BITMAP_EXTRA, tabIconBitmap);
    outState.putParcelable(TAB_BACKGROUND_COLOR_EXTRA, tabBackgroundColor);
    outState.putInt(TAB_CONTENT_BACKGROUND_COLOR_EXTRA, tabContentBackgroundColor);
    outState.putParcelable(TAB_TITLE_TEXT_COLOR_EXTRA, tabTitleTextColor);
    outState.putInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA, tabCloseButtonIconId);
    outState.putParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA, tabCloseButtonIconBitmap);
    outState.putInt(TAB_PROGRESS_BAR_COLOR_EXTRA, tabProgressBarColor);
    outState.putBoolean(SHOW_TOOLBARS_EXTRA, showToolbars);
    outState.putCharSequence(TOOLBAR_TITLE_EXTRA, toolbarTitle);
    getContentRecyclerAdapter().saveInstanceState(outState);
}
 
Example 6
Project: FragmentRigger   File: SharedElementFragment.java   View Source Code Vote up 6 votes
private void startSecondFragment(int type, View view) {
  SharedTargetFragment fragment = SharedTargetFragment.newInstance(type);
  Bundle bundle = fragment.getArguments();
  int[] screenLocation = new int[2];
  view.getLocationOnScreen(screenLocation);
  bundle.putIntArray(BUNDLE_KEY + 1, screenLocation);
  bundle.putIntArray(BUNDLE_KEY + 2, new int[]{view.getWidth(), view.getHeight()});
  switch (type) {
    case TYPE_HAMMER:
      break;
    case TYPE_HOURGLASS:
      break;
    case TYPE_SEND:
      break;
    case TYPE_CLOUD:
      break;
  }
  Rigger.getRigger(this).startFragment(fragment);
}
 
Example 7
Project: NeoTerm   File: TabSwitcherModel.java   View Source Code Vote up 6 votes
@Override
public final void saveInstanceState(@NonNull final Bundle outState) {
    outState.putSerializable(LOG_LEVEL_EXTRA, logLevel);
    outState.putParcelableArrayList(TABS_EXTRA, tabs);
    outState.putBoolean(SWITCHER_SHOWN_EXTRA, switcherShown);
    outState.putParcelable(SELECTED_TAB_EXTRA, selectedTab);
    outState.putIntArray(PADDING_EXTRA, padding);
    outState.putInt(TAB_ICON_ID_EXTRA, tabIconId);
    outState.putParcelable(TAB_ICON_BITMAP_EXTRA, tabIconBitmap);
    outState.putParcelable(TAB_BACKGROUND_COLOR_EXTRA, tabBackgroundColor);
    outState.putParcelable(TAB_TITLE_TEXT_COLOR_EXTRA, tabTitleTextColor);
    outState.putInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA, tabCloseButtonIconId);
    outState.putParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA, tabCloseButtonIconBitmap);
    outState.putBoolean(SHOW_TOOLBARS_EXTRA, showToolbars);
    outState.putCharSequence(TOOLBAR_TITLE_EXTRA, toolbarTitle);
    childRecyclerAdapter.saveInstanceState(outState);
}
 
Example 8
Project: OpenHomeAnalysis   File: TimeFragment.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    this.spinnerSavedInstanceState = new int[]{
            this.spinnerHour.getSelectedItemPosition(),
            this.spinnerMinute.getSelectedItemPosition(),
            this.spinnerSecond.getSelectedItemPosition(),
    };
    outState.putIntArray(String.valueOf(this.getId()), spinnerSavedInstanceState);
}
 
Example 9
Project: ucar-weex-core   File: ArgumentsUtil.java   View Source Code Vote up 5 votes
public static void fromArrayToBundle(Bundle bundle, String key, Object array) {
    if (bundle != null && !TextUtils.isEmpty(key) && array != null) {
        if (array instanceof String[]) {
            bundle.putStringArray(key, (String[]) ((String[]) array));
        } else if (array instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) ((byte[]) array));
        } else if (array instanceof short[]) {
            bundle.putShortArray(key, (short[]) ((short[]) array));
        } else if (array instanceof int[]) {
            bundle.putIntArray(key, (int[]) ((int[]) array));
        } else if (array instanceof long[]) {
            bundle.putLongArray(key, (long[]) ((long[]) array));
        } else if (array instanceof float[]) {
            bundle.putFloatArray(key, (float[]) ((float[]) array));
        } else if (array instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) ((double[]) array));
        } else if (array instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) ((boolean[]) array));
        } else if (array instanceof char[]) {
            bundle.putCharArray(key, (char[]) ((char[]) array));
        } else {
            if (!(array instanceof JSONArray)) {
                throw new IllegalArgumentException("Unknown array type " + array.getClass());
            }

            ArrayList arraylist = new ArrayList();
            JSONArray jsonArray = (JSONArray) array;
            Iterator it = jsonArray.iterator();

            while (it.hasNext()) {
                JSONObject object = (JSONObject) it.next();
                arraylist.add(fromJsonToBundle(object));
            }

            bundle.putParcelableArrayList(key, arraylist);
        }

    }
}
 
Example 10
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
/**
 * Save the state of any managed dialogs.
 *
 * @param outState place to store the saved state.
 */
private void saveManagedDialogs(Bundle outState) {
    if (mManagedDialogs == null) {
        return;
    }

    final int numDialogs = mManagedDialogs.size();
    if (numDialogs == 0) {
        return;
    }

    Bundle dialogState = new Bundle();

    int[] ids = new int[mManagedDialogs.size()];

    // save each dialog's bundle, gather the ids
    for (int i = 0; i < numDialogs; i++) {
        final int key = mManagedDialogs.keyAt(i);
        ids[i] = key;
        final ManagedDialog md = mManagedDialogs.valueAt(i);
        dialogState.putBundle(savedDialogKeyFor(key), md.mDialog.onSaveInstanceState());
        if (md.mArgs != null) {
            dialogState.putBundle(savedDialogArgsKeyFor(key), md.mArgs);
        }
    }

    dialogState.putIntArray(SAVED_DIALOG_IDS_KEY, ids);
    outState.putBundle(SAVED_DIALOGS_TAG, dialogState);
}
 
Example 11
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
/**
 * Save the state of any managed dialogs.
 *
 * @param outState place to store the saved state.
 */
private void saveManagedDialogs(Bundle outState) {
    if (mManagedDialogs == null) {
        return;
    }

    final int numDialogs = mManagedDialogs.size();
    if (numDialogs == 0) {
        return;
    }

    Bundle dialogState = new Bundle();

    int[] ids = new int[mManagedDialogs.size()];

    // save each dialog's bundle, gather the ids
    for (int i = 0; i < numDialogs; i++) {
        final int key = mManagedDialogs.keyAt(i);
        ids[i] = key;
        final ManagedDialog md = mManagedDialogs.valueAt(i);
        dialogState.putBundle(savedDialogKeyFor(key), md.mDialog.onSaveInstanceState());
        if (md.mArgs != null) {
            dialogState.putBundle(savedDialogArgsKeyFor(key), md.mArgs);
        }
    }

    dialogState.putIntArray(SAVED_DIALOG_IDS_KEY, ids);
    outState.putBundle(SAVED_DIALOGS_TAG, dialogState);
}
 
Example 12
Project: android-SpringAnimator   File: BaseAdjustmentFragment.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    int[] values = new int[mAdjustmentViews.size()];
    for (int i = 0, l = values.length; i < l; i++) {
        values[i] = mAdjustmentViews.get(i).getValue();
    }

    outState.putIntArray(KEY_VALUES, values);
}
 
Example 13
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
/**
 * Save the state of any managed dialogs.
 *
 * @param outState place to store the saved state.
 */
private void saveManagedDialogs(Bundle outState) {
    if (mManagedDialogs == null) {
        return;
    }

    final int numDialogs = mManagedDialogs.size();
    if (numDialogs == 0) {
        return;
    }

    Bundle dialogState = new Bundle();

    int[] ids = new int[mManagedDialogs.size()];

    // save each dialog's bundle, gather the ids
    for (int i = 0; i < numDialogs; i++) {
        final int key = mManagedDialogs.keyAt(i);
        ids[i] = key;
        final ManagedDialog md = mManagedDialogs.valueAt(i);
        dialogState.putBundle(savedDialogKeyFor(key), md.mDialog.onSaveInstanceState());
        if (md.mArgs != null) {
            dialogState.putBundle(savedDialogArgsKeyFor(key), md.mArgs);
        }
    }

    dialogState.putIntArray(SAVED_DIALOG_IDS_KEY, ids);
    outState.putBundle(SAVED_DIALOGS_TAG, dialogState);
}
 
Example 14
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public void putIntArray(Bundle state, String key, int[] x) {
    state.putIntArray(key + baseKey, x);
}
 
Example 15
Project: MagicBox   File: IntArrayWriter.java   View Source Code Vote up 4 votes
@Override
public void write(Bundle bundle, Object to, StateField field) throws IllegalAccessException {
    Field propertyField = field.getField();
    propertyField.setAccessible(true);
    bundle.putIntArray(field.getBundleKey(), (int[]) propertyField.get(to));
}
 
Example 16
Project: cdep-android-studio-freetype-sample   File: SDLActivity.java   View Source Code Vote up 4 votes
/**
 * This method is called by SDL using JNI.
 * Shows the messagebox from UI thread and block calling thread.
 * buttonFlags, buttonIds and buttonTexts must have same length.
 * @param buttonFlags array containing flags for every button.
 * @param buttonIds array containing id for every button.
 * @param buttonTexts array containing text for every button.
 * @param colors null for default or array of length 5 containing colors.
 * @return button id or -1.
 */
public int messageboxShowMessageBox(
        final int flags,
        final String title,
        final String message,
        final int[] buttonFlags,
        final int[] buttonIds,
        final String[] buttonTexts,
        final int[] colors) {

    messageboxSelection[0] = -1;

    // sanity checks

    if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) {
        return -1; // implementation broken
    }

    // collect arguments for Dialog

    final Bundle args = new Bundle();
    args.putInt("flags", flags);
    args.putString("title", title);
    args.putString("message", message);
    args.putIntArray("buttonFlags", buttonFlags);
    args.putIntArray("buttonIds", buttonIds);
    args.putStringArray("buttonTexts", buttonTexts);
    args.putIntArray("colors", colors);

    // trigger Dialog creation on UI thread

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            showDialog(dialogs++, args);
        }
    });

    // block the calling thread

    synchronized (messageboxSelection) {
        try {
            messageboxSelection.wait();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
            return -1;
        }
    }

    // return selected value

    return messageboxSelection[0];
}
 
Example 17
Project: GravityBox   File: ModDisplay.java   View Source Code Vote up 4 votes
@Override
public void onReceive(Context context, Intent intent) {
    if (DEBUG) log("Broadcast received: " + intent.toString());
    if (intent.getAction().equals(ACTION_GET_AUTOBRIGHTNESS_CONFIG) &&
            intent.hasExtra("receiver")) {
        ResultReceiver receiver = intent.getParcelableExtra("receiver");
        Bundle data = new Bundle();
        Resources res = context.getResources();
        data.putIntArray("config_autoBrightnessLevels",
                res.getIntArray(res.getIdentifier(
                        "config_autoBrightnessLevels", "array", "android")));
        data.putIntArray("config_autoBrightnessLcdBacklightValues",
                res.getIntArray(res.getIdentifier(
                        "config_autoBrightnessLcdBacklightValues", "array", "android")));
        receiver.send(RESULT_AUTOBRIGHTNESS_CONFIG, data);
    } else if (intent.getAction().equals(ACTION_SET_AUTOBRIGHTNESS_CONFIG)) {
        int[] luxArray = intent.getIntArrayExtra("config_autoBrightnessLevels");
        int[] brightnessArray = intent.getIntArrayExtra("config_autoBrightnessLcdBacklightValues");
        updateAutobrightnessConfig(luxArray, brightnessArray);
    } else if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_BUTTON_BACKLIGHT_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BB_MODE)) {
            mButtonBacklightMode = intent.getStringExtra(GravityBoxSettings.EXTRA_BB_MODE);
            updateButtonBacklight();
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_BB_NOTIF)) {
            mButtonBacklightNotif = intent.getBooleanExtra(GravityBoxSettings.EXTRA_BB_NOTIF, false);
            if (!mButtonBacklightNotif) {
                updateButtonBacklight();
            }
        }
    } else if ((intent.getAction().equals(Intent.ACTION_SCREEN_ON)
            || intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) &&
            !mButtonBacklightMode.equals(GravityBoxSettings.BB_MODE_DEFAULT)) {
        updateButtonBacklight(intent.getAction().equals(Intent.ACTION_SCREEN_ON));
    } else if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_LOCKSCREEN_BG_CHANGED) &&
            intent.hasExtra(GravityBoxSettings.EXTRA_LOCKSCREEN_BG)) {
        mLsBgLastScreenEnabled = intent.getStringExtra(GravityBoxSettings.EXTRA_LOCKSCREEN_BG)
                .equals(GravityBoxSettings.LOCKSCREEN_BG_LAST_SCREEN);
        if (DEBUG_KIS) log("mLsBgLastScreenEnabled = " + mLsBgLastScreenEnabled);
    } else if (intent.getAction().equals(GravityBoxSettings.ACTION_BATTERY_LED_CHANGED) &&
            intent.hasExtra(GravityBoxSettings.EXTRA_BLED_CHARGING)) {
        ChargingLed cg = ChargingLed.valueOf(intent.getStringExtra(GravityBoxSettings.EXTRA_BLED_CHARGING));
        if (cg == ChargingLed.EMULATED || cg == ChargingLed.CONSTANT) {
            resetLight(LIGHT_ID_BATTERY);
        }
        mChargingLed = cg;
        if (!mPendingNotif) {
            resetLight(LIGHT_ID_NOTIFICATIONS);
        }
    } else if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
        boolean charging = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
        int level = (int) (100f * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0)
                / intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100));
        if (mCharging != charging || mBatteryLevel != level) {
            mCharging = charging;
            mBatteryLevel = level;
            if ((mChargingLed == ChargingLed.EMULATED || mChargingLed == ChargingLed.CONSTANT) &&
                    !mPendingNotif) {
                resetLight(LIGHT_ID_NOTIFICATIONS);
            }
        }
    }
}
 
Example 18
Project: vlayout   File: StaggeredGridLayoutHelper.java   View Source Code Vote up 4 votes
@Override
public void onSaveState(Bundle bundle) {
    super.onSaveState(bundle);
    bundle.putIntArray(LOOKUP_BUNDLE_KEY, mLazySpanLookup.mData);
    // TODO: store span info
}
 
Example 19
Project: MRouter   File: MainActivity.java   View Source Code Vote up 4 votes
public Bundle assembleBundle() {
    User user = new User();
    user.setAge(90);
    user.setGender(1);
    user.setName("kitty");

    Address address = new Address();
    address.setCity("HangZhou");
    address.setProvince("ZheJiang");

    Bundle extras = new Bundle();
    extras.putString("extra", "from extras");


    ArrayList<String> stringList = new ArrayList<>();
    stringList.add("Java");
    stringList.add("C#");
    stringList.add("Kotlin");

    ArrayList<String> stringArrayList = new ArrayList<>();
    stringArrayList.add("American");
    stringArrayList.add("China");
    stringArrayList.add("England");

    ArrayList<Integer> intArrayList = new ArrayList<>();
    intArrayList.add(100);
    intArrayList.add(101);
    intArrayList.add(102);

    ArrayList<Integer> intList = new ArrayList<>();
    intList.add(10011);
    intList.add(10111);
    intList.add(10211);

    ArrayList<Address> addressList = new ArrayList<>();
    addressList.add(new Address("JiangXi", "ShangRao", null));
    addressList.add(new Address("ZheJiang", "NingBo", null));

    Address[] addressArray = new Address[]{
            new Address("Beijing", "Beijing", null),
            new Address("Shanghai", "Shanghai", null),
            new Address("Guangzhou", "Guangzhou", null)
    };
    Bundle bundle = new Bundle();
    bundle.putSerializable("user", user);
    bundle.putParcelable("address", address);
    bundle.putParcelableArrayList("addressList", addressList);
    bundle.putParcelableArray("addressArray", addressArray);
    bundle.putString("param", "chiclaim");
    bundle.putStringArray("stringArray", new String[]{"a", "b", "c"});
    bundle.putStringArrayList("stringArrayList", stringList);
    bundle.putStringArrayList("stringList", stringArrayList);
    bundle.putByte("byte", (byte) 2);
    bundle.putByteArray("byteArray", new byte[]{1, 2, 3, 4, 5});
    bundle.putInt("age", 33);
    bundle.putIntArray("intArray", new int[]{10, 11, 12, 13});
    bundle.putIntegerArrayList("intList", intList);
    bundle.putIntegerArrayList("intArrayList", intArrayList);
    bundle.putChar("chara", 'c');
    bundle.putCharArray("charArray", "chiclaim".toCharArray());
    bundle.putShort("short", (short) 1000000);
    bundle.putShortArray("shortArray", new short[]{(short) 10.9, (short) 11.9});
    bundle.putDouble("double", 1200000);
    bundle.putDoubleArray("doubleArray", new double[]{1232, 9999, 8789, 3.1415926});
    bundle.putLong("long", 999999999);
    bundle.putLongArray("longArray", new long[]{1000, 2000, 3000});
    bundle.putFloat("float", 333);
    bundle.putFloatArray("floatArray", new float[]{12.9f, 234.9f});
    bundle.putBoolean("boolean", true);
    bundle.putBooleanArray("booleanArray", new boolean[]{true, false, true});

    return bundle;
}
 
Example 20
Project: Watermark   File: MediaGridFragment.java   View Source Code Vote up 4 votes
/**
 * 区分功能
 */
private void radioNext(MediaBean mediaBean) {
    Logger.i("isCrop :" + mConfiguration.isCrop());
    if (!mConfiguration.isCrop()) {
        setPostMediaBean(mediaBean);
        getActivity().finish();
    } else {
        //裁剪根据大家需求加上选择完图片后的回调
        setPostMediaBean(mediaBean);
        String originalPath = mediaBean.getOriginalPath();
        File file = new File(originalPath);
        Random random = new Random();
        String outName = String.format(IMAGE_STORE_FILE_NAME, SimpleDateUtils.getNowTime() + "_" + random.nextInt(1024));
        Logger.i("--->isCrop:" + mImageStoreCropDir);
        Logger.i("--->mediaBean.getOriginalPath():" + mediaBean.getOriginalPath());
        mCropPath = new File(mImageStoreCropDir, outName);
        Uri outUri = Uri.fromFile(mCropPath);
        if (!mImageStoreCropDir.exists()) {
            mImageStoreCropDir.mkdirs();
        }
        if (!file.exists()) {
            file.mkdirs();
        }
        Uri inputUri = Uri.fromFile(new File(mediaBean.getOriginalPath()));
        Intent intent = new Intent(getContext(), UCropActivity.class);


        // UCrop 参数 start
        Bundle bundle = new Bundle();

        bundle.putParcelable(UCrop.EXTRA_OUTPUT_URI, outUri);
        bundle.putParcelable(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS, mediaBean);
        bundle.putInt(UCrop.Options.EXTRA_STATUS_BAR_COLOR, uCropStatusColor);
        bundle.putInt(UCrop.Options.EXTRA_TOOL_BAR_COLOR, uCropToolbarColor);
        bundle.putString(UCrop.Options.EXTRA_UCROP_TITLE_TEXT_TOOLBAR, uCropTitle);
        bundle.putInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, uCropActivityWidgetColor);
        bundle.putInt(UCrop.Options.EXTRA_UCROP_WIDGET_COLOR_TOOLBAR, uCropToolbarWidgetColor);
        bundle.putBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, mConfiguration.isHideBottomControls());
        bundle.putIntArray(UCrop.Options.EXTRA_ALLOWED_GESTURES, mConfiguration.getAllowedGestures());
        bundle.putInt(UCrop.Options.EXTRA_COMPRESSION_QUALITY, mConfiguration.getCompressionQuality());
        bundle.putInt(UCrop.Options.EXTRA_MAX_BITMAP_SIZE, mConfiguration.getMaxBitmapSize());
        bundle.putFloat(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, mConfiguration.getMaxScaleMultiplier());
        bundle.putFloat(UCrop.EXTRA_ASPECT_RATIO_X, mConfiguration.getAspectRatioX());
        bundle.putFloat(UCrop.EXTRA_ASPECT_RATIO_Y, mConfiguration.getAspectRatioY());
        bundle.putInt(UCrop.EXTRA_MAX_SIZE_X, mConfiguration.getMaxResultWidth());
        bundle.putInt(UCrop.EXTRA_MAX_SIZE_Y, mConfiguration.getMaxResultHeight());
        bundle.putInt(UCrop.Options.EXTRA_ASPECT_RATIO_SELECTED_BY_DEFAULT, mConfiguration.getSelectedByDefault());
        bundle.putBoolean(UCrop.Options.EXTRA_FREE_STYLE_CROP, mConfiguration.isFreestyleCropEnabled());
        bundle.putParcelable(UCrop.EXTRA_INPUT_URI, inputUri);
        // UCrop 参数 end

        int bk = FileUtils.existImageDir(inputUri.getPath());
        Logger.i("--->" + inputUri.getPath());
        Logger.i("--->" + outUri.getPath());
        ArrayList<AspectRatio> aspectRatioList = new ArrayList<>();
        AspectRatio[] aspectRatios = mConfiguration.getAspectRatio();
        if (aspectRatios != null) {
            for (int i = 0; i < aspectRatios.length; i++) {
                aspectRatioList.add(i, aspectRatios[i]);
                Logger.i("自定义比例=>" + aspectRatioList.get(i).getAspectRatioX() + " " + aspectRatioList.get(i).getAspectRatioY());
            }
        }
        //  AspectRatio[]aspectRatios =  mConfiguration.getAspectRatio();
        bundle.putParcelableArrayList(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS, aspectRatioList);//EXTRA_CONFIGURATION
        intent.putExtras(bundle);
        if (bk != -1) {
            //裁剪
            startActivityForResult(intent, CROP_IMAGE_REQUEST_CODE);
        } else {
            Logger.w("点击图片无效");
        }
    }
}