Java Code Examples for android.os.bundle#putBooleanArray()

The following examples show how to use android.os.bundle#putBooleanArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverlayPinchImageView.java    From Augendiagnose with GNU General Public License v2.0 6 votes vote down vote up
@NonNull
@Override
protected final Parcelable onSaveInstanceState() {
	Bundle bundle = new Bundle();
	bundle.putParcelable("instanceState", super.onSaveInstanceState());
	bundle.putFloat("mOverlayX", this.mOverlayX);
	bundle.putFloat("mOverlayY", this.mOverlayY);
	bundle.putFloat("mOverlayScaleFactor", this.mOverlayScaleFactor);
	bundle.putFloat("mPupilOverlayX", this.mPupilOverlayX);
	bundle.putFloat("mPupilOverlayY", this.mPupilOverlayY);
	bundle.putFloat("mPupilOverlayScaleFactor", this.mPupilOverlayScaleFactor);
	bundle.putBooleanArray("mShowOverlay", this.mShowOverlay);
	bundle.putBoolean("mLocked", this.mLocked);
	bundle.putSerializable("mPinchMode", mPinchMode);
	bundle.putFloat("mBrightness", this.mBrightness);
	bundle.putFloat("mContrast", this.mContrast);
	bundle.putFloat("mSaturation", this.mSaturation);
	bundle.putFloat("mColorTemperature", this.mColorTemperature);
	bundle.putInt("mOverlayColor", mOverlayColor);
	bundle.putParcelable("mMetadata", mMetadata);
	return bundle;
}
 
Example 2
Source File: MultiChoiceFragment.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private static void show(FragmentManager fm, int requestCode, String title, CharSequence csPositive, CharSequence csNagative, String[] items, boolean hasDefaultSelect, boolean[] selectedIndexes){
	MultiChoiceFragment dialog = new MultiChoiceFragment();
	Bundle args = new Bundle();
	args.putString(ARG_TITLE, title);
	args.putStringArray(ARG_ITEMS, items);
	if (!hasDefaultSelect){
		boolean[] bs = new boolean[args.getStringArray(ARG_ITEMS).length];
		for(int i=0; i<bs.length; i++){
			bs[i] = false;
		}
		args.putBooleanArray(ARG_SELECTED_INDEXES, bs);
	}else{
		args.putBooleanArray(ARG_SELECTED_INDEXES, selectedIndexes);
	}
	args.putInt(ARG_REQUEST_CODE, requestCode);
	args.putCharSequence(ARG_POSITIVE_TEXT, csPositive);
	args.putCharSequence(ARG_NAGATIVE_TEXT, csNagative);
	dialog.setArguments(args);
	dialog.setCancelable(false);
	dialog.show(fm, TAG);
}
 
Example 3
Source File: MultiStateToggleButton.java    From multistatetogglebutton with MIT License 5 votes vote down vote up
@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();
    bundle.putParcelable(KEY_INSTANCE_STATE, super.onSaveInstanceState());
    bundle.putBooleanArray(KEY_BUTTON_STATES, getStates());
    return bundle;
}
 
Example 4
Source File: VerticalStepperFormView.java    From VerticalStepperForm with Apache License 2.0 5 votes vote down vote up
@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();

    boolean[] completedSteps = new boolean[stepHelpers.size()];
    String[] titles = new String[stepHelpers.size()];
    String[] subtitles = new String[stepHelpers.size()];
    String[] buttonTexts = new String[stepHelpers.size()];
    String[] errorMessages = new String[stepHelpers.size()];
    for (int i = 0; i < completedSteps.length; i++) {
        StepHelper stepHelper = stepHelpers.get(i);
        completedSteps[i] = stepHelper.getStepInstance().isCompleted();
        titles[i] = stepHelper.getStepInstance().getTitle();
        subtitles[i] = stepHelper.getStepInstance().getSubtitle();
        buttonTexts[i] = stepHelper.getStepInstance().getNextButtonText();
        if (!stepHelper.getStepInstance().isCompleted()) {
            errorMessages[i] = stepHelper.getStepInstance().getErrorMessage();
        }
    }

    bundle.putParcelable("superState", super.onSaveInstanceState());
    bundle.putInt("openStep", this.getOpenStepPosition());
    bundle.putBooleanArray("completedSteps", completedSteps);
    bundle.putStringArray("titles", titles);
    bundle.putStringArray("subtitles", subtitles);
    bundle.putStringArray("buttonTexts", buttonTexts);
    bundle.putStringArray("errorMessages", errorMessages);
    bundle.putBoolean("formCompleted", formCompleted);

    return bundle;
}
 
