Search in sources :

Example 1 with Source

use of io.plaidapp.data.Source in project plaid by nickbutcher.

the class FilterAdapter method onDribbbleLogout.

@Override
public void onDribbbleLogout() {
    for (int i = 0; i < filters.size(); i++) {
        Source filter = filters.get(i);
        if (filter.active && isAuthorisedDribbbleSource(filter)) {
            filter.active = false;
            SourceManager.updateSource(filter, context);
            dispatchFiltersChanged(filter);
            notifyItemChanged(i, FilterAnimator.FILTER_DISABLED);
        }
    }
}
Also used : Source(io.plaidapp.data.Source)

Example 2 with Source

use of io.plaidapp.data.Source in project plaid by nickbutcher.

the class SourceManager method setupDefaultSources.

private static void setupDefaultSources(Context context, SharedPreferences.Editor editor) {
    ArrayList<Source> defaultSources = getDefaultSources(context);
    Set<String> keys = new HashSet<>(defaultSources.size());
    for (Source source : defaultSources) {
        keys.add(source.key);
        editor.putBoolean(source.key, source.active);
    }
    editor.putStringSet(KEY_SOURCES, keys);
    editor.commit();
}
Also used : Source(io.plaidapp.data.Source) HashSet(java.util.HashSet)

Example 3 with Source

use of io.plaidapp.data.Source in project plaid by nickbutcher.

the class SourceManager method getDefaultSources.

private static ArrayList<Source> getDefaultSources(Context context) {
    ArrayList<Source> defaultSources = new ArrayList<>(11);
    defaultSources.add(new Source.DesignerNewsSource(SOURCE_DESIGNER_NEWS_POPULAR, 100, context.getString(R.string.source_designer_news_popular), true));
    defaultSources.add(new Source.DesignerNewsSource(SOURCE_DESIGNER_NEWS_RECENT, 101, context.getString(R.string.source_designer_news_recent), false));
    // 200 sort order range left for DN searches
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_POPULAR, 300, context.getString(R.string.source_dribbble_popular), true));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_FOLLOWING, 301, context.getString(R.string.source_dribbble_following), false));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_USER_SHOTS, 302, context.getString(R.string.source_dribbble_user_shots), false));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_USER_LIKES, 303, context.getString(R.string.source_dribbble_user_likes), false));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_RECENT, 304, context.getString(R.string.source_dribbble_recent), false));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_DEBUTS, 305, context.getString(R.string.source_dribbble_debuts), false));
    defaultSources.add(new Source.DribbbleSource(SOURCE_DRIBBBLE_ANIMATED, 306, context.getString(R.string.source_dribbble_animated), false));
    defaultSources.add(new Source.DribbbleSearchSource(context.getString(R.string.source_dribbble_search_material_design), true));
    // 400 sort order range left for dribbble searches
    defaultSources.add(new Source(SOURCE_PRODUCT_HUNT, 500, context.getString(R.string.source_product_hunt), R.drawable.ic_product_hunt, false));
    return defaultSources;
}
Also used : ArrayList(java.util.ArrayList) Source(io.plaidapp.data.Source)

Example 4 with Source

use of io.plaidapp.data.Source in project sbt-android by scala-android.

the class SourceManager method setupDefaultSources.

private static void setupDefaultSources(Context context, SharedPreferences.Editor editor) {
    ArrayList<Source> defaultSources = getDefaultSources(context);
    Set<String> keys = new HashSet<>(defaultSources.size());
    for (Source source : defaultSources) {
        keys.add(source.key);
        editor.putBoolean(source.key, source.active);
    }
    editor.putStringSet(KEY_SOURCES, keys);
    editor.commit();
}
Also used : Source(io.plaidapp.data.Source) HashSet(java.util.HashSet)

Example 5 with Source

use of io.plaidapp.data.Source in project sbt-android by scala-android.

the class SourceManager method getSources.

public static List<Source> getSources(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(SOURCES_PREF, Context.MODE_PRIVATE);
    Set<String> sourceKeys = prefs.getStringSet(KEY_SOURCES, null);
    if (sourceKeys == null) {
        setupDefaultSources(context, prefs.edit());
        return getDefaultSources(context);
    }
    List<Source> sources = new ArrayList<>(sourceKeys.size());
    for (String sourceKey : sourceKeys) {
        if (sourceKey.startsWith(Source.DribbbleSearchSource.DRIBBBLE_QUERY_PREFIX)) {
            sources.add(new Source.DribbbleSearchSource(sourceKey.replace(Source.DribbbleSearchSource.DRIBBBLE_QUERY_PREFIX, ""), prefs.getBoolean(sourceKey, false)));
        } else if (sourceKey.startsWith(Source.DesignerNewsSearchSource.DESIGNER_NEWS_QUERY_PREFIX)) {
            sources.add(new Source.DesignerNewsSearchSource(sourceKey.replace(Source.DesignerNewsSearchSource.DESIGNER_NEWS_QUERY_PREFIX, ""), prefs.getBoolean(sourceKey, false)));
        } else {
            // TODO improve this O(n2) search
            sources.add(getSource(context, sourceKey, prefs.getBoolean(sourceKey, false)));
        }
    }
    Collections.sort(sources, new Source.SourceComparator());
    return sources;
}
Also used : SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) Source(io.plaidapp.data.Source)

Aggregations

Source (io.plaidapp.data.Source)18 RecyclerView (android.support.v7.widget.RecyclerView)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)4 FilterTouchHelperCallback (io.plaidapp.ui.recyclerview.FilterTouchHelperCallback)3 ActivityOptions (android.app.ActivityOptions)2 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)2 ViewGroup (android.view.ViewGroup)2 WindowInsets (android.view.WindowInsets)2 ActionMenuView (android.widget.ActionMenuView)2 FrameLayout (android.widget.FrameLayout)2 BindView (butterknife.BindView)2 DataManager (io.plaidapp.data.DataManager)2 InfiniteScrollListener (io.plaidapp.ui.recyclerview.InfiniteScrollListener)2 HashSet (java.util.HashSet)2