-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
231 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.github.xwz.base"> | ||
|
||
<application android:allowBackup="true" | ||
android:label="@string/app_name" | ||
> | ||
|
||
</application> | ||
<manifest | ||
package="io.github.xwz.base" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name"/> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
base/src/main/java/io/github/xwz/base/fragments/CategoryFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package io.github.xwz.base.fragments; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v17.leanback.app.VerticalGridFragment; | ||
import android.support.v17.leanback.widget.ArrayObjectAdapter; | ||
import android.support.v17.leanback.widget.OnItemViewClickedListener; | ||
import android.support.v17.leanback.widget.Presenter; | ||
import android.support.v17.leanback.widget.Row; | ||
import android.support.v17.leanback.widget.RowPresenter; | ||
import android.support.v17.leanback.widget.VerticalGridPresenter; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
import java.util.List; | ||
|
||
import io.github.xwz.base.adapters.CardSelector; | ||
import io.github.xwz.base.adapters.EpisodePresenter; | ||
import io.github.xwz.base.adapters.FilmPresenter; | ||
import io.github.xwz.base.api.IEpisodeModel; | ||
import io.github.xwz.base.content.IContentManager; | ||
|
||
public abstract class CategoryFragment extends VerticalGridFragment { | ||
private static final String TAG = "CategoryFragment"; | ||
|
||
private static final int FILM_COLUMNS = 10; | ||
private static final int SHOW_COLUMNS = 5; | ||
private String category; | ||
private boolean isFilm = false; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
Log.d(TAG, "onCreate"); | ||
super.onCreate(savedInstanceState); | ||
category = getActivity().getIntent().getStringExtra(IContentManager.CONTENT_ID); | ||
isFilm = category.contains("Film/") || category.equals("Film"); | ||
setupFragment(); | ||
setupListeners(); | ||
} | ||
|
||
private void setupFragment() { | ||
VerticalGridPresenter gridPresenter = new VerticalGridPresenter(); | ||
gridPresenter.setNumberOfColumns(isFilm ? FILM_COLUMNS : SHOW_COLUMNS); | ||
setGridPresenter(gridPresenter); | ||
setTitle(category); | ||
|
||
List<IEpisodeModel> all = getContentManger().getAllShowsByCategory(category); | ||
ArrayObjectAdapter adapter; | ||
if (isFilm) { | ||
adapter = new ArrayObjectAdapter(new FilmPresenter(true)); | ||
} else { | ||
adapter = new ArrayObjectAdapter(new EpisodePresenter()); | ||
} | ||
adapter.addAll(0, all); | ||
|
||
setAdapter(adapter); | ||
} | ||
|
||
private void setupListeners() { | ||
setOnSearchClickedListener(getSearchClickedListener()); | ||
setOnItemViewClickedListener(getItemClickedListener()); | ||
} | ||
|
||
private View.OnClickListener getSearchClickedListener() { | ||
return new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Intent intent = new Intent(getActivity(), getSearchActivityClass()); | ||
startActivity(intent); | ||
} | ||
}; | ||
} | ||
|
||
private OnItemViewClickedListener getItemClickedListener() { | ||
return new OnItemViewClickedListener() { | ||
@Override | ||
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { | ||
if (item instanceof IEpisodeModel) { | ||
Intent intent = new Intent(getActivity(), getDetailsActivityClass()); | ||
intent.putExtra(IContentManager.CONTENT_ID, (IEpisodeModel) item); | ||
startActivity(intent); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
protected abstract IContentManager getContentManger(); | ||
|
||
protected abstract Class<?> getSearchActivityClass(); | ||
|
||
protected abstract Class<?> getDetailsActivityClass(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
iview/src/main/java/io/github/xwz/iview/activities/CategoryActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.xwz.iview.activities; | ||
|
||
import android.os.Bundle; | ||
|
||
import io.github.xwz.base.activities.BaseActivity; | ||
import io.github.xwz.iview.R; | ||
|
||
public class CategoryActivity extends BaseActivity { | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.category_activity); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
iview/src/main/java/io/github/xwz/iview/fragments/CategoryFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.xwz.iview.fragments; | ||
|
||
import io.github.xwz.base.content.IContentManager; | ||
import io.github.xwz.iview.activities.DetailsActivity; | ||
import io.github.xwz.iview.activities.SearchActivity; | ||
import io.github.xwz.iview.content.ContentManager; | ||
|
||
public class CategoryFragment extends io.github.xwz.base.fragments.CategoryFragment { | ||
@Override | ||
protected IContentManager getContentManger() { | ||
return ContentManager.getInstance(); | ||
} | ||
|
||
@Override | ||
protected Class<?> getSearchActivityClass() { | ||
return SearchActivity.class; | ||
} | ||
|
||
@Override | ||
protected Class<?> getDetailsActivityClass() { | ||
return DetailsActivity.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<fragment | ||
android:id="@+id/details_fragment" | ||
android:name="io.github.xwz.iview.fragments.CategoryFragment" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:deviceIds="tv"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
sbs/src/main/java/io/github/xwz/sbs/activities/CategoryActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.xwz.sbs.activities; | ||
|
||
import android.os.Bundle; | ||
|
||
import io.github.xwz.base.activities.BaseActivity; | ||
import io.github.xwz.sbs.R; | ||
|
||
public class CategoryActivity extends BaseActivity { | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.category_activity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
sbs/src/main/java/io/github/xwz/sbs/fragments/CategoryFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.xwz.sbs.fragments; | ||
|
||
import io.github.xwz.base.content.IContentManager; | ||
import io.github.xwz.sbs.activities.DetailsActivity; | ||
import io.github.xwz.sbs.activities.SearchActivity; | ||
import io.github.xwz.sbs.content.ContentManager; | ||
|
||
public class CategoryFragment extends io.github.xwz.base.fragments.CategoryFragment { | ||
@Override | ||
protected IContentManager getContentManger() { | ||
return ContentManager.getInstance(); | ||
} | ||
|
||
@Override | ||
protected Class<?> getSearchActivityClass() { | ||
return SearchActivity.class; | ||
} | ||
|
||
@Override | ||
protected Class<?> getDetailsActivityClass() { | ||
return DetailsActivity.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.