Example 5
Source File: NewAlarmFormActivity.java    From VerticalStepperForm with Apache License 2.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    savedInstanceState.putString(STATE_TITLE, nameStep.getStepData());
    savedInstanceState.putString(STATE_DESCRIPTION, descriptionStep.getStepData());
    savedInstanceState.putInt(STATE_TIME_HOUR, timeStep.getStepData().hour);
    savedInstanceState.putInt(STATE_TIME_MINUTES, timeStep.getStepData().minutes);
    savedInstanceState.putBooleanArray(STATE_WEEK_DAYS, daysStep.getStepData());

    // IMPORTANT: The call to super method must be here at the end
    super.onSaveInstanceState(savedInstanceState);
}
 
Example 6
Source File: OutlineListView.java    From mOrgAnd with GNU General Public License v2.0 5 votes vote down vote up
public void saveState(Bundle outState) {
    outState.putLongArray(OUTLINE_NODES, adapter.getNodeState());
    outState.putIntegerArrayList(OUTLINE_LEVELS, adapter.getLevelState());
    outState.putBooleanArray(OUTLINE_EXPANDED, adapter.getExpandedState());
    outState.putInt(OUTLINE_CHECKED_POS, getCheckedItemPosition());
    outState.putInt(OUTLINE_SCROLL_POS, getFirstVisiblePosition());
}
 
Example 7
Source File: MultiSelectQuizView.java    From android-topeka with Apache License 2.0 5 votes vote down vote up
@Override
public Bundle getUserInput() {
    Bundle bundle = new Bundle();
    boolean[] bundleableAnswer = getBundleableAnswer();
    bundle.putBooleanArray(KEY_ANSWER, bundleableAnswer);
    return bundle;
}
 
Example 8
Source File: ManageGroupDialog.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable("group", group);
    outState.putString("uid", uid);
    outState.putStringArray("valueArray", valueArray);
    outState.putBooleanArray("selectedArray", selectedArray);
    outState.putStringArrayList("currentList", currentList);
    outState.putStringArrayList("addList", addList);
    outState.putStringArrayList("removeList", removeList);
}
 
Example 9
Source File: ManageGroupDialog.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable("group", group);
    outState.putString("uid", uid);
    outState.putStringArray("valueArray", valueArray);
    outState.putBooleanArray("selectedArray", selectedArray);
    outState.putStringArrayList("currentList", currentList);
    outState.putStringArrayList("addList", addList);
    outState.putStringArrayList("removeList", removeList);
}
 
Example 10
Source File: ShadowActivity.java    From RxPermission with Apache License 2.0 4 votes vote down vote up
@Override protected void onSaveInstanceState(final Bundle outState) {
  outState.putBooleanArray(SAVE_RATIONALE, shouldShowRequestPermissionRationale);
  super.onSaveInstanceState(outState);
}
 
Example 11
Source File: Query.java    From FreezeYou with Apache License 2.0 4 votes vote down vote up
@Override
public Bundle call(String method, String arg, Bundle extras) {
    Context context = getContext();
    Bundle bundle = new Bundle();
    if (method != null && extras != null) {
        String queryPkg = extras.getString("packageName");
        switch (method) {
            case QUERY_MODE:
                if (context != null && DevicePolicyManagerUtils.isDeviceOwner(getContext())) {
                    bundle.putString("currentMode", "dpm");
                } else if (FUFUtils.checkRootPermission()) {
                    bundle.putString("currentMode", "root");
                } else {
                    bundle.putString("currentMode", "unavailable");
                }
                return bundle;
            case QUERY_FREEZE_STATUS:
                if (context == null) {
                    bundle.putInt("status", -1);
                } else if (queryPkg == null) {
                    bundle.putInt("status", -2);
                } else {
                    if (ApplicationInfoUtils.getApplicationInfoFromPkgName(queryPkg, context) == null) {
                        bundle.putInt("status", 998);
                    } else {
                        boolean dpmFrozen = FUFUtils.checkMRootFrozen(context, queryPkg);
                        boolean rootFrozen = FUFUtils.checkRootFrozen(context, queryPkg, null);
                        if (dpmFrozen && rootFrozen) {
                            bundle.putInt("status", 3);
                        } else if (dpmFrozen) {
                            bundle.putInt("status", 2);
                        } else if (rootFrozen) {
                            bundle.putInt("status", 1);
                        } else {
                            bundle.putInt("status", 0);
                        }
                    }
                }
                return bundle;
            case QUERY_IF_CAN_INSTALL_APPLICATIONS_STATUS:
                if (context == null) {
                    bundle.putBooleanArray("status", new boolean[]{false, false, false, false}); // 可用状态、installActivityEnabled、hasRootPerm、hasDpmPerm
                } else {
                    boolean installActivityEnabled, hasRootPerm, hasDpmPerm;
                    switch (context.getPackageManager().getComponentEnabledSetting(
                            new ComponentName(context, "cf.playhi.freezeyou.InstallPackagesActivity"))) {
                        case android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED:
                            installActivityEnabled = true;
                            break;
                        case android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
                        case android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED:
                        case android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED:
                        case android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER:
                        default:
                            installActivityEnabled = false;
                            break;
                    }
                    hasDpmPerm = DevicePolicyManagerUtils.isDeviceOwner(context);
                    hasRootPerm = FUFUtils.checkRootPermission();
                    bundle.putBooleanArray(
                            "status",
                            new boolean[]{
                                    installActivityEnabled && (hasDpmPerm || hasRootPerm),
                                    installActivityEnabled,
                                    hasRootPerm,
                                    hasDpmPerm
                            }
                    );
                }
                return bundle;
            default:
                break;
        }
    }
    return bundle;
}
 
Example 12
Source File: InstanceStateManager.java    From AndroidCommons with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static void setBundleValue(@NonNull Field field, @NonNull Object obj,
        @NonNull Bundle bundle, @NonNull String key, boolean isGson)
        throws IllegalAccessException {

    if (isGson) {
        bundle.putString(key, GsonHelper.toJson(field.get(obj)));
        return;
    }

    Class<?> type = field.getType();
    Type[] genericTypes = null;
    if (field.getGenericType() instanceof ParameterizedType) {
        genericTypes = ((ParameterizedType) field.getGenericType()).getActualTypeArguments();
    }

    if (type.equals(Boolean.TYPE)) {
        bundle.putBoolean(key, field.getBoolean(obj));

    } else if (type.equals(boolean[].class)) {
        bundle.putBooleanArray(key, (boolean[]) field.get(obj));

    } else if (type.equals(Bundle.class)) {
        bundle.putBundle(key, (Bundle) field.get(obj));

    } else if (type.equals(Byte.TYPE)) {
        bundle.putByte(key, field.getByte(obj));

    } else if (type.equals(byte[].class)) {
        bundle.putByteArray(key, (byte[]) field.get(obj));

    } else if (type.equals(Character.TYPE)) {
        bundle.putChar(key, field.getChar(obj));

    } else if (type.equals(char[].class)) {
        bundle.putCharArray(key, (char[]) field.get(obj));

    } else if (type.equals(CharSequence.class)) {
        bundle.putCharSequence(key, (CharSequence) field.get(obj));

    } else if (type.equals(CharSequence[].class)) {
        bundle.putCharSequenceArray(key, (CharSequence[]) field.get(obj));

    } else if (type.equals(Double.TYPE)) {
        bundle.putDouble(key, field.getDouble(obj));

    } else if (type.equals(double[].class)) {
        bundle.putDoubleArray(key, (double[]) field.get(obj));

    } else if (type.equals(Float.TYPE)) {
        bundle.putFloat(key, field.getFloat(obj));

    } else if (type.equals(float[].class)) {
        bundle.putFloatArray(key, (float[]) field.get(obj));

    } else if (type.equals(Integer.TYPE)) {
        bundle.putInt(key, field.getInt(obj));

    } else if (type.equals(int[].class)) {
        bundle.putIntArray(key, (int[]) field.get(obj));

    } else if (type.equals(Long.TYPE)) {
        bundle.putLong(key, field.getLong(obj));

    } else if (type.equals(long[].class)) {
        bundle.putLongArray(key, (long[]) field.get(obj));

    } else if (type.equals(Short.TYPE)) {
        bundle.putShort(key, field.getShort(obj));

    } else if (type.equals(short[].class)) {
        bundle.putShortArray(key, (short[]) field.get(obj));

    } else if (type.equals(String.class)) {
        bundle.putString(key, (String) field.get(obj));

    } else if (type.equals(String[].class)) {
        bundle.putStringArray(key, (String[]) field.get(obj));

    } else if (Parcelable.class.isAssignableFrom(type)) {
        bundle.putParcelable(key, (Parcelable) field.get(obj));

    } else if (type.equals(ArrayList.class)
            && genericTypes != null
            && genericTypes[0] instanceof Class
            && Parcelable.class.isAssignableFrom((Class<?>) genericTypes[0])) {
        bundle.putParcelableArrayList(key, (ArrayList<? extends Parcelable>) field.get(obj));

    } else if (type.isArray() && Parcelable.class.isAssignableFrom(type.getComponentType())) {
        bundle.putParcelableArray(key, (Parcelable[]) field.get(obj));

    } else if (Serializable.class.isAssignableFrom(type)) {
        bundle.putSerializable(key, (Serializable) field.get(obj));

    } else {
        throw new RuntimeException("Unsupported field type: " + field.getName()
                + ", " + type.getName());
    }
}
 
