智慧考勤 v1.0.28版本的 MD5 值为:12729d810518c958a6eb8d5a86a946dd
以下内容为反编译后的 SatisfactionChangeFacePresenter.java 源代码,内容仅作参考
package com.bjhuitou.evaluate.satisfaction.ui.changeface;
import androidx.lifecycle.LifecycleOwner;
import com.bjhuitou.evaluate.satisfaction.manage.SatisfactionManage;
import com.bjhuitou.evaluate.satisfaction.rest.model.SatisfactionUserFaceModel;
import com.bjhuitou.evaluate.satisfaction.ui.changeface.SatisfactionChangeFaceContract;
import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Map;
import net.itgoo.component.sdk.mvp.MVPLoadDataCallback;
public class SatisfactionChangeFacePresenter implements SatisfactionChangeFaceContract.Presenter {
private boolean isInit = false;
private Map<String, String> mParams;
private final SatisfactionChangeFaceContract.DataSource mRepository;
private final SatisfactionChangeFaceContract.View mView;
public SatisfactionChangeFacePresenter(Map<String, String> params, SatisfactionChangeFaceContract.View view, SatisfactionChangeFaceContract.DataSource repository) {
this.mParams = params;
this.mView = (SatisfactionChangeFaceContract.View) Preconditions.checkNotNull(view);
this.mRepository = (SatisfactionChangeFaceContract.DataSource) Preconditions.checkNotNull(repository);
view.setPresenter(this);
}
@Override
public void onResume(LifecycleOwner owner) {
if (this.isInit) {
return;
}
getUserFace();
this.isInit = true;
}
@Override
public void onDestroy(LifecycleOwner owner) {
this.mRepository.cancel();
}
private void getUserFace() {
this.mRepository.getFace(SatisfactionManage.getInstance(this.mView.getContext()).getUserId(), new MVPLoadDataCallback<SatisfactionUserFaceModel>() {
@Override
public void onDataLoaded(SatisfactionUserFaceModel data) {
if (!SatisfactionChangeFacePresenter.this.mView.isActive() || data.getFace() == null || data.getFace().isEmpty()) {
return;
}
SatisfactionChangeFacePresenter.this.mView.showUserFace("http://www.tssx.site/upload/passport/" + data.getFace());
}
@Override
public void onDataError(String error) {
if (!SatisfactionChangeFacePresenter.this.mView.isActive()) {
}
}
});
}
@Override
public void uploadFace(String file) {
if (file == null || file.isEmpty() || !new File(file).exists()) {
this.mView.showUploadFaceFailure("请选择照片");
return;
}
final int userId = SatisfactionManage.getInstance(this.mView.getContext()).getUserId();
this.mRepository.uploadFace(userId, file, new MVPLoadDataCallback<SatisfactionUserFaceModel>() {
@Override
public void onDataLoaded(SatisfactionUserFaceModel data) {
if (SatisfactionChangeFacePresenter.this.mView.isActive()) {
SatisfactionManage.getInstance(SatisfactionChangeFacePresenter.this.mView.getContext()).updateUserFeature(userId, data.getFeatureLight());
SatisfactionChangeFacePresenter.this.mView.showUploadFaceSuccess();
}
}
@Override
public void onDataError(String error) {
if (SatisfactionChangeFacePresenter.this.mView.isActive()) {
SatisfactionChangeFacePresenter.this.mView.showUploadFaceFailure(error);
}
}
});
this.mView.showHUD();
}
}