界面优化,数据整理
This commit is contained in:
parent
43133e503d
commit
90bc939a61
@ -123,6 +123,6 @@ public interface PDLiveApi {
|
||||
*/
|
||||
@GET("/api/public/?service=User.setAttents")
|
||||
Observable<ResponseModel<List<SetAttentsModel>>> setAttents(
|
||||
@Query("liveuid") String liveuid
|
||||
@Query("touid") String liveuid
|
||||
);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
@ -91,9 +92,7 @@ public class LiveNetManager {
|
||||
API.get().pdLiveApi(mContext).getLiveInfo(liveuid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<List<LiveInfoModel>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<List<LiveInfoModel>> listResponseModel) throws Exception {
|
||||
.subscribe(listResponseModel -> {
|
||||
List<LiveInfoModel> liveInfoModels = listResponseModel.getData().getInfo();
|
||||
if (liveInfoModels.size() > 0) {
|
||||
LiveInfoModel liveInfoModel = liveInfoModels.get(0);
|
||||
@ -104,10 +103,37 @@ public class LiveNetManager {
|
||||
callback.onError("直播已结束");
|
||||
}
|
||||
|
||||
}
|
||||
}, throwable -> {
|
||||
if (callback != null)
|
||||
callback.onError(throwable.getMessage());
|
||||
});
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注主播
|
||||
*
|
||||
* @param liveuid
|
||||
* @return
|
||||
*/
|
||||
public void setAttents(String liveuid, HttpCallback<SetAttentsModel> callback) {
|
||||
API.get().pdLiveApi(mContext).setAttents(liveuid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(listResponseModel -> {
|
||||
List<SetAttentsModel> setAttentsModels = listResponseModel.getData().getInfo();
|
||||
if (setAttentsModels.size() > 0) {
|
||||
if (callback != null)
|
||||
callback.onSuccess(setAttentsModels.get(0));
|
||||
} else {
|
||||
if (callback != null)
|
||||
callback.onError("操作失效");
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null)
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -8,6 +9,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.SearchModel;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.SearchResultsViewHolder;
|
||||
|
||||
@ -17,6 +21,11 @@ import java.util.List;
|
||||
public class SearchResultsAdapter extends RecyclerView.Adapter {
|
||||
private List<SearchModel> searchModels = new ArrayList<>();
|
||||
private int type = -1;
|
||||
private Context context;
|
||||
|
||||
public SearchResultsAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@ -29,6 +38,23 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
|
||||
if (holder instanceof SearchResultsViewHolder) {
|
||||
SearchResultsViewHolder resultsViewHolder = (SearchResultsViewHolder) holder;
|
||||
resultsViewHolder.showData(searchModels.get(position), type);
|
||||
resultsViewHolder.setCallback(new SearchResultsViewHolder.SearchResultsCallback() {
|
||||
@Override
|
||||
public void focusOn(SearchModel model) {
|
||||
LiveNetManager.get(context)
|
||||
.setAttents(String.valueOf(model.getId()), new HttpCallback<SetAttentsModel>() {
|
||||
@Override
|
||||
public void onSuccess(SetAttentsModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ public class AnchorSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView anchorMore;
|
||||
private SearchResultsAdapter resultsAdapter;
|
||||
private FrameLayout typeTitle;
|
||||
private List<SearchModel> searchModels;
|
||||
|
||||
public AnchorSearchResultsItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@ -39,7 +40,8 @@ public class AnchorSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
|
||||
public void showAnchors(List<SearchModel> searchModels, int type) {
|
||||
resultsAdapter = new SearchResultsAdapter();
|
||||
this.searchModels = searchModels;
|
||||
resultsAdapter = new SearchResultsAdapter(itemView.getContext());
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
anchorList.setAdapter(resultsAdapter);
|
||||
resultsAdapter.putData(searchModels, type);
|
||||
|
@ -24,6 +24,12 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
private LinearLayout nickLayout;
|
||||
private RelativeLayout avatarLayout;
|
||||
private SearchModel model;
|
||||
private SearchResultsCallback callback;
|
||||
|
||||
public SearchResultsViewHolder setCallback(SearchResultsCallback callback) {
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchResultsViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@ -37,6 +43,12 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
avatarLayout = itemView.findViewById(R.id.avatar_layout);
|
||||
nickLayout.setOnClickListener(jumpUserHome);
|
||||
avatarLayout.setOnClickListener(jumpUserHome);
|
||||
//关注主播或者用户
|
||||
itemView.findViewById(R.id.focus_on).setOnClickListener(v -> {
|
||||
if (callback != null) {
|
||||
callback.focusOn(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showData(SearchModel model, int type) {
|
||||
@ -75,4 +87,8 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
|
||||
Bus.get().post(new JumpUserHomeEvent(model));
|
||||
}
|
||||
};
|
||||
|
||||
public interface SearchResultsCallback {
|
||||
void focusOn(SearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class UserSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
|
||||
public void showAnchors(List<SearchModel> searchModels, int type) {
|
||||
resultsAdapter = new SearchResultsAdapter();
|
||||
resultsAdapter = new SearchResultsAdapter(itemView.getContext());
|
||||
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
anchorList.setAdapter(resultsAdapter);
|
||||
resultsAdapter.putData(searchModels, type);
|
||||
|
Loading…
Reference in New Issue
Block a user