Example 13
Source File: ParameterHelper.java    From IPCInvoker with Apache License 2.0 4 votes vote down vote up
public static void put(Bundle bundle, String key, Object value) {
        if (value instanceof Integer) {
            bundle.putInt(key, (Integer) value);
        } else if (value instanceof Float) {
            bundle.putFloat(key, (Float) value);
        } else if (value instanceof Character) {
            bundle.putChar(key, (Character) value);
        } else if (value instanceof CharSequence) {
            bundle.putCharSequence(key, (CharSequence) value);
        } else if (value instanceof Long) {
            bundle.putLong(key, (Long) value);
        } else if (value instanceof Short) {
            bundle.putShort(key, (Short) value);
        } else if (value instanceof Byte) {
            bundle.putByte(key, (Byte) value);
        } else if (value instanceof Boolean) {
            bundle.putBoolean(key, (Boolean) value);
        } else if (value instanceof Double) {
            bundle.putDouble(key, (Double) value);
        } else if (value instanceof Parcelable) {
            bundle.putParcelable(key, (Parcelable) value);
        } else if (value instanceof Bundle) {
            bundle.putBundle(key, (Bundle) value);
        } else if (value instanceof int[]) {
            bundle.putIntArray(key, (int[]) value);
        } else if (value instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) value);
        } else if (value instanceof float[]) {
            bundle.putFloatArray(key, (float[]) value);
        } else if (value instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) value);
        } else if (value instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) value);
        } else if (value instanceof long[]) {
            bundle.putLongArray(key, (long[]) value);
        } else if (value instanceof Parcelable[]) {
            bundle.putParcelableArray(key, (Parcelable[]) value);
        } else if (value instanceof short[]) {
            bundle.putShortArray(key, (short[]) value);
        } else if (value instanceof String[]) {
            bundle.putStringArray(key, (String[]) value);
        } else {
//            bundle.putString(key, String.valueOf(value));
        }
    }
 
Example 14
Source File: ActivityOptionsCompatICS.java    From nono-android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 将各种坐标和参数放入bundle中传递
 * 
    * Returns the created options as a Bundle, which can be passed to
    * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle)
    * Context.startActivity(Intent, Bundle)} and related methods.
    * Note that the returned Bundle is still owned by the ActivityOptions
    * object; you must not modify it, but can supply it to the startActivity
    * methods that take an options Bundle.
    */
public Bundle toBundle() {
	if (mAnimationType == ANIM_DEFAULT) {
           return null;
       }
	Bundle bundle = new Bundle();
       bundle.putInt(KEY_ANIM_TYPE, mAnimationType);
       switch (mAnimationType) {
       
           case ANIM_CUSTOM:
           	bundle.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId);
               bundle.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId);
               break;
               
           case ANIM_SCALE_UP:
       		bundle.putBoolean(KEY_IS_VERTICAL_SCREEN, mIsVerticalScreen);
       		bundle.putBoolean(KEY_IS_IN_THE_SCREEN, mIsInTheScreen);
       		
       		bundle.putInt(KEY_ANIM_WIDTH, mWidth);
       		bundle.putInt(KEY_ANIM_HEIGHT, mHeight);
       		bundle.putInt(KEY_ANIM_START_X, mStartX);
       		bundle.putInt(KEY_ANIM_START_Y, mStartY);
               break;
               
           case ANIM_THUMBNAIL_SCALE_UP:
           	bundle.putBoolean(KEY_IS_START_FULL_SCREEN, mIsStartFullScreen);
           	bundle.putBoolean(KEY_IS_VERTICAL_SCREEN, mIsVerticalScreen);
       		bundle.putBoolean(KEY_IS_IN_THE_SCREEN, mIsInTheScreen);
               bundle.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
               bundle.putInt(KEY_ANIM_START_X, mStartX);
               bundle.putInt(KEY_ANIM_START_Y, mStartY);
               bundle.putInt(KEY_ANIM_WIDTH, mWidth);
               bundle.putInt(KEY_ANIM_HEIGHT, mHeight);
               break;
               
           case ANIM_SCENE_TRANSITION:
       		bundle.putBoolean(KEY_IS_VERTICAL_SCREEN, mIsVerticalScreen);
       		bundle.putBoolean(KEY_IS_START_FULL_SCREEN, mIsStartFullScreen);
       		
       		bundle.putBooleanArray(kEY_IS_IN_THE_SCREEN_ARR, mIsInTheScreenArr);
       		bundle.putIntegerArrayList(kEY_SHARED_ELEMENT_ID_LIST, mSharedElementIds);
       		bundle.putParcelableArrayList(kEY_SHARED_ELEMENT_BOUNDS_LIST, mSharedElementBounds);
               break;
       }

	return bundle;
}
 
