diff --git a/base/src/main/java/io/github/xwz/base/content/ContentManagerBase.java b/base/src/main/java/io/github/xwz/base/content/ContentManagerBase.java new file mode 100644 index 0000000..1e57c8c --- /dev/null +++ b/base/src/main/java/io/github/xwz/base/content/ContentManagerBase.java @@ -0,0 +1,174 @@ +package io.github.xwz.base.content; + +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.database.MatrixCursor; +import android.net.Uri; +import android.provider.BaseColumns; +import android.util.Log; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import io.github.xwz.base.models.IEpisodeModel; + +public abstract class ContentManagerBase implements IContentManager { + + private static final String TAG = "ContentManagerBase"; + + private static ContentManagerBase instance = null; + + private Context mContext = null; + private ContentCacheManager mCache = null; + + public enum RecommendationPosition { + FIRST(0), SECOND(1); + private final int id; + + private RecommendationPosition(int id) { + this.id = id; + } + + public int getId() { + return id; + } + } + + public ContentManagerBase(Context context) { + instance = this; + mContext = context; + mCache = new ContentCacheManager(context); + } + + public static ContentManagerBase getInstance() { + return instance; + } + + public static ContentCacheManager cache() { + return getInstance().mCache; + } + + protected Context getContext() { + return mContext; + } + + public void broadcastChange(String change, String tag, String id) { + mCache.broadcastChange(change, tag, id); + } + + public void broadcastChange(String change, String tag) { + mCache.broadcastChange(change, tag); + } + + public void broadcastChange(String change) { + mCache.broadcastChange(change); + } + + public List searchShows(String query) { + List results = new ArrayList<>(); + query = query.toLowerCase(); + for (IEpisodeModel episode : mCache.getAllShows()) { + if (episode.matches(query)) { + results.add(episode); + } + } + Log.d(TAG, "Search: '" + query + "' found : " + results.size()); + return results; + } + + public Cursor searchShowsCursor(String query) { + String[] columns = new String[]{ + BaseColumns._ID, + KEY_SERIES_TITLE, + KEY_TITLE, + KEY_IMAGE, + KEY_DATA_TYPE, + KEY_IS_LIVE, + KEY_VIDEO_WIDTH, + KEY_VIDEO_HEIGHT, + KEY_PRODUCTION_YEAR, + KEY_COLUMN_DURATION, + KEY_ACTION, + KEY_EXTRA_DATA, + KEY_EXTRA_NAME + }; + MatrixCursor cursor = new MatrixCursor(columns); + for (IEpisodeModel ep : searchShows(query)) { + LinkedHashMap row = new LinkedHashMap(); + row.put(BaseColumns._ID, ep.getHref()); + row.put(KEY_SERIES_TITLE, ep.getSeriesTitle()); + row.put(KEY_TITLE, ep.getTitle()); + row.put(KEY_IMAGE, ep.getThumbnail()); + row.put(KEY_DATA_TYPE, "video/mp4"); + row.put(KEY_IS_LIVE, ep.getLivestream()); + row.put(KEY_VIDEO_WIDTH, 1280); + row.put(KEY_VIDEO_HEIGHT, 720); + row.put(KEY_PRODUCTION_YEAR, 2015); + row.put(KEY_COLUMN_DURATION, ep.getDuration() * 1000); + row.put(KEY_ACTION, GLOBAL_SEARCH_INTENT); + row.put(KEY_EXTRA_DATA, ep.getHref()); + row.put(KEY_EXTRA_NAME, KEY_EXTRA_DATA); + cursor.addRow(row.values()); + } + return cursor; + } + + public List suggestions(String query) { + return mCache.getSuggestions(query); + } + + public List getAllShows() { + return mCache.getAllShows(); + } + + public IEpisodeModel getEpisode(String href) { + return mCache.getEpisode(href); + } + + public Uri getEpisodeStreamUrl(IEpisodeModel episode) { + return mCache.getEpisodeStreamUrl(episode.getHref()); + } + + public LinkedHashMap> getAllShowsByCategories() { + return cache().getCollections(); + } + + public IEpisodeModel findNextEpisode(List urls, String current) { + String next = null; + boolean found = false; + for (String href : urls) { + if (found) { + next = href; + break; + } + found = href.equals(current); + } + if (!found && next == null && urls.size() > 0) { + next = urls.get(0); + } + if (next != null) { + return getEpisode(next); + } + return null; + } + + public void recommendEpisode(Context context, IEpisodeModel ep, RecommendationPosition position) { + Intent intent = new Intent(context, getRecommendationServiceClass()); + intent.putExtra(IContentManager.CONTENT_ID, ep); + intent.putExtra(IContentManager.CONTENT_TAG, position.getId()); + context.startService(intent); + } + + public void updateRecommendations(Context context) { + List shows = getRecommendations(); + int i = 0; + for (IEpisodeModel show : shows) { + Log.d(TAG, "Recommendation: " + i + ", " + show); + if (i < 2) { + recommendEpisode(context, show, RecommendationPosition.values()[i++]); + } + } + } +} diff --git a/base/src/main/java/io/github/xwz/base/content/IContentManager.java b/base/src/main/java/io/github/xwz/base/content/IContentManager.java index ed727be..1f42d21 100644 --- a/base/src/main/java/io/github/xwz/base/content/IContentManager.java +++ b/base/src/main/java/io/github/xwz/base/content/IContentManager.java @@ -53,7 +53,6 @@ public interface IContentManager { String KEY_EXTRA_DATA = SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA; String KEY_EXTRA_NAME = SearchManager.EXTRA_DATA_KEY; - void updateRecommendations(Context context); LinkedHashMap> getAllShowsByCategories(); void fetchShowList(boolean force); IEpisodeModel getEpisode(String href); @@ -63,4 +62,8 @@ public interface IContentManager { void fetchAuthToken(IEpisodeModel episode); Uri getEpisodeStreamUrl(IEpisodeModel episode); IEpisodeModel findNextEpisode(List urls, String current); + List getAllShows(); + List getRecommendations(); + void updateRecommendations(Context context); + Class getRecommendationServiceClass(); } diff --git a/base/src/main/java/io/github/xwz/base/content/SearchProviderBase.java b/base/src/main/java/io/github/xwz/base/content/SearchProviderBase.java new file mode 100644 index 0000000..4c55e8f --- /dev/null +++ b/base/src/main/java/io/github/xwz/base/content/SearchProviderBase.java @@ -0,0 +1,76 @@ +package io.github.xwz.base.content; + +import android.app.SearchManager; +import android.content.ContentProvider; +import android.content.ContentValues; +import android.content.UriMatcher; +import android.database.Cursor; +import android.net.Uri; +import android.util.Log; + +public abstract class SearchProviderBase extends ContentProvider { + + private static String TAG = "SearchProviderBase"; + private static final int SEARCH_SUGGEST = 0; + private static final int REFRESH_SHORTCUT = 1; + + protected abstract String getAuthority(); + protected abstract Cursor getSuggestions(String query); + + @Override + public boolean onCreate() { + Log.d(TAG, "onCreate"); + return false; + } + + private UriMatcher getUriMatcher() { + UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); + // to get suggestions... + Log.d(TAG, "suggest_uri_path_query: " + SearchManager.SUGGEST_URI_PATH_QUERY); + matcher.addURI(getAuthority(), SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); + matcher.addURI(getAuthority(), SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); + return matcher; + } + + @Override + public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + switch (getUriMatcher().match(uri)) { + case SEARCH_SUGGEST: + Log.d(TAG, "search suggest: " + selectionArgs[0] + " URI: " + uri); + if (selectionArgs == null) { + throw new IllegalArgumentException( + "selectionArgs must be provided for the Uri: " + uri); + } + return getSuggestions(selectionArgs[0]); + default: + throw new IllegalArgumentException("Unknown Uri: " + uri+" authority: " + getAuthority()); + } + } + + @Override + public String getType(Uri uri) { + switch (getUriMatcher().match(uri)) { + case SEARCH_SUGGEST: + return SearchManager.SUGGEST_MIME_TYPE; + case REFRESH_SHORTCUT: + return SearchManager.SHORTCUT_MIME_TYPE; + default: + throw new IllegalArgumentException("Unknown URL " + uri); + } + } + + @Override + public Uri insert(Uri uri, ContentValues values) { + return null; + } + + @Override + public int delete(Uri uri, String selection, String[] selectionArgs) { + return 0; + } + + @Override + public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { + return 0; + } +} diff --git a/base/src/main/java/io/github/xwz/base/fragments/SearchFragment.java b/base/src/main/java/io/github/xwz/base/fragments/SearchFragment.java index 8b87eea..40f4757 100644 --- a/base/src/main/java/io/github/xwz/base/fragments/SearchFragment.java +++ b/base/src/main/java/io/github/xwz/base/fragments/SearchFragment.java @@ -97,6 +97,7 @@ public void setQuery(String str) { @Override public void run() { + Log.d(TAG, "Searching: " + query); List results = getContentManger().searchShows(query); EpisodePresenter card = new EpisodePresenter(); ArrayObjectAdapter row = new ArrayObjectAdapter(card); diff --git a/iview/src/main/java/io/github/xwz/iview/content/ContentManager.java b/iview/src/main/java/io/github/xwz/iview/content/ContentManager.java index 1894dbc..537d8b4 100644 --- a/iview/src/main/java/io/github/xwz/iview/content/ContentManager.java +++ b/iview/src/main/java/io/github/xwz/iview/content/ContentManager.java @@ -1,13 +1,7 @@ package io.github.xwz.iview.content; import android.content.Context; -import android.content.Intent; -import android.database.Cursor; -import android.database.MatrixCursor; -import android.net.Uri; import android.os.AsyncTask; -import android.provider.BaseColumns; -import android.util.Log; import java.util.ArrayList; import java.util.Date; @@ -15,15 +9,14 @@ import java.util.List; import java.util.Map; -import io.github.xwz.base.content.ContentCacheManager; +import io.github.xwz.base.ImmutableMap; +import io.github.xwz.base.content.ContentManagerBase; +import io.github.xwz.base.models.IEpisodeModel; import io.github.xwz.iview.api.AuthApi; import io.github.xwz.iview.api.EpisodeDetailsApi; import io.github.xwz.iview.api.TvShowListApi; -import io.github.xwz.base.ImmutableMap; -import io.github.xwz.base.content.IContentManager; -import io.github.xwz.base.models.IEpisodeModel; -public class ContentManager implements IContentManager { +public class ContentManager extends ContentManagerBase { public static final Map CATEGORIES = ImmutableMap.of( "arts", "Arts & Culture", @@ -45,144 +38,47 @@ public class ContentManager implements IContentManager { "iview", "iView Exclusives" ); - private static final String TAG = "ContentManager"; - - public enum RecommendationPosition { - FIRST(0), SECOND(1); - private final int id; - - private RecommendationPosition(int id) { - this.id = id; - } - - public int getId() { - return id; - } - } - - private Context mContext = null; - private ContentCacheManager mCache = null; - - private static ContentManager instance = null; - public ContentManager(Context context) { - instance = this; - mContext = context; - mCache = new ContentCacheManager(context); - } - - public static ContentManager getInstance() { - return instance; - } - - public static ContentCacheManager cache() { - return getInstance().mCache; - } - - public void broadcastChange(String change, String tag, String id) { - mCache.broadcastChange(change, tag, id); - } - - public void broadcastChange(String change, String tag) { - mCache.broadcastChange(change, tag); - } - - public void broadcastChange(String change) { - mCache.broadcastChange(change); - } - - @Override - public void fetchAuthToken(IEpisodeModel episode) { - mCache.broadcastChange(CONTENT_AUTH_FETCHING, episode.getHref()); - new AuthApi(mContext, episode.getHref()).execute(episode.getStream()); + super(context); } private TvShowListApi fetchShows; private long lastFetchList = 0; + @Override public void fetchShowList(boolean force) { long now = (new Date()).getTime(); boolean shouldFetch = force || now - lastFetchList > 1800000; if (shouldFetch && (fetchShows == null || fetchShows.getStatus() == AsyncTask.Status.FINISHED)) { - mCache.broadcastChange(CONTENT_SHOW_LIST_FETCHING); - fetchShows = new TvShowListApi(mContext); + broadcastChange(CONTENT_SHOW_LIST_FETCHING); + fetchShows = new TvShowListApi(getContext()); fetchShows.execute(); lastFetchList = now; } } + @Override + public void fetchAuthToken(IEpisodeModel episode) { + cache().broadcastChange(CONTENT_AUTH_FETCHING, episode.getHref()); + new AuthApi(getContext(), episode.getHref()).execute(episode.getStream()); + } + @Override public void fetchEpisode(IEpisodeModel episode) { - mCache.broadcastChange(CONTENT_EPISODE_FETCHING, episode.getHref()); - IEpisodeModel existing = mCache.getEpisode(episode.getHref()); + broadcastChange(CONTENT_EPISODE_FETCHING, episode.getHref()); + IEpisodeModel existing = getEpisode(episode.getHref()); if (existing != null && existing.hasExtras() && existing.hasOtherEpisodes()) { - mCache.broadcastChangeDelayed(100, CONTENT_EPISODE_DONE, episode.getHref(), null); + cache().broadcastChangeDelayed(100, CONTENT_EPISODE_DONE, episode.getHref(), null); } else { - new EpisodeDetailsApi(mContext, episode.getHref()).execute(episode.getHref()); - } - } - - public List searchShows(String query) { - List results = new ArrayList<>(); - query = query.toLowerCase(); - for (IEpisodeModel episode : mCache.getAllShows()) { - if (episode.matches(query)) { - results.add(episode); - } + new EpisodeDetailsApi(getContext(), episode.getHref()).execute(episode.getHref()); } - Log.d(TAG, "Search: '" + query + "' found : " + results.size()); - return results; - } - - public Cursor searchShowsCursor(String query) { - String[] columns = new String[]{ - BaseColumns._ID, - KEY_SERIES_TITLE, - KEY_TITLE, - KEY_IMAGE, - KEY_DATA_TYPE, - KEY_IS_LIVE, - KEY_VIDEO_WIDTH, - KEY_VIDEO_HEIGHT, - KEY_PRODUCTION_YEAR, - KEY_COLUMN_DURATION, - KEY_ACTION, - KEY_EXTRA_DATA, - KEY_EXTRA_NAME - }; - MatrixCursor cursor = new MatrixCursor(columns); - for (IEpisodeModel ep : searchShows(query)) { - LinkedHashMap row = new LinkedHashMap(); - row.put(BaseColumns._ID, ep.getHref()); - row.put(KEY_SERIES_TITLE, ep.getSeriesTitle()); - row.put(KEY_TITLE, ep.getTitle()); - row.put(KEY_IMAGE, ep.getThumbnail()); - row.put(KEY_DATA_TYPE, "video/mp4"); - row.put(KEY_IS_LIVE, ep.getLivestream()); - row.put(KEY_VIDEO_WIDTH, 1280); - row.put(KEY_VIDEO_HEIGHT, 720); - row.put(KEY_PRODUCTION_YEAR, 2015); - row.put(KEY_COLUMN_DURATION, ep.getDuration() * 1000); - row.put(KEY_ACTION, GLOBAL_SEARCH_INTENT); - row.put(KEY_EXTRA_DATA, ep.getHref()); - row.put(KEY_EXTRA_NAME, KEY_EXTRA_DATA); - cursor.addRow(row.values()); - } - return cursor; - } - - public List suggestions(String query) { - return mCache.getSuggestions(query); - } - - public List getAllShows() { - return mCache.getAllShows(); } + @Override public LinkedHashMap> getAllShowsByCategories() { - List shows = mCache.getAllShows(); + List shows = getAllShows(); LinkedHashMap> all = new LinkedHashMap<>(); - all.putAll(mCache.getCollections()); + all.putAll(cache().getCollections()); for (Map.Entry channel : CHANNELS.entrySet()) { List episodes = new ArrayList<>(); @@ -205,33 +101,7 @@ public LinkedHashMap> getAllShowsByCategories() { return all; } - public IEpisodeModel getEpisode(String href) { - return mCache.getEpisode(href); - } - - public Uri getEpisodeStreamUrl(IEpisodeModel episode) { - return mCache.getEpisodeStreamUrl(episode.getHref()); - } - - public IEpisodeModel findNextEpisode(List urls, String current) { - String next = null; - boolean found = false; - for (String href : urls) { - if (found) { - next = href; - break; - } - found = href.equals(current); - } - if (!found && next == null && urls.size() > 0) { - next = urls.get(0); - } - if (next != null) { - return ContentManager.getInstance().getEpisode(next); - } - return null; - } - + @Override public List getRecommendations() { List all = getAllShows(); if (all.size() > 40) { @@ -240,21 +110,8 @@ public List getRecommendations() { return new ArrayList<>(); } - public void recommendEpisode(Context context, IEpisodeModel ep, RecommendationPosition position) { - Intent intent = new Intent(context, RecommendationsService.class); - intent.putExtra(ContentManager.CONTENT_ID, ep); - intent.putExtra(ContentManager.CONTENT_TAG, position.getId()); - context.startService(intent); - } - - public void updateRecommendations(Context context) { - List shows = ContentManager.getInstance().getRecommendations(); - int i = 0; - for (IEpisodeModel show : shows) { - Log.d(TAG, "Recommendation: " + i + ", " + show); - if (i < 2) { - recommendEpisode(context, show, RecommendationPosition.values()[i++]); - } - } + @Override + public Class getRecommendationServiceClass() { + return RecommendationsService.class; } } diff --git a/iview/src/main/java/io/github/xwz/iview/content/SearchContentProvider.java b/iview/src/main/java/io/github/xwz/iview/content/SearchContentProvider.java index af4e0ea..c06c604 100644 --- a/iview/src/main/java/io/github/xwz/iview/content/SearchContentProvider.java +++ b/iview/src/main/java/io/github/xwz/iview/content/SearchContentProvider.java @@ -1,80 +1,20 @@ package io.github.xwz.iview.content; -import android.app.SearchManager; -import android.content.ContentProvider; -import android.content.ContentValues; -import android.content.UriMatcher; import android.database.Cursor; -import android.net.Uri; -import android.util.Log; -public class SearchContentProvider extends ContentProvider { +import io.github.xwz.base.content.SearchProviderBase; - public static String AUTHORITY = "io.github.xwz.iview.search"; - - private static String TAG = "SearchContentProvider"; - private static final int SEARCH_SUGGEST = 0; - private static final int REFRESH_SHORTCUT = 1; - private static final UriMatcher URI_MATCHER = buildUriMatcher(); +public class SearchContentProvider extends SearchProviderBase { - private static UriMatcher buildUriMatcher() { - UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); - // to get suggestions... - Log.d(TAG, "suggest_uri_path_query: " + SearchManager.SUGGEST_URI_PATH_QUERY); - matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); - matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); - return matcher; - } + public static String AUTHORITY = "io.github.xwz.iview.search"; @Override - public boolean onCreate() { - Log.d(TAG, "onCreate"); - return false; + protected String getAuthority() { + return AUTHORITY; } @Override - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - switch (URI_MATCHER.match(uri)) { - case SEARCH_SUGGEST: - Log.d(TAG, "search suggest: " + selectionArgs[0] + " URI: " + uri); - if (selectionArgs == null) { - throw new IllegalArgumentException( - "selectionArgs must be provided for the Uri: " + uri); - } - return getSuggestions(selectionArgs[0]); - default: - throw new IllegalArgumentException("Unknown Uri: " + uri); - } - } - - private Cursor getSuggestions(String query) { + protected Cursor getSuggestions(String query) { return ContentManager.getInstance().searchShowsCursor(query); } - - @Override - public String getType(Uri uri) { - switch (URI_MATCHER.match(uri)) { - case SEARCH_SUGGEST: - return SearchManager.SUGGEST_MIME_TYPE; - case REFRESH_SHORTCUT: - return SearchManager.SHORTCUT_MIME_TYPE; - default: - throw new IllegalArgumentException("Unknown URL " + uri); - } - } - - @Override - public Uri insert(Uri uri, ContentValues values) { - return null; - } - - @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { - return 0; - } - - @Override - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - return 0; - } } diff --git a/sbs/src/main/AndroidManifest.xml b/sbs/src/main/AndroidManifest.xml index e10f218..398eee4 100644 --- a/sbs/src/main/AndroidManifest.xml +++ b/sbs/src/main/AndroidManifest.xml @@ -51,12 +51,12 @@ - + diff --git a/sbs/src/main/java/io/github/xwz/sbs/content/ContentManager.java b/sbs/src/main/java/io/github/xwz/sbs/content/ContentManager.java index 5cade5b..7449376 100644 --- a/sbs/src/main/java/io/github/xwz/sbs/content/ContentManager.java +++ b/sbs/src/main/java/io/github/xwz/sbs/content/ContentManager.java @@ -5,116 +5,66 @@ import android.os.AsyncTask; import android.util.Log; +import java.util.ArrayList; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import io.github.xwz.base.content.ContentCacheManager; +import io.github.xwz.base.content.ContentManagerBase; import io.github.xwz.base.content.IContentManager; import io.github.xwz.base.models.IEpisodeModel; import io.github.xwz.sbs.api.SBSApi; import io.github.xwz.sbs.api.SBSAuthApi; import io.github.xwz.sbs.api.SBSRelatedApi; -public class ContentManager implements IContentManager { +public class ContentManager extends ContentManagerBase { - private static ContentManager instance = null; + private SBSApi fetchShows; - private Context mContext = null; - private ContentCacheManager mCache = null; + private long lastFetchList = 0; public ContentManager(Context context) { - instance = this; - mContext = context; - mCache = new ContentCacheManager(context); - } - - public static ContentManager getInstance() { - return instance; - } - - public static ContentCacheManager cache() { - return getInstance().mCache; - } - - public void broadcastChange(String change, String tag, String id) { - mCache.broadcastChange(change, tag, id); - } - - public void broadcastChange(String change, String tag) { - mCache.broadcastChange(change, tag); - } - - public void broadcastChange(String change) { - mCache.broadcastChange(change); - } - - @Override - public void updateRecommendations(Context context) { - - } - - @Override - public LinkedHashMap> getAllShowsByCategories() { - return mCache.getCollections(); + super(context); } - private SBSApi fetchShows; - - private long lastFetchList = 0; - @Override public void fetchShowList(boolean force) { long now = (new Date()).getTime(); boolean shouldFetch = force || now - lastFetchList > 1800000; Log.d("ContentManager", "diff:" + (now - lastFetchList)); if (shouldFetch && (fetchShows == null || fetchShows.getStatus() == AsyncTask.Status.FINISHED)) { - mCache.broadcastChange(CONTENT_SHOW_LIST_FETCHING); - fetchShows = new SBSApi(mContext); + cache().broadcastChange(CONTENT_SHOW_LIST_FETCHING); + fetchShows = new SBSApi(getContext()); fetchShows.execute(); lastFetchList = now; } } - @Override - public IEpisodeModel getEpisode(String href) { - return mCache.getEpisode(href); - } - @Override public void fetchEpisode(IEpisodeModel episode) { - mCache.broadcastChange(CONTENT_EPISODE_FETCHING, episode.getHref()); - IEpisodeModel existing = mCache.getEpisode(episode.getHref()); + broadcastChange(CONTENT_EPISODE_FETCHING, episode.getHref()); + IEpisodeModel existing = cache().getEpisode(episode.getHref()); if (existing != null && existing.hasExtras() && existing.hasOtherEpisodes()) { - mCache.broadcastChangeDelayed(100, CONTENT_EPISODE_DONE, episode.getHref(), null); + cache().broadcastChangeDelayed(100, CONTENT_EPISODE_DONE, episode.getHref(), null); } else { - new SBSRelatedApi(mContext, episode.getHref()).execute(episode.getHref()); + new SBSRelatedApi(getContext(), episode.getHref()).execute(episode.getHref()); } } - @Override - public List suggestions(String query) { - return null; - } - - @Override - public List searchShows(String query) { - return null; - } - @Override public void fetchAuthToken(IEpisodeModel episode) { - mCache.broadcastChange(CONTENT_AUTH_FETCHING, episode.getHref()); - new SBSAuthApi(mContext, episode.getHref()).execute(episode.getHref()); + cache().broadcastChange(CONTENT_AUTH_FETCHING, episode.getHref()); + new SBSAuthApi(getContext() , episode.getHref()).execute(episode.getHref()); } @Override - public Uri getEpisodeStreamUrl(IEpisodeModel episode) { - return mCache.getEpisodeStreamUrl(episode.getHref()); + public List getRecommendations() { + return new ArrayList<>(); } @Override - public IEpisodeModel findNextEpisode(List urls, String current) { + public Class getRecommendationServiceClass() { return null; } } diff --git a/sbs/src/main/java/io/github/xwz/sbs/content/SearchContentProvider.java b/sbs/src/main/java/io/github/xwz/sbs/content/SearchContentProvider.java new file mode 100644 index 0000000..c36bca6 --- /dev/null +++ b/sbs/src/main/java/io/github/xwz/sbs/content/SearchContentProvider.java @@ -0,0 +1,19 @@ +package io.github.xwz.sbs.content; + +import android.database.Cursor; + +import io.github.xwz.base.content.SearchProviderBase; + +public class SearchContentProvider extends SearchProviderBase { + + public static String AUTHORITY = "io.github.xwz.sbs.search"; + + @Override + protected String getAuthority() { + return AUTHORITY; + } + + protected Cursor getSuggestions(String query) { + return ContentManager.getInstance().searchShowsCursor(query); + } +} diff --git a/sbs/src/main/java/io/github/xwz/sbs/fragments/MainFragment.java b/sbs/src/main/java/io/github/xwz/sbs/fragments/MainFragment.java index 2e60e86..f43ec50 100644 --- a/sbs/src/main/java/io/github/xwz/sbs/fragments/MainFragment.java +++ b/sbs/src/main/java/io/github/xwz/sbs/fragments/MainFragment.java @@ -6,6 +6,7 @@ import io.github.xwz.base.content.IContentManager; import io.github.xwz.sbs.R; import io.github.xwz.sbs.activities.DetailsActivity; +import io.github.xwz.sbs.activities.SearchActivity; import io.github.xwz.sbs.content.ContentManager; @@ -29,7 +30,7 @@ protected BrowseFrameLayout getBrowseFrame(View root) { @Override protected Class getSearchActivityClass() { - return null; + return SearchActivity.class; } @Override