@@ -127,10 +127,6 @@  | 
            ||
| 127 | 127 | 
                android:label="@string/app_name"  | 
            
| 128 | 128 | 
                android:screenOrientation="portrait"/>  | 
            
| 129 | 129 | 
                 | 
            
| 130 | 
                - <activity android:name=".upgrade.BoxUpgradeActivity"  | 
            |
| 131 | 
                - android:configChanges="keyboardHidden|orientation|screenSize"  | 
            |
| 132 | 
                - android:label="@string/app_name"  | 
            |
| 133 | 
                - android:screenOrientation="portrait"/>  | 
            |
| 134 | 130 | 
                 | 
            
| 135 | 131 | 
                <activity  | 
            
| 136 | 132 | 
                android:name=".wxapi.WXEntryActivity"  | 
            
                @@ -27,7 +27,6 @@ import ai.pai.lensman.utils.UmengEvent;  | 
            ||
| 27 | 27 | 
                import ai.pai.lensman.utils.UrlContainer;  | 
            
| 28 | 28 | 
                import butterknife.BindView;  | 
            
| 29 | 29 | 
                import butterknife.ButterKnife;  | 
            
| 30 | 
                -import butterknife.OnCheckedChanged;  | 
            |
| 31 | 30 | 
                import butterknife.OnClick;  | 
            
| 32 | 31 | 
                 | 
            
| 33 | 32 | 
                 public class BriefsActivity extends BaseActivity implements BriefsContract.View{
               | 
            
                @@ -89,11 +88,6 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
               | 
            ||
| 89 | 88 | 
                presenter = new BriefsPresenter(this,this);  | 
            
| 90 | 89 | 
                }  | 
            
| 91 | 90 | 
                 | 
            
| 92 | 
                - @OnClick(R.id.tv_box_version)  | 
            |
| 93 | 
                -    public void checkBoxUpdate(){
               | 
            |
| 94 | 
                - presenter.clickBoxUpdate();  | 
            |
| 95 | 
                - }  | 
            |
| 96 | 
                -  | 
            |
| 97 | 91 | 
                @OnClick(R.id.switcher_order_msg)  | 
            
