From 760aee20870a34e6130a1c12237c5b747e2b00bd Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 28 一月 2022 12:58:40 +0800
Subject: [PATCH] 隐私合规,青少年模式,64位兼容

---
 MGVideo/src/com/mugua/mgvideo/ui/main/CategoryFragment.java |   47 +++++++++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/MGVideo/src/com/mugua/mgvideo/ui/main/CategoryFragment.java b/MGVideo/src/com/mugua/mgvideo/ui/main/CategoryFragment.java
index aa38bb0..d194255 100644
--- a/MGVideo/src/com/mugua/mgvideo/ui/main/CategoryFragment.java
+++ b/MGVideo/src/com/mugua/mgvideo/ui/main/CategoryFragment.java
@@ -44,6 +44,7 @@
 import com.lcjian.library.util.common.StorageUtils;
 import com.lcjian.library.util.common.StringUtils;
 import com.mugua.mgvideo.R;
+import com.yeshi.base.utils.JsonUtil;
 import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
 import com.viewpagerindicator.CirclePageIndicator;
 import com.yeshi.base.utils.http.BasicTextHttpResponseHandler;
@@ -82,6 +83,15 @@
 
     private CirclePageIndicator indicator_theme;
 
+    public static CategoryFragment newInstance(boolean showSearchBar) {
+        Bundle bundle = new Bundle();
+        bundle.putBoolean("searchBar", showSearchBar);
+        CategoryFragment fragment = new CategoryFragment();
+        fragment.setArguments(bundle);
+        return fragment;
+    }
+
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -102,6 +112,12 @@
 
     @Override
     public void onCreateView(View contentView, Bundle savedInstanceState) {
+
+        if (getArguments() != null && getArguments().getBoolean("searchBar", false)) {
+            contentView.findViewById(R.id.rl_search_bar).setVisibility(View.VISIBLE);
+        } else {
+            contentView.findViewById(R.id.rl_search_bar).setVisibility(View.GONE);
+        }
 
         tv_no_network = (TextView) contentView.findViewById(R.id.tv_no_network);
         tv_no_network.setOnClickListener(this);
@@ -240,11 +256,8 @@
                         try {
                             snapshot = cache.get(getKey("getCategories"));
                             if (snapshot != null) {
-                                Gson gson = new GsonBuilder()
-                                        .setFieldNamingPolicy(
-                                                FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                        .create();
-                                List<VideoType> categories = gson.fromJson(
+
+                                List<VideoType> categories = JsonUtil.videoGson.fromJson(
                                         snapshot.getString(0),
                                         new TypeToken<List<VideoType>>() {
                                         }.getType());
@@ -265,11 +278,7 @@
                         try {
                             snapshot = cache.get(getKey("getHotStars"));
                             if (snapshot != null) {
-                                Gson gson = new GsonBuilder()
-                                        .setFieldNamingPolicy(
-                                                FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                        .create();
-                                List<HotVideoType> hotStars = gson.fromJson(
+                                List<HotVideoType> hotStars = JsonUtil.videoGson.fromJson(
                                         snapshot.getString(0),
                                         new TypeToken<List<HotVideoType>>() {
                                         }.getType());
@@ -389,10 +398,8 @@
                                                  Header[] headers, JSONObject jsonObject)
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
-                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
-                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
-                            hotSearchs = gson.fromJson(jsonObject
+
+                            hotSearchs = JsonUtil.videoGson.fromJson(jsonObject
                                     .getJSONObject("Data").getJSONArray("data")
                                     .toString(), new TypeToken<List<String>>() {
                             }.getType());
@@ -416,10 +423,8 @@
                                                  Header[] headers, JSONObject jsonObject)
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
-                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
-                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
-                            List<VideoType> categories = gson.fromJson(
+
+                            List<VideoType> categories = JsonUtil.videoGson.fromJson(
                                     jsonObject.getJSONObject("Data")
                                             .getJSONArray("data").toString(),
                                     new TypeToken<List<VideoType>>() {
@@ -467,10 +472,8 @@
                                                  Header[] headers, JSONObject jsonObject)
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
-                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
-                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
-                            List<HotVideoType> hotStars = gson.fromJson(
+
+                            List<HotVideoType> hotStars = JsonUtil.videoGson.fromJson(
                                     jsonObject.getJSONObject("Data")
                                             .getJSONArray("data").toString(),
                                     new TypeToken<List<HotVideoType>>() {

--
Gitblit v1.8.0