Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
SDL committed Jun 27, 2022
1 parent b9b2ce1 commit ba2fc9e
Show file tree
Hide file tree
Showing 22 changed files with 495 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ private void cancel() {
protected void onDestroy() {
super.onDestroy();
cancel();
try {
if (searchExecutorService != null) {
searchExecutorService.shutdownNow();
}
} catch (Throwable th) {
th.printStackTrace();
}
EventBus.getDefault().unregister(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.github.tvbox.osc.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.picasso.RoundTransformation;
import com.github.tvbox.osc.util.MD5;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;

import me.jessyan.autosize.utils.AutoSizeUtils;

public class HomeHotVodAdapter extends BaseQuickAdapter<HomeHotVodAdapter.HotVod, BaseViewHolder> {
public static class HotVod {
String name;
String rate;
String pic;

public HotVod(String name, String rate, String pic) {
this.name = name;
this.rate = rate;
this.pic = pic;
}

public String getName() {
return name;
}
}

public HomeHotVodAdapter() {
super(R.layout.item_user_hot_vod, new ArrayList<>());
}

@Override
protected void convert(BaseViewHolder helper, HotVod item) {
TextView tvRate = helper.getView(R.id.tvRate);
if (item.rate == null || item.rate.isEmpty()) {
tvRate.setVisibility(View.GONE);
} else {
tvRate.setText(item.rate);
}
helper.setText(R.id.tvName, item.name);
ImageView ivThumb = helper.getView(R.id.ivThumb);
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
Picasso.get()
.load(item.pic)
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.error_loading)
.error(R.drawable.error_loading)
.into(ivThumb);
} else {
ivThumb.setImageResource(R.drawable.error_loading);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void onClick(View v) {
history.remove(10);
Hawk.put(HawkConfig.API_HISTORY, history);
listener.onchange(newApi);
dismiss();
}
}
});
Expand All @@ -76,7 +77,9 @@ public void onClick(View v) {
dialog.setAdapter(new ApiHistoryDialogAdapter.SelectDialogInterface() {
@Override
public void click(String value) {
inputApi.setText(value);
listener.onchange(value);
dialog.dismiss();
}

@Override
Expand Down
107 changes: 102 additions & 5 deletions app/src/main/java/com/github/tvbox/osc/ui/fragment/UserFragment.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
package com.github.tvbox.osc.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.view.animation.BounceInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.BaseLazyFragment;
import com.github.tvbox.osc.event.ServerEvent;
import com.github.tvbox.osc.ui.activity.HistoryActivity;
import com.github.tvbox.osc.ui.activity.LivePlayActivity;
import com.github.tvbox.osc.ui.activity.SearchActivity;
import com.github.tvbox.osc.ui.activity.SettingActivity;
import com.github.tvbox.osc.ui.adapter.HomeHotVodAdapter;
import com.github.tvbox.osc.util.FastClickCheckUtil;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.AbsCallback;
import com.lzy.okgo.model.Response;
import com.orhanobut.hawk.Hawk;
import com.owen.tvrecyclerview.widget.TvRecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;

/**
* @author pj567
* @date :2021/3/9
* @description:
*/
public class UserFragment extends BaseLazyFragment implements View.OnClickListener {
private FrameLayout tvLive;
private FrameLayout tvSearch;
private FrameLayout tvSetting;
private FrameLayout tvHistory;
private LinearLayout tvLive;
private LinearLayout tvSearch;
private LinearLayout tvSetting;
private LinearLayout tvHistory;

public static UserFragment newInstance() {
return new UserFragment();
Expand All @@ -52,6 +67,88 @@ protected void init() {
tvSearch.setOnFocusChangeListener(focusChangeListener);
tvSetting.setOnFocusChangeListener(focusChangeListener);
tvHistory.setOnFocusChangeListener(focusChangeListener);
TvRecyclerView tvHotList = findViewById(R.id.tvHotList);
HomeHotVodAdapter adapter = new HomeHotVodAdapter();
adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
if(ApiConfig.get().getSourceBeanList().isEmpty())
return;
String title = ((HomeHotVodAdapter.HotVod) adapter.getItem(position)).getName();
Intent newIntent = new Intent(mContext, SearchActivity.class);
newIntent.putExtra("title", title);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
mActivity.startActivity(newIntent);
}
});
tvHotList.setOnItemListener(new TvRecyclerView.OnItemListener() {
@Override
public void onItemPreSelected(TvRecyclerView parent, View itemView, int position) {
itemView.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
}

@Override
public void onItemSelected(TvRecyclerView parent, View itemView, int position) {
itemView.animate().scaleX(1.05f).scaleY(1.05f).setDuration(300).setInterpolator(new BounceInterpolator()).start();
}

@Override
public void onItemClick(TvRecyclerView parent, View itemView, int position) {

}
});
tvHotList.setAdapter(adapter);

initHomeHotVod(adapter);
}

private void initHomeHotVod(HomeHotVodAdapter adapter) {
try {
long time = Hawk.get("douban_hot_date", 0L);
if (System.currentTimeMillis() - time < 6 * 60 * 60 * 1000) {
String json = Hawk.get("douboan_hot", "");
if (!json.isEmpty()) {
adapter.setNewData(loadHots(json));
return;
}
}
OkGo.<String>get("https://movie.douban.com/j/new_search_subjects?sort=R&range=0,10&tags=&playable=1&start=0").execute(new AbsCallback<String>() {
@Override
public void onSuccess(Response<String> response) {
String netJson = response.body();
Hawk.put("douban_hot_date", System.currentTimeMillis());
Hawk.put("douboan_hot", netJson);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.setNewData(loadHots(netJson));
}
});
}

@Override
public String convertResponse(okhttp3.Response response) throws Throwable {
return response.body().string();
}
});
} catch (Throwable th) {
th.printStackTrace();
}
}

