Support epg - part 4

pull/362/head
FongMi 2 years ago
parent e8daa3f0b1
commit e562a28acf
  1. 30
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  2. 2
      app/src/leanback/res/layout/activity_live.xml
  3. 52
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  4. 9
      app/src/mobile/java/com/fongmi/android/tv/ui/adapter/EpgAdapter.java
  5. 22
      app/src/mobile/res/layout/activity_live.xml
  6. 12
      app/src/mobile/res/layout/view_widget_live.xml

@ -274,9 +274,9 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
}
private void setWidth(Live live) {
int base = ResUtil.dp2px(50);
for (Group group : live.getGroups()) live.setWidth(Math.max(live.getWidth(), ResUtil.getTextWidth(group.getName(), 16)));
mBinding.group.getLayoutParams().width = live.getWidth() == 0 ? 0 : Math.min(live.getWidth() + base, ResUtil.dp2px(200));
for (Group item : live.getGroups()) live.setWidth(Math.max(live.getWidth(), ResUtil.getTextWidth(item.getName(), 16)));
mBinding.group.getLayoutParams().width = live.getWidth() == 0 ? 0 : Math.min(live.getWidth() + ResUtil.dp2px(50), ResUtil.dp2px(200));
mBinding.channel.getLayoutParams().width = live.getLogo().isEmpty() ? ResUtil.dp2px(200) : ResUtil.dp2px(260);
mBinding.divide.setVisibility(live.getWidth() == 0 ? View.GONE : View.VISIBLE);
}
@ -465,17 +465,6 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
App.removeCallbacks(mR3);
}
private void showEpg() {
String epg = mChannel.getData().getEpg();
mBinding.widget.name.setMaxEms(epg.isEmpty() ? mChannel.getName().length() : 12);
mBinding.widget.play.setText(epg);
setMetadata();
}
private void setEpg(Epg epg) {
if (mChannel != null && mChannel.getName().equals(epg.getKey())) showEpg();
}
private void setTraffic() {
Traffic.setSpeed(mBinding.widget.traffic);
App.post(mR2, Constant.INTERVAL_TRAFFIC);
@ -584,7 +573,18 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
mBinding.control.line.setText(mChannel.getLineText());
mBinding.widget.line.setVisibility(mChannel.getLineVisible());
mBinding.control.line.setVisibility(mChannel.getLineVisible());
showEpg();
setEpg();
}
private void setEpg() {
String epg = mChannel.getData().getEpg();
mBinding.widget.name.setMaxEms(epg.isEmpty() ? mChannel.getName().length() : 12);
mBinding.widget.play.setText(epg);
setMetadata();
}
private void setEpg(Epg epg) {
if (mChannel != null && mChannel.getName().equals(epg.getKey())) setEpg();
}
private void fetch() {

@ -78,7 +78,7 @@
<com.fongmi.android.tv.ui.custom.CustomLiveListView
android:id="@+id/channel"
android:layout_width="280dp"
android:layout_width="0dp"
android:layout_height="match_parent"
tools:itemCount="5"
tools:listitem="@layout/adapter_channel" />

@ -79,7 +79,7 @@ import java.util.List;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
public class LiveActivity extends BaseActivity implements CustomKeyDownLive.Listener, TrackDialog.Listener, Biometric.Callback, PassCallback, LiveCallback, GroupAdapter.OnClickListener, ChannelAdapter.OnClickListener, SubtitleCallback, CastDialog.Listener, InfoDialog.Listener {
public class LiveActivity extends BaseActivity implements CustomKeyDownLive.Listener, TrackDialog.Listener, Biometric.Callback, PassCallback, LiveCallback, GroupAdapter.OnClickListener, ChannelAdapter.OnClickListener, EpgAdapter.OnClickListener, SubtitleCallback, CastDialog.Listener, InfoDialog.Listener {
private ActivityLiveBinding mBinding;
private ChannelAdapter mChannelAdapter;
@ -204,17 +204,13 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
mBinding.control.action.speed.setOnLongClickListener(view -> onSpeedLong());
mBinding.control.action.getRoot().setOnTouchListener(this::onActionTouch);
mBinding.video.setOnTouchListener((view, event) -> mKeyDown.onTouchEvent(event));
mBinding.channel.setOnTouchListener(this::onRecyclerTouch);
mBinding.group.setOnTouchListener(this::onRecyclerTouch);
mBinding.epg.setOnTouchListener(this::onRecyclerTouch);
}
private void setRecyclerView() {
mBinding.epg.setItemAnimator(null);
mBinding.group.setItemAnimator(null);
mBinding.channel.setItemAnimator(null);
mBinding.epg.setAdapter(mEpgAdapter = new EpgAdapter());
mBinding.group.setAdapter(mGroupAdapter = new GroupAdapter(this));
mBinding.widget.epg.setAdapter(mEpgAdapter = new EpgAdapter(this));
mBinding.channel.setAdapter(mChannelAdapter = new ChannelAdapter(this));
}
@ -309,7 +305,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
for (Group item : live.getGroups()) live.setWidth(Math.max(live.getWidth(), ResUtil.getTextWidth(item.getName(), 14)));
mBinding.group.getLayoutParams().width = live.getWidth() == 0 ? 0 : Math.min(live.getWidth() + ResUtil.dp2px(44), ResUtil.dp2px(180));
mBinding.channel.getLayoutParams().width = live.getLogo().isEmpty() ? ResUtil.dp2px(180) : ResUtil.dp2px(236);
mBinding.divide1.setVisibility(live.getWidth() == 0 ? View.GONE : View.VISIBLE);
mBinding.divide.setVisibility(live.getWidth() == 0 ? View.GONE : View.VISIBLE);
}
private void setPosition(int[] position) {
@ -331,7 +327,6 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
if (change) mChannelAdapter.addAll(mGroup.getChannel());
mChannelAdapter.setSelected(mGroup.getPosition());
mBinding.channel.scrollToPosition(mGroup.getPosition());
mBinding.epg.scrollToPosition(mEpgAdapter.getPosition());
}
private void onCast() {
@ -455,11 +450,6 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
return false;
}
private boolean onRecyclerTouch(View v, MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) onSingleTap();
return true;
}
private void hideUI() {
if (isGone(mBinding.recycler)) return;
mBinding.recycler.setVisibility(View.GONE);
@ -529,20 +519,6 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
App.removeCallbacks(mR3);
}
private void showEpg() {
String epg = mChannel.getData().getEpg();
mBinding.widget.play.setText(epg);
mBinding.widget.name.setMaxEms(epg.isEmpty() ? mChannel.getName().length() : 12);
mBinding.epg.setVisibility(mChannel.getData().getList().isEmpty() ? View.GONE : View.VISIBLE);
mBinding.divide2.setVisibility(mChannel.getData().getList().isEmpty() ? View.GONE : View.VISIBLE);
mEpgAdapter.addAll(mChannel.getData().getList());
setMetadata();
}
private void setEpg(Epg epg) {
if (mChannel != null && mChannel.getName().equals(epg.getKey())) showEpg();
}
private void setTraffic() {
Traffic.setSpeed(mBinding.widget.traffic);
App.post(mR2, Constant.INTERVAL_TRAFFIC);
@ -623,6 +599,11 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
return true;
}
@Override
public void onItemClick(Epg item) {
}
private void addKeep(Channel item) {
getKeep().add(item);
Keep keep = new Keep();
@ -649,7 +630,19 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
mBinding.widget.line.setVisibility(mChannel.getLineVisible());
mBinding.control.action.line.setText(mBinding.widget.line.getText());
mBinding.control.action.line.setVisibility(mBinding.widget.line.getVisibility());
showEpg();
setEpg();
}
private void setEpg() {
String epg = mChannel.getData().getEpg();
mBinding.widget.name.setMaxEms(epg.isEmpty() ? mChannel.getName().length() : 12);
mEpgAdapter.addAll(mChannel.getData().getList());
mBinding.widget.play.setText(epg);
setMetadata();
}
private void setEpg(Epg epg) {
if (mChannel != null && mChannel.getName().equals(epg.getKey())) setEpg();
}
private void fetch() {
@ -674,8 +667,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
}
private void resetAdapter() {
mBinding.divide1.setVisibility(View.GONE);
mBinding.divide2.setVisibility(View.GONE);
mBinding.divide.setVisibility(View.GONE);
mChannelAdapter.clear();
mGroupAdapter.clear();
mEpgAdapter.clear();

@ -14,12 +14,19 @@ import java.util.List;
public class EpgAdapter extends RecyclerView.Adapter<EpgAdapter.ViewHolder> {
private final OnClickListener mListener;
private final List<Epg> mItems;
public EpgAdapter() {
public EpgAdapter(OnClickListener listener) {
this.mListener = listener;
this.mItems = new ArrayList<>();
}
public interface OnClickListener {
void onItemClick(Epg item);
}
public void clear() {
mItems.clear();
notifyDataSetChanged();

@ -72,7 +72,7 @@
tools:listitem="@layout/adapter_group" />
<View
android:id="@+id/divide1"
android:id="@+id/divide"
android:layout_width="0.3dp"
android:layout_height="match_parent"
android:background="@color/grey_700"
@ -80,7 +80,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/channel"
android:layout_width="180dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
@ -89,24 +89,6 @@
tools:itemCount="5"
tools:listitem="@layout/adapter_channel" />
<View
android:id="@+id/divide2"
android:layout_width="0.3dp"
android:layout_height="match_parent"
android:background="@color/grey_700"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/epg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:padding="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="5"
tools:listitem="@layout/adapter_epg" />
</LinearLayout>
</FrameLayout>

@ -182,6 +182,18 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/epg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:padding="8dp"
android:visibility="gone"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="5"
tools:listitem="@layout/adapter_epg" />
<LinearLayout
android:id="@+id/info_pip"
android:layout_width="match_parent"

Loading…
Cancel
Save