Search in sources :

Example 16 with PreferenceGroupAdapter

use of android.support.v7.preference.PreferenceGroupAdapter in project materialistic by hidroh.

the class FontPreferenceTest method setUp.

@Before
public void setUp() {
    controller = Robolectric.buildActivity(PreferencesActivity.class);
    activity = controller.withIntent(new Intent().putExtra(PreferencesActivity.EXTRA_TITLE, R.string.display).putExtra(PreferencesActivity.EXTRA_PREFERENCES, R.xml.preferences_display)).create().postCreate(null).start().resume().visible().get();
    RecyclerView list = (RecyclerView) activity.findViewById(R.id.list);
    list.setLayoutManager(new LinearLayoutManager(activity));
    RecyclerView.Adapter adapter = list.getAdapter();
    int position = ShadowSupportPreferenceManager.getPreferencePosition((PreferenceGroupAdapter) adapter, FontPreference.class);
    RecyclerView.ViewHolder holder = CustomShadows.customShadowOf(adapter).getViewHolder(position);
    preferenceView = holder.itemView;
}
Also used : PreferencesActivity(io.github.hidroh.materialistic.PreferencesActivity) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Before(org.junit.Before)

Example 17 with PreferenceGroupAdapter

use of android.support.v7.preference.PreferenceGroupAdapter in project materialistic by hidroh.

the class FontSizePreferenceTest method setUp.

@Before
public void setUp() {
    controller = Robolectric.buildActivity(PreferencesActivity.class);
    activity = controller.withIntent(new Intent().putExtra(PreferencesActivity.EXTRA_TITLE, R.string.display).putExtra(PreferencesActivity.EXTRA_PREFERENCES, R.xml.preferences_display)).create().postCreate(null).start().resume().visible().get();
    RecyclerView list = (RecyclerView) activity.findViewById(R.id.list);
    list.setLayoutManager(new LinearLayoutManager(activity));
    RecyclerView.Adapter adapter = list.getAdapter();
    int position = ShadowSupportPreferenceManager.getPreferencePosition((PreferenceGroupAdapter) adapter, FontSizePreference.class);
    RecyclerView.ViewHolder holder = CustomShadows.customShadowOf(adapter).getViewHolder(position);
    preferenceView = holder.itemView;
}
Also used : PreferencesActivity(io.github.hidroh.materialistic.PreferencesActivity) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Before(org.junit.Before)

Example 18 with PreferenceGroupAdapter

use of android.support.v7.preference.PreferenceGroupAdapter in project materialistic by hidroh.

the class ThemePreferenceTest method setUp.

@Before
public void setUp() {
    controller = Robolectric.buildActivity(PreferencesActivity.class);
    activity = controller.withIntent(new Intent().putExtra(PreferencesActivity.EXTRA_TITLE, R.string.display).putExtra(PreferencesActivity.EXTRA_PREFERENCES, R.xml.preferences_display)).create().postCreate(null).start().resume().visible().get();
    RecyclerView list = (RecyclerView) activity.findViewById(R.id.list);
    list.setLayoutManager(new LinearLayoutManager(activity));
    RecyclerView.Adapter adapter = list.getAdapter();
    int position = ShadowSupportPreferenceManager.getPreferencePosition((PreferenceGroupAdapter) adapter, ThemePreference.class);
    RecyclerView.ViewHolder holder = CustomShadows.customShadowOf(adapter).getViewHolder(position);
    preferenceView = holder.itemView;
}
Also used : PreferencesActivity(io.github.hidroh.materialistic.PreferencesActivity) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Before(org.junit.Before)

Example 19 with PreferenceGroupAdapter

use of android.support.v7.preference.PreferenceGroupAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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;
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference)

Example 20 with PreferenceGroupAdapter

use of android.support.v7.preference.PreferenceGroupAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) PreferenceGroupAdapter(android.support.v7.preference.PreferenceGroupAdapter)

Aggregations

Preference (android.support.v7.preference.Preference)14 PreferenceGroupAdapter (android.support.v7.preference.PreferenceGroupAdapter)14 RecyclerView (android.support.v7.widget.RecyclerView)11 Intent (android.content.Intent)9 LayoutPreference (com.android.settings.applications.LayoutPreference)7 Bundle (android.os.Bundle)6 SmallTest (android.support.test.filters.SmallTest)6 AccessibilitySettings (com.android.settings.accessibility.AccessibilitySettings)6 CustomDialogPreference (com.android.settingslib.CustomDialogPreference)6 CustomEditTextPreference (com.android.settingslib.CustomEditTextPreference)6 Test (org.junit.Test)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 PreferencesActivity (io.github.hidroh.materialistic.PreferencesActivity)3 Before (org.junit.Before)3 CustomDialogPreference (org.cyanogenmod.cmparts.widget.CustomDialogPreference)1 LayoutPreference (org.cyanogenmod.cmparts.widget.LayoutPreference)1