| | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Color; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.text.Editable; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.view.KeyEvent; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.View.OnTouchListener; |
| | | import android.widget.AbsListView; |
| | | import android.view.ViewGroup; |
| | | import android.view.inputmethod.EditorInfo; |
| | | import android.widget.AdapterView; |
| | | import android.widget.AdapterView.OnItemClickListener; |
| | | import android.widget.ArrayAdapter; |
| | | import android.widget.AutoCompleteTextView; |
| | | import android.widget.BaseAdapter; |
| | | import android.widget.Filter; |
| | | import android.widget.Filterable; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.LinearLayout.LayoutParams; |
| | | import android.widget.ListView; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.lcjian.library.util.common.SoftKeyboardUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.ADSize; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | import com.weikou.beibeivideo.entity.video.VideoContent; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.discover.StarWorksAdapter; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.yeshi.buwanshequ.R; |
| | | import com.weikou.beibeivideo.ui.video.SearchResultAdapter; |
| | | import com.weikou.beibeivideo.ui.video.SuggestKeysAdapter; |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | private AutoCompleteTextView et_search_key; |
| | | |
| | | private TextView tv_back; |
| | | private TextView tv_search_cancel; |
| | | |
| | | private ImageView tv_search_cancel; |
| | | private RecyclerView rv_video_search; |
| | | |
| | | private ListView lv_video_search; |
| | | private List<VideoContent> mVideoInfos; |
| | | |
| | | private StarWorksAdapter adapter; |
| | | private SearchResultAdapter adapter; |
| | | |
| | | private List<VideoInfo> mVideoInfos; |
| | | |
| | | private int mCurrentPage = 1; |
| | | |
| | |
| | | |
| | | private boolean mFirst = true; |
| | | |
| | | private RefreshLayout rl_search_result; |
| | | private SwipeRefreshLayout rl_search_result; |
| | | |
| | | // private ImageView iv_search_result_ad;// 添加聚效广告图片 |
| | | private ExpressAdManager expressAdManager; |
| | | |
| | | private boolean isLoad; |
| | | |
| | | private View loading; |
| | | |
| | | private LinearLayout ll_top_bar; |
| | | |
| | | List<VideoType> typeList; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.search_result_activity); |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | |
| | | rl_search_result = (RefreshLayout) findViewById(R.id.rl_search_result); |
| | | et_search_key = (AutoCompleteTextView) findViewById(R.id.et_search_key); |
| | | tv_back = (TextView) findViewById(R.id.tv_top_bar_left); |
| | | tv_back.setOnClickListener(this); |
| | | tv_search_cancel = (ImageView) findViewById(R.id.tv_search_cancel); |
| | | lv_video_search = (ListView) findViewById(R.id.gv_video_search); |
| | | findViewById(R.id.tv_moive_all).setOnClickListener(this); |
| | | findViewById(R.id.tv_moive).setOnClickListener(this); |
| | | findViewById(R.id.tv_moive_special).setOnClickListener(this); |
| | | rl_search_result = findViewById(R.id.rl_search_result); |
| | | et_search_key = findViewById(R.id.et_search_key); |
| | | tv_search_cancel = findViewById(R.id.tv_search_cancel); |
| | | rv_video_search = findViewById(R.id.rv_video_search); |
| | | ll_top_bar = findViewById(R.id.ll_top_bar); |
| | | |
| | | tv_search_cancel.setOnClickListener(this); |
| | | et_search_key.addTextChangedListener(new TextWatcher() { |
| | | |
| | |
| | | } |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | R.drawable.ic_clear, 0); |
| | | // tv_search_cancel.setText(R.string.search); |
| | | } else { |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | 0, 0); |
| | | // tv_search_cancel.setText(R.string.cancel); |
| | | } |
| | | } |
| | | }); |
| | |
| | | mCurrentKey = parent.getItemAtPosition(position).toString(); |
| | | SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this); |
| | | mCurrentPage = 1; |
| | | refreshAd(); |
| | | //清除顶部分类 |
| | | typeList = null; |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | }); |
| | | |
| | |
| | | }); |
| | | |
| | | |
| | | et_search_key.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
| | | @Override |
| | | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
| | | if (actionId == EditorInfo.IME_ACTION_SEARCH) { |
| | | if (StringUtils.isEmpty(et_search_key.getEditableText() |
| | | .toString())) { |
| | | mCurrentKey = et_search_key.getText().toString(); |
| | | } else { |
| | | mCurrentKey = et_search_key.getEditableText().toString(); |
| | | } |
| | | SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this); |
| | | mCurrentPage = 1; |
| | | rl_search_result.setRefreshing(true); |
| | | //清除顶部分类 |
| | | typeList = null; |
| | | search(mCurrentKey, mCurrentType); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | mCurrentKey = getIntent().getStringExtra("key"); |
| | | et_search_key.setText(mCurrentKey); |
| | | et_search_key.setSelection(mCurrentKey.length()); |
| | | // et_search_key.setText(mCurrentKey); |
| | | |
| | | mVideoInfos = new ArrayList<VideoInfo>(); |
| | | mVideoInfos = new ArrayList<>(); |
| | | rl_search_result.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | mCurrentPage = 1; |
| | | refreshAd(); |
| | | } |
| | | }); |
| | | rl_search_result.setOnLoadListener(new RefreshLayout.OnLoadListener() { |
| | | @Override |
| | | public void onLoad() { |
| | | mCurrentPage++; |
| | | refreshAd(); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | }); |
| | | |
| | | lv_video_search.setOnItemClickListener(new OnItemClickListener() { |
| | | |
| | | rv_video_search.setLayoutManager(new MyLinearLayoutManager(getApplicationContext())); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(rv_video_search.getContext(), 6)); |
| | | rv_video_search.addItemDecoration(decoration); |
| | | |
| | | adapter = new SearchResultAdapter(this, mVideoInfos); |
| | | loading = LayoutInflater.from(this).inflate(R.layout.item_loading, null); |
| | | loading.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | loading.setVisibility(View.GONE); |
| | | adapter.setFooterView(loading); |
| | | |
| | | rv_video_search.setAdapter(adapter); |
| | | rv_video_search.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { |
| | | super.onScrollStateChanged(recyclerView, newState); |
| | | LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | int first = manager.findFirstVisibleItemPosition(); |
| | | int last = manager.findLastVisibleItemPosition(); |
| | | int total = manager.getItemCount(); |
| | | if (newState == RecyclerView.SCROLL_STATE_IDLE) { |
| | | if ((!isLoad) && last == total - 1 && mVideoInfos.size() < 1000) { |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0 && !rl_search_result.isRefreshing()) {//列表中有数据才能加载更多 |
| | | mCurrentPage++; |
| | | isLoad = true; |
| | | loading.setVisibility(View.VISIBLE); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | VideoInfo videoInfo = (VideoInfo) parent |
| | | .getItemAtPosition(position); |
| | | Intent intent = new Intent(SearchResultActivity.this, |
| | | VideoDetailActivity.class); |
| | | intent.putExtra("video_info", videoInfo); |
| | | startActivity(intent); |
| | | public void onScrolled(RecyclerView recyclerView, int dx, final int dy) { |
| | | super.onScrolled(recyclerView, dx, dy); |
| | | } |
| | | }); |
| | | lv_video_search.setOnScrollListener(new AbsListView.OnScrollListener() { |
| | | @Override |
| | | public void onScrollStateChanged(AbsListView view, int scrollState) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { |
| | | |
| | | } |
| | | }); |
| | | lv_video_search.addHeaderView(new View(this)); |
| | | adapter = new StarWorksAdapter(mVideoInfos, getApplicationContext()); |
| | | lv_video_search.setAdapter(adapter); |
| | | ProgressBar pb = new ProgressBar(SearchResultActivity.this); |
| | | rl_search_result.setFooter(pb); |
| | | refreshAd(); |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | // loadAd(); |
| | | } |
| | | |
| | | private void initTopBar(List<VideoType> videoTypeList) { |
| | | int p = 0; |
| | | ll_top_bar.removeAllViews(); |
| | | LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); |
| | | for (int i = 0; i < videoTypeList.size(); i++) { |
| | | final View view = inflater.inflate(R.layout.item_search_result_top_bar_content, null); |
| | | TextView tv_name = view.findViewById(R.id.tv_name); |
| | | tv_name.setText(videoTypeList.get(i).getName()); |
| | | setTopBarSelect(tv_name, i == p); |
| | | ll_top_bar.addView(view); |
| | | ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); |
| | | params.rightMargin = DimenUtils.dip2px(getApplicationContext(), 17); |
| | | params.leftMargin = DimenUtils.dip2px(getApplicationContext(), 10); |
| | | view.setTag(i); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | int p = Integer.parseInt(view.getTag() + ""); |
| | | selectTopBar(p); |
| | | VideoType vt = videoTypeList.get(p); |
| | | |
| | | if (StringUtils.isBlank(mCurrentType) || !mCurrentType.equalsIgnoreCase(vt.getId())) { |
| | | mCurrentPage = 1; |
| | | mCurrentType = vt.getId(); |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | private void setTopBarSelect(TextView tv_name, boolean selected) { |
| | | if (selected) { |
| | | tv_name.setBackgroundResource(R.drawable.vpi__tab_selected_focused_holo); |
| | | tv_name.setTextSize(17); |
| | | tv_name.setTextColor(Color.parseColor("#FFFFFF")); |
| | | tv_name.setPadding(0, 0, 0, DimenUtils.dip2px(getApplicationContext(), 5)); |
| | | } else { |
| | | tv_name.setBackground(null); |
| | | tv_name.setTextSize(12); |
| | | tv_name.setTextColor(Color.parseColor("#999999")); |
| | | tv_name.setPadding(0, 0, 0, 0); |
| | | } |
| | | } |
| | | |
| | | private void selectTopBar(int p) { |
| | | for (int i = 0; i < ll_top_bar.getChildCount(); i++) { |
| | | TextView tv = ll_top_bar.getChildAt(i).findViewById(R.id.tv_name); |
| | | setTopBarSelect(tv, i == p); |
| | | } |
| | | } |
| | | |
| | | private void suggestSearch(String key) { |
| | |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<String>>() { |
| | | }.getType()); |
| | | ArrayAdapter<String> adapter = new ArrayAdapter<String>( |
| | | SearchResultActivity.this, |
| | | android.R.layout.simple_list_item_1, |
| | | results); |
| | | SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results); |
| | | et_search_key.setAdapter(adapter); |
| | | adapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void fillAD(List<ExpressAdContainer> adList) { |
| | | if (adList != null) { |
| | | SearchResultActivity.this.adList.addAll(adList); |
| | | } |
| | | |
| | | if (adList.size() > 0) { |
| | | boolean hasAd = false; |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) |
| | | for (VideoContent vc : mVideoInfos) { |
| | | if (vc.getType() == VideoContent.TYPE_AD) { |
| | | hasAd = true; |
| | | break; |
| | | } |
| | | } |
| | | //不存在广告 |
| | | if (!hasAd) { |
| | | mVideoInfos.add(0, VideoContent.createAdContent(SearchResultActivity.this.adList.get(0))); |
| | | SearchResultActivity.this.adList.remove(0); |
| | | adapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void loadAd() { |
| | | ExpressAdContainer ad = SearchResultAdManager.getInstance(getApplicationContext()).consumeAD(); |
| | | if (ad == null) { |
| | | SearchResultAdManager.getInstance(getApplicationContext()).loadAD(1, new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | fillAD(adList); |
| | | } |
| | | }); |
| | | } else { |
| | | List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | adList.add(ad); |
| | | fillAD(adList); |
| | | } |
| | | //加载下一个需要的广告 |
| | | SearchResultAdManager.getInstance(getApplicationContext()).autoLoadAd(); |
| | | } |
| | | |
| | | private List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | |
| | | private void search(String key, String videoType) { |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | JSONObject rootData = jsonObject.getJSONObject("Data"); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | |
| | | rootData.getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | |
| | | mVideoInfos.addAll(videoInfos); |
| | | if (mVideoInfos.size() > 0) |
| | | adapter.notifyDataSetChanged(); |
| | | //设置导航栏 |
| | | if (rootData.opt("typeList") != null) { |
| | | if (typeList == null) { |
| | | typeList = gson.fromJson( |
| | | rootData |
| | | .getJSONArray("typeList").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | initTopBar(typeList); |
| | | } |
| | | } |
| | | |
| | | List<VideoContent> videoContentList = new ArrayList<>(); |
| | | for (VideoInfo video : videoInfos) { |
| | | videoContentList.add(VideoContent.createVideoContent(video)); |
| | | } |
| | | |
| | | |
| | | if (adList.size() > 0) { |
| | | int adPosition = (int) (videoContentList.size() * Math.random()); |
| | | if (mCurrentPage == 1) |
| | | adPosition = 0; |
| | | videoContentList.add(adPosition, VideoContent.createAdContent(adList.get(0))); |
| | | adList.remove(0); |
| | | } |
| | | if (mCurrentPage <= 1) { |
| | | mVideoInfos.clear(); |
| | | } |
| | | mVideoInfos.addAll(videoContentList); |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | //加载下一次要用的广告 |
| | | if (videoInfos.size() > 0) { |
| | | if (adList.size() < 1) |
| | | loadAd(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | isLoad = false; |
| | | rl_search_result.setRefreshing(false); |
| | | rl_search_result.setLoading(false); |
| | | loading.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_search_cancel: { |
| | | if (StringUtils.isEmpty(et_search_key.getEditableText() |
| | | .toString())) { |
| | | mCurrentKey = et_search_key.getText().toString(); |
| | | } else { |
| | | mCurrentKey = et_search_key.getEditableText().toString(); |
| | | } |
| | | SoftKeyboardUtils.hideSoftInput(this); |
| | | mCurrentPage = 1; |
| | | refreshAd(); |
| | | finish(); |
| | | } |
| | | break; |
| | | case R.id.tv_top_bar_left: |
| | | finish(); |
| | | break; |
| | | case R.id.tv_moive_all: |
| | | rl_search_result.setRefreshing(true); |
| | | mVideoInfos.clear(); |
| | | // adapter.notifyDataSetChanged(); |
| | | mCurrentPage = 1; |
| | | mCurrentType = "0"; |
| | | findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select2); |
| | | findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select1); |
| | | findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select1); |
| | | refreshAd(); |
| | | |
| | | break; |
| | | case R.id.tv_moive: |
| | | mVideoInfos.clear(); |
| | | rl_search_result.setRefreshing(true); |
| | | mCurrentPage = 1; |
| | | mCurrentType = "1"; |
| | | findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select1); |
| | | findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select2); |
| | | findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select1); |
| | | refreshAd(); |
| | | break; |
| | | case R.id.tv_moive_special: |
| | | mVideoInfos.clear(); |
| | | rl_search_result.setRefreshing(true); |
| | | mCurrentPage = 1; |
| | | mCurrentType = "2"; |
| | | findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select1); |
| | | findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select1); |
| | | findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select2); |
| | | refreshAd(); |
| | | break; |
| | | // case R.id.iv_search_result_ad:// 聚效广告点击事件处理 |
| | | // if (list.size() > 0) { |
| | | // list.get(0).onAdClicked(); |
| | | // } |
| | | // break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | builder.substring(0, builder.length() - 1)).commit(); |
| | | } |
| | | |
| | | // 1.加载广告,先设置加载上下文环境和条件 |
| | | private void refreshAd() { |
| | | if (mCurrentPage == 1) { |
| | | mVideoInfos.clear(); |
| | | |
| | | class MyLinearLayoutManager extends LinearLayoutManager { |
| | | |
| | | public MyLinearLayoutManager(Context context) { |
| | | super(context); |
| | | } |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(SearchResultActivity.this, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_ID, BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE, new NativeExpressAD.NativeExpressADListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | tv_back.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (null != list && list.size() > 0) { |
| | | VideoInfo info = new VideoInfo(); |
| | | info.setAdView(list.get(0)); |
| | | mVideoInfos.add(info); |
| | | } |
| | | |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | }); |
| | | |
| | | @Override |
| | | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { |
| | | try { |
| | | super.onLayoutChildren(recycler, state); |
| | | } catch (IndexOutOfBoundsException 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_back.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); // 传入Activity |
| | | // 注意:如果您在联盟平台上新建原生模板广告位时,选择了支持视频,那么可以进行个性化设置(可选) |
| | | nativeExpressAD.setVideoOption(new VideoOption.Builder() |
| | | .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 |
| | | .setAutoPlayMuted(true) // 自动播放时为静音 |
| | | .build()); // |
| | | nativeExpressAD.loadAD(2); |
| | | } |
| | | } |
| | | } |