| | |
| | | import com.mugua.mgvideo.entity.recommend.HomeClass; |
| | | import com.mugua.mgvideo.test.MyViewPager; |
| | | import com.mugua.mgvideo.ui.category.bean.HotStar; |
| | | import com.mugua.mgvideo.ui.common.CommonFragmentActivity; |
| | | import com.mugua.mgvideo.ui.recommend.RecommendNewAdapter; |
| | | import com.mugua.mgvideo.ui.recommend.RecommendTopAdapter; |
| | | import com.mugua.mgvideo.ui.recommend.SearchActivity; |
| | | import com.mugua.mgvideo.util.DimenUtils; |
| | | import com.yeshi.base.utils.JsonUtil; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.viewpagerindicator.LinePageIndicator; |
| | | import com.yeshi.base.entity.JumpDetail; |
| | | import com.yeshi.base.entity.ad.AdPositionEnum; |
| | |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.ui.DividerItemDecoration; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | |
| | | |
| | | private TextView tv_go_search; |
| | | |
| | | private TextView tv_shop; |
| | | |
| | | private TextView tv_category; |
| | | |
| | | private SwipeRefreshLayout.OnRefreshListener mRefreshListener = new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | //加载广告 |
| | | if (mRecommendNewAdapter != null) { |
| | | mRecommendNewAdapter.refresh(); |
| | | } |
| | | loadAd(); |
| | | getHomeAd(); |
| | | Log.i("mResult", "onCreate---setOnRefreshListener---loadAD1"); |
| | |
| | | return; |
| | | if (mRecommendNewAdapter.getAdCount() == 0) { |
| | | if (adList != null && adList.size() > 0) { |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 2); |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 0); |
| | | } |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | |
| | | .findViewById(R.id.rv_recommend); |
| | | |
| | | rv_recommend.setLayoutManager(new LinearLayoutManager(context)); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(rv_recommend.getContext(), 0)); |
| | | rv_recommend.addItemDecoration(decoration); |
| | | // DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | // decoration.setSize(DimenUtils.dip2px(rv_recommend.getContext(), 0)); |
| | | // rv_recommend.addItemDecoration(decoration); |
| | | |
| | | loading = LayoutInflater.from(getContext()).inflate(R.layout.item_loading, null); |
| | | loading.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | |
| | | iv_right_ad_close = contentView.findViewById(R.id.iv_right_ad_close); |
| | | ll_right_ad = contentView.findViewById(R.id.ll_right_ad); |
| | | |
| | | tv_shop = contentView.findViewById(R.id.tv_shop); |
| | | tv_category = contentView.findViewById(R.id.tv_category); |
| | | |
| | | tv_shop.setOnClickListener(this); |
| | | tv_category.setOnClickListener(this); |
| | | |
| | | type = (HomeClass) getArguments().getSerializable("videotype"); |
| | | position = (Integer) getArguments().get("position"); |
| | | |
| | |
| | | if (recommendAdManager.getSourceType() == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.RECOMMEND_BIG_IMG_AD; |
| | | height = (int) (width * 0.78); |
| | | } else if (recommendAdManager.getSourceType() == AdUtil.AD_TYPE.gdt2) { |
| | | } else if (recommendAdManager.getSourceType() == AdUtil.AD_TYPE.gdt) { |
| | | pid = GDTConstant.PID_HOME_RECOMMEND_BIG_IMG; |
| | | } |
| | | |
| | |
| | | try { |
| | | snapshot = cache.get(getKey("getHomeType") + type.getId()); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeType> homeTypes = gson.fromJson( |
| | | |
| | | List<HomeType> homeTypes = JsonUtil.videoGson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HomeType>>() { |
| | | }.getType()); |
| | |
| | | needRefresh = true; |
| | | } |
| | | |
| | | private void setNavShow() { |
| | | if (YouthUtil.isOpenYouthMode(getActivity())) { |
| | | tv_category.setVisibility(View.GONE); |
| | | tv_shop.setVisibility(View.GONE); |
| | | } else { |
| | | if (AdUtil.isCanInitCSJ() && AdUtil.getAdType(getContext(), AdPositionEnum.splashHotStart) != null) { |
| | | tv_category.setVisibility(View.VISIBLE); |
| | | tv_shop.setVisibility(View.VISIBLE); |
| | | } else { |
| | | tv_category.setVisibility(View.GONE); |
| | | tv_shop.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | indicator_recommend.setViewPager(vp_recommend); |
| | | mChangeHelper.registerReceiver(); |
| | | if (YouthUtil.isOpenYouthMode(getContext())) { |
| | | tv_go_search.setVisibility(View.GONE); |
| | | } else { |
| | | tv_go_search.setVisibility(View.VISIBLE); |
| | | } |
| | | if (needRefresh) { |
| | | needRefresh = false; |
| | | rl_recommend.setRefreshing(true); |
| | | mRefreshListener.onRefresh(); |
| | | } |
| | | setNavShow(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .excludeFieldsWithoutExposeAnnotation() |
| | | .create(); |
| | | JSONObject data = jsonObject |
| | | .getJSONObject("Data"); |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HomeType> homeTypes = new ArrayList<HomeType>(); |
| | | JSONArray array = jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data"); |
| | |
| | | |
| | | |
| | | if (obj.optJSONObject("Ad") != null) |
| | | type.setAd(gson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class)); |
| | | type.setAd(JsonUtil.videoGson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class)); |
| | | |
| | | JSONArray homeArray = obj |
| | | .optJSONArray("HomeVideoList"); |
| | |
| | | if (homeArray != null && homeArray.length() > 0) { |
| | | for (int j = 0; j < homeArray.length(); j++) { |
| | | |
| | | homeList.add(gson.fromJson(homeArray |
| | | homeList.add(JsonUtil.videoGson.fromJson(homeArray |
| | | .optJSONObject(j).toString(), |
| | | HomeVideo.class)); |
| | | } |
| | |
| | | if (itemArray != null && itemArray.length() > 0) { |
| | | for (int k = 0; k < itemArray.length(); k++) { |
| | | if (itemArray.optJSONObject(k) != null) { |
| | | itemList.add(gson.fromJson( |
| | | itemList.add(JsonUtil.videoGson.fromJson( |
| | | itemArray.optJSONObject(k) |
| | | .toString(), |
| | | HomeTypeItem.class)); |
| | |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | |
| | | case R.id.tv_shop: { |
| | | Intent intent = new Intent(getContext(), CommonFragmentActivity.class); |
| | | intent.putExtra("title", "集市"); |
| | | intent.putExtra("fragment", ShopFragment.class.getName()); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | |
| | | case R.id.tv_category: { |
| | | Intent intent = new Intent(getContext(), CommonFragmentActivity.class); |
| | | intent.putExtra("title", "分类"); |
| | | intent.putExtra("fragment", CategoryFragment.class.getName()); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | |
| | | |
| | | default: |
| | | break; |
| | | } |
| | |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | EventBus.getDefault().unregister(this); |
| | | if (mRecommendNewAdapter != null) { |
| | | mRecommendNewAdapter.onDestory(); |
| | | } |
| | | } |
| | | |
| | | private List<HomeVideo> adList1 = new ArrayList<>(); |