diff --git a/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java b/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java index 37aab8302..e64e48793 100644 --- a/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java +++ b/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java @@ -10,8 +10,8 @@ import java.util.List; */ public class AnchorRecommendModel extends BaseModel { /** - * list_show : 1 - * up_show : 1 + * list_show : 1 //1,展示 0,不展示 + * up_show : 1 //1,刷新按钮展示 0不展示 * list : [{"islive":1,"uid":97616,"title":"12","stream":"97616_1649830285","pull":"http://pullry.yaoulive.com/uwd1c0sxu1p71/97616_1649830285.flv","thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","isvideo":0,"type":0,"type_val":"","anyway":1,"landscape":1,"liveclassid":1,"is_rong":1,"hot_num":30579,"content_pic_size_one":"","content_pic_size_two":"","content_pic_size_three":"","nums":"1","avatar":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar_thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar2":"","user_nicename":"RongCloudcs20","level":"32","level_anchor":"58"},{"islive":1,"uid":97617,"title":"23","stream":"97617_1649830293","pull":"http://pullry.yaoulive.com/uwd1c0sxu1p71/97617_1649830293.flv","thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","isvideo":0,"type":0,"type_val":"","anyway":1,"landscape":1,"liveclassid":1,"is_rong":1,"hot_num":5356,"content_pic_size_one":"","content_pic_size_two":"","content_pic_size_three":"","nums":"1","avatar":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar_thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar2":"","user_nicename":"RongCloudcs21","level":"32","level_anchor":"12"},{"islive":1,"uid":97619,"title":"45","stream":"97619_1649830309","pull":"http://pullry.yaoulive.com/uwd1c0sxu1p71/97619_1649830309.flv","thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","isvideo":0,"type":0,"type_val":"","anyway":1,"landscape":1,"liveclassid":1,"is_rong":1,"hot_num":41061,"content_pic_size_one":"","content_pic_size_two":"","content_pic_size_three":"","nums":"4","avatar":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar_thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar2":"","user_nicename":"RongCloudcs23","level":"32","level_anchor":"21"},{"islive":1,"uid":97620,"title":"56","stream":"97620_1649830320","pull":"http://pullry.yaoulive.com/uwd1c0sxu1p71/97620_1649830320.flv","thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","isvideo":0,"type":0,"type_val":"","anyway":1,"landscape":1,"liveclassid":1,"is_rong":1,"hot_num":29610,"content_pic_size_one":"","content_pic_size_two":"","content_pic_size_three":"","nums":"4","avatar":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar_thumb":"https://qny.shayucm.com/20210805013115_aaf2203dd76321d068943bb6868c3461?imageView2/2/w/600/h/600","avatar2":"","user_nicename":"RongCloudcs24","level":"32","level_anchor":"34"},{"islive":1,"uid":97712,"title":"宽哥太牛辣","stream":"97712_1658912067","pull":"http://pullry.yaoulive.com/uwd1c0sxu1p71/97712_2022.flv","thumb":"https://qny.shayucm.com/20220329113227_c661f791c5fc878c2ef357ee022f9fbc?imageView2/2/w/600/h/600","isvideo":0,"type":0,"type_val":"","anyway":1,"landscape":1,"liveclassid":1,"is_rong":1,"hot_num":41498,"content_pic_size_one":"","content_pic_size_two":"","content_pic_size_three":"","nums":"3","avatar":"https://qny.shayucm.com/20220329113227_c661f791c5fc878c2ef357ee022f9fbc?imageView2/2/w/600/h/600","avatar_thumb":"https://qny.shayucm.com/20220329113227_c661f791c5fc878c2ef357ee022f9fbc?imageView2/2/w/200/h/200","avatar2":"","user_nicename":"rongyun002","level":"71","level_anchor":"14"}] */ //是否展示0=不展示1=展示 diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java index c658d1517..d3d3303b1 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java @@ -65,18 +65,18 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList goHomeUser, anchorName, liveDurationAnchor, liveVotes, liveWatchNum; private RelativeLayout userLiveEnd, anchorLiveEnd; private ClipPathCircleImage clipImageUser, clipImageanchor; - private LinearLayout followUser; + private LinearLayout followUser, listShow; private ImageView changeBatchUser; private RecyclerView likeList; private SearchRecommendBodyAdapter adapter; private IMLoginModel model = null; - public LiveEndViewHolder(Context context, ViewGroup parentView,String uid) { + public LiveEndViewHolder(Context context, ViewGroup parentView, String uid) { super(context, parentView); model = IMLoginManager.get(mContext).getUserInfo(); - if (TextUtils.equals(model.getId()+"",uid)){ + if (TextUtils.equals(model.getId() + "", uid)) { type = LiveOfType.ANCHOR; - }else { + } else { type = LiveOfType.USER; } } @@ -124,6 +124,16 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList .anchorRecommend("3", new HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { + if (data.getListShow() == 1) { + listShow.setVisibility(View.VISIBLE); + } else { + listShow.setVisibility(View.GONE); + } + if (data.getUpShow() == 1) { + changeBatchUser.setVisibility(View.VISIBLE); + } else { + changeBatchUser.setVisibility(View.GONE); + } fragment.dismiss(); //组装搜索历史数据 adapter.showData(data.getList()); @@ -149,6 +159,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList clipImageUser = (ClipPathCircleImage) findViewById(R.id.clip_image_user); followUser = (LinearLayout) findViewById(R.id.follow_user); + listShow = (LinearLayout) findViewById(R.id.list_show); changeBatchUser = (ImageView) findViewById(R.id.change_batch_user); likeList = (RecyclerView) findViewById(R.id.like_list); goHomeUser.setOnClickListener(new View.OnClickListener() { @@ -197,7 +208,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList }); } - public static void upData(String votes, String length, int nums,String uname) { + public static void upData(String votes, String length, int nums, String uname) { Log.e("收", votes + "votes" + length + "length" + nums + "nums"); // mVotes.setText(votes); @@ -214,9 +225,9 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList } public void showData(LiveBean liveBean, final String stream) { - if (TextUtils.equals(model.getId()+"",liveBean.getUid())){ + if (TextUtils.equals(model.getId() + "", liveBean.getUid())) { type = LiveOfType.ANCHOR; - }else { + } else { type = LiveOfType.USER; } if (type == LiveOfType.USER) { diff --git a/live/src/main/res/layout/view_live_end.xml b/live/src/main/res/layout/view_live_end.xml index 7ad791403..a487cf0ce 100644 --- a/live/src/main/res/layout/view_live_end.xml +++ b/live/src/main/res/layout/view_live_end.xml @@ -169,7 +169,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="#b3000000" - android:visibility="gone"> + android:visibility="visible"> - + + @@ -343,7 +348,8 @@ android:id="@+id/anchor_live_end" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#b3000000"> + android:background="#b3000000" + android:visibility="gone"> diff --git a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java index 233b56f17..814353eac 100644 --- a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java @@ -3,12 +3,13 @@ package com.yunbao.main.activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.text.Editable; import android.text.TextUtils; -import android.text.TextWatcher; +import android.view.KeyEvent; import android.view.View; +import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import android.widget.TextView; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -65,7 +66,7 @@ public class SearchActivity extends AbsActivity { transaction.replace(R.id.context_layout, searchRecommendFragment); transaction.commit(); mEditText = findViewById(R.id.edit); - mEditText.addTextChangedListener(textWatcher); + mEditText.setOnEditorActionListener(onEditorActionListener); //退出检索页面保存搜索记录 findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() { @Override @@ -105,42 +106,38 @@ public class SearchActivity extends AbsActivity { finish(); } - //輸入框監聽函數 - TextWatcher textWatcher = new TextWatcher() { + TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + // 保存关键词到本地数据库 + String search_word = mEditText.getText().toString().trim(); + if (TextUtils.isEmpty(search_word.trim())) { + //檢索推薦頁面 + SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment(); + FragmentManager manager = getSupportFragmentManager(); + FragmentTransaction transaction = manager.beginTransaction(); + transaction.replace(R.id.context_layout, searchRecommendFragment); + transaction.commit(); + } else { + //展示檢索頁面 + SearchResultsFragment searchResultsFragment = new SearchResultsFragment(); + FragmentManager manager = getSupportFragmentManager(); + FragmentTransaction transaction = manager.beginTransaction(); + Bundle bundle = new Bundle(); + bundle.putString("searchKey", search_word.toString()); + searchResultsFragment.setArguments(bundle); + transaction.replace(R.id.context_layout, searchResultsFragment); + transaction.commit(); + } + return true; - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - if (TextUtils.isEmpty(s.toString())) { - //檢索推薦頁面 - SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment(); - FragmentManager manager = getSupportFragmentManager(); - FragmentTransaction transaction = manager.beginTransaction(); - transaction.replace(R.id.context_layout, searchRecommendFragment); - transaction.commit(); - } else { - //展示檢索頁面 - SearchResultsFragment searchResultsFragment = new SearchResultsFragment(); - FragmentManager manager = getSupportFragmentManager(); - FragmentTransaction transaction = manager.beginTransaction(); - Bundle bundle = new Bundle(); - bundle.putString("searchKey", s.toString()); - searchResultsFragment.setArguments(bundle); - transaction.replace(R.id.context_layout, searchResultsFragment); - transaction.commit(); } - - } - - @Override - public void afterTextChanged(Editable s) { - + return false; } }; + /** * 跳转用户首页 */ @@ -184,6 +181,15 @@ public class SearchActivity extends AbsActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onChip(String chip) { mEditText.setText(chip); + //展示檢索頁面 + SearchResultsFragment searchResultsFragment = new SearchResultsFragment(); + FragmentManager manager = getSupportFragmentManager(); + FragmentTransaction transaction = manager.beginTransaction(); + Bundle bundle = new Bundle(); + bundle.putString("searchKey", chip); + searchResultsFragment.setArguments(bundle); + transaction.replace(R.id.context_layout, searchResultsFragment); + transaction.commit(); } } diff --git a/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java b/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java index d095a72be..aea0a208b 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java @@ -61,7 +61,7 @@ public class SearchRecommendFragment extends BaseFragment { LoadingDialog fragment = new LoadingDialog(); fragment.show(getChildFragmentManager(), "LoadingDialog"); MainNetManager.get(getActivity()) - .anchorRecommend("6", new HttpCallback() { + .anchorRecommend("10", new HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { fragment.dismiss(); diff --git a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java index 96330e563..24c0b8390 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java @@ -69,7 +69,9 @@ public class SearchResultsItemFragment extends BaseFragment { * @param type 類型 */ public void setSearchKey(String searchKey, int type) { - + //展示网络请求弹窗 + LoadingDialog fragment = new LoadingDialog(); + fragment.show(getChildFragmentManager(), "LoadingDialog"); this.searchKey = searchKey; this.type = type; if (type == 1) { @@ -79,6 +81,7 @@ public class SearchResultsItemFragment extends BaseFragment { type, page, new HttpCallback>>() { @Override public void onSuccess(List> data) { + fragment.dismiss(); if (page > 1) { itemAdapter.onLoadMoreData(data); } else { @@ -88,7 +91,8 @@ public class SearchResultsItemFragment extends BaseFragment { @Override public void onError(String error) { - ToastUtil.show(error); + + fragment.dismiss(); } }); } else { @@ -98,8 +102,9 @@ public class SearchResultsItemFragment extends BaseFragment { type, page, new HttpCallback>() { @Override public void onSuccess(List data) { + fragment.dismiss(); if (data.size() == 0) { - ToastUtil.show(R.string.refresh_footer_nothing); + } else { List> listList = new ArrayList<>(); listList.add(data); @@ -114,7 +119,8 @@ public class SearchResultsItemFragment extends BaseFragment { @Override public void onError(String error) { - ToastUtil.show(error); + + fragment.dismiss(); } }); } diff --git a/main/src/main/res/layout/view_anchor_search_results_item_holder.xml b/main/src/main/res/layout/view_anchor_search_results_item_holder.xml index 22878c096..c59684010 100644 --- a/main/src/main/res/layout/view_anchor_search_results_item_holder.xml +++ b/main/src/main/res/layout/view_anchor_search_results_item_holder.xml @@ -40,6 +40,7 @@