use of android.support.v7.preference.PreferenceGroupAdapter in project android_packages_apps_CMParts by LineageOS.
the class SettingsPreferenceFragment method findListPositionFromKey.
private int findListPositionFromKey(PreferenceGroupAdapter adapter, String key) {
final int count = adapter.getItemCount();
for (int n = 0; n < count; n++) {
final Preference preference = adapter.getItem(n);
final String preferenceKey = preference.getKey();
if (preferenceKey != null && preferenceKey.equals(key)) {
return n;
}
}
return -1;
}
use of android.support.v7.preference.PreferenceGroupAdapter in project android_packages_apps_Settings by DirtyUnicorns.
the class SettingsPreferenceFragment method canUseListViewForHighLighting.
/**
* Return a valid ListView position or -1 if none is found
*/
private int canUseListViewForHighLighting(String key) {
if (getListView() == null) {
return -1;
}
RecyclerView listView = getListView();
RecyclerView.Adapter adapter = listView.getAdapter();
if (adapter != null && adapter instanceof PreferenceGroupAdapter) {
return findListPositionFromKey((PreferenceGroupAdapter) adapter, key);
}
return -1;
}
use of android.support.v7.preference.PreferenceGroupAdapter in project android_packages_apps_Settings by DirtyUnicorns.
the class SettingsPreferenceFragment method findListPositionFromKey.
private int findListPositionFromKey(PreferenceGroupAdapter adapter, String key) {
final int count = adapter.getItemCount();
for (int n = 0; n < count; n++) {
final Preference preference = adapter.getItem(n);
final String preferenceKey = preference.getKey();
if (preferenceKey != null && preferenceKey.equals(key)) {
return n;
}
}
return -1;
}
use of android.support.v7.preference.PreferenceGroupAdapter in project android_packages_apps_Settings by DirtyUnicorns.
the class SettingsPreferenceFragmentTest method testHighlightCaptions.
@Test
public void testHighlightCaptions() throws InterruptedException {
final String prefKey = "captioning_preference_screen";
Bundle args = new Bundle();
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, prefKey);
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(mTargetContext, SubSettings.class);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, "com.android.settings.accessibility.AccessibilitySettings");
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
SettingsActivity activity = (SettingsActivity) mInstrumentation.startActivitySync(intent);
AccessibilitySettings fragment = (AccessibilitySettings) activity.getFragmentManager().getFragments().get(0);
// Allow time for highlight from post-delay.
Thread.sleep(SettingsPreferenceFragment.DELAY_HIGHLIGHT_DURATION_MILLIS);
if (!fragment.mPreferenceHighlighted) {
Thread.sleep(SettingsPreferenceFragment.DELAY_HIGHLIGHT_DURATION_MILLIS);
}
int prefPosition = -1;
PreferenceGroupAdapter adapter = (PreferenceGroupAdapter) fragment.getListView().getAdapter();
for (int n = 0, count = adapter.getItemCount(); n < count; n++) {
final Preference preference = adapter.getItem(n);
final String preferenceKey = preference.getKey();
if (preferenceKey.equals(prefKey)) {
prefPosition = n;
break;
}
}
assertThat(fragment.mAdapter.initialHighlightedPosition).isEqualTo(prefPosition);
}
use of android.support.v7.preference.PreferenceGroupAdapter in project platform_packages_apps_Settings by BlissRoms.
the class SettingsPreferenceFragment method findListPositionFromKey.
private int findListPositionFromKey(PreferenceGroupAdapter adapter, String key) {
final int count = adapter.getItemCount();
for (int n = 0; n < count; n++) {
final Preference preference = adapter.getItem(n);
final String preferenceKey = preference.getKey();
if (preferenceKey != null && preferenceKey.equals(key)) {
return n;
}
}
return -1;
}
Aggregations