Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
81763110d7
@ -33,7 +33,16 @@ public class DrawerTaskAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
DrawerTaskChildViewHolder taskChildViewHolder = (DrawerTaskChildViewHolder) holder;
|
||||
taskChildViewHolder.setData(child.get(position));
|
||||
taskChildViewHolder.setData(child.get(position), position);
|
||||
taskChildViewHolder.setListener(new DrawerTaskChildViewHolder.DrawerTaskChildListener() {
|
||||
@Override
|
||||
public void giftSuccess(CustomSidebarChildModel model, int index) {
|
||||
//将领取的任务移动至任务列表尾部
|
||||
child.remove(index);
|
||||
child.add(child.size() - 1, model);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,17 @@ public class CustomSidebarChildModel extends BaseModel {
|
||||
private String nowNum;
|
||||
@SerializedName("activity_id")
|
||||
private String activityId;
|
||||
@SerializedName("flag")
|
||||
private String flag;
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public CustomSidebarChildModel setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
|
@ -256,4 +256,10 @@ public interface PDLiveApi {
|
||||
*/
|
||||
@GET("/api/public/?service=Live.getCustomSidebarInfo")
|
||||
Observable<ResponseModel<List<CustomSidebarInfoModel>>> getCustomSidebarInfo();
|
||||
|
||||
/**
|
||||
* 任务领取接口
|
||||
*/
|
||||
@GET("/api/public/?service=Task.sendTaskGift")
|
||||
Observable<ResponseModel<Observable>> sendTaskGift(@Query("flag") String flag, @Query("type") String type);
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.bean.StarChallengeStatusModel;
|
||||
import com.yunbao.common.bean.VipModel;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
@ -271,4 +273,22 @@ public class LiveNetManager {
|
||||
throwable.printStackTrace();
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务领取接口
|
||||
*/
|
||||
public void sendTaskGift(String flag, HttpCallback<String> callback) {
|
||||
|
||||
API.get().pdLiveApi(mContext)
|
||||
.sendTaskGift(flag, "2")
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(observableResponseModel -> {
|
||||
if (observableResponseModel.getData().getCode() == 0) {
|
||||
callback.onSuccess("");
|
||||
} else {
|
||||
callback.onError(observableResponseModel.getData().getMsg());
|
||||
}
|
||||
}, throwable -> callback.onError(throwable.getMessage())).isDisposed();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.event.CustomDrawerPopupEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
@ -35,7 +37,7 @@ public class DrawerTaskChildViewHolder extends RecyclerView.ViewHolder {
|
||||
toReceiveLayout = itemView.findViewById(R.id.to_receive_layout);
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarChildModel model) {
|
||||
public void setData(CustomSidebarChildModel model, int index) {
|
||||
ImgLoader.display2(itemView.getContext(), model.getIcon(), icon);
|
||||
StringBuffer titleBuffer = new StringBuffer();
|
||||
titleBuffer
|
||||
@ -70,9 +72,33 @@ public class DrawerTaskChildViewHolder extends RecyclerView.ViewHolder {
|
||||
.setDisMiss(true));
|
||||
|
||||
if (TextUtils.equals(model.getStatus(), "2")) {
|
||||
ToastUtil.show("敬请期待");
|
||||
LiveNetManager.get(itemView.getContext())
|
||||
.sendTaskGift(model.getFlag(), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
if (listener != null) {
|
||||
listener.giftSuccess(model, index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private DrawerTaskChildListener listener;
|
||||
|
||||
public DrawerTaskChildViewHolder setListener(DrawerTaskChildListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface DrawerTaskChildListener {
|
||||
void giftSuccess(CustomSidebarChildModel model, int index);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user