| | |
| | | package com.weikou.beibeivideo.ui.recommend; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Typeface; |
| | | 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.view.View.OnTouchListener; |
| | | 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.ImageView; |
| | | import android.widget.LinearLayout.LayoutParams; |
| | | import android.widget.EditText; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.LinearLayout; |
| | | 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.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.SoftKeyboardUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.NativeADUnifiedListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedAD; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | 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.video.SearchResultAdapter; |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | public class SearchResultActivity extends BaseActivity implements |
| | | OnClickListener { |
| | | |
| | | private AutoCompleteTextView et_search_key; |
| | | private EditText et_search_key; |
| | | |
| | | private TextView tv_search_cancel; |
| | | |
| | |
| | | |
| | | private View loading; |
| | | |
| | | private LinearLayout ll_top_bar; |
| | | |
| | | List<VideoType> typeList; |
| | | |
| | | private LinearLayout ll_empty; |
| | | |
| | | private SearchSuggestFragment suggestFragment; |
| | | |
| | | private FrameLayout fl_suggest; |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.search_result_activity); |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | suggestFragment = new SearchSuggestFragment(); |
| | | |
| | | 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); |
| | | findViewById(R.id.tv_moive_all).setOnClickListener(this); |
| | | findViewById(R.id.tv_moive).setOnClickListener(this); |
| | | findViewById(R.id.tv_moive_special).setOnClickListener(this); |
| | | ll_top_bar = findViewById(R.id.ll_top_bar); |
| | | ll_empty = findViewById(R.id.ll_empty); |
| | | fl_suggest = findViewById(R.id.fl_suggest); |
| | | |
| | | tv_search_cancel.setOnClickListener(this); |
| | | et_search_key.addTextChangedListener(new TextWatcher() { |
| | | |
| | |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | if (!TextUtils.isEmpty(s.toString()) |
| | | || !TextUtils.isEmpty(et_search_key.getText())) { |
| | | if (mFirst) { |
| | | mFirst = false; |
| | | } else { |
| | | suggestSearch(s.toString()); |
| | | } |
| | | if (!TextUtils.isEmpty(s.toString())) { |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | R.drawable.ic_clear, 0); |
| | | } else { |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | 0, 0); |
| | | } |
| | | } |
| | | }); |
| | | et_search_key.setOnItemClickListener(new OnItemClickListener() { |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | mFirst = true; |
| | | mCurrentKey = parent.getItemAtPosition(position).toString(); |
| | | SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this); |
| | | mCurrentPage = 1; |
| | | search(mCurrentKey, mCurrentType); |
| | | if (mFirst) { |
| | | mFirst = false; |
| | | } else { |
| | | suggestSearch(s != null ? s.toString() : null); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | @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); |
| | | search(mCurrentKey, mCurrentType); |
| | | startSearch(); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | }); |
| | | |
| | | |
| | | rv_video_search.setLayoutManager(new LinearLayoutManager(getApplicationContext())); |
| | | rv_video_search.setLayoutManager(new MyLinearLayoutManager(getApplicationContext())); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(rv_video_search.getContext(), 6)); |
| | | decoration.setSize(DimenUtils.dip2px(rv_video_search.getContext(), 15)); |
| | | rv_video_search.addItemDecoration(decoration); |
| | | |
| | | adapter = new SearchResultAdapter(this, mVideoInfos); |
| | | adapter = new SearchResultAdapter(this, mVideoInfos, new SearchResultAdapter.VideoAlbumNavClickListener() { |
| | | @Override |
| | | public void onNav(int p) { |
| | | navClick(p); |
| | | } |
| | | }); |
| | | 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); |
| | |
| | | int total = manager.getItemCount(); |
| | | if (newState == RecyclerView.SCROLL_STATE_IDLE) { |
| | | if ((!isLoad) && last == total - 1 && mVideoInfos.size() < 1000) { |
| | | mCurrentPage++; |
| | | isLoad = true; |
| | | loading.setVisibility(View.VISIBLE); |
| | | search(mCurrentKey, mCurrentType); |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0 && !rl_search_result.isRefreshing()) {//列表中有数据才能加载更多 |
| | | mCurrentPage++; |
| | | isLoad = true; |
| | | loading.setVisibility(View.VISIBLE); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | // loadAd(); |
| | | } |
| | | |
| | | private void startSearch() { |
| | | 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); |
| | | } |
| | | |
| | | |
| | | private void initTopBar() { |
| | | int p = 0; |
| | | ll_top_bar.removeAllViews(); |
| | | LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); |
| | | for (int i = 0; i < typeList.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(typeList.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() + ""); |
| | | navClick(p); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | private void navClick(int p) { |
| | | if (typeList == null || typeList.size() <= p) |
| | | return; |
| | | selectTopBar(p); |
| | | VideoType vt = typeList.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(19); |
| | | tv_name.setTextColor(getResources().getColor(R.color.search_nav_highlight_text_color)); |
| | | tv_name.setPadding(0, 0, 0, DimenUtils.dip2px(getApplicationContext(), 5)); |
| | | tv_name.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); |
| | | } else { |
| | | tv_name.setBackground(null); |
| | | tv_name.setTextSize(14); |
| | | tv_name.setTextColor(getResources().getColor(R.color.nav_text_color)); |
| | | tv_name.setPadding(0, 0, 0, 0); |
| | | tv_name.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); |
| | | } |
| | | } |
| | | |
| | | 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 hiddenSuggestFragment() { |
| | | fl_suggest.setVisibility(View.GONE); |
| | | getSupportFragmentManager().beginTransaction().remove(suggestFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | private void showSuggestFragment(String key, List<String> list) { |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("key", key); |
| | | bundle.putString("list", new Gson().toJson(list)); |
| | | fl_suggest.setVisibility(View.VISIBLE); |
| | | suggestFragment.setItemClickListener(new SearchSuggestFragment.OnItemClickListener() { |
| | | @Override |
| | | public void onClick(String st) { |
| | | mFirst = true; |
| | | hiddenSuggestFragment(); |
| | | et_search_key.setText(st); |
| | | startSearch(); |
| | | } |
| | | }); |
| | | |
| | | suggestFragment.setArguments(bundle); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_suggest, suggestFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | |
| | | private void suggestSearch(String key) { |
| | | if (StringUtils.isEmpty(key)) { |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | List<String> results = null; |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<String> results = gson.fromJson(jsonObject |
| | | results = gson.fromJson(jsonObject |
| | | .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); |
| | | et_search_key.setAdapter(adapter); |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | |
| | | // SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results); |
| | | // et_search_key.setAdapter(adapter); |
| | | // adapter.notifyDataSetChanged(); |
| | | } |
| | | |
| | | if (results != null && results.size() > 0) { |
| | | showSuggestFragment(key, results); |
| | | suggestFragment.setData(key, results); |
| | | } else { |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void fillAD(List<ExpressAdContainer> adList) { |
| | | if (adList != null) { |
| | | SearchResultActivity.this.adList.addAll(adList); |
| | | } |
| | | private synchronized void fillAD(List<ExpressAdContainer> 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; |
| | | } |
| | | //判断当前页面是否需要广告 |
| | | int albumCount = 0; |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) |
| | | for (int i = 0; i < mVideoInfos.size(); i++) { |
| | | VideoContent vc = mVideoInfos.get(i); |
| | | if (vc.getType() == VideoContent.TYPE_AD) { |
| | | //更新广告 |
| | | vc.setAd(adList.get(0)); |
| | | adapter.notifyItemChanged(i); |
| | | return; |
| | | } else if (vc.getVideo().getShowType() == 1) { |
| | | albumCount++; |
| | | } |
| | | //不存在广告 |
| | | if (!hasAd) { |
| | | mVideoInfos.add(0, VideoContent.createAdContent(SearchResultActivity.this.adList.get(0))); |
| | | SearchResultActivity.this.adList.remove(0); |
| | | adapter.notifyDataSetChanged(); |
| | | } |
| | | |
| | | if (albumCount >= 2) { |
| | | VideoContent videoContent = VideoContent.createAdContent(adList.get(0)); |
| | | mVideoInfos.add(2, videoContent); |
| | | adapter.notifyItemInserted(2); |
| | | } |
| | | |
| | | } |
| | | |
| | | //拉取2.0的自渲染广告 |
| | | 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) { |
| | | String pid = GDTConstant.PID_2_SEARCH_RESULT_ALBUM; |
| | | NativeUnifiedAD mAdManager = new NativeUnifiedAD(this, pid, new NativeADUnifiedListener() { |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoaded(List<NativeUnifiedADData> list) { |
| | | if (list != null && list.size() > 0) { |
| | | List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | adList.add(new ExpressAdContainer(list.get(0))); |
| | | fillAD(adList); |
| | | } |
| | | }); |
| | | } else { |
| | | List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | adList.add(ad); |
| | | fillAD(adList); |
| | | } |
| | | //加载下一个需要的广告 |
| | | SearchResultAdManager.getInstance(getApplicationContext()).autoLoadAd(); |
| | | } |
| | | }); |
| | | mAdManager.setVideoPlayPolicy(VideoOption.VideoPlayPolicy.AUTO); |
| | | mAdManager.loadData(1); |
| | | } |
| | | |
| | | private List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | // 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 void search(String key, String videoType) { |
| | | |
| | | UmengEventUtil.search(getApplicationContext(), videoType); |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.search(this, uid, key, videoType, |
| | | String.valueOf(mCurrentPage), |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | |
| | | 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()); |
| | | |
| | | //设置导航栏 |
| | | if (rootData.opt("typeList") != null) { |
| | | if (typeList == null) { |
| | | typeList = gson.fromJson( |
| | | rootData |
| | | .getJSONArray("typeList").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | initTopBar(); |
| | | } |
| | | } |
| | | |
| | | List<VideoContent> videoContentList = new ArrayList<>(); |
| | | for (VideoInfo video : videoInfos) { |
| | |
| | | } |
| | | |
| | | |
| | | 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) |
| | | //记录当前的广告信息 |
| | | VideoContent adContent = null; |
| | | int adContentP = -1; |
| | | if (mCurrentPage <= 1) { |
| | | for (int i = 0; i < mVideoInfos.size(); i++) { |
| | | if (mVideoInfos.get(i).getType() == VideoContent.TYPE_AD) { |
| | | adContent = mVideoInfos.get(i); |
| | | adContentP = i; |
| | | } |
| | | } |
| | | mVideoInfos.clear(); |
| | | } |
| | | |
| | | mVideoInfos.addAll(videoContentList); |
| | | if (adContent != null && mVideoInfos.size() >= adContentP) { |
| | | mVideoInfos.add(adContentP, adContent); |
| | | } |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | //加载下一次要用的广告 |
| | | if (videoInfos.size() > 0) { |
| | | if (adList.size() < 1) |
| | | loadAd(); |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) { |
| | | //有值 |
| | | ll_empty.setVisibility(View.GONE); |
| | | rl_search_result.setVisibility(View.VISIBLE); |
| | | } else { |
| | | //无值 |
| | | ll_empty.setVisibility(View.VISIBLE); |
| | | rl_search_result.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (mCurrentPage == 1) { |
| | | loadAd(); |
| | | } |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("搜索结果页"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("搜索结果页"); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_search_cancel: { |
| | | finish(); |
| | | if (fl_suggest.getVisibility() == View.VISIBLE) { |
| | | hiddenSuggestFragment(); |
| | | } else { |
| | | finish(); |
| | | } |
| | | } |
| | | break; |
| | | case R.id.tv_top_bar_left: |
| | | finish(); |
| | | break; |
| | | case R.id.tv_moive_all: |
| | | rl_search_result.setRefreshing(true); |
| | | mVideoInfos.clear(); |
| | | 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); |
| | | search(mCurrentKey, mCurrentType); |
| | | 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); |
| | | search(mCurrentKey, mCurrentType); |
| | | 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); |
| | | search(mCurrentKey, mCurrentType); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | .putString("history", |
| | | builder.substring(0, builder.length() - 1)).commit(); |
| | | } |
| | | |
| | | |
| | | class MyLinearLayoutManager extends LinearLayoutManager { |
| | | |
| | | public MyLinearLayoutManager(Context context) { |
| | | super(context); |
| | | } |
| | | |
| | | @Override |
| | | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { |
| | | try { |
| | | super.onLayoutChildren(recycler, state); |
| | | } catch (IndexOutOfBoundsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |