129 lines
4.6 KiB
Java
129 lines
4.6 KiB
Java
package com.ubt.jimu.pack.presenter;
|
|
|
|
import android.content.Context;
|
|
import com.ubt.jimu.base.db.robot.PackageDbHandler;
|
|
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
|
import com.ubt.jimu.base.entities.ApiResult;
|
|
import com.ubt.jimu.base.entities.Package;
|
|
import com.ubt.jimu.base.entities.Robot;
|
|
import com.ubt.jimu.base.http.ApiClient;
|
|
import com.ubt.jimu.base.http.ApiConstants;
|
|
import com.ubt.jimu.base.http.service.CourseService;
|
|
import com.ubt.jimu.pack.contract.RobotContract$Presenter;
|
|
import com.ubt.jimu.pack.contract.RobotContract$View;
|
|
import com.ubt.jimu.pack.repository.RobotRepository;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubtech.utils.XLog;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class RobotPresenter implements RobotContract$Presenter {
|
|
private Context a;
|
|
private RobotContract$View b;
|
|
private CompositeDisposable c;
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public RobotPresenter(Context context) {
|
|
this.a = context;
|
|
this.b = (RobotContract$View) context;
|
|
this.b.setPresenter(this);
|
|
this.c = new CompositeDisposable();
|
|
}
|
|
|
|
@Override // com.ubtech.presenter.BasePresenter
|
|
public void unSubscribe() {
|
|
this.c.dispose();
|
|
this.c.a();
|
|
}
|
|
|
|
public void b(long j) {
|
|
LogUtils.c("packageId:" + j);
|
|
this.b.v();
|
|
RobotRepository.a(this.a, j, 150, 1).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<List<Robot>>() { // from class: com.ubt.jimu.pack.presenter.RobotPresenter.1
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(List<Robot> list) {
|
|
if (list == null || list.size() == 0) {
|
|
RobotPresenter.this.b.q();
|
|
} else {
|
|
RobotPresenter.this.b.j(list);
|
|
RobotPresenter.this.b.Z();
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
th.printStackTrace();
|
|
XLog.c("RobotPresenter", th.toString());
|
|
RobotPresenter.this.b.y();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
RobotPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
public Package a(long j) {
|
|
return PackageDbHandler.selectById(j);
|
|
}
|
|
|
|
public void a(Package r1) {
|
|
PackageDbHandler.saveOrUpdate(r1);
|
|
}
|
|
|
|
public void a() {
|
|
this.b.v();
|
|
Map<String, String> basicParams = ApiConstants.getBasicParams();
|
|
basicParams.put("pageNum", "1");
|
|
basicParams.put("pageSize", "1000");
|
|
((CourseService) ApiClient.getService(CourseService.class)).missionModelsList(basicParams).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<ApiResult<Robot>>() { // from class: com.ubt.jimu.pack.presenter.RobotPresenter.2
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(ApiResult<Robot> apiResult) {
|
|
RobotPresenter.this.a(apiResult);
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
RobotPresenter.this.b.y();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
RobotPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(ApiResult<Robot> apiResult) {
|
|
if (apiResult != null && apiResult.getModels() != null && apiResult.getModels().size() != 0) {
|
|
if (apiResult == null || !apiResult.isStatus()) {
|
|
return;
|
|
}
|
|
List<Robot> models = apiResult.getModels();
|
|
RobotDbHandler.saveOrUpdate(models);
|
|
this.b.j(models);
|
|
this.b.Z();
|
|
return;
|
|
}
|
|
this.b.q();
|
|
}
|
|
}
|