| 98 | 92 | 
                     public void clickOrderMsg(){
               | 
            
| 99 | 93 | 
                presenter.clickCurrentOrderMsg();  | 
            
                @@ -20,7 +20,6 @@ public class BriefsContract {
               | 
            ||
| 20 | 20 | 
                void clickCurrentOrderMsg();  | 
            
| 21 | 21 | 
                void clickCurrentSysMsg();  | 
            
| 22 | 22 | 
                void clickSettingPrice();  | 
            
| 23 | 
                - void clickBoxUpdate();  | 
            |
| 24 | 23 | 
                }  | 
            
| 25 | 24 | 
                 | 
            
| 26 | 25 | 
                 | 
            
                @@ -2,7 +2,6 @@ package ai.pai.lensman.briefs;  | 
            ||
| 2 | 2 | 
                 | 
            
| 3 | 3 | 
                import android.content.Context;  | 
            
| 4 | 4 | 
                import android.content.Intent;  | 
            
| 5 | 
                -import android.widget.Toast;  | 
            |
| 6 | 5 | 
                 | 
            
| 7 | 6 | 
                import com.android.common.utils.NetworkUtil;  | 
            
| 8 | 7 | 
                 | 
            
                @@ -18,19 +17,16 @@ import ai.pai.lensman.base.BaseInteractor;  | 
            ||
| 18 | 17 | 
                import ai.pai.lensman.bean.BriefsBean;  | 
            
| 19 | 18 | 
                import ai.pai.lensman.bean.MessageBean;  | 
            
| 20 | 19 | 
                import ai.pai.lensman.bean.SystemMessageBean;  | 
            
| 21 | 
                -import ai.pai.lensman.db.Preferences;  | 
            |
| 22 | 20 | 
                import ai.pai.lensman.main.QueryBoxStatusInteractor;  | 
            
| 23 | 
                -import ai.pai.lensman.upgrade.BoxUpgradeActivity;  | 
            |
| 24 | 
                -import ai.pai.lensman.upgrade.CheckBoxUpgradeInfoInteractor;  | 
            |
| 21 | 
                +  | 
            |
| 25 | 22 | 
                 | 
            
| 26 | 23 | 
                public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.InteractorListener<BriefsBean>,  | 
            
| 27 | 
                -        QueryBoxStatusInteractor.BoxStatusListener,CheckBoxUpgradeInfoInteractor.FetchUpgradeInfoListener {
               | 
            |
| 24 | 
                +        QueryBoxStatusInteractor.BoxStatusListener {
               | 
            |
| 28 | 25 | 
                 | 
            
| 29 | 26 | 
                private Context context;  | 
            
| 30 | 27 | 
                private BriefsContract.View briefsView;  | 
            
| 31 | 28 | 
                private BriefsInteractor interactor;  | 
            
| 32 | 29 | 
                private QueryBoxStatusInteractor boxStatusInteractor;  | 
            
| 33 | 
                - private CheckBoxUpgradeInfoInteractor checkBoxUpgradeInfoInteractor;  | 
            |
| 34 | 30 | 
                 | 
            
| 35 | 31 | 
                private BriefsBean briefsBean;  | 
            
| 36 | 32 | 
                private String NULL_STR = "";  | 
            
                @@ -56,9 +52,6 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.  | 
            ||
| 56 | 52 | 
                     public void stop() {
               | 
            
| 57 | 53 | 
                interactor.cancelJob();  | 
            
| 58 | 54 | 
                boxStatusInteractor.cancelJob();  | 
            
| 59 | 
                -        if(checkBoxUpgradeInfoInteractor!=null){
               | 
            |
| 60 | 
                - checkBoxUpgradeInfoInteractor.cancelJob();  | 
            |
| 61 | 
                - }  | 
            |
| 62 | 55 | 
                         if(timer!=null){
               | 
            
| 63 | 56 | 
                timer.cancel();  | 
            
| 64 | 57 | 
                }  | 
            
                @@ -147,19 +140,4 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.  | 
            ||
| 147 | 140 | 
                context.startActivity(intent);  | 
            
| 148 | 141 | 
                }  | 
            
| 149 | 142 | 
                 | 
            
| 150 | 
                - @Override  | 
            |
| 151 | 
                -    public void clickBoxUpdate() {
               | 
            |
| 152 | 
                - checkBoxUpgradeInfoInteractor = new CheckBoxUpgradeInfoInteractor(Preferences.getInstance().getLensManId(),this);  | 
            |
| 153 | 
                - checkBoxUpgradeInfoInteractor.startJob();  | 
            |
| 154 | 
                - }  | 
            |
| 155 | 
                -  | 
            |
| 156 | 
                - @Override  | 
            |
| 157 | 
                -    public void onUpgradeInfoFetched(boolean result, String bpversion_str, int versionCode) {
               | 
            |
| 158 | 
                -        if(result){
               | 
            |
| 159 | 
                - BoxUpgradeActivity.startBoxUpgradeActivity(context,bpversion_str,versionCode);  | 
            |
| 160 | 
                -        }else{
               | 
            |
| 161 | 
                - Toast.makeText(context,R.string.current_version_is_latest,Toast.LENGTH_SHORT).show();  | 
            |
| 162 | 
                - }  | 
            |
| 163 | 
                -  | 
            |
| 164 | 
                - }  | 
            |
| 165 | 143 | 
                }  | 
            
                @@ -20,20 +20,14 @@ import butterknife.OnClick;  | 
            ||
| 20 | 20 | 
                 | 
            
| 21 | 21 | 
                 public class SettingsActivity extends BaseActivity {
               | 
            
| 22 | 22 | 
                 | 
            
| 23 | 
                - @BindView(R.id.et_box_ip) EditText boxIPET;  | 
            |
| 24 | 
                -  | 
            |
| 25 | 23 | 
                @Override  | 
            
| 26 | 24 | 
                     protected void onCreate(@Nullable Bundle savedInstanceState) {
               | 
            
| 27 | 25 | 
                super.onCreate(savedInstanceState);  | 
            
| 28 | 26 | 
                setContentView(R.layout.activity_settings);  | 
            
| 29 | 27 | 
                unbinder = ButterKnife.bind(this);  | 
            
| 30 | 
                - boxIPET.setText(BoxUrlContainer.BOX_IP);  | 
            |
| 31 | 28 | 
                }  | 
            
| 32 | 29 | 
                 | 
            
| 33 | 
                - @OnClick(R.id.title_bar_middle_txt)  | 
            |
| 34 | 
                -    void showIPEdit(){
               | 
            |
| 35 | 
                - findViewById(R.id.layout_box_ip).setVisibility(View.VISIBLE);  | 
            |
| 36 | 
                - }  | 
            |
| 30 | 
                +  | 
            |
| 37 | 31 | 
                @OnClick(R.id.title_bar_back_layout)  | 
            
| 38 | 32 | 
                     void back(){
               | 
            
| 39 | 33 | 
                finish();  | 
            
                @@ -57,10 +51,4 @@ public class SettingsActivity extends BaseActivity {
               | 
            ||
| 57 | 51 | 
                startActivity(new Intent(this, FeedbackActivity.class));  | 
            
| 58 | 52 | 
                }  | 
            
| 59 | 53 | 
                 | 
            
| 60 | 
                - @OnClick(R.id.btn_confirm_ip)  | 
            |
| 61 | 
                -    void resetIP(){
               | 
            |
| 62 | 
                - BoxUrlContainer.resetIPHost( boxIPET.getText().toString());  | 
            |
| 63 | 
                - Toast.makeText(this,"IP已设置为"+BoxUrlContainer.BOX_IP,Toast.LENGTH_SHORT).show();  | 
            |
| 64 | 
                - }  | 
            |
| 65 | 
                -  | 
            |
| 66 | 54 | 
                }  | 
            
                @@ -1,126 +0,0 @@  | 
            ||
| 1 | 
                -package ai.pai.lensman.upgrade;  | 
            |
| 2 | 
                -  | 
            |
| 3 | 
                -import android.content.Context;  | 
            |
| 4 | 
                -import android.content.Intent;  | 
            |
| 5 | 
                -import android.os.Bundle;  | 
            |
| 6 | 
                -import android.text.TextUtils;  | 
            |
| 7 | 
                -import android.view.KeyEvent;  | 
            |
| 8 | 
                -import android.view.View;  | 
            |
| 9 | 
                -import android.widget.Button;  | 
            |
| 10 | 
                -import android.widget.TextView;  | 
            |
| 11 | 
                -import android.widget.Toast;  | 
            |
| 12 | 
                -  | 
            |
| 13 | 
                -import com.android.common.utils.LogHelper;  | 
            |
| 14 | 
                -import com.android.views.loadingdrawable.LoadingView;  | 
            |
| 15 | 
                -  | 
            |
| 16 | 
                -import ai.pai.lensman.R;  | 
            |
| 17 | 
                -import ai.pai.lensman.base.BaseActivity;  | 
            |
| 18 | 
                -import ai.pai.lensman.db.Preferences;  | 
            |
| 19 | 
                -import ai.pai.lensman.main.QueryBoxStatusInteractor;  | 
            |
| 20 | 
                -import butterknife.BindView;  | 
            |
| 21 | 
                -import butterknife.ButterKnife;  | 
            |
| 22 | 
                -import butterknife.OnClick;  | 
            |
| 23 | 
                -  | 
            |
| 24 | 
                -/**  | 
            |
| 25 | 
                - * Created by chengzhenyu on 2017/4/22.  | 
            |
| 26 | 
                - */  | 
            |
| 27 | 
                -  | 
            |
| 28 | 
                -public class BoxUpgradeActivity extends BaseActivity implements BoxUpgradeInteractor.BoxUpgradeListener,QueryBoxStatusInteractor.BoxStatusListener{
               | 
            |
| 29 | 
                -  | 
            |
| 30 | 
                - @BindView(R.id.layout_choose_update) View chooseUpdateView;  | 
            |
| 31 | 
                - @BindView(R.id.layout_box_updating) View boxUpdatingView;  | 
            |
| 32 | 
                - @BindView(R.id.tv_updating_status) TextView updatingStatusTextView;  | 
            |
| 33 | 
                - @BindView(R.id.btn_return_work) Button backBtn;  | 
            |
| 34 | 
                - @BindView(R.id.loading_gear_view) LoadingView loadingView;  | 
            |
| 35 | 
                - private BoxUpgradeInteractor upgradeInteractor;  | 
            |
| 36 | 
                - private QueryBoxStatusInteractor boxStatusInteractor;  | 
            |
| 37 | 
                - private String bpversion_str;  | 
            |
| 38 | 
                - private int updatingVersionCode;  | 
            |
| 39 | 
                - private boolean isDestroyed;  | 
            |
| 40 | 
                -  | 
            |
| 41 | 
                -    public static void startBoxUpgradeActivity(Context context,String bpversion_str,int updatingVersionCode){
               | 
            |
| 42 | 
                - Intent intent = new Intent(context, BoxUpgradeActivity.class);  | 
            |
| 43 | 
                -        intent.putExtra("bpversion_str",bpversion_str);
               | 
            |
| 44 | 
                -        intent.putExtra("versionCode",updatingVersionCode);
               | 
            |
| 45 | 
                - context.startActivity(intent);  | 
            |
| 46 | 
                - }  | 
            |
| 47 | 
                -  | 
            |
| 48 | 
                - @Override  | 
            |
| 49 | 
                -    protected void onCreate(Bundle savedInstanceState) {
               | 
            |
| 50 | 
                - super.onCreate(savedInstanceState);  | 
            |
| 51 | 
                - setContentView(R.layout.activity_box_upgrade);  | 
            |
| 52 | 
                - unbinder = ButterKnife.bind(this);  | 
            |
| 53 | 
                -        bpversion_str = getIntent().getStringExtra("bpversion_str");
               | 
            |
| 54 | 
                -        updatingVersionCode = getIntent().getIntExtra("versionCode",0);
               | 
            |
| 55 | 
                -        if(TextUtils.isEmpty(bpversion_str)||updatingVersionCode==0){
               | 
            |
| 56 | 
                - finish();  | 
            |
| 57 | 
                - }  | 
            |
| 58 | 
                - }  | 
            |
| 59 | 
                -  | 
            |
| 60 | 
                - @Override  | 
            |
| 61 | 
                -    protected void onDestroy() {
               | 
            |
| 62 | 
                - super.onDestroy();  | 
            |
| 63 | 
                - isDestroyed = true;  | 
            |
| 64 | 
                - }  | 
            |
| 65 | 
                -  | 
            |
| 66 | 
                - @OnClick(R.id.btn_update_now)  | 
            |
| 67 | 
                -    public void updateNow(){
               | 
            |
| 68 | 
                - chooseUpdateView.setVisibility(View.GONE);  | 
            |
| 69 | 
                - boxUpdatingView.setVisibility(View.VISIBLE);  | 
            |
| 70 | 
                - upgradeInteractor = new BoxUpgradeInteractor(bpversion_str,this);  | 
            |
| 71 | 
                - upgradeInteractor.startJob();  | 
            |
| 72 | 
                - }  | 
            |
| 73 | 
                -  | 
            |
| 74 | 
                - @OnClick(R.id.btn_update_later)  | 
            |
| 75 | 
                -    public void UpdateLater(){
               | 
            |
| 76 | 
                - finish();  | 
            |
| 77 | 
                - }  | 
            |
| 78 | 
                -  | 
            |
| 79 | 
                - @OnClick(R.id.btn_return_work)  | 
            |
| 80 | 
                -    public void back2work(){
               | 
            |
| 81 | 
                -        if(boxStatusInteractor!=null){
               | 
            |
| 82 | 
                - boxStatusInteractor.cancelJob();  | 
            |
| 83 | 
                - boxStatusInteractor = null;  | 
            |
| 84 | 
                - }  | 
            |
| 85 | 
                -        if(upgradeInteractor!=null){
               | 
            |
| 86 | 
                - upgradeInteractor.cancelJob();  | 
            |
| 87 | 
                - upgradeInteractor = null;  | 
            |
| 88 | 
                - }  | 
            |
| 89 | 
                - finish();  | 
            |
| 90 | 
                - }  | 
            |
| 91 | 
                - @Override  | 
            |
| 92 | 
                -    public boolean onKeyDown(int keyCode, KeyEvent event) {
               | 
            |
| 93 | 
                -        if(event.getKeyCode()==KeyEvent.KEYCODE_BACK){
               | 
            |
| 94 | 
                - return true;  | 
            |
| 95 | 
                - }  | 
            |
| 96 | 
                - return super.onKeyDown(keyCode, event);  | 
            |
| 97 | 
                - }  | 
            |
| 98 | 
                -  | 
            |
| 99 | 
                - @Override  | 
            |
| 100 | 
                -    public void onBoxUpgrade(boolean result) {
               | 
            |
| 101 | 
                -        if(isDestroyed){
               | 
            |
| 102 | 
                - return;  | 
            |
| 103 | 
                - }  | 
            |
| 104 | 
                -        LogHelper.d("czy","box开始升级,开始轮询box状态");
               | 
            |
| 105 | 
                -        if(result){
               | 
            |
| 106 | 
                - boxStatusInteractor = new QueryBoxStatusInteractor(this);  | 
            |
| 107 | 
                - boxStatusInteractor.startJob();  | 
            |
| 108 | 
                -        }else{
               | 
            |
| 109 | 
                - boxUpdatingView.setVisibility(View.GONE);  | 
            |
| 110 | 
                - chooseUpdateView.setVisibility(View.VISIBLE);  | 
            |
| 111 | 
                - Toast.makeText(this,R.string.box_updating_fail,Toast.LENGTH_SHORT).show();  | 
            |
| 112 | 
                - }  | 
            |
| 113 | 
                - }  | 
            |
| 114 | 
                -  | 
            |
| 115 | 
                - @Override  | 
            |
| 116 | 
                -    public void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode) {
               | 
            |
| 117 | 
                -        if(isDestroyed){
               | 
            |
| 118 | 
                - return;  | 
            |
| 119 | 
                - }  | 
            |
| 120 | 
                - Preferences.getInstance().setBoxVersionCode(updatingVersionCode);  | 
            |
| 121 | 
                - updatingStatusTextView.setText(R.string.box_update_success);  | 
            |
| 122 | 
                - loadingView.setVisibility(View.GONE);  | 
            |
| 123 | 
                - backBtn.setVisibility(View.VISIBLE);  | 
            |
| 124 | 
                - }  | 
            |
| 125 | 
                -  | 
            |
| 126 | 
                -}  | 
            
                @@ -1,86 +0,0 @@  | 
            ||
| 1 | 
                -package ai.pai.lensman.upgrade;  | 
            |
| 2 | 
                -  | 
            |
| 3 | 
                -import android.os.AsyncTask;  | 
            |
| 4 | 
                -  | 
            |
| 5 | 
                -import com.android.common.executors.ThreadExecutor;  | 
            |
| 6 | 
                -import com.android.common.utils.LogHelper;  | 
            |
| 7 | 
                -  | 
            |
| 8 | 
                -import org.json.JSONObject;  | 
            |
| 9 | 
                -  | 
            |
| 10 | 
                -import java.util.HashMap;  | 
            |
| 11 | 
                -  | 
            |
| 12 | 
                -import ai.pai.lensman.BuildConfig;  | 
            |
| 13 | 
                -import ai.pai.lensman.base.BaseInteractor;  | 
            |
| 14 | 
                -import ai.pai.lensman.utils.BoxUrlContainer;  | 
            |
| 15 | 
                -import ai.pai.lensman.utils.HttpPostTask;  | 
            |
| 16 | 
                -  | 
            |
| 17 | 
                -  | 
            |
| 18 | 
                -public class BoxUpgradeInteractor implements BaseInteractor {
               | 
            |
| 19 | 
                - private HttpPostTask upgradeTask;  | 
            |
| 20 | 
                - private String bpversion_str;  | 
            |
| 21 | 
                - private BoxUpgradeListener listener;  | 
            |
| 22 | 
                -  | 
            |
| 23 | 
                -    public BoxUpgradeInteractor(String bpversion_str, BoxUpgradeListener listener) {
               | 
            |
| 24 | 
                - this.listener = listener;  | 
            |
| 25 | 
                - this.bpversion_str = bpversion_str;  | 
            |
| 26 | 
                - }  | 
            |
| 27 | 
                -  | 
            |
| 28 | 
                - @Override  | 
            |
| 29 | 
                -    public void startJob() {
               | 
            |
| 30 | 
                - cancelJob();  | 
            |
| 31 | 
                - HashMap<String, String> params = new HashMap<>();  | 
            |
| 32 | 
                -        params.put("bpversion_str", bpversion_str);
               | 
            |
| 33 | 
                -        LogHelper.d("czy", "开始box设置升级任务");
               | 
            |
| 34 | 
                -        upgradeTask = new HttpPostTask(params) {
               | 
            |
| 35 | 
                -  | 
            |
| 36 | 
                - @Override  | 
            |
| 37 | 
                -            protected boolean parseResponse(String response) {
               | 
            |
| 38 | 
                -                LogHelper.d("czy", "box设置升级任务 box应答=" + response);
               | 
            |
| 39 | 
                -                if(BuildConfig.isTestMode){
               | 
            |
| 40 | 
                - return true;  | 
            |
| 41 | 
                - }  | 
            |
| 42 | 
                -                try {
               | 
            |
| 43 | 
                - JSONObject json = new JSONObject(response);  | 
            |
| 44 | 
                -                    int status = json.getInt("status");
               | 
            |
| 45 | 
                -                    if (status == 200) {
               | 
            |
| 46 | 
                - return true;  | 
            |
| 47 | 
                - }  | 
            |
| 48 | 
                -                } catch (Exception e) {
               | 
            |
| 49 | 
                -                    LogHelper.d("czy", "box设置升级任务 box应答异常 " + e);
               | 
            |
| 50 | 
                - }  | 
            |
| 51 | 
                - return false;  | 
            |
| 52 | 
                - }  | 
            |
| 53 | 
                -  | 
            |
| 54 | 
                - @Override  | 
            |
| 55 | 
                -            protected void onPostFail() {
               | 
            |
| 56 | 
                - super.onPostFail();  | 
            |
| 57 | 
                - listener.onBoxUpgrade(false);  | 
            |
| 58 | 
                -                LogHelper.d("czy", "box设置升级任务失败");
               | 
            |
| 59 | 
                - }  | 
            |
| 60 | 
                -  | 
            |
| 61 | 
                - @Override  | 
            |
| 62 | 
                -            protected void onPostSuccess() {
               | 
            |
| 63 | 
                - super.onPostSuccess();  | 
            |
| 64 | 
                - listener.onBoxUpgrade(true);  | 
            |
| 65 | 
                -                LogHelper.d("czy", "box设置升级任务成功");
               | 
            |
| 66 | 
                - }  | 
            |
| 67 | 
                - };  | 
            |
| 68 | 
                - upgradeTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.SET_VERSION);  | 
            |
| 69 | 
                - }  | 
            |
| 70 | 
                -  | 
            |
| 71 | 
                - @Override  | 
            |
| 72 | 
                -    public void cancelJob() {
               | 
            |
| 73 | 
                -        if (upgradeTask == null) {
               | 
            |
| 74 | 
                - return;  | 
            |
| 75 | 
                - }  | 
            |
| 76 | 
                -        if (upgradeTask.getStatus() == AsyncTask.Status.RUNNING) {
               | 
            |
| 77 | 
                - upgradeTask.cancel(true);  | 
            |
| 78 | 
                - }  | 
            |
| 79 | 
                - upgradeTask = null;  | 
            |
| 80 | 
                - }  | 
            |
| 81 | 
                -  | 
            |
| 82 | 
                -    public interface BoxUpgradeListener {
               | 
            |
| 83 | 
                - void onBoxUpgrade(boolean result);  | 
            |
| 84 | 
                - }  | 
            |
| 85 | 
                -  | 
            |
| 86 | 
                -}  | 
            
                @@ -1,98 +0,0 @@  | 
            ||
| 1 | 
                -package ai.pai.lensman.upgrade;  | 
            |
| 2 | 
                -  | 
            |
| 3 | 
                -import android.os.AsyncTask;  | 
            |
| 4 | 
                -import android.text.TextUtils;  | 
            |
| 5 | 
                -  | 
            |
| 6 | 
                -import com.android.common.executors.ThreadExecutor;  | 
            |
| 7 | 
                -import com.android.common.utils.LogHelper;  | 
            |
| 8 | 
                -  | 
            |
| 9 | 
                -import org.json.JSONObject;  | 
            |
| 10 | 
                -  | 
            |
| 11 | 
                -import java.util.HashMap;  | 
            |
| 12 | 
                -  | 
            |
| 13 | 
                -import ai.pai.lensman.base.BaseInteractor;  | 
            |
| 14 | 
                -import ai.pai.lensman.db.Preferences;  | 
            |
| 15 | 
                -import ai.pai.lensman.utils.HttpPostTask;  | 
            |
| 16 | 
                -import ai.pai.lensman.utils.UrlContainer;  | 
            |
| 17 | 
                -  | 
            |
| 18 | 
                -  | 
            |
| 19 | 
                -public class CheckBoxUpgradeInfoInteractor implements BaseInteractor {
               | 
            |
| 20 | 
                - private HttpPostTask upgradeTask;  | 
            |
| 21 | 
                - private String lensmanId;  | 
            |
| 22 | 
                - private FetchUpgradeInfoListener listener;  | 
            |
| 23 | 
                -  | 
            |
| 24 | 
                - private static final String TAG = "CheckBoxUpgradeInfoInteractor";  | 
            |
| 25 | 
                -  | 
            |
| 26 | 
                -    public CheckBoxUpgradeInfoInteractor(String lensmanId, FetchUpgradeInfoListener listener) {
               | 
            |
| 27 | 
                - this.listener = listener;  | 
            |
| 28 | 
                - this.lensmanId = lensmanId;  | 
            |
| 29 | 
                - }  | 
            |
| 30 | 
                -  | 
            |
| 31 | 
                - @Override  | 
            |
| 32 | 
                -    public void startJob() {
               | 
            |
| 33 | 
                - cancelJob();  | 
            |
| 34 | 
                - HashMap<String, String> params = new HashMap<>();  | 
            |
| 35 | 
                -        params.put("user_id", lensmanId);
               | 
            |
| 36 | 
                - LogHelper.d(TAG, "开始box升级任务");  | 
            |
| 37 | 
                -        upgradeTask = new HttpPostTask(params) {
               | 
            |
| 38 | 
                -  | 
            |
| 39 | 
                - String bpversion_str ="";  | 
            |
| 40 | 
                - int latestVersionCode=0;  | 
            |
| 41 | 
                - @Override  | 
            |
| 42 | 
                -            protected boolean parseResponse(String response) {
               | 
            |
| 43 | 
                - LogHelper.d(TAG, "box升级任务 服务器应答=" + response);  | 
            |
| 44 | 
                -  | 
            |
| 45 | 
                -                try {
               | 
            |
| 46 | 
                - JSONObject json = new JSONObject(response);  | 
            |
| 47 | 
                -                    int status = json.getInt("status");
               | 
            |
| 48 | 
                -                    if (status == 200) {
               | 
            |
| 49 | 
                -                        JSONObject data = json.getJSONObject("data");
               | 
            |
| 50 | 
                -                        bpversion_str = data.getString("bpversion_str");
               | 
            |
| 51 | 
                -                        latestVersionCode = data.getJSONObject("bpversion").getInt("srv_version_code");
               | 
            |
| 52 | 
                - }  | 
            |
| 53 | 
                -                } catch (Exception e) {
               | 
            |
| 54 | 
                - LogHelper.d(TAG, "box升级任务 服务器应答异常 " + e);  | 
            |
| 55 | 
                - }  | 
            |
| 56 | 
                - LogHelper.d(TAG,"box升级任务 服务器最新版本="+latestVersionCode+"\t客户端版本="+Preferences.getInstance().getBoxVersionCode());  | 
            |
| 57 | 
                -                if(latestVersionCode<= Preferences.getInstance().getBoxVersionCode()){
               | 
            |
| 58 | 
                - return false;  | 
            |
| 59 | 
                - }  | 
            |
| 60 | 
                -                if(TextUtils.isEmpty(bpversion_str)){
               | 
            |
| 61 | 
                - return false;  | 
            |
| 62 | 
                - }  | 
            |
| 63 | 
                - return true;  | 
            |
| 64 | 
                - }  | 
            |
| 65 | 
                -  | 
            |
| 66 | 
                - @Override  | 
            |
| 67 | 
                -            protected void onPostFail() {
               | 
            |
| 68 | 
                - super.onPostFail();  | 
            |
| 69 | 
                - listener.onUpgradeInfoFetched(false, bpversion_str,latestVersionCode);  | 
            |
| 70 | 
                - LogHelper.d(TAG, "box升级任务 获取更新失败或者无需更新");  | 
            |
| 71 | 
                - }  | 
            |
| 72 | 
                -  | 
            |
| 73 | 
                - @Override  | 
            |
| 74 | 
                -            protected void onPostSuccess() {
               | 
            |
| 75 | 
                - super.onPostSuccess();  | 
            |
| 76 | 
                - listener.onUpgradeInfoFetched(true, bpversion_str,latestVersionCode);  | 
            |
| 77 | 
                - LogHelper.d(TAG, "box升级任务 需要更新");  | 
            |
| 78 | 
                - }  | 
            |
| 79 | 
                - };  | 
            |
| 80 | 
                - upgradeTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.BOX_VERSION_URL);  | 
            |
| 81 | 
                - }  | 
            |
| 82 | 
                -  | 
            |
| 83 | 
                - @Override  | 
            |
| 84 | 
                -    public void cancelJob() {
               | 
            |
| 85 | 
                -        if (upgradeTask == null) {
               | 
            |
| 86 | 
                - return;  | 
            |
| 87 | 
                - }  | 
            |
| 88 | 
                -        if (upgradeTask.getStatus() == AsyncTask.Status.RUNNING) {
               | 
            |
| 89 | 
                - upgradeTask.cancel(true);  | 
            |
| 90 | 
                - }  | 
            |
| 91 | 
                - upgradeTask = null;  | 
            |
| 92 | 
                - }  | 
            |
| 93 | 
                -  | 
            |
| 94 | 
                -    public interface FetchUpgradeInfoListener {
               | 
            |
| 95 | 
                - void onUpgradeInfoFetched(boolean result, String bpversion_str,int versionCode);  | 
            |
| 96 | 
                - }  | 
            |
| 97 | 
                -  | 
            |
| 98 | 
                -}  | 
            
                @@ -29,33 +29,4 @@ public class BoxUrlContainer {
               | 
            ||
| 29 | 29 | 
                 | 
            
| 30 | 30 | 
                public static String BOX_TIME_URL = BASE_URL+"box_time";  | 
            
| 31 | 31 | 
                 | 
            
| 32 | 
                - public static String SET_VERSION = BASE_URL+"set_version";  | 
            |
| 33 | 
                -  | 
            |
| 34 | 
                -    public static void resetIPHost(String ip) {
               | 
            |
| 35 | 
                - BOX_IP = ip;  | 
            |
| 36 | 
                -  | 
            |
| 37 | 
                - BASE_URL = "http://" + BOX_IP + ":8002/";  | 
            |
| 38 | 
                -  | 
            |
| 39 | 
                - SESSION_START_URL = BASE_URL + "session_start";  | 
            |
| 40 | 
                -  | 
            |
| 41 | 
                - SESSION_END_URL = BASE_URL + "session_end";  | 
            |
| 42 | 
                -  | 
            |
| 43 | 
                - DELETE_PHOTO_URL = BASE_URL + "delete_photo";  | 
            |
| 44 | 
                -  | 
            |
| 45 | 
                - FETCH_THUMBNAIL_URL = BASE_URL + "fetch_thumbnail";  | 
            |
| 46 | 
                -  | 
            |
| 47 | 
                - PHOTO_PATH_PREFIX_URL = BASE_URL + "static/";  | 
            |
| 48 | 
                -  | 
            |
| 49 | 
                - FETCH_ORIGIN_URL = BASE_URL +"fetch_origin";  | 
            |
| 50 | 
                -  | 
            |
| 51 | 
                - BOX_INFO_URL = BASE_URL+"box_info";  | 
            |
| 52 | 
                -  | 
            |
| 53 | 
                - SET_TIME_URL = BASE_URL+"set_time";  | 
            |
| 54 | 
                -  | 
            |
| 55 | 
                - BOX_TIME_URL = BASE_URL+"box_time";  | 
            |
| 56 | 
                -  | 
            |
| 57 | 
                - SET_VERSION = BASE_URL+"set_version";  | 
            |
| 58 | 
                - }  | 
            |
| 59 | 
                -  | 
            |
| 60 | 
                -  | 
            |
| 61 | 32 | 
                }  |