Java Code Examples for android.os.Bundle#getIntegerArrayList()

The following examples show how to use android.os.Bundle#getIntegerArrayList() . These examples are extracted from open source projects. 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
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state)
{
    mScannerView = new ZXingScannerView(getActivity());

    if (state != null)
    {
        mAutoFocus = state.getBoolean(AUTO_FOCUS_STATE, true);
        mSelectedIndices = state.getIntegerArrayList(SELECTED_FORMATS);
        mCameraId = state.getInt(CAMERA_ID, -1);
    }
    else
    {
        mAutoFocus = true;
        mSelectedIndices = null;
        mCameraId = -1;
    }
    setupFormats();
    return mScannerView;
}
 
Example 2
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    setStyle(STYLE_NO_TITLE, getTheme());

    Bundle arguments = getArguments();
    titleInfo = arguments.getInt(TITLE_INFO);
    descriptionInfo = arguments.getInt(DESC_INFO);
    profilesInfo = arguments.getIntegerArrayList(PROFILES_INFO);
    connectType = BlueToothService.GattConnectType.values()[arguments.getInt(CONN_TYPE_INFO, 0)];
    adapter.setHasStableIds(true);

    rotateIconAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.rotate_progress_dialog_spinner);
}
 
Example 3
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_weapon_tree_expandable, container, false);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.content_recyclerview);
    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = createWeaponAdapter();
    mRecyclerView.setAdapter(mAdapter);

    // Restores old groups if we are returning to the fragment
    if (savedInstanceState != null) {
        List<Integer> groups = savedInstanceState.getIntegerArrayList(GROUPS_KEY);
        mAdapter.restoreGroups(groups);
    }

    return rootView;
}
 
Example 4
Source Project: FimiX8-RE   File: LabelsView.java    License: MIT License 5 votes vote down vote up
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_STATE));
        ColorStateList color = (ColorStateList) bundle.getParcelable(KEY_TEXT_COLOR_STATE);
        if (color != null) {
            setLabelTextColor(color);
        }
        setLabelTextSize(bundle.getFloat(KEY_TEXT_SIZE_STATE, this.mTextSize));
        int[] padding = bundle.getIntArray(KEY_PADDING_STATE);
        if (padding != null && padding.length == 4) {
            setLabelTextPadding(padding[0], padding[1], padding[2], padding[3]);
        }
        setWordMargin(bundle.getInt(KEY_WORD_MARGIN_STATE, this.mWordMargin));
        setLineMargin(bundle.getInt(KEY_LINE_MARGIN_STATE, this.mLineMargin));
        setSelectType(SelectType.get(bundle.getInt(KEY_SELECT_TYPE_STATE, this.mSelectType.value)));
        setMaxSelect(bundle.getInt(KEY_MAX_SELECT_STATE, this.mMaxSelect));
        List compulsory = bundle.getIntegerArrayList(KEY_COMPULSORY_LABELS_STATE);
        if (!(compulsory == null || compulsory.isEmpty())) {
            setCompulsorys(compulsory);
        }
        ArrayList<Integer> selectLabel = bundle.getIntegerArrayList(KEY_SELECT_LABELS_STATE);
        if (selectLabel != null && !selectLabel.isEmpty()) {
            int size = selectLabel.size();
            int[] positions = new int[size];
            for (int i = 0; i < size; i++) {
                positions[i] = ((Integer) selectLabel.get(i)).intValue();
            }
            setSelects(positions);
            return;
        }
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 5
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    // code copied from https://developer.android.com/training/material/lists-cards.html
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.content_recyclerview);

    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new MyAdapter(getActivity(), new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int position = mRecyclerView.getChildPosition(v);
            mAdapter.toggleGroup(position);
        }
    });
    mRecyclerView.setAdapter(mAdapter);

    MyContent content = getDummyContent();
    mAdapter.add(content);
    List<MyComment> comments = getDummyComments();
    mAdapter.addAll(comments);

    if (savedInstanceState != null) {
        List<Integer> groups = savedInstanceState.getIntegerArrayList(GROUPS_KEY);
        mAdapter.restoreGroups(groups);
    }

    return rootView;
}
 
