| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.annotation.Nullable; |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hanju.video.app.entity.ad.AdPositionEnum; |
| | | import com.hanju.video.app.entity.video.HomeNav; |
| | | import com.hanju.video.app.ui.mine.DownloadActivity; |
| | | import com.hanju.lib.library.util.cache.DiskLruCache; |
| | | import com.hanju.lib.library.util.common.StorageUtils; |
| | | import com.hanju.lib.library.util.common.StringUtils; |
| | | import com.hanju.video.app.util.JsonUtil; |
| | | import com.hanju.video.app.util.ad.AdUtil; |
| | | import com.hanju.video.app.util.ad.CSJADConstant; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | | import com.hanju.video.app.util.ad.IntertitialAdUtil; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.video.youth.util.YouthUtil; |
| | | import com.viewpagerindicator.MainTabPageIndicator; |
| | | import com.hanju.video.app.util.http.BasicTextHttpResponseHandler; |
| | | import com.hanju.video.app.util.http.HttpApiUtil; |
| | |
| | | private boolean isLogin = false; |
| | | |
| | | SharedPreferences preferences;// |
| | | |
| | | private AQuery mAquery; |
| | | |
| | | public HomeFragment() { |
| | | super(HomeFragment.class.getClass().getName()); |
| | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | getActivity().setTheme(R.style.AppTabThemeMain); |
| | | mAquery = new AQuery(contentView); |
| | | initView(contentView); |
| | | pager = contentView.findViewById(R.id.pager_recomend_category); |
| | | fl_indicator = contentView.findViewById(R.id.fl_indicator); |
| | |
| | | if (cache != null) { |
| | | snapshot = cache.get(getKey("getCategories")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeNav> list = gson.fromJson( |
| | | List<HomeNav> list = JsonUtil.videoGson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HomeNav>>() { |
| | | }.getType()); |
| | |
| | | super.onResume(); |
| | | isLogin = !StringUtils.isEmpty(preferences.getString("LoginUid", "")); |
| | | EventBus.getDefault().register(this); |
| | | |
| | | if (YouthUtil.isOpenYouthMode(getContext())) { |
| | | mAquery.id(R.id.ll_top).visibility(View.GONE); |
| | | } else { |
| | | mAquery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | categories.clear(); |
| | | |
| | | List<HomeNav> list = gson.fromJson( |
| | | List<HomeNav> list = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HomeNav>>() { |
| | |
| | | try { |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getCategories")); |
| | | editor.set(0, gson.toJson(categories)); |
| | | editor.set(0, JsonUtil.videoGson.toJson(categories)); |
| | | editor.commit(); |
| | | } catch (IOException e) { |
| | | } |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | AdUtil.AD_TYPE adType = AdUtil.getAdType(getContext(), AdPositionEnum.homeInterstitial); |
| | | if (adType != null) { |
| | | //Android 5.0 |
| | | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) { |
| | | adType = AdUtil.AD_TYPE.gdt; |
| | | } |
| | | |
| | | if (adType == AdUtil.AD_TYPE.csj) { |
| | | IntertitialAdUtil.showAd(getActivity(), adType, CSJADConstant.HOME_INTERSTITIALAD); |
| | | } else { |
| | | IntertitialAdUtil.showAd(getActivity(), adType, GDTADConstant.HOME_INTERSTITIALAD); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | Gson gson = new GsonBuilder() |
| | | .create(); |
| | | List<String> hotSearchs = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |