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);
}
}
}
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();
}
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;
}
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();
}
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;
}
Aggregations