Example 6
/**
 * Restores the previous state of the selection on the items.
 *
 * @param savedInstanceState Previous state
 * @since 1.0.0
 */
public void onRestoreInstanceState(Bundle savedInstanceState) {
    // Fix for #651 - Check nullable: it happens that the list is null in some unknown cases
    List selectedItems = savedInstanceState.getIntegerArrayList(TAG);
    if (selectedItems != null) {
        mSelectedPositions.addAll(selectedItems);
        if (getSelectedItemCount() > 0) {
            log.d("Restore selection %s", mSelectedPositions);
        }
    }
}
 
Example 7
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    setStyle(STYLE_NO_TITLE, getTheme());

    Bundle arguments = getArguments();
    titleInfo = arguments.getInt(TITLE_INFO);
    descriptionInfo = arguments.getInt(DESC_INFO);
    profilesInfo = arguments.getIntegerArrayList(PROFILES_INFO);
    connectType = BlueToothService.GattConnectType.values()[arguments.getInt(CONN_TYPE_INFO, 0)];
    adapter.setHasStableIds(true);
}
 
Example 8
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Restores old groups if we are returning to the fragment
    if (savedInstanceState != null) {
        List<Integer> groups = savedInstanceState.getIntegerArrayList(GROUPS_KEY);
        mAdapter.restoreGroups(groups);
    }
}
 
Example 9
public static TestClassBundled unbundle(Bundle bundle, Gson gson) {
    return new AutoValue_TestClassBundled(
            bundle,
            bundle.getByte("some_byte"),
            bundle.getBoolean("some_boolean"),
            bundle.getShort("some_short"),
            bundle.getInt("some_int"),
            bundle.getLong("some_long"),
            bundle.getChar("some_char"),
            bundle.getFloat("some_float"),
            bundle.getDouble("some_double"),
            bundle.getString("some_string"),
            bundle.getCharSequence("some_char_sequence"),
            bundle.getParcelable("some_parcelable"),
            bundle.getParcelableArrayList("some_parcelable_array_list"),
            bundle.getSparseParcelableArray("some_parcelable_sparse_array"),
            bundle.getSerializable("some_serializable"),
            bundle.getIntegerArrayList("some_integer_array_list"),
            bundle.getStringArrayList("some_string_array_list"),
            bundle.getCharSequenceArrayList("some_char_sequence_array_list"),
            bundle.getByteArray("some_byte_array"),
            bundle.getShortArray("some_short_array"),
            bundle.getCharArray("some_char_array"),
            bundle.getFloatArray("some_float_array"),
            gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
            gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
            gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
 
Example 10
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // UI elements
    setupViews();

    // Array to ArrayList
    mItems = new ArrayList<String>(Arrays.asList(ITEMS));
    mListSectionPos = new ArrayList<Integer>();
    mListItems = new ArrayList<String>();

    // for handling configuration change
    if (savedInstanceState != null) {
        mListItems = savedInstanceState.getStringArrayList("mListItems");
        mListSectionPos = savedInstanceState.getIntegerArrayList("mListSectionPos");

        if (mListItems != null && mListItems.size() > 0
                && mListSectionPos != null && mListSectionPos.size() > 0) {
            setListAdaptor();
        }

        String constraint = savedInstanceState.getString("constraint");
        if (constraint != null && constraint.length() > 0) {
            mSearchView.setText(constraint);
            setIndexBarViewVisibility(constraint);
        }
    } else {
        new Poplulate().execute(mItems);
    }
}
 
Example 11
DetailsAdapter(ExperimentDetailsFragment parent, Bundle savedInstanceState) {
  items = new ArrayList<>();
  parentReference = new WeakReference<ExperimentDetailsFragment>(parent);
  if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SAVED_SENSOR_INDICES)) {
    sensorIndices = savedInstanceState.getIntegerArrayList(KEY_SAVED_SENSOR_INDICES);
  }
}
 
