删除UpdateAppManager相关代码

This commit is contained in:
pppscn 2021-02-12 18:34:05 +08:00
parent 966356ff57
commit 811238d096
5 changed files with 8 additions and 291 deletions

View File

@ -46,8 +46,8 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//okhttp //okhttp
implementation 'com.squareup.okhttp3:okhttp:3.6.0' implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.okio:okio:1.11.0' implementation 'com.squareup.okio:okio:2.10.0'
//fastjson //fastjson
implementation "com.alibaba:fastjson:1.2.75" implementation "com.alibaba:fastjson:1.2.75"
@ -61,11 +61,6 @@ dependencies {
//使ProxyBuilder类 //使ProxyBuilder类
//implementation 'com.linkedin.dexmaker:dexmaker-mockito:2.12.1' //implementation 'com.linkedin.dexmaker:dexmaker-mockito:2.12.1'
//appupdate
implementation 'com.qianwen:update-app:3.5.2'
implementation 'com.qianwen:okhttp-utils:3.8.0'
implementation 'com.lzy.net:okgo:3.0.4'
//SDK都依赖基础组件库 //SDK都依赖基础组件库
implementation "com.umeng.umsdk:common:9.3.6" implementation "com.umeng.umsdk:common:9.3.6"
implementation "com.umeng.umsdk:asms:1.2.0" implementation "com.umeng.umsdk:asms:1.2.0"

View File

@ -15,17 +15,8 @@ import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.idormy.sms.forwarder.BroadCastReceiver.RebootBroadcastReceiver; import com.idormy.sms.forwarder.BroadCastReceiver.RebootBroadcastReceiver;
import com.idormy.sms.forwarder.model.vo.FeedBackResult;
import com.idormy.sms.forwarder.utils.HttpI;
import com.idormy.sms.forwarder.utils.HttpUtil;
import com.idormy.sms.forwarder.utils.UpdateAppHttpUtil;
import com.idormy.sms.forwarder.utils.aUtil; import com.idormy.sms.forwarder.utils.aUtil;
import com.vector.update_app.UpdateAppManager;
import com.vector.update_app.UpdateCallback;
import com.vector.update_app.listener.ExceptionHandler;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -86,38 +77,8 @@ public class SettingActivity extends AppCompatActivity {
} }
private void checkNewVersion() { private void checkNewVersion() {
String geturl = "http://api.allmything.com/api/version/hasnew?versioncode=";
try { try {
geturl += aUtil.getVersionCode(SettingActivity.this);
Log.i("SettingActivity", geturl);
new UpdateAppManager
.Builder()
//当前Activity
.setActivity(SettingActivity.this)
//更新地址
.setUpdateUrl(geturl)
//全局异常捕获
.handleException(new ExceptionHandler() {
@Override
public void onException(Exception e) {
Log.e(TAG, "onException: ", e);
Toast.makeText(SettingActivity.this, "更新失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
})
//实现httpManager接口的对象
.setHttpManager(new UpdateAppHttpUtil())
.build()
.checkNewApp(new UpdateCallback() {
/**
* 没有新版本
*/
protected void noNewApp(String error) {
Toast.makeText(SettingActivity.this, "没有新版本", Toast.LENGTH_SHORT).show();
}
});
// .update();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -142,7 +103,7 @@ public class SettingActivity extends AppCompatActivity {
Map<String, String> feedBackData = new HashMap<>(); Map<String, String> feedBackData = new HashMap<>();
feedBackData.put("email", feedback_et_email.getText().toString()); feedBackData.put("email", feedback_et_email.getText().toString());
feedBackData.put("text", feedback_et_text.getText().toString()); feedBackData.put("text", feedback_et_text.getText().toString());
new HttpUtil().asyncPost("https://api.sl.willanddo.com/api/tsms/feedBack", feedBackData, new HttpI.Callback() { /*new HttpUtil().asyncPost("https://api.sl.willanddo.com/api/tsms/feedBack", feedBackData, new HttpI.Callback() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
Log.i(TAG, "onResponse: " + result); Log.i(TAG, "onResponse: " + result);
@ -170,7 +131,7 @@ public class SettingActivity extends AppCompatActivity {
Toast.makeText(SettingActivity.this, error, Toast.LENGTH_LONG).show(); Toast.makeText(SettingActivity.this, error, Toast.LENGTH_LONG).show();
} }
}); });*/
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(SettingActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); Toast.makeText(SettingActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();

View File

@ -1,117 +0,0 @@
package com.idormy.sms.forwarder.utils;
import android.support.annotation.NonNull;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.FileCallBack;
import com.zhy.http.okhttp.callback.StringCallback;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
public class HttpUtil implements HttpI {
/**
* 异步get
*
* @param url get请求地址
* @param params get参数
* @param callBack 回调
*/
public void asyncGet(@NonNull String url, @NonNull Map<String, String> params, @NonNull final Callback callBack) {
params.put("aaa", "bbbbb");
params.put("ccc", "ddd");
Map<String, String> headers = new HashMap<>();
OkHttpUtils.get()
.url(url)
.headers(headers)
.params(params)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Response response, Exception e, int id) {
callBack.onError(validateError(e, response));
}
@Override
public void onResponse(String response, int id) {
callBack.onResponse(response);
}
});
}
/**
* 异步post
*
* @param url post请求地址
* @param params post请求参数
* @param callBack 回调
*/
public void asyncPost(@NonNull String url, @NonNull Map<String, String> params, @NonNull final Callback callBack) {
params.put("eeee", "fff");
params.put("gggg", "hhhh");
Map<String, String> headers = new HashMap<>();
headers.put("heada", "bb");
OkHttpUtils.post()
.url(url)
.headers(headers)
.params(params)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Response response, Exception e, int id) {
callBack.onError(validateError(e, response));
}
@Override
public void onResponse(String response, int id) {
callBack.onResponse(response);
}
});
}
/**
* 下载
*
* @param url 下载地址
* @param path 文件保存路径
* @param fileName 文件名称
* @param callback 回调
*/
public void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull final FileCallback callback) {
OkHttpUtils.get()
.url(url)
.build()
.execute(new FileCallBack(path, fileName) {
@Override
public void inProgress(float progress, long total, int id) {
callback.onProgress(progress, total);
}
@Override
public void onError(Call call, Response response, Exception e, int id) {
callback.onError(validateError(e, response));
}
@Override
public void onResponse(File response, int id) {
callback.onResponse(response);
}
@Override
public void onBefore(Request request, int id) {
super.onBefore(request, id);
callback.onBefore();
}
});
}
}

View File

@ -1,124 +0,0 @@
package com.idormy.sms.forwarder.utils;
import android.support.annotation.NonNull;
import android.util.Log;
import com.vector.update_app.HttpManager;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.FileCallBack;
import com.zhy.http.okhttp.callback.StringCallback;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
public class UpdateAppHttpUtil implements HttpManager {
/**
* 异步get
*
* @param url get请求地址
* @param params get参数
* @param callBack 回调
*/
@Override
public void asyncGet(@NonNull String url, @NonNull Map<String, String> params, @NonNull final HttpManager.Callback callBack) {
Log.i("UpdateAppHttpUtil", "asyncGet" + url);
Map<String, String> headers = new HashMap<>();
headers.put("heada", "bb");
OkHttpUtils.get()
.url(url)
.headers(headers)
.params(params)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Response response, Exception e, int id) {
Log.i("UpdateAppHttpUtil", "err response" + response);
callBack.onError(validateError(e, response));
}
@Override
public void onResponse(String response, int id) {
Log.i("UpdateAppHttpUtil", "response" + response);
callBack.onResponse(response);
}
});
}
/**
* 异步post
*
* @param url post请求地址
* @param params post请求参数
* @param callBack 回调
*/
@Override
public void asyncPost(@NonNull String url, @NonNull Map<String, String> params, @NonNull final HttpManager.Callback callBack) {
Log.i("UpdateAppHttpUtil", "asyncPost" + url);
// params.put("gggg","hhhh");
Map<String, String> headers = new HashMap<>();
headers.put("heada", "bb");
OkHttpUtils.post()
.url(url)
.headers(headers)
.params(params)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Response response, Exception e, int id) {
callBack.onError(validateError(e, response));
}
@Override
public void onResponse(String response, int id) {
callBack.onResponse(response);
}
});
}
/**
* 下载
*
* @param url 下载地址
* @param path 文件保存路径
* @param fileName 文件名称
* @param callback 回调
*/
@Override
public void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull final HttpManager.FileCallback callback) {
OkHttpUtils.get()
.url(url)
.build()
.execute(new FileCallBack(path, fileName) {
@Override
public void inProgress(float progress, long total, int id) {
callback.onProgress(progress, total);
}
@Override
public void onError(Call call, Response response, Exception e, int id) {
callback.onError(validateError(e, response));
}
@Override
public void onResponse(File response, int id) {
callback.onResponse(response);
}
@Override
public void onBefore(Request request, int id) {
super.onBefore(request, id);
callback.onBefore();
}
});
}
}

View File

@ -5,8 +5,9 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://dl.bintray.com/umsdk/release' } maven { url 'https://dl.bintray.com/umsdk/release' }
maven { url "https://jitpack.io" }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.2' classpath 'com.android.tools.build:gradle:4.1.2'
@ -21,8 +22,9 @@ allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://dl.bintray.com/umsdk/release' } maven { url 'https://dl.bintray.com/umsdk/release' }
maven { url "https://jitpack.io" }
} }
} }