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() 

Source Link

Document

Create a new empty ArraySet.

Usage

From source file:com.franmontiel.persistentcookiejar.cache.SetCookieCache.java

public SetCookieCache() {
    cookies = new ArraySet<>();
}

From source file:com.example.android.downloadablefonts.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    initializeSeekBars();/* w  w  w .ja  v a 2 s  . co  m*/
    mFamilyNameSet = new ArraySet<>();
    mFamilyNameSet.addAll(Arrays.asList(getResources().getStringArray(R.array.family_names)));

    mDownloadableFontTextView = findViewById(R.id.textview);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.family_names));
    final TextInputLayout familyNameInput = findViewById(R.id.auto_complete_family_name_input);
    final AutoCompleteTextView autoCompleteFamilyName = findViewById(R.id.auto_complete_family_name);
    autoCompleteFamilyName.setAdapter(adapter);
    autoCompleteFamilyName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
            // No op
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int start, int count, int after) {
            if (isValidFamilyName(charSequence.toString())) {
                familyNameInput.setErrorEnabled(false);
                familyNameInput.setError("");
            } else {
                familyNameInput.setErrorEnabled(true);
                familyNameInput.setError(getString(R.string.invalid_family_name));
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
            // No op
        }
    });

    mRequestDownloadButton = findViewById(R.id.button_request);
    mRequestDownloadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String familyName = autoCompleteFamilyName.getText().toString();
            if (!isValidFamilyName(familyName)) {
                familyNameInput.setErrorEnabled(true);
                familyNameInput.setError(getString(R.string.invalid_family_name));
                Toast.makeText(MainActivity.this, R.string.invalid_input, Toast.LENGTH_SHORT).show();
                return;
            }
            requestDownload(familyName);
            mRequestDownloadButton.setEnabled(false);
        }
    });
    mBestEffort = findViewById(R.id.checkbox_best_effort);
}

From source file:cc.metapro.openct.data.university.model.classinfo.EnrichedClassInfo.java

/**
 * judge whether this class is on schedule in this week
 *
 * @param week current week or selected week
 * @return time when has class this week
 */// w  w  w  . j a v  a 2s .c o m
@NonNull
Set<ClassTime> hasClassThisWeek(int week) {
    Set<ClassTime> result = new ArraySet<>();
    for (ClassTime time : mTimeSet) {
        if (time.hasClass(week)) {
            result.add(time);
        }
    }
    return result;
}

From source file:cc.metapro.openct.data.university.model.classinfo.EnrichedClassInfo.java

/**
 * judge whether this class is on schedule today
 *
 * @param week current week or selected week
 * @return time when has class today//from   w  w w . j a v a 2 s .  c om
 */
@NonNull
Set<ClassTime> hasClassToday(int week) {
    Calendar calendar = Calendar.getInstance();
    Set<ClassTime> timeList = hasClassThisWeek(week);
    Set<ClassTime> result = new ArraySet<>();
    for (ClassTime time : timeList) {
        if (time.inSameDay(calendar)) {
            result.add(time);
        }
    }
    return result;
}

From source file:cc.metapro.openct.data.university.model.classinfo.EnrichedClassInfo.java

/**
 * merge class with same name to one, the differences should be in time, place, teacher, during
 * and time is the key of them/*from   w w  w  .  ja va2 s .c  o m*/
 *
 * @param info another class info which has the same name with this one
 */
void combine(EnrichedClassInfo info) {
    if (info == null)
        return;
    ArraySet<ClassTime> mixedTime = new ArraySet<>();
    mixedTime.addAll(mTimeSet);

    for (ClassTime time : info.getTimeSet()) {
        boolean found = false;
        for (ClassTime myTime : mTimeSet) {
            if (myTime.equals(time)) {
                found = true;
                myTime.combineDuring(time.getDuring());
                mixedTime.add(myTime);
            }
        }
        if (!found) {
            mixedTime.add(time);
        }
    }
    mTimeSet = mixedTime;
}

From source file:android.support.text.emoji.EmojiCompat.java

/**
 * Private constructor for singleton instance.
 *
 * @see #init(Config)//from w  w  w . j av a 2  s  .c o m
 */
private EmojiCompat(@NonNull final Config config) {
    mInitLock = new ReentrantReadWriteLock();
    mReplaceAll = config.mReplaceAll;
    mEmojiSpanIndicatorEnabled = config.mEmojiSpanIndicatorEnabled;
    mEmojiSpanIndicatorColor = config.mEmojiSpanIndicatorColor;
    mMetadataLoader = config.mMetadataLoader;
    mMainHandler = new Handler(Looper.getMainLooper());
    mInitCallbacks = new ArraySet<>();
    if (config.mInitCallbacks != null && !config.mInitCallbacks.isEmpty()) {
        mInitCallbacks.addAll(config.mInitCallbacks);
    }
    mHelper = Build.VERSION.SDK_INT < 19 ? new CompatInternal(this) : new CompatInternal19(this);
    loadMetadata();
}