热词只在第一次打开时加载一次;

pull/143/head
于俊 9 months ago
parent 6ddcd4e43c
commit 84ba314835
  1. 8
      app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java
  2. 15
      app/src/main/res/layout/activity_fast_search.xml
  3. 8
      app/src/main/res/layout/activity_search.xml

@ -394,6 +394,7 @@ public class SearchActivity extends BaseActivity {
});
}
private static ArrayList<String> hots;
private void initData() {
initCheckedSourcesForSearch();
Intent intent = getIntent();
@ -408,6 +409,11 @@ public class SearchActivity extends BaseActivity {
search(title);
}
}
if(hots!=null && !hots.isEmpty()){
wordAdapter.setNewData(hots);
return;
}
// 加载热词
OkGo.<String>get("https://node.video.qq.com/x/api/hot_search")
// OkGo.<String>get("https://api.web.360kan.com/v1/rank")
@ -418,7 +424,7 @@ public class SearchActivity extends BaseActivity {
@Override
public void onSuccess(Response<String> response) {
try {
ArrayList<String> hots = new ArrayList<>();
hots = new ArrayList<String>();
JsonArray itemList = JsonParser.parseString(response.body()).getAsJsonObject().get("data").getAsJsonObject().get("mapResult").getAsJsonObject().get("0").getAsJsonObject().get("listInfo").getAsJsonArray();
// JsonArray itemList = JsonParser.parseString(response.body()).getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement ele : itemList) {

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -9,14 +10,13 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/vs_50"
android:layout_marginTop="@dimen/vs_10"
android:layout_marginBottom="@dimen/vs_10"
android:paddingLeft="20mm"
>
android:layout_marginTop="@dimen/vs_10"
android:layout_marginBottom="@dimen/vs_10"
android:paddingLeft="20mm">
<TextView
android:id="@+id/mSearchTitle"
android:layout_width="@dimen/vs_180"
android:layout_width="@dimen/vs_200"
android:layout_height="match_parent"
android:text="搜索(0/0)"
android:layout_gravity="center_horizontal"
@ -44,7 +44,7 @@
<LinearLayout
android:id="@+id/llWord"
android:layout_width="@dimen/vs_180"
android:layout_width="@dimen/vs_200"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20mm"
@ -69,7 +69,8 @@
android:orientation="vertical"
android:paddingLeft="20mm"
android:paddingBottom="@dimen/vs_20"
android:paddingRight="20mm" >
android:paddingRight="20mm"
tools:ignore="InOrMmUsage">
<com.owen.tvrecyclerview.widget.TvRecyclerView

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
@ -21,7 +22,7 @@
<TextView
android:id="@+id/tvSearchCheckboxBtn"
android:layout_width="match_parent"
android:layout_height="@dimen/vs_50"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/shape_user_focus"
android:focusable="true"
@ -109,13 +110,14 @@
android:layout_width="300mm"
android:layout_height="300mm"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20mm" />
android:layout_marginTop="20mm"
tools:ignore="InOrMmUsage" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/llWord"
android:layout_width="@dimen/vs_160"
android:layout_width="@dimen/vs_200"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/vs_20"

Loading…
Cancel
Save