Example usage for android.support.v4.util ArraySet ArraySet

List of usage examples for android.support.v4.util ArraySet ArraySet

Introduction

In this page you can find the example usage for android.support.v4.util ArraySet ArraySet.

Prototype

public ArraySet(Collection<E> set) 

Source Link

Usage

From source file:com.zhihu.matisse.MimeType.java

private static Set<String> arraySetOf(String... suffixes) {
    return new ArraySet<>(Arrays.asList(suffixes));
}

From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        final DialogPreference preference = getPreference();
        mDialogTitle = preference.getDialogTitle();
        mDialogMessage = preference.getDialogMessage();

        if (preference instanceof ListPreference) {
            mMulti = false;/*from w  ww .ja v a2 s .  c  om*/
            mEntries = ((ListPreference) preference).getEntries();
            mEntryValues = ((ListPreference) preference).getEntryValues();
            mInitialSelection = ((ListPreference) preference).getValue();
        } else if (preference instanceof MultiSelectListPreference) {
            mMulti = true;
            mEntries = ((MultiSelectListPreference) preference).getEntries();
            mEntryValues = ((MultiSelectListPreference) preference).getEntryValues();
            mInitialSelections = ((MultiSelectListPreference) preference).getValues();
        } else {
            throw new IllegalArgumentException(
                    "Preference must be a ListPreference or " + "MultiSelectListPreference");
        }
    } else {
        mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE);
        mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE);
        mMulti = savedInstanceState.getBoolean(SAVE_STATE_IS_MULTI);
        mEntries = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRIES);
        mEntryValues = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRY_VALUES);
        if (mMulti) {
            final String[] initialSelections = savedInstanceState.getStringArray(SAVE_STATE_INITIAL_SELECTIONS);
            mInitialSelections = new ArraySet<>(initialSelections != null ? initialSelections.length : 0);
            if (initialSelections != null) {
                Collections.addAll(mInitialSelections, initialSelections);
            }
        } else {
            mInitialSelection = savedInstanceState.getString(SAVE_STATE_INITIAL_SELECTION);
        }
    }
}

From source file:cc.metapro.openct.classdetail.ClassDetailActivity.java

@Override
public void onBackPressed() {
    mInfoEditing.setName(mName.getText().toString());
    mInfoEditing.setType(mType.getText().toString());
    mInfoEditing.setTimes(new ArraySet<>(mClassTimes));
    try {/*  www .  j  av a2 s.  co  m*/
        if (mClassTimes == null || mClassTimes.isEmpty()) {
            try {
                DBManger.getInstance(this).updateSingleClass(mOldName, "", null);
            } catch (Exception e) {
                Log.d(TAG, e.getMessage(), e);
            }
        } else {
            try {
                DBManger.getInstance(this).updateSingleClass(mOldName, mInfoEditing.getName(), mInfoEditing);
            } catch (Exception e) {
                Log.d(TAG, e.getMessage(), e);
                Toast.makeText(this, R.string.class_with_same_name, Toast.LENGTH_LONG).show();
                return;
            }
        }
    } finally {
        Constants.sClasses.setInfoByName(mOldName, mInfoEditing);
    }
    super.onBackPressed();
}