Fix live home sort

pull/123/head
FongMi 3 years ago
parent 0b7bfdd211
commit e2a0636b69
  1. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/adapter/LiveAdapter.java
  2. 29
      app/src/leanback/res/layout/adapter_live.xml
  3. 8
      app/src/leanback/res/layout/dialog_live.xml
  4. 9
      app/src/main/java/com/fongmi/android/tv/bean/Live.java

@ -10,7 +10,6 @@ import com.fongmi.android.tv.api.LiveConfig;
import com.fongmi.android.tv.bean.Live;
import com.fongmi.android.tv.databinding.AdapterLiveBinding;
import java.util.Collections;
import java.util.List;
public class LiveAdapter extends RecyclerView.Adapter<LiveAdapter.ViewHolder> {
@ -21,7 +20,6 @@ public class LiveAdapter extends RecyclerView.Adapter<LiveAdapter.ViewHolder> {
public LiveAdapter(OnClickListener listener) {
this.mListener = listener;
this.mItems = LiveConfig.get().getLives();
Collections.sort(mItems, new Live.Sorter());
}
public interface OnClickListener {

@ -1,22 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_text"
android:ellipsize="middle"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="18sp"
tools:text="https://fongmi.github.io/live.json" />
</LinearLayout>
android:background="@drawable/selector_text"
android:ellipsize="middle"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="18sp"
tools:text="https://fongmi.github.io/live.json" />

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<com.fongmi.android.tv.ui.custom.CustomRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:maxHeight="236dp"
tools:itemCount="5"
tools:listitem="@layout/adapter_live" />

@ -8,7 +8,6 @@ import com.google.gson.JsonElement;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class Live {
@ -129,12 +128,4 @@ public class Live {
Live it = (Live) obj;
return getName().equals(it.getName()) && getUrl().equals(it.getUrl());
}
public static class Sorter implements Comparator<Live> {
@Override
public int compare(Live live1, Live live2) {
return Boolean.compare(live2.isActivated(), live1.isActivated());
}
}
}

Loading…
Cancel
Save