|
@@ -1,28 +1,48 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.database.Cursor;
|
|
|
|
|
+import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
import android.os.Message;
|
|
|
|
|
+import android.provider.MediaStore;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.widget.ListView;
|
|
import android.widget.ListView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.kfzs.appstore.utils.string.HexUtils;
|
|
|
|
|
+import com.kfzs.duanduan.event.BigEvent;
|
|
|
|
|
+import com.kfzs.duanduan.event.EventTypes;
|
|
|
|
|
+import com.kfzs.duanduan.react.upfile.UpFileListener;
|
|
|
|
|
+import com.kfzs.duanduan.react.upfile.UpFileUtils;
|
|
|
import com.sheep.gamegroup.di.components.DaggerTaskListComponent;
|
|
import com.sheep.gamegroup.di.components.DaggerTaskListComponent;
|
|
|
import com.sheep.gamegroup.di.modules.TaskListModule;
|
|
import com.sheep.gamegroup.di.modules.TaskListModule;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.RecyleObj;
|
|
import com.sheep.gamegroup.model.entity.RecyleObj;
|
|
|
import com.sheep.gamegroup.model.entity.RecyleType;
|
|
import com.sheep.gamegroup.model.entity.RecyleType;
|
|
|
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
|
|
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.TaskEty;
|
|
|
import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.UploadResult;
|
|
|
import com.sheep.gamegroup.presenter.TaskListContract;
|
|
import com.sheep.gamegroup.presenter.TaskListContract;
|
|
|
import com.sheep.gamegroup.presenter.TaskListPresenter;
|
|
import com.sheep.gamegroup.presenter.TaskListPresenter;
|
|
|
|
|
+import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
import com.sheep.gamegroup.view.adapter.TaskListItemAdp;
|
|
import com.sheep.gamegroup.view.adapter.TaskListItemAdp;
|
|
|
|
|
+import com.sheep.gamegroup.view.dialog.DialogShowLoading;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -30,13 +50,14 @@ import javax.inject.Inject;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
import butterknife.ButterKnife;
|
|
|
|
|
+import go.kfzssafe.Kfzssafe;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 任务列表
|
|
* 任务列表
|
|
|
* Created by ljy on 2018/3/21.
|
|
* Created by ljy on 2018/3/21.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-public class TaskListAct extends BaseActivity implements TaskListContract.View{
|
|
|
|
|
|
|
+public class TaskListAct extends BaseActivity implements TaskListContract.View, UpFileListener {
|
|
|
@BindView(R.id.withdrawal_listview)
|
|
@BindView(R.id.withdrawal_listview)
|
|
|
ListView withdrawalListview;
|
|
ListView withdrawalListview;
|
|
|
|
|
|
|
@@ -46,6 +67,13 @@ public class TaskListAct extends BaseActivity implements TaskListContract.View{
|
|
|
private TaskListItemAdp adp;
|
|
private TaskListItemAdp adp;
|
|
|
private List<TaskAcceptedEty> etyList = new ArrayList<>();
|
|
private List<TaskAcceptedEty> etyList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
+ private TaskAcceptedEty taskEty;
|
|
|
|
|
+ private DialogShowLoading dialogShowLoading;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上传进度
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isUpload = true;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
protected int getLayoutId() {
|
|
@@ -54,6 +82,7 @@ public class TaskListAct extends BaseActivity implements TaskListContract.View{
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
activity = this;
|
|
activity = this;
|
|
|
DaggerTaskListComponent.builder()
|
|
DaggerTaskListComponent.builder()
|
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
@@ -76,6 +105,7 @@ public class TaskListAct extends BaseActivity implements TaskListContract.View{
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
|
|
+ showProgress();
|
|
|
presenter.acceptedTask(0,10);
|
|
presenter.acceptedTask(0,10);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -95,6 +125,117 @@ public class TaskListAct extends BaseActivity implements TaskListContract.View{
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void failView(Object o) {
|
|
public void failView(Object o) {
|
|
|
|
|
+ hideProgress();
|
|
|
G.showToast(((BaseMessage) o).getMsg()+"");
|
|
G.showToast(((BaseMessage) o).getMsg()+"");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void taskStatusSuccess(BaseMessage baseMessage) {
|
|
|
|
|
+ dialogShowLoading.getTextView().setText("完成");
|
|
|
|
|
+// onGetNetImageUrl(data);
|
|
|
|
|
+ dialogShowLoading.getAlertDialog().dismiss();
|
|
|
|
|
+ G.showToast("提交成功,等待审核!");
|
|
|
|
|
+ initData();
|
|
|
|
|
+// EventBus.getDefault().post(new BigEvent().setEventTypes(EventTypes.ONFRESH_TRYMAKEMANY_PAGE));
|
|
|
|
|
+ UMConfigUtils.finishTask();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onDestroy() {
|
|
|
|
|
+ super.onDestroy();
|
|
|
|
|
+
|
|
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void taskStatusFaile(BaseMessage baseMessage) {
|
|
|
|
|
+ updateError("失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void Success(String msg) {
|
|
|
|
|
+ String json;
|
|
|
|
|
+ if (TextUtils.isEmpty(msg)) {
|
|
|
|
|
+ updateError("失败");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (msg.startsWith("{")) {
|
|
|
|
|
+ json = msg;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ try {
|
|
|
|
|
+ byte[] bytes = HexUtils.hexStr2Bytes(msg);
|
|
|
|
|
+ byte[] byteDecode = Kfzssafe.XByteDecode(bytes);
|
|
|
|
|
+ json = new String(byteDecode);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ updateError("失败");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ UploadResult uploadResult = JSON.parseObject(json, UploadResult.class);
|
|
|
|
|
+ if (uploadResult != null) {
|
|
|
|
|
+ final String data = uploadResult.getData().getUrl();
|
|
|
|
|
+ dialogShowLoading.getTextView().setText("提交中");
|
|
|
|
|
+ if(taskEty == null){
|
|
|
|
|
+ updateError("提交错误!");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("id", taskEty.getId());
|
|
|
|
|
+ jsonObject.put("screenshots",data+"");
|
|
|
|
|
+ jsonObject.put("remark",taskEty.getRemarks()+"");
|
|
|
|
|
+ jsonObject.put("package_name",taskEty.getRelease_task().getTask().getPackage_names()+"");
|
|
|
|
|
+ jsonObject.put("status",7+"");
|
|
|
|
|
+ presenter.taskStatus(jsonObject);
|
|
|
|
|
+ taskEty.setScreenshots(data);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updateError(String msg) {
|
|
|
|
|
+ dialogShowLoading.getTextView().setText(msg);
|
|
|
|
|
+// onNotGetImage(msg);
|
|
|
|
|
+ dialogShowLoading.getAlertDialog().dismiss();
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void Progress(String progress) {
|
|
|
|
|
+ dialogShowLoading.getTextView().setText(progress);
|
|
|
|
|
+ dialogShowLoading.getTextView().append("%");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void Failure(String err) {
|
|
|
|
|
+ G.showToast(err);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Subscribe
|
|
|
|
|
+ public void onEventMainThread(BigEvent event){
|
|
|
|
|
+ switch (event.getEventTypes()){
|
|
|
|
|
+ case TASK_AGAIN_UPLOAD_FILE:
|
|
|
|
|
+ if(event.getData() instanceof TaskAcceptedEty)
|
|
|
|
|
+ taskEty = (TaskAcceptedEty) event.getData();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
+
|
|
|
|
|
+ //获取图片路径
|
|
|
|
|
+ if (requestCode == 1 && resultCode == Activity.RESULT_OK && data != null) {
|
|
|
|
|
+ Uri selectedImage = data.getData();
|
|
|
|
|
+ String[] filePathColumns = {MediaStore.Images.Media.DATA};
|
|
|
|
|
+ Cursor c = getContentResolver().query(selectedImage, filePathColumns, null, null, null);
|
|
|
|
|
+ c.moveToFirst();
|
|
|
|
|
+ int columnIndex = c.getColumnIndex(filePathColumns[0]);
|
|
|
|
|
+ String imagePath = c.getString(columnIndex);
|
|
|
|
|
+ if (isUpload) {
|
|
|
|
|
+ dialogShowLoading = DialogShowLoading.showDialog(activity);
|
|
|
|
|
+ UpFileUtils.upImage(new File(imagePath), TaskListAct.this);
|
|
|
|
|
+ }
|
|
|
|
|
+ c.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|