diff options
Diffstat (limited to 'src/com/android/tv/guide/ProgramTableAdapter.java')
-rw-r--r-- | src/com/android/tv/guide/ProgramTableAdapter.java | 92 |
1 files changed, 6 insertions, 86 deletions
diff --git a/src/com/android/tv/guide/ProgramTableAdapter.java b/src/com/android/tv/guide/ProgramTableAdapter.java index 83755b5f..a86c1332 100644 --- a/src/com/android/tv/guide/ProgramTableAdapter.java +++ b/src/com/android/tv/guide/ProgramTableAdapter.java @@ -26,9 +26,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Bitmap; import android.media.tv.TvContentRating; -import android.media.tv.TvInputInfo; import android.os.Handler; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.RecycledViewPool; @@ -45,15 +43,11 @@ import android.widget.ImageView; import android.widget.TextView; import com.android.tv.R; -import com.android.tv.TvApplication; import com.android.tv.data.Channel; import com.android.tv.data.Program; import com.android.tv.guide.ProgramManager.TableEntriesUpdatedListener; import com.android.tv.parental.ParentalControlSettings; import com.android.tv.ui.HardwareLayerAnimatorListenerAdapter; -import com.android.tv.util.ImageCache; -import com.android.tv.util.ImageLoader; -import com.android.tv.util.ImageLoader.LoadTvInputLogoTask; import com.android.tv.util.TvInputManagerHelper; import com.android.tv.util.Utils; @@ -63,8 +57,8 @@ import java.util.List; /** * Adapts the {@link ProgramListAdapter} list to the body of the program guide table. */ -public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapter.ProgramRowHolder> - implements ProgramManager.TableEntryChangedListener { +public class ProgramTableAdapter extends + RecyclerView.Adapter<ProgramTableAdapter.ProgramRowHolder> { private static final String TAG = "ProgramTableAdapter"; private static final boolean DEBUG = false; @@ -90,10 +84,10 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte private final int mDetailPadding; private final TextAppearanceSpan mEpisodeTitleStyle; - public ProgramTableAdapter(Context context, ProgramManager programManager, - ProgramGuide programGuide) { + public ProgramTableAdapter(Context context, TvInputManagerHelper tvInputManagerHelper, + ProgramManager programManager, ProgramGuide programGuide) { mContext = context; - mTvInputManagerHelper = TvApplication.getSingletons(context).getTvInputManagerHelper(); + mTvInputManagerHelper = tvInputManagerHelper; mProgramManager = programManager; mProgramGuide = programGuide; @@ -146,7 +140,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte } }); update(); - mProgramManager.addTableEntryChangedListener(this); } private void update() { @@ -156,8 +149,7 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte } mProgramListAdapters.clear(); for (int i = 0; i < mProgramManager.getChannelCount(); i++) { - ProgramListAdapter listAdapter = new ProgramListAdapter(mContext.getResources(), - mProgramManager, i); + ProgramListAdapter listAdapter = new ProgramListAdapter(mContext, mProgramManager, i); mProgramManager.addTableEntriesUpdatedListener(listAdapter); mProgramListAdapters.add(listAdapter); } @@ -187,14 +179,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte return new ProgramRowHolder(itemView); } - @Override - public void onTableEntryChanged(ProgramManager.TableEntry tableEntry) { - int channelIndex = mProgramManager.getChannelIndex(tableEntry.channelId); - int pos = mProgramManager.getProgramIdIndex(tableEntry.channelId, tableEntry.getId()); - if (DEBUG) Log.d(TAG, "update(" + channelIndex + ", " + pos + ")"); - mProgramListAdapters.get(channelIndex).notifyItemChanged(pos, tableEntry); - } - // TODO: make it static public class ProgramRowHolder extends RecyclerView.ViewHolder implements ProgramRow.ChildFocusListener { @@ -239,9 +223,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte private final TextView mChannelNameView; private final ImageView mChannelLogoView; private final ImageView mChannelBlockView; - private final ImageView mInputLogoView; - - private boolean mIsInputLogoVisible; public ProgramRowHolder(View itemView) { super(itemView); @@ -263,7 +244,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte mChannelNameView = (TextView) mContainer.findViewById(R.id.channel_name); mChannelLogoView = (ImageView) mContainer.findViewById(R.id.channel_logo); mChannelBlockView = (ImageView) mContainer.findViewById(R.id.channel_block); - mInputLogoView = (ImageView) mContainer.findViewById(R.id.input_logo); } public void onBind(int position) { @@ -287,8 +267,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte if (DEBUG) Log.d(TAG, "onBindChannel " + channel); mChannel = channel; - mInputLogoView.setVisibility(View.GONE); - mIsInputLogoVisible = false; if (channel == null) { mChannelNumberView.setVisibility(View.GONE); mChannelNameView.setVisibility(View.GONE); @@ -489,43 +467,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte } } - /** - * Update tv input logo. It should be called when the visible child item in ProgramGrid - * changed. - */ - public void updateInputLogo(int lastPosition, boolean forceShow) { - if (mChannel == null) { - mInputLogoView.setVisibility(View.GONE); - mIsInputLogoVisible = false; - return; - } - - boolean showLogo = forceShow; - if (!showLogo) { - Channel lastChannel = mProgramManager.getChannel(lastPosition); - if (lastChannel == null - || !mChannel.getInputId().equals(lastChannel.getInputId())) { - showLogo = true; - } - } - - if (showLogo) { - if (!mIsInputLogoVisible) { - mIsInputLogoVisible = true; - TvInputInfo info = mTvInputManagerHelper.getTvInputInfo(mChannel.getInputId()); - if (info != null) { - LoadTvInputLogoTask task = new LoadTvInputLogoTask( - itemView.getContext(), ImageCache.getInstance(), info); - ImageLoader.loadBitmap(createTvInputLogoLoadedCallback(info, this), task); - } - } - } else { - mInputLogoView.setVisibility(View.GONE); - mInputLogoView.setImageDrawable(null); - mIsInputLogoVisible = false; - } - } - private void updateTextView(TextView textView, String text) { if (!TextUtils.isEmpty(text)) { textView.setVisibility(View.VISIBLE); @@ -546,14 +487,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte mChannelLogoView.setVisibility(View.VISIBLE); } - private void updateInputLogoInternal(@NonNull Bitmap tvInputLogo) { - if (!mIsInputLogoVisible) { - return; - } - mInputLogoView.setImageBitmap(tvInputLogo); - mInputLogoView.setVisibility(View.VISIBLE); - } - private void onHorizontalScrolled() { if (mDetailInAnimator != null) { mHandler.removeCallbacks(mDetailInStarter); @@ -593,17 +526,4 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte } }; } - - private static ImageLoaderCallback<ProgramRowHolder> createTvInputLogoLoadedCallback( - final TvInputInfo info, ProgramRowHolder holder) { - return new ImageLoaderCallback<ProgramRowHolder>(holder) { - @Override - public void onBitmapLoaded(ProgramRowHolder holder, @Nullable Bitmap logo) { - if (logo != null && info.getId() - .equals(holder.mChannel.getInputId())) { - holder.updateInputLogoInternal(logo); - } - } - }; - } } |