Search in sources :

Example 6 with UiThread

use of android.annotation.UiThread in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnSettings method setShownPreferences.

@VisibleForTesting
@UiThread
public void setShownPreferences(final Collection<Preference> updates) {
    mLegacyVpnPreferences.values().retainAll(updates);
    mAppPreferences.values().retainAll(updates);
    // Change {@param updates} in-place to only contain new preferences that were not already
    // added to the preference screen.
    final PreferenceGroup vpnGroup = getPreferenceScreen();
    for (int i = vpnGroup.getPreferenceCount() - 1; i >= 0; i--) {
        Preference p = vpnGroup.getPreference(i);
        if (updates.contains(p)) {
            updates.remove(p);
        } else {
            vpnGroup.removePreference(p);
        }
    }
    // Show any new preferences on the screen
    for (Preference pref : updates) {
        vpnGroup.addPreference(pref);
    }
}
Also used : GearPreference(com.android.settings.widget.GearPreference) Preference(androidx.preference.Preference) PreferenceGroup(androidx.preference.PreferenceGroup) VisibleForTesting(androidx.annotation.VisibleForTesting) UiThread(android.annotation.UiThread)

Example 7 with UiThread

use of android.annotation.UiThread in project android_packages_apps_Settings by omnirom.

the class VpnSettings method setShownPreferences.

@VisibleForTesting
@UiThread
public void setShownPreferences(final Collection<Preference> updates) {
    mLegacyVpnPreferences.values().retainAll(updates);
    mAppPreferences.values().retainAll(updates);
    // Change {@param updates} in-place to only contain new preferences that were not already
    // added to the preference screen.
    final PreferenceGroup vpnGroup = getPreferenceScreen();
    for (int i = vpnGroup.getPreferenceCount() - 1; i >= 0; i--) {
        Preference p = vpnGroup.getPreference(i);
        if (updates.contains(p)) {
            updates.remove(p);
        } else {
            vpnGroup.removePreference(p);
        }
    }
    // Show any new preferences on the screen
    for (Preference pref : updates) {
        vpnGroup.addPreference(pref);
    }
}
Also used : GearPreference(com.android.settings.widget.GearPreference) Preference(androidx.preference.Preference) PreferenceGroup(androidx.preference.PreferenceGroup) VisibleForTesting(androidx.annotation.VisibleForTesting) UiThread(android.annotation.UiThread)

Aggregations

UiThread (android.annotation.UiThread)7 GearPreference (com.android.settings.widget.GearPreference)7 Preference (android.support.v7.preference.Preference)5 PreferenceGroup (android.support.v7.preference.PreferenceGroup)5 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)5 VisibleForTesting (androidx.annotation.VisibleForTesting)2 Preference (androidx.preference.Preference)2 PreferenceGroup (androidx.preference.PreferenceGroup)2