Example 15
Source File: InjectionHelper.java    From android-state with Eclipse Public License 1.0 4 votes vote down vote up
public void putBooleanArray(Bundle state, String key, boolean[] x) {
    state.putBooleanArray(key + mBaseKey, x);
}
 
Example 16
Source File: ForegroundManager.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	outState.putBooleanArray(EXTRA_SELECTED, selected);
}
 
Example 17
Source File: GroupEditActivity.java    From smartcard-reader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    GroupItem groupItem = mGrpAdapter.getGroup(0);
    outState.putBooleanArray("member_array", groupItem.member);
}
 
Example 18
Source File: ActivityAlarmSettings.java    From AlarmOn with Apache License 2.0 3 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putBoolean(SETTINGS_VIBRATE_KEY, settings.getVibrate());

    outState.putInt(SETTINGS_SNOOZE_KEY, settings.getSnoozeMinutes());

    if (originalInfo != null && info != null) {
        final AlarmTime infoTime = info.getTime();

        outState.putInt(SETTINGS_TIME_HOUR_OF_DAY_KEY,
                infoTime.calendar().get(Calendar.HOUR_OF_DAY));

        outState.putInt(SETTINGS_TIME_MINUTE_KEY,
                infoTime.calendar().get(Calendar.MINUTE));

        outState.putInt(SETTINGS_TIME_SECOND_KEY,
                infoTime.calendar().get(Calendar.SECOND));

        outState.putString(SETTINGS_NAME_KEY, info.getName());

        outState.putBooleanArray(SETTINGS_DAYS_OF_WEEK_KEY,
                info.getTime().getDaysOfWeek().bitmask());
    }

    outState.putParcelable(SETTINGS_TONE_URI_KEY, settings.getTone());

    outState.putString(SETTINGS_TONE_NAME_KEY, settings.getToneName());

    outState.putInt(SETTINGS_VOLUME_START_PERCENT_KEY,
            settings.getVolumeStartPercent());

    outState.putInt(SETTINGS_VOLUME_END_PERCENT_KEY,
            settings.getVolumeEndPercent());

    outState.putInt(SETTINGS_VOLUME_CHANGE_TIME_SEC_KEY,
            settings.getVolumeChangeTimeSec());
}
 
Example 19
Source File: BooleanArrayCoder.java    From lyra with Apache License 2.0 2 votes vote down vote up
/**
 * Write a field's value into the saved state {@link Bundle}.
 *
 * @param state      {@link Bundle} used to save the state
 * @param key        key retrieved from {@code fieldDeclaringClass#fieldName}
 * @param fieldValue value of field
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull boolean[] fieldValue) {
    state.putBooleanArray(key, fieldValue);
}
 
Example 20
Source File: ExpandableRecyclerViewAdapter.java    From expandable-recycler-view with MIT License 2 votes vote down vote up
/**
 * Stores the expanded state map across state loss.
 * <p>
 * Should be called from whatever {@link Activity} that hosts the RecyclerView that {@link
 * ExpandableRecyclerViewAdapter} is attached to.
 * <p>
 * This will make sure to add the expanded state map as an extra to the
 * instance state bundle to be used in {@link #onRestoreInstanceState(Bundle)}.
 *
 * @param savedInstanceState The {@code Bundle} into which to store the
 * expanded state map
 */
public void onSaveInstanceState(Bundle savedInstanceState) {
  savedInstanceState.putBooleanArray(EXPAND_STATE_MAP, expandableList.expandedGroupIndexes);
}