关注主播
This commit is contained in:
@@ -7,18 +7,33 @@ import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
import com.yunbao.common.dialog.LoadingDialog;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.SearchHistoryRecordManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.JumpUserHomeEvent;
|
||||
import com.yunbao.main.fragment.SearchRecommendFragment;
|
||||
import com.yunbao.main.fragment.SearchResultsFragment;
|
||||
import com.yunbao.main.utils.WordsTypeUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/25.
|
||||
@@ -26,6 +41,7 @@ import com.yunbao.main.utils.WordsTypeUtil;
|
||||
|
||||
public class SearchActivity extends AbsActivity {
|
||||
private EditText mEditText;
|
||||
private InputMethodManager imm;
|
||||
|
||||
public static void forward(Context context) {
|
||||
context.startActivity(new Intent(context, SearchActivity.class));
|
||||
@@ -40,6 +56,8 @@ public class SearchActivity extends AbsActivity {
|
||||
//历史记录
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
//進入頁面首先展示推薦頁面
|
||||
SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
@@ -66,6 +84,7 @@ public class SearchActivity extends AbsActivity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,5 +134,44 @@ public class SearchActivity extends AbsActivity {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳转用户首页
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJumpUserHome(JumpUserHomeEvent event) {
|
||||
//展示网络请求弹窗
|
||||
LoadingDialog fragment = new LoadingDialog();
|
||||
fragment.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
LiveNetManager.get(mContext)
|
||||
.getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback<LiveInfoModel>() {
|
||||
@Override
|
||||
public void onSuccess(LiveInfoModel data) {
|
||||
fragment.dismiss();
|
||||
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
|
||||
finish();
|
||||
});
|
||||
//讲数据转成json
|
||||
String json = GsonUtils.toJson(data);
|
||||
LiveBean liveBean = GsonUtils.fromJson(json, LiveBean.class);
|
||||
mCheckLivePresenter.checkLive(liveBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
fragment.dismiss();
|
||||
//跳转到个人资料
|
||||
if (imm != null && mEditText != null) {
|
||||
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunbao.main.event;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.SearchModel;
|
||||
|
||||
public class JumpUserHomeEvent extends BaseModel {
|
||||
//携带用户信息
|
||||
private SearchModel model = new SearchModel();
|
||||
|
||||
public JumpUserHomeEvent(SearchModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public SearchModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public JumpUserHomeEvent setModel(SearchModel model) {
|
||||
this.model = model;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class AnchorSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public void showAnchors(List<SearchModel> searchModels, int type) {
|
||||
resultsAdapter = new SearchResultsAdapter();
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, true));
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
anchorList.setAdapter(resultsAdapter);
|
||||
resultsAdapter.putData(searchModels, type);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.yunbao.main.views;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -12,11 +14,16 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.bean.SearchModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.JumpUserHomeEvent;
|
||||
|
||||
public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView avatar, isLive, sex, focusOn, contribute;
|
||||
private TextView nickName;
|
||||
private LinearLayout nickLayout;
|
||||
private RelativeLayout avatarLayout;
|
||||
private SearchModel model;
|
||||
|
||||
public SearchResultsViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@@ -26,9 +33,14 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
focusOn = itemView.findViewById(R.id.focus_on);
|
||||
nickName = itemView.findViewById(R.id.nick_name);
|
||||
contribute = itemView.findViewById(R.id.contribute);
|
||||
nickLayout = itemView.findViewById(R.id.nick_layout);
|
||||
avatarLayout = itemView.findViewById(R.id.avatar_layout);
|
||||
nickLayout.setOnClickListener(jumpUserHome);
|
||||
avatarLayout.setOnClickListener(jumpUserHome);
|
||||
}
|
||||
|
||||
public void showData(SearchModel model, int type) {
|
||||
this.model = model;
|
||||
ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar);
|
||||
//用戶直接隱藏
|
||||
if (type == 3) {
|
||||
@@ -53,4 +65,14 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
nickName.setText(model.getUserNicename());
|
||||
focusOn.setVisibility(TextUtils.equals(model.getIsattention(), "1") ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转点击用户主页
|
||||
*/
|
||||
View.OnClickListener jumpUserHome = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bus.get().post(new JumpUserHomeEvent(model));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,13 +40,14 @@ public class UserSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public void showAnchors(List<SearchModel> searchModels, int type) {
|
||||
resultsAdapter = new SearchResultsAdapter();
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, true));
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
anchorList.setAdapter(resultsAdapter);
|
||||
resultsAdapter.putData(searchModels, type);
|
||||
//滾動到頂部
|
||||
anchorList.smoothScrollToPosition(0);
|
||||
}
|
||||
public void hideTypeTitle(){
|
||||
|
||||
public void hideTypeTitle() {
|
||||
typeTitle.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp">
|
||||
|
||||
@@ -23,6 +24,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/nick_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
|
||||
Reference in New Issue
Block a user