Example 12
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  initiallySelectedPhotos =
      savedInstanceState != null
          ? savedInstanceState.getIntegerArrayList(KEY_SELECTED_PHOTOS)
          : new ArrayList<>();

  galleryAdapter =
      new GalleryItemAdapter(
          getActivity(),
          () -> {
            addButtonEnabled.onNext(!galleryAdapter.selectedIndices.isEmpty());
            updateTitle();
          });

  permissionGranted
      .distinctUntilChanged()
      .takeUntil(destroyed.happens())
      .subscribe(
          granted -> {
            if (granted) {
              loadImages();
            } else {
              complainPermissions();
            }
          });

  whenLoaderManager.onSuccess(getLoaderManager());
}
 
Example 13
@Override
protected void loadState(Bundle bundle) {
    counter = bundle.getInt("BUNDLE_HINT_COUNTER");
    ArrayList<Integer> list = bundle.getIntegerArrayList("BUNDLE_HINT_VISITED");

    visited.clear();

    if (list != null) {
        for (Integer i : list) {
            visited.add(cards[i]);
        }
    }
}
 
Example 14
public FieldSelector(
        CheckBox enableView,
        TextView outputView,
        List<Field> validFields,
        @Nullable Bundle savedState) {
  fieldStates = new HashMap<>();
  for (Field field : validFields) {
    fieldStates.put(field, new State(field));
  }

  if (savedState != null) {
    List<Integer> selectedFields = savedState.getIntegerArrayList(SELECTED_PLACE_FIELDS_KEY);
    if (selectedFields != null) {
      restoreState(selectedFields);
    }
    outputView.setText(getSelectedString());
  }

  outputView.setOnClickListener(
      v -> {
        if (v.isEnabled()) {
          showDialog(v.getContext());
        }
      });

  enableView.setOnClickListener(
          view -> {
            boolean isChecked = enableView.isChecked();
            outputView.setEnabled(isChecked);
            if (isChecked) {
              showDialog(view.getContext());
            } else {
              outputView.setText("");
              for (State state : fieldStates.values()) {
                state.checked = false;
          }
        }
      });

  this.outputView = outputView;
}
 
Example 15
Source Project: DanDanPlayForAndroid   File: LabelsView.java    License: MIT License 4 votes vote down vote up
@Override
    protected void onRestoreInstanceState(Parcelable state) {
        if (state instanceof Bundle) {
            Bundle bundle = (Bundle) state;
            //恢复父类信息
            super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_STATE));

            //恢复标签文字颜色
            ColorStateList color = bundle.getParcelable(KEY_TEXT_COLOR_STATE);
            if (color != null) {
                setLabelTextColor(color);
            }
            //恢复标签文字大小
            setLabelTextSize(bundle.getFloat(KEY_TEXT_SIZE_STATE, mTextSize));
//            //恢复标签背景  (由于背景改用Drawable,所以不能自动保存和恢复)
//            int resId = bundle.getInt(KEY_BG_RES_ID_STATE, mLabelBgResId);
//            if (resId != 0) {
//                setLabelBackgroundResource(resId);
//            }
            //恢复标签内边距
            int[] padding = bundle.getIntArray(KEY_PADDING_STATE);
            if (padding != null && padding.length == 4) {
                setLabelTextPadding(padding[0], padding[1], padding[2], padding[3]);
            }
            //恢复标签间隔
            setWordMargin(bundle.getInt(KEY_WORD_MARGIN_STATE, mWordMargin));
            //恢复行间隔
            setLineMargin(bundle.getInt(KEY_LINE_MARGIN_STATE, mLineMargin));
            //恢复标签的选择类型
            setSelectType(SelectType.get(bundle.getInt(KEY_SELECT_TYPE_STATE, mSelectType.value)));
            //恢复标签的最大选择数量
            setMaxSelect(bundle.getInt(KEY_MAX_SELECT_STATE, mMaxSelect));
            //恢复标签的最少选择数量
            setMinSelect(bundle.getInt(KEY_MIN_SELECT_STATE, mMinSelect));
            //恢复标签的最大行数
            setMaxLines(bundle.getInt(KEY_MAX_LINES_STATE, mMaxLines));
            //恢复是否是指示器模式
            setIndicator(bundle.getBoolean(KEY_INDICATOR_STATE, isIndicator));

//            //恢复标签列表
//            ArrayList<String> labels = bundle.getStringArrayList(KEY_LABELS_STATE);
//            if (labels != null && !labels.isEmpty()) {
//                setLabels(labels);
//            }
            //恢复必选项列表
            ArrayList<Integer> compulsory = bundle.getIntegerArrayList(KEY_COMPULSORY_LABELS_STATE);
            if (compulsory != null && !compulsory.isEmpty()) {
                setCompulsorys(compulsory);
            }
            //恢复已选择的标签列表
            ArrayList<Integer> selectLabel = bundle.getIntegerArrayList(KEY_SELECT_LABELS_STATE);
            if (selectLabel != null && !selectLabel.isEmpty()) {
                int size = selectLabel.size();
                int[] positions = new int[size];
                for (int i = 0; i < size; i++) {
                    positions[i] = selectLabel.get(i);
                }
                setSelects(positions);
            }
            return;
        }
        super.onRestoreInstanceState(state);
    }
 
Example 16
public ArrayList<Integer> getIntegerArrayList(Bundle state, String key) {
    return state.getIntegerArrayList(key + mBaseKey);
}
 
Example 17
@Nullable
@Override
public List<Integer> get(@NonNull String key, @NonNull Bundle bundle) {
    return bundle.getIntegerArrayList(key);
}
 
Example 18
public void restoreSelectionStates(Bundle savedStates) {
    List<Integer> selectedPositions = savedStates.getIntegerArrayList(SELECTED_POSITIONS);
    mInSelectionMode = savedStates.getBoolean(SELECTING_MODE);
    restoreSelections(selectedPositions);
}
 
Example 19
Source Project: LabelsView   File: LabelsView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
    protected void onRestoreInstanceState(Parcelable state) {
        if (state instanceof Bundle) {
            Bundle bundle = (Bundle) state;
            //恢复父类信息
            super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_STATE));

            //恢复标签文字颜色
            ColorStateList color = bundle.getParcelable(KEY_TEXT_COLOR_STATE);
            if (color != null) {
                setLabelTextColor(color);
            }
            //恢复标签文字大小
            setLabelTextSize(bundle.getFloat(KEY_TEXT_SIZE_STATE, mTextSize));
//            //恢复标签背景  (由于背景改用Drawable,所以不能自动保存和恢复)
//            int resId = bundle.getInt(KEY_BG_RES_ID_STATE, mLabelBgResId);
//            if (resId != 0) {
//                setLabelBackgroundResource(resId);
//            }
            //恢复标签宽高
            mLabelWidth = bundle.getInt(KEY_LABEL_WIDTH_STATE, mLabelWidth);
            mLabelHeight = bundle.getInt(KEY_LABEL_HEIGHT_STATE, mLabelHeight);
            //恢复标签方向
            setLabelGravity(bundle.getInt(KEY_LABEL_GRAVITY_STATE, mLabelGravity));
            //恢复标签内边距
            int[] padding = bundle.getIntArray(KEY_PADDING_STATE);
            if (padding != null && padding.length == 4) {
                setLabelTextPadding(padding[0], padding[1], padding[2], padding[3]);
            }
            //恢复标签间隔
            setWordMargin(bundle.getInt(KEY_WORD_MARGIN_STATE, mWordMargin));
            //恢复行间隔
            setLineMargin(bundle.getInt(KEY_LINE_MARGIN_STATE, mLineMargin));
            //恢复标签的选择类型
            setSelectType(SelectType.get(bundle.getInt(KEY_SELECT_TYPE_STATE, mSelectType.value)));
            //恢复标签的最大选择数量
            setMaxSelect(bundle.getInt(KEY_MAX_SELECT_STATE, mMaxSelect));
            //恢复标签的最少选择数量
            setMinSelect(bundle.getInt(KEY_MIN_SELECT_STATE, mMinSelect));
            //恢复标签的最大行数
            setMaxLines(bundle.getInt(KEY_MAX_LINES_STATE, mMaxLines));
            //恢复是否是指示器模式
            setIndicator(bundle.getBoolean(KEY_INDICATOR_STATE, isIndicator));

            setSingleLine(bundle.getBoolean(KEY_SINGLE_LINE_STATE, isSingleLine));

//            //恢复标签列表
//            ArrayList<String> labels = bundle.getStringArrayList(KEY_LABELS_STATE);
//            if (labels != null && !labels.isEmpty()) {
//                setLabels(labels);
//            }
            //恢复必选项列表
            ArrayList<Integer> compulsory = bundle.getIntegerArrayList(KEY_COMPULSORY_LABELS_STATE);
            if (compulsory != null && !compulsory.isEmpty()) {
                setCompulsorys(compulsory);
            }
            //恢复已选择的标签列表
            ArrayList<Integer> selectLabel = bundle.getIntegerArrayList(KEY_SELECT_LABELS_STATE);
            if (selectLabel != null && !selectLabel.isEmpty()) {
                int size = selectLabel.size();
                int[] positions = new int[size];
                for (int i = 0; i < size; i++) {
                    positions[i] = selectLabel.get(i);
                }
                setSelects(positions);
            }
            return;
        }
        super.onRestoreInstanceState(state);
    }
 
Example 20
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// This error condition will trigger if activity is backgrounded while activity is in foreground,
	// app process is killed while app is in background and then app is yet again launched to foreground
	if(WebViewApp.getCurrentApp() == null) {
		DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onCreate");
		finish();
		return;
	}

	AdUnit.setAdUnitActivity(this);
	Intent.setActiveActivity(this);

	createLayout();

	ViewUtilities.removeViewFromParent(_layout);
	addContentView(_layout, _layout.getLayoutParams());

	AdUnitEvent event;

	if (savedInstanceState == null) {
		_views = getIntent().getStringArrayExtra(EXTRA_VIEWS);
		_keyEventList = getIntent().getIntegerArrayListExtra(EXTRA_KEY_EVENT_LIST);

		if (getIntent().hasExtra(EXTRA_ORIENTATION)) {
			_orientation = getIntent().getIntExtra(EXTRA_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
		}
		if (getIntent().hasExtra(EXTRA_SYSTEM_UI_VISIBILITY)) {
			_systemUiVisibility = getIntent().getIntExtra(EXTRA_SYSTEM_UI_VISIBILITY, 0);
		}
		if (getIntent().hasExtra(EXTRA_ACTIVITY_ID)) {
			_activityId = getIntent().getIntExtra(EXTRA_ACTIVITY_ID, -1);
		}
		if (getIntent().hasExtra(EXTRA_DISPLAY_CUTOUT_MODE)) {
			_displayCutoutMode = getIntent().getIntExtra(EXTRA_DISPLAY_CUTOUT_MODE, 0);
		}

		event = AdUnitEvent.ON_CREATE;
	} else {
		_views = savedInstanceState.getStringArray(EXTRA_VIEWS);
		_orientation = savedInstanceState.getInt(EXTRA_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
		_systemUiVisibility = savedInstanceState.getInt(EXTRA_SYSTEM_UI_VISIBILITY, 0);
		_keyEventList = savedInstanceState.getIntegerArrayList(EXTRA_KEY_EVENT_LIST);
		_keepScreenOn = savedInstanceState.getBoolean(EXTRA_KEEP_SCREEN_ON);
		_activityId = savedInstanceState.getInt(EXTRA_ACTIVITY_ID, -1);
		_displayCutoutMode = savedInstanceState.getInt(EXTRA_DISPLAY_CUTOUT_MODE, 0);
		setKeepScreenOn(_keepScreenOn);
		event = AdUnitEvent.ON_RESTORE;
	}

	setOrientation(_orientation);
	setSystemUiVisibility(_systemUiVisibility);
	setLayoutInDisplayCutoutMode(_displayCutoutMode);

	if(_views != null) {
		for (String viewName : _views) {
			IAdUnitViewHandler handler = getViewHandler(viewName);

			if (handler != null) {
				handler.onCreate(this, savedInstanceState);
			}
		}
	}

	WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, event, _activityId);
}