From 3945f9a2c70335958c64c73894e3a1a14a7113b3 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 08 八月 2020 10:11:14 +0800 Subject: [PATCH] '完善' --- BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java | 708 ++++++++++++++--------------------------------------------- 1 files changed, 168 insertions(+), 540 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java index bce8a4d..ba92779 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java @@ -8,18 +8,13 @@ import android.os.Bundle; import android.provider.Settings; import android.support.v4.app.Fragment; -import android.support.v4.view.PagerAdapter; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.util.Log; -import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; -import android.view.WindowManager; -import android.widget.AbsListView; -import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; import com.bumptech.glide.Glide; @@ -30,12 +25,10 @@ import com.lcjian.library.RetainViewFragment; import com.lcjian.library.content.ConnectivityChangeHelper; import com.lcjian.library.content.ConnectivityChangeHelper.OnConnectivityChangeListener; -import com.lcjian.library.util.SingleToast; import com.lcjian.library.util.SystemCommon; import com.lcjian.library.util.cache.DiskLruCache; import com.lcjian.library.util.common.StorageUtils; import com.lcjian.library.util.common.StringUtils; -import com.lcjian.library.widget.RatioLayout; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; import com.qq.e.ads.cfg.DownAPPConfirmPolicy; import com.qq.e.ads.cfg.VideoOption; @@ -44,7 +37,6 @@ import com.qq.e.ads.nativ.NativeExpressADView; import com.qq.e.comm.util.AdError; import com.umeng.analytics.MobclickAgent; -import com.viewpagerindicator.LinePageIndicator; import com.weikou.beibeivideo.BasicTextHttpResponseHandler; import com.weikou.beibeivideo.BeibeiVideoAPI; import com.weikou.beibeivideo.entity.HomeAd; @@ -53,11 +45,14 @@ import com.weikou.beibeivideo.entity.HomeVideo; import com.weikou.beibeivideo.entity.VideoInfo; import com.weikou.beibeivideo.entity.VideoType; -import com.weikou.beibeivideo.test.MyViewPager; +import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; +import com.weikou.beibeivideo.entity.recommend.RecommendContent; import com.weikou.beibeivideo.ui.category.bean.HotStar; import com.weikou.beibeivideo.ui.mine.BrowserActivity; import com.weikou.beibeivideo.util.BeibeiConstant; -import com.weikou.wpc.superad.banner.Superbanner; +import com.weikou.beibeivideo.util.DimenUtils; +import com.weikou.beibeivideo.util.ad.ExpressAdManager; +import com.weikou.beibeivideo.util.ui.DividerItemDecoration; import com.yeshi.buwanshequ.R; import com.ysh.wpc.appupdate.GoReview; import com.ysh.wpc.appupdate.service.DownLoadFileService; @@ -74,28 +69,18 @@ import java.util.Date; import java.util.List; -import de.greenrobot.event.EventBus; - public class RecommendFragment extends RetainViewFragment implements OnClickListener { -// private TextView tv_go_search; - - private View recommend_top; - - private MyViewPager vp_recommend; - -// private VerticalViewPager vp_ad; - - private LinePageIndicator indicator_recommend; - private SwipeRefreshLayout rl_recommend; - private ListView lv_recommend; + private RecyclerView rv_recommend; - private RecommendAdapter mRecommendAdapter; + private RecommendNewAdapter mRecommendNewAdapter; private List<HomeType> mHomeTypes; + + private List<HomeAd> mHomeAds; private DiskLruCache cache; @@ -111,11 +96,11 @@ private ImageView iv_right_ad; - private RatioLayout rl_recommend_top; - private boolean isBottom = false; boolean isReview; + + private List<RecommendContent> contentList; public static Fragment newInstance(VideoType type, String position) { if (Integer.parseInt(position) < 2) { @@ -133,21 +118,7 @@ fragment.setArguments(bundle); return fragment; } - } - - private Runnable mAutoScroller = new Runnable() { - - @Override - public void run() { - PagerAdapter adapter = vp_recommend.getAdapter(); - if (adapter != null && adapter.getCount() != 0) { - vp_recommend.setCurrentItem((vp_recommend.getCurrentItem() + 1) - % adapter.getCount(), true); - } - vp_recommend.postDelayed(this, 5000); - } - }; @Override public void onCreate(Bundle savedInstanceState) { @@ -166,7 +137,6 @@ public void onSaveInstanceState(Bundle outState) { outState.putString("flash back", "show"); super.onSaveInstanceState(outState); - } public static int getVersionNum(Context context) { @@ -191,12 +161,37 @@ return date; } + + //濉厖鏁版嵁 + private void setContent() { + contentList.clear(); + contentList.add(new RecommendContent(RecommendContent.TYPE_BANNER, mHomeAds)); + if (mHomeTypes != null && mHomeTypes.size() > 0) + for (HomeType ht : mHomeTypes) { + contentList.add(new RecommendContent(RecommendContent.TYPE_HOMETYPE, ht)); + } + else { + contentList.add(RecommendContent.createHomeType(null)); + } + //濉厖骞垮憡 + if (adList != null && adList.size() > 0) + contentList.add(2, RecommendContent.createAd(adList.get(0))); + else + contentList.add(2, RecommendContent.createAd(null)); + + if (adList != null && adList.size() > 1) { + contentList.add(RecommendContent.createAd(adList.get(1))); + } else { + contentList.add(RecommendContent.createAd(null)); + } + } + @Override public void onCreateView(View contentView, Bundle savedInstanceState) { - tv_no_network = (TextView) contentView.findViewById(R.id.tv_no_network); + tv_no_network = contentView.findViewById(R.id.tv_no_network); tv_no_network.setOnClickListener(this); // 鍏憡 - tv_notice = (TextView) contentView.findViewById(R.id.include_notice); + tv_notice = contentView.findViewById(R.id.include_notice); mChangeHelper = new ConnectivityChangeHelper(tv_no_network.getContext(), new OnConnectivityChangeListener() { @Override @@ -232,76 +227,117 @@ int width = (int) SystemCommon.getScreenWidth(tv_no_network.getContext()); - rl_recommend = (SwipeRefreshLayout) contentView.findViewById(R.id.rl_recommend); - lv_recommend = (ListView) contentView - .findViewById(R.id.lv_recommend); + rl_recommend = contentView.findViewById(R.id.rl_recommend); + rv_recommend = contentView + .findViewById(R.id.rv_recommend); + + rv_recommend.setLayoutManager(new LinearLayoutManager(rv_recommend.getContext())); + DividerItemDecoration decoration = new DividerItemDecoration(); + decoration.setSize(DimenUtils.dip2px(rv_recommend.getContext(), 6)); + rv_recommend.addItemDecoration(decoration); + rl_recommend.setClickable(false); - iv_right_ad = (ImageView) contentView.findViewById(R.id.iv_right_ad); - recommend_top = LayoutInflater.from(tv_no_network.getContext()).inflate( - R.layout.recommend_top, null); - rl_recommend_top = (RatioLayout) recommend_top.findViewById(R.id.rl_recommend_top); - - FrameLayout fl_ad = (FrameLayout) recommend_top.findViewById(R.id.fl_ad); - // banner骞垮憡 - WindowManager wm = (WindowManager) tv_no_network.getContext().getSystemService( - Context.WINDOW_SERVICE); - Superbanner.initBanner(getActivity(), "100011", fl_ad, (int) (wm - .getDefaultDisplay().getWidth() * (98 / 600f))); - - vp_recommend = (MyViewPager) recommend_top - .findViewById(R.id.vp_recommend); + iv_right_ad = contentView.findViewById(R.id.iv_right_ad); type = (VideoType) getArguments().getSerializable("videotype"); position = (Integer) getArguments().get("position"); - vp_recommend.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_MOVE: - rl_recommend.setEnabled(false); - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - rl_recommend.setEnabled(true); - break; - } - return false; - } - }); - indicator_recommend = (LinePageIndicator) recommend_top - .findViewById(R.id.indicator_recommend); - isReview = GoReview.getGoReview(indicator_recommend.getContext(), BeibeiConstant.GO_REVIEW_KEY); - if (position == 0) { - vp_recommend.setAdapter(new RecommendTopAdapter(null, getActivity(), isReview)); - } else { - vp_recommend.setAdapter(new RecommendTopAdapter(null, getActivity(), false)); - } - indicator_recommend.setScreenWidth(width); - indicator_recommend.setSelectedColor(vp_recommend.getContext().getResources() - .getColor(R.color.yellow)); - indicator_recommend.setUnselectedColor(0xbbADA9A7); + + isReview = GoReview.getGoReview(getContext(), BeibeiConstant.GO_REVIEW_KEY); + mHomeTypes = new ArrayList<HomeType>(); - mRecommendAdapter = new RecommendAdapter(mHomeTypes, getActivity()); - lv_recommend.addHeaderView(recommend_top); - lv_recommend.setAdapter(mRecommendAdapter); + mHomeAds = new ArrayList<>(); + rl_recommend.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (position == 0) { getHotStars(); } - EventBus.getDefault().post(type); - rl_recommend.setRefreshing(false); -// vp_recommend.setCurrentItem(0, true); + //鍔犺浇骞垮憡 + loadAd(); getHomeAd(); - getHomeType(); Log.i("mResult", "onCreate---setOnRefreshListener---loadAD1"); } }); + contentList = new ArrayList<>(); + //鍔犺浇缂撳瓨鏁版嵁 + loadCacheData(); + setContent(); + + + mRecommendNewAdapter = new RecommendNewAdapter(getActivity(), contentList); + rv_recommend.setAdapter(mRecommendNewAdapter); + rv_recommend.postDelayed(new Runnable() { + + @Override + public void run() { + if (getActivity() != null) { + rl_recommend.setRefreshing(true); + getHomeAd(); + Log.i("mResult", "onCreate---postDelayed---loadAD1"); + if (position == 0) + getHotStars(); + } + } + }, 500); + + //鍔犺浇骞垮憡 + loadAd(); + + getNotice(); + if (position == 0) { + getAdRecommendRight(); + } + } + + private List<ExpressAdContainer> adList; + + private void loadAd() { + try { + ExpressAdManager recommendAdManager = new ExpressAdManager(ExpressAdManager.SOURCE_GDT, getContext()); + recommendAdManager.loadRecommendLargeAd(new ExpressAdManager.IAdLoadListener() { + @Override + public void onSuccess(List<ExpressAdContainer> adList) { + //濉厖骞垮憡浣� + RecommendFragment.this.adList = adList; + boolean hasAd = false; + int p = 0; + for (RecommendContent content : contentList) { + if (content.getType() == RecommendContent.TYPE_AD && content.getAd() == null) { + hasAd = true; + break; + } + p++; + } + + int adP = 0; + for (int i = 0; i < contentList.size(); i++) { + //濉厖骞垮憡鏁版嵁 + if (contentList.get(i).getType() == RecommendContent.TYPE_AD && contentList.get(i).getAd() == null) { + //濉厖骞垮憡鏁版嵁 + if (adP < RecommendFragment.this.adList.size()) { + hasAd = true; + contentList.get(i).setAd(RecommendFragment.this.adList.get(adP++)); + } + } + } + + //鏈夊~鍏呭箍鍛� + if (hasAd) { + mRecommendNewAdapter.notifyDataSetChanged(); + } + } + }); + } catch (Exception e) { + + } + } + + private void loadCacheData() { if (cache != null && position == 0) { { DiskLruCache.Snapshot snapshot = null; @@ -343,9 +379,9 @@ } if (adList != null && adList.size() > 0) { - vp_recommend - .setAdapter(new RecommendTopAdapter( - adList, getActivity(), isReview)); + mHomeAds.clear(); + mHomeAds.addAll(adList); +// mRecommendNewAdapter.notifyDataSetChanged(); } } catch (JSONException e) { e.printStackTrace(); @@ -374,7 +410,7 @@ mHomeTypes.clear(); if (homeTypes != null) { mHomeTypes.addAll(homeTypes); - mRecommendAdapter.notifyDataSetChanged(); +// mRecommendNewAdapter.notifyDataSetChanged(); } } } catch (IOException e) { @@ -386,49 +422,12 @@ } } } - lv_recommend.postDelayed(new Runnable() { - @Override - public void run() { - if (getActivity() != null) { - vp_recommend.setCurrentItem(0, true); - rl_recommend.setRefreshing(true); - getHomeAd(); - getHomeType(); - Log.i("mResult", "onCreate---postDelayed---loadAD1"); - if (position == 0) - getHotStars(); - } - } - }, 500); - getNotice(); - - lv_recommend.setOnScrollListener(new AbsListView.OnScrollListener() { - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - if (mHomeTypes.size() > 0 && (firstVisibleItem + visibleItemCount) < totalItemCount) { - isBottom = false; - } - if (mHomeTypes.size() > 0 && !isBottom && (firstVisibleItem + visibleItemCount) >= totalItemCount) { - SingleToast.showToast(indicator_recommend.getContext(), "娌℃湁鏇村浜�"); - isBottom = true; - } - } - }); - - if (position == 0) { - getAdRecommendRight(); - } } private void getAdRecommendRight() { - BeibeiVideoAPI.getAdRecommendRight(indicator_recommend.getContext(), new BasicTextHttpResponseHandler() { + BeibeiVideoAPI.getAdRecommendRight(rv_recommend.getContext(), new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.getBoolean("IsPost")) { @@ -438,7 +437,7 @@ final String linkType = jsonObject.optJSONObject("Data").optString("linkType"); final String webLink = jsonObject.optJSONObject("Data").optString("webLink"); final String downloadLink = jsonObject.optJSONObject("Data").optString("downloadLink"); - Glide.with(indicator_recommend.getContext()).load("https://r1.ykimg.com/050E00005CE60A62859B5EC26201389E?x-oss-process=image/resize,w_290/interlace,1/quality,Q_80/sharpen,100").into(iv_right_ad); + Glide.with(rv_recommend.getContext()).load(img).into(iv_right_ad); if (mstatus.equalsIgnoreCase("0")) { iv_right_ad.setVisibility(View.GONE); } else { @@ -449,12 +448,12 @@ @Override public void onClick(View v) { if (linkType.equalsIgnoreCase("0")) { - Intent intent = new Intent(indicator_recommend.getContext(), BrowserActivity.class); + Intent intent = new Intent(rv_recommend.getContext(), BrowserActivity.class); intent.putExtra("url", webLink); startActivity(intent); } else { try { - Intent intent = new Intent(indicator_recommend.getContext(), + Intent intent = new Intent(rv_recommend.getContext(), DownLoadFileService.class); getContext().stopService(intent); } catch (Exception e) { @@ -463,7 +462,7 @@ Bundle bundle = new Bundle(); bundle.putString("downloadurl", downloadLink); - Intent intent = new Intent(indicator_recommend.getContext(), + Intent intent = new Intent(rv_recommend.getContext(), DownLoadFileService.class); intent.putExtras(bundle); getContext().startService(intent); @@ -493,21 +492,15 @@ @Override public void onResume() { super.onResume(); - indicator_recommend.setViewPager(vp_recommend); - vp_recommend.postDelayed(mAutoScroller, 2000); mChangeHelper.registerReceiver(); MobclickAgent.onPageStart("涓婚〉闈⑩�旀帹鑽�"); -// EventBus.getDefault().register(this); } @Override public void onPause() { super.onPause(); - vp_recommend.removeCallbacks(mAutoScroller); -// vp_ad.removeCallbacks(mAdAutoScroller); mChangeHelper.unregisterReceiver(); MobclickAgent.onPageEnd("涓婚〉闈⑩�旀帹鑽�"); -// EventBus.getDefault().unregister(this); } private String content; @@ -575,14 +568,12 @@ .getJSONObject("Data").getJSONArray("data") .toString(), new TypeToken<List<HomeAd>>() { }.getType()); - if (position == 1) { - rl_recommend_top.setRatio(0.56f); - vp_recommend.setAdapter(new RecommendTopAdapter( - homeAds, getActivity(), false)); - } else { - vp_recommend.setAdapter(new RecommendTopAdapter( - homeAds, getActivity(), isReview)); + + if (homeAds != null) { + mHomeAds.clear(); + mHomeAds.addAll(homeAds); } + if (position == 0) { DiskLruCache.Editor editor = cache @@ -596,7 +587,7 @@ @Override public void onFinish() { - rl_recommend.setRefreshing(false); + getHomeType(); } }); } @@ -606,17 +597,17 @@ */ private void getHomeType() { + SharedPreferences preferences = tv_no_network.getContext().getSharedPreferences( "user", Context.MODE_PRIVATE); String uid = preferences.getString("uid", ""); - BeibeiVideoAPI.getHomeType(tv_no_network.getContext(), uid, type.getId(), + BeibeiVideoAPI.getHomeType(getContext(), uid, type.getId(), new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { - rl_recommend.setRefreshing(false); if (jsonObject.getBoolean("IsPost")) { if (mHomeTypes != null || mHomeTypes.size() > 0) { mHomeTypes.clear(); @@ -663,32 +654,27 @@ } } type.setItemTypeList(itemList); -// if (type.getId().equalsIgnoreCase("1111")) { -// type.getHomeVideoList().clear(); -// type.getHomeVideoList().addAll(liveList); -// } homeTypes.add(type); } mHomeTypes.addAll(homeTypes); - - mRecommendAdapter.notifyDataSetChanged(); + //濉厖鏁版嵁 + setContent(); + mRecommendNewAdapter.notifyDataSetChanged(); } } @Override public void onFinish() { + rl_recommend.setRefreshing(false); try { - loadAD1(); } catch (Exception e) { e.printStackTrace(); } - } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBytes, Throwable throwable) { - // TODO Auto-generated method stub super.onFailure(statusCode, headers, responseBytes, throwable); } @@ -708,386 +694,13 @@ } } - /** - * 鑾峰彇鐩存挱鍒楄〃淇℃伅 - * - * @param homeType - */ - private List<HomeVideo> liveList; - - private void getLiveInfo() { - SharedPreferences preferences = tv_no_network.getContext().getSharedPreferences( - "user", Context.MODE_PRIVATE); - String uid = preferences.getString("uid", ""); - BeibeiVideoAPI.getLiveList(tv_no_network.getContext(), uid, "meinv_mm", - new BasicTextHttpResponseHandler() { - - @Override - public void onSuccessPerfect(int statusCode, - Header[] headers, JSONObject jsonObject) - throws Exception { - if (jsonObject.optBoolean("IsPost")) { - Gson gson = new GsonBuilder().setFieldNamingPolicy( - FieldNamingPolicy.UPPER_CAMEL_CASE) - .create(); - JSONArray homeArray = jsonObject.optJSONObject( - "Data").optJSONArray("data"); - liveList = new ArrayList<>(); - for (int j = 0; j < homeArray.length(); j++) { - liveList.add(gson.fromJson(homeArray - .optJSONObject(j).toString(), - HomeVideo.class)); - } - for (int i = 0; i < mHomeTypes.size(); i++) { - if (mHomeTypes.get(i).getId().equalsIgnoreCase("1111")) { - mHomeTypes.get(i).getHomeVideoList().clear(); - mHomeTypes.get(i).getHomeVideoList().addAll(liveList); - } - } - if (position <= 1) { - DiskLruCache.Editor editor = cache - .edit(getKey("getHomeType") + type.getId()); - editor.set(0, gson.toJson(mHomeTypes)); - editor.commit(); - - //鎻掑叆鏄庢槦鍒楄〃 - if (hotStars != null && hotStars.size() > 0) { - HomeType homeType = new HomeType(); - homeType.setName("鏄庢槦鍚堣緫"); - homeType.setColumns(4); - homeType.setHotStars(hotStars); - homeType.setActivity(""); - homeType.setBeizhu(""); - homeType.setParams(""); - homeType.setHasMore("true"); - homeType.setId("9998"); - mHomeTypes.add(homeType); - } - if (BeibeiConstant.AD_SETTING_RECOMMEND_FIRST) - if (adInfo != null && mHomeTypes != null && mHomeTypes.size() > 0) { - mHomeTypes.get(0).getHomeVideoList().get(0).setVideo(adInfo); - Log.i("mResult", "鏇挎崲骞垮憡鏁版嵁"); - } - } - //鎻掑叆澶у睆骞垮憡 - if (adList != null && adList.size() > 0) { - HomeType homeType = new HomeType(); - homeType.setName("鎺ㄥ箍"); - homeType.setColumns(1); - homeType.setHomeVideoList(adList); - homeType.setActivity(""); - homeType.setBeizhu(""); - homeType.setParams(""); - homeType.setHasMore("false"); - homeType.setId("9999"); - mHomeTypes.add(1, homeType); - } - if (adList1 != null && adList1.size() > 0) { - HomeType homeType = new HomeType(); - homeType.setName("鎺ㄥ箍"); - homeType.setColumns(1); - homeType.setHomeVideoList(adList1); - homeType.setActivity(""); - homeType.setBeizhu(""); - homeType.setParams(""); - homeType.setHasMore("false"); - homeType.setId("8888"); - mHomeTypes.add(homeType); - } - mRecommendAdapter.notifyDataSetChanged(); - } - } - - @Override - public void onFinish() { - super.onFinish(); - rl_recommend.setRefreshing(false); -// getHomeType(); - Log.i("mResult", "getLiveInfo---onFinish---getHomeType"); - } - }); - } - @Override public void onDestroy() { super.onDestroy(); } - private List<HomeVideo> adList = new ArrayList<>(); private List<HomeVideo> adList1 = new ArrayList<>(); - /** - * 涓睆 - */ - // 1.鍔犺浇骞垮憡锛屽厛璁剧疆鍔犺浇涓婁笅鏂囩幆澧冨拰鏉′欢 - private void loadAD1() { - NativeExpressAD nativeExpressAD = new NativeExpressAD(indicator_recommend.getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), - BeibeiConstant.GDT_ID, BeibeiConstant.GDT_RECOMMAND_NATIVE, new NativeExpressAD.NativeExpressADListener() { - @Override - public void onADLoaded(final List<NativeExpressADView> list) { - tv_notice.post(new Runnable() { - @Override - public void run() { - if (list != null && list.size() > 0) { - HomeVideo homeVideo = new HomeVideo(); - VideoInfo info = new VideoInfo(); - info.setAdView(list.get(0)); - homeVideo.setVideo(info); - adList.add(homeVideo); - } - try { - loadAD3(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - - } - - @Override - public void onRenderFail(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onRenderSuccess(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADExposure(NativeExpressADView nativeExpressADView) { - } - - @Override - public void onADClicked(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADClosed(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADLeftApplication(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onNoAD(AdError adError) { - tv_notice.post(new Runnable() { - @Override - public void run() { - try { - loadAD3(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - }); // 浼犲叆Activity - // 娉ㄦ剰锛氬鏋滄偍鍦ㄨ仈鐩熷钩鍙颁笂鏂板缓鍘熺敓妯℃澘骞垮憡浣嶆椂锛岄�夋嫨浜嗘敮鎸佽棰戯紝閭d箞鍙互杩涜涓�у寲璁剧疆锛堝彲閫夛級 - nativeExpressAD.setVideoOption(new VideoOption.Builder() - .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 鐜涓嬪彲浠ヨ嚜鍔ㄦ挱鏀捐棰� - .setAutoPlayMuted(true) // 鑷姩鎾斁鏃朵负闈欓煶 - .build()); // - nativeExpressAD.setDownAPPConfirmPolicy(DownAPPConfirmPolicy.Default); - nativeExpressAD.loadAD(2); - } - - /** - * 棣栭〉搴曞睆 - */ - // 1.鍔犺浇骞垮憡锛屽厛璁剧疆鍔犺浇涓婁笅鏂囩幆澧冨拰鏉′欢 - private void loadAD2() throws Exception { - String positionAdID; - if (position == 0) { - positionAdID = BeibeiConstant.GDT_RECOMMAND_MIN_NATIVE; - } else { - positionAdID = BeibeiConstant.GDT_RECOMMEND_CATEGORY_MIN_NATIVE; - } - NativeExpressAD nativeExpressAD = new NativeExpressAD(indicator_recommend.getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), - BeibeiConstant.GDT_ID, positionAdID, new NativeExpressAD.NativeExpressADListener() { - @Override - public void onADLoaded(List<NativeExpressADView> list) { - if (list != null && list.size() > 0) { - HomeVideo homeVideo = new HomeVideo(); - VideoInfo info = new VideoInfo(); - info.setAdView(list.get(0)); - homeVideo.setVideo(info); - adList1.add(homeVideo); - } - tv_no_network.post(new Runnable() { - @Override - public void run() { - getLiveInfo(); - } - }); - } - - @Override - public void onRenderFail(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onRenderSuccess(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADExposure(NativeExpressADView nativeExpressADView) { - } - - @Override - public void onADClicked(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADClosed(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADLeftApplication(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onNoAD(AdError adError) { - tv_no_network.post(new Runnable() { - @Override - public void run() { - getLiveInfo(); - } - }); - } - }); // 浼犲叆Activity - // 娉ㄦ剰锛氬鏋滄偍鍦ㄨ仈鐩熷钩鍙颁笂鏂板缓鍘熺敓妯℃澘骞垮憡浣嶆椂锛岄�夋嫨浜嗘敮鎸佽棰戯紝閭d箞鍙互杩涜涓�у寲璁剧疆锛堝彲閫夛級 - nativeExpressAD.setVideoOption(new VideoOption.Builder() - .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 鐜涓嬪彲浠ヨ嚜鍔ㄦ挱鏀捐棰� - .setAutoPlayMuted(true) // 鑷姩鎾斁鏃朵负闈欓煶 - .build()); // - nativeExpressAD.loadAD(2); - } - - /** - * 鍒嗙被棣栧睆 - */ - VideoInfo adInfo; - - // 1.鍔犺浇骞垮憡锛屽厛璁剧疆鍔犺浇涓婁笅鏂囩幆澧冨拰鏉′欢 - private void loadAD3() throws Exception { - String positionAdID; - if (position == 0) { - positionAdID = BeibeiConstant.GDT_RECOMMAND_MIN_NATIVE; - } else { - positionAdID = BeibeiConstant.GDT_RECOMMEND_CATEGORY_MIN_NATIVE; - } - NativeExpressAD nativeExpressAD = new NativeExpressAD(indicator_recommend.getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), - BeibeiConstant.GDT_ID, positionAdID, new NativeExpressAD.NativeExpressADListener() { - @Override - public void onADLoaded(final List<NativeExpressADView> list) { - tv_notice.post(new Runnable() { - @Override - public void run() { - if (null != list && list.size() > 0) { - adInfo = new VideoInfo(); - adInfo.setAdView(list.get(0)); - } - try { - loadAD2(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - @Override - public void onRenderFail(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onRenderSuccess(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADExposure(NativeExpressADView nativeExpressADView) { - } - - @Override - public void onADClicked(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADClosed(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADLeftApplication(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onNoAD(AdError adError) { - tv_notice.post(new Runnable() { - @Override - public void run() { - try { - loadAD2(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - - } - }); // 浼犲叆Activity - // 娉ㄦ剰锛氬鏋滄偍鍦ㄨ仈鐩熷钩鍙颁笂鏂板缓鍘熺敓妯℃澘骞垮憡浣嶆椂锛岄�夋嫨浜嗘敮鎸佽棰戯紝閭d箞鍙互杩涜涓�у寲璁剧疆锛堝彲閫夛級 - nativeExpressAD.setVideoOption(new VideoOption.Builder() - .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 鐜涓嬪彲浠ヨ嚜鍔ㄦ挱鏀捐棰� - .setAutoPlayMuted(true) // 鑷姩鎾斁鏃朵负闈欓煶 - .build()); // - nativeExpressAD.loadAD(2); - } List<HotStar> hotStars = new ArrayList<>(); @@ -1112,6 +725,21 @@ new TypeToken<List<HotStar>>() { }.getType()); hotStars.addAll(hotStarList); + + //鎻掑叆鏄庢槦鍒楄〃 + if (hotStars != null && hotStars.size() > 0) { + HomeType homeType = new HomeType(); + homeType.setName("鏄庢槦鍚堣緫"); + homeType.setColumns(4); + homeType.setHotStars(hotStars); + homeType.setActivity(""); + homeType.setBeizhu(""); + homeType.setParams(""); + homeType.setHasMore("true"); + homeType.setId("9998"); + mHomeTypes.add(homeType); + mRecommendNewAdapter.notifyDataSetChanged(); + } } } -- Gitblit v1.8.0