-
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
15 changed files
with
165 additions
and
35 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
26 changes: 26 additions & 0 deletions
26
base/src/main/java/io/github/xwz/base/adapters/CardSelector.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,26 @@ | ||
package io.github.xwz.base.adapters; | ||
|
||
import android.support.v17.leanback.widget.Presenter; | ||
import android.support.v17.leanback.widget.PresenterSelector; | ||
|
||
import io.github.xwz.base.api.CategoryModel; | ||
import io.github.xwz.base.api.IEpisodeModel; | ||
|
||
public class CardSelector extends PresenterSelector { | ||
final EpisodePresenter card = new EpisodePresenter(); | ||
final CategoryPresenter cat = new CategoryPresenter(); | ||
final FilmPresenter film = new FilmPresenter(); | ||
|
||
@Override | ||
public Presenter getPresenter(Object item) { | ||
if (item instanceof IEpisodeModel) { | ||
IEpisodeModel model = (IEpisodeModel) item; | ||
if (model instanceof CategoryModel) { | ||
return cat; | ||
} else if (model.hasCover()) { | ||
return film; | ||
} | ||
} | ||
return card; | ||
} | ||
} |
28 changes: 23 additions & 5 deletions
28
base/src/main/java/io/github/xwz/base/adapters/EpisodePresenter.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
25 changes: 25 additions & 0 deletions
25
base/src/main/java/io/github/xwz/base/adapters/FilmPresenter.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,25 @@ | ||
package io.github.xwz.base.adapters; | ||
|
||
import android.content.Context; | ||
import android.graphics.Point; | ||
import android.support.v17.leanback.widget.BaseCardView; | ||
import android.support.v17.leanback.widget.ImageCardView; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import io.github.xwz.base.R; | ||
|
||
public class FilmPresenter extends EpisodePresenter { | ||
@Override | ||
protected Point getCardSize(Context context) { | ||
return new Point(context.getResources().getDimensionPixelSize(R.dimen.poster_width), | ||
context.getResources().getDimensionPixelSize(R.dimen.poster_height)); | ||
} | ||
|
||
@Override | ||
protected ImageCardView getCardView(Context context) { | ||
ImageCardView card = super.getCardView(context); | ||
card.setCardType(BaseCardView.CARD_TYPE_MAIN_ONLY); | ||
return card; | ||
} | ||
} |
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
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
Oops, something went wrong.