private ArrayList<HomeHotVodAdapter.HotVod> loadHots(String json) {
ArrayList<HomeHotVodAdapter.HotVod> result = new ArrayList<>();
try {
JsonObject infoJson = new Gson().fromJson(json, JsonObject.class);
JsonArray array = infoJson.getAsJsonArray("data");
for (JsonElement ele : array) {
JsonObject obj = (JsonObject) ele;
result.add(new HomeHotVodAdapter.HotVod(obj.get("title").getAsString(), obj.get("rate").getAsString(), obj.get("cover").getAsString()));
}
} catch (Throwable th) {

}
return result;
}

private View.OnFocusChangeListener focusChangeListener = new View.OnFocusChangeListener() {
Expand Down
Binary file removed app/src/main/res/drawable-xhdpi/main_bg.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/search_icon.png
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/setting_icon.png
Binary file not shown.
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/bottom_shape.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="10mm"
android:bottomRightRadius="10mm" />
<solid android:color="@color/color_66000000" />
android:bottomLeftRadius="@dimen/vs_10"
android:bottomRightRadius="@dimen/vs_10" />
<solid android:color="@color/color_99000000" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_collect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M96.43,397.1A247.77,247.77 0,0 1,512 214.83a247.77,247.77 0,0 1,415.57 182.27c0,118.91 -69.59,227.07 -149.85,308.1 -80.68,81.49 -179.46,143.1 -252.29,167.3a42.67,42.67 0,0 1,-26.88 0c-72.83,-24.19 -171.61,-85.8 -252.25,-167.25 -80.26,-81.07 -149.89,-189.23 -149.89,-308.14zM344.19,234.67A162.43,162.43 0,0 0,181.76 397.1c0,86.19 51.63,173.78 125.18,248.06 67.67,68.35 147.75,119.04 205.06,141.48 57.3,-22.4 137.39,-73.13 205.06,-141.48 73.56,-74.28 125.18,-161.92 125.18,-248.06a162.43,162.43 0,0 0,-295.34 -93.4,42.67 42.67,0 0,1 -69.8,0A162.18,162.18 0,0 0,344.19 234.67z"
android:fillColor="#ffffff"/>
</vector>
Binary file removed app/src/main/res/drawable/ic_history.png
Binary file not shown.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_history.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M554.75,341.33a42.67,42.67 0,1 0,-85.33 0v170.84a42.67,42.67 0,0 0,12.5 30.17l106.58,106.5a42.67,42.67 0,1 0,60.33 -60.33L554.67,494.46V341.33z"
android:fillColor="#ffffff"/>
<path
android:pathData="M273.66,267.65h36.65a42.67,42.67 0,1 1,0 85.33H170.67a42.67,42.67 0,0 1,-42.67 -42.67V170.67a42.67,42.67 0,0 1,85.33 0v36.65A425.39,425.39 0,0 1,512 85.33c235.65,0 426.67,191.02 426.67,426.67s-191.02,426.67 -426.67,426.67S85.33,747.65 85.33,512a42.67,42.67 0,1 1,85.33 0,341.33 341.33,0 1,0 103,-244.35z"
android:fillColor="#ffffff"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_live.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M752.73,128c-36.91,0.6 -78.42,10.54 -124.59,29.82 -38.78,16.21 -77.48,37.12 -116.14,62.68a701.7,701.7 0,0 0,-116.18 -62.72c-46.12,-19.24 -87.64,-29.18 -124.59,-29.74 -44.37,-0.68 -79.49,11.95 -105.39,37.8 -25.9,25.9 -38.49,61.01 -37.8,105.39 0.55,36.95 10.5,78.46 29.78,124.59 16.21,38.83 37.12,77.53 62.68,116.18a701.65,701.65 0,0 0,-62.72 116.18c-19.24,46.12 -29.18,87.64 -29.74,124.59 -0.68,44.37 11.95,79.49 37.8,105.39 25.9,25.9 61.01,38.49 105.39,37.8 36.95,-0.55 78.46,-10.45 124.59,-29.78 38.83,-16.21 77.53,-37.12 116.18,-62.68a701.57,701.57 0,0 0,116.18 62.72c46.08,19.24 87.64,29.18 124.59,29.74 44.37,0.68 79.49,-11.95 105.39,-37.8 25.9,-25.9 38.49,-61.01 37.8,-105.39 -0.55,-36.95 -10.5,-78.51 -29.78,-124.59 -16.21,-38.83 -37.12,-77.53 -62.68,-116.18a701.74,701.74 0,0 0,62.72 -116.18c19.24,-46.12 29.18,-87.64 29.74,-124.59 0.68,-44.37 -11.95,-79.49 -37.8,-105.39 -25.9,-25.9 -61.01,-38.49 -105.39,-37.8zM363.95,234.24c25.43,10.62 50.94,23.64 76.54,39a1152.13,1152.13 0,0 0,-87.72 79.49,1152.21 1152.21,0 0,0 -79.49,87.72c-15.36,-25.6 -28.37,-51.11 -39.04,-76.54 -15.19,-36.35 -22.95,-67.63 -23.38,-93.87 -0.3,-21.08 4.22,-36.27 13.61,-45.65 9.39,-9.39 24.53,-13.87 45.57,-13.57 26.28,0.43 57.6,8.19 93.87,23.38zM671.32,352.73a1152.77,1152.77 0,0 0,-87.72 -79.49c25.6,-15.36 51.11,-28.37 76.54,-39.04 36.35,-15.19 67.63,-22.95 93.87,-23.38 21.08,-0.3 36.27,4.22 45.65,13.61 9.39,9.39 13.87,24.53 13.57,45.57 -0.43,26.28 -8.23,57.6 -23.38,93.87 -10.67,25.47 -23.68,50.99 -39.04,76.59a1151.7,1151.7 0,0 0,-79.49 -87.72zM411.31,411.26c33.71,-33.71 67.29,-63.36 100.74,-89.05a1032.96,1032.96 0,0 1,100.69 89.05c33.71,33.71 63.4,67.29 89.09,100.74a1032.79,1032.79 0,0 1,-89.05 100.69A1033.81,1033.81 0,0 1,512 701.82a1032.96,1032.96 0,0 1,-100.69 -89.05A1032.96,1032.96 0,0 1,322.18 512a1033.13,1033.13 0,0 1,89.05 -100.69zM789.85,660.1c15.15,36.35 22.95,67.63 23.38,93.87 0.3,21.08 -4.22,36.27 -13.61,45.65 -9.39,9.39 -24.53,13.87 -45.57,13.57 -26.28,-0.43 -57.6,-8.23 -93.87,-23.38a594.6,594.6 0,0 1,-76.59 -39.04,1152.77 1152.77,0 0,0 87.72,-79.49 1152.77,1152.77 0,0 0,79.49 -87.72c15.36,25.6 28.37,51.11 39.04,76.54zM234.24,660.1c10.67,-25.43 23.68,-50.94 39.04,-76.54a1152.77,1152.77 0,0 0,79.49 87.72,1152 1152,0 0,0 87.72,79.49c-25.6,15.36 -51.11,28.37 -76.54,39.04 -36.35,15.15 -67.63,22.95 -93.87,23.38 -21.08,0.3 -36.27,-4.22 -45.65,-13.61 -9.39,-9.39 -13.87,-24.53 -13.57,-45.57 0.43,-26.28 8.19,-57.6 23.38,-93.87z"
android:fillColor="#ffffff"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_push.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M413.27,106.67c-14.51,0 -27.73,8.11 -34.35,20.99l-197.46,385.07a38.61,38.61 0,0 0,34.35 56.23L417.28,568.96l-77.35,300.12a38.61,38.61 0,0 0,66.05 35.54l430.85,-476.76a38.61,38.61 0,0 0,-28.67 -64.47L617.39,363.39l149.67,-194.56a38.61,38.61 0,0 0,-30.63 -62.17L413.27,106.67zM278.95,491.73l157.87,-307.84h221.18l-149.67,194.56a38.61,38.61 0,0 0,30.59 62.12h182.36l-267.39,295.94 50.6,-196.57a38.61,38.61 0,0 0,-37.38 -48.21h-188.16z"
android:fillColor="#ffffff"/>
</vector>
Binary file removed app/src/main/res/drawable/ic_search1.png
Binary file not shown.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_search1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M337.37,318.12a196.1,196.1 0,0 1,138.97 -57.6c54.27,0 103.47,22.1 139.01,57.6a42.67,42.67 0,0 1,-60.33 60.33,110.72 110.72,0 0,0 -78.68,-32.55c-30.72,0 -58.45,12.37 -78.63,32.55a42.67,42.67 0,0 1,-60.33 -60.33z"
android:fillColor="#ffffff"/>
<path
android:pathData="M106.67,476.33a369.66,369.66 0,1 1,659.5 229.55l138.67,138.62a42.67,42.67 0,1 1,-60.33 60.33l-138.67,-138.67A369.66,369.66 0,0 1,106.67 476.33zM476.33,192a284.33,284.33 0,1 0,0 568.7,284.33 284.33,0 0,0 0,-568.7z"
android:fillColor="#ffffff"/>
</vector>
Binary file removed app/src/main/res/drawable/ic_setting.png
Binary file not shown.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_setting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M512,341.33a170.67,170.67 0,1 0,0 341.33,170.67 170.67,0 0,0 0,-341.33zM426.67,512a85.33,85.33 0,1 1,170.67 0,85.33 85.33,0 0,1 -170.67,0z"
android:fillColor="#ffffff"/>
<path
android:pathData="M447.32,123.52a42.67,42.67 0,0 0,-49.37 -21.76A426.03,426.03 0,0 0,221.53 200.53a42.67,42.67 0,0 0,-9.22 50.13,72.53 72.53,0 0,1 -65.11,104.53h-1.02a42.67,42.67 0,0 0,-41.3 29.87,428.37 428.37,0 0,0 -10.88,213.89 42.67,42.67 0,0 0,45.95 33.92,72.53 72.53,0 0,1 62.72,118.91 42.67,42.67 0,0 0,1.88 57.09,426.54 426.54,0 0,0 185.51,113.15 42.67,42.67 0,0 0,52.82 -27.9,72.58 72.58,0 0,1 138.24,0 42.67,42.67 0,0 0,52.82 27.9,426.54 426.54,0 0,0 185.51,-113.15 42.67,42.67 0,0 0,1.88 -57.09,72.53 72.53,0 0,1 62.72,-118.91 42.67,42.67 0,0 0,45.95 -33.92,428.37 428.37,0 0,0 -10.88,-213.89 42.67,42.67 0,0 0,-41.3 -29.87h-1.02a72.53,72.53 0,0 1,-65.11 -104.53,42.67 42.67,0 0,0 -9.22,-50.13 426.07,426.07 0,0 0,-176.43 -98.73,42.67 42.67,0 0,0 -49.37,21.76 72.53,72.53 0,0 1,-129.37 0zM305.07,282.62c0,-12.93 -1.58,-25.51 -4.52,-37.55A340.74,340.74 0,0 1,392.11 193.28,157.53 157.53,0 0,0 512,248.49a157.53,157.53 0,0 0,119.89 -55.17c33.28,12.5 64.09,30.04 91.56,51.71a157.91,157.91 0,0 0,121.47 192.21,342.53 342.53,0 0,1 6.53,111.91 157.91,157.91 0,0 0,-117.46 223.15,341.33 341.33,0 0,1 -90.88,55.98A157.65,157.65 0,0 0,512 758.31c-54.66,0 -102.78,27.82 -131.11,69.97a341.38,341.38 0,0 1,-90.88 -55.98,157.91 157.91,0 0,0 -117.46,-223.15 345.64,345.64 0,0 1,6.57 -111.91A157.91,157.91 0,0 0,305.07 282.62z"
android:fillColor="#ffffff"/>
</vector>
Binary file removed app/src/main/res/drawable/ic_tv.png
Binary file not shown.
Loading

0 comments on commit ba2fc9e

Please sign in to comment.