新增APk内置更新功能
This commit is contained in:
parent
4ad2020b57
commit
af58ec755d
@ -199,6 +199,15 @@ public class CommonHttpUtil {
|
|||||||
JSONArray levelArray = obj.getJSONArray("levelanchor_new");
|
JSONArray levelArray = obj.getJSONArray("levelanchor_new");
|
||||||
new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
|
new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
|
||||||
}
|
}
|
||||||
|
if (obj.containsKey("apk_ver")) {
|
||||||
|
IMLoginManager.get(context).setApkVer(obj.getString("apk_ver"));
|
||||||
|
}
|
||||||
|
if (obj.containsKey("apk_url")) {
|
||||||
|
IMLoginManager.get(context).setAPKUrl(obj.getString("apk_url"));
|
||||||
|
}
|
||||||
|
if (obj.containsKey("apk_des")) {
|
||||||
|
IMLoginManager.get(context).setAPKDes(obj.getString("apk_des"));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
|
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
|
||||||
ErrorActivity.forward("GetConfig接口返回数据异常", error);
|
ErrorActivity.forward("GetConfig接口返回数据异常", error);
|
||||||
|
@ -18,6 +18,7 @@ import com.yunbao.common.manager.base.BaseCacheManager;
|
|||||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||||
import com.yunbao.common.utils.SpUtil;
|
import com.yunbao.common.utils.SpUtil;
|
||||||
|
import com.yunbao.common.utils.VersionUtil;
|
||||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -39,6 +40,33 @@ public class IMLoginManager extends BaseCacheManager {
|
|||||||
private final String IS_HINT = "is_hint";
|
private final String IS_HINT = "is_hint";
|
||||||
private final String IS_HINT2 = "is_hint2";
|
private final String IS_HINT2 = "is_hint2";
|
||||||
private final String SELECT_CLARITY = "selectClarity";
|
private final String SELECT_CLARITY = "selectClarity";
|
||||||
|
private final String APK_VER = "apk_ver";
|
||||||
|
private final String APK_URL = "apk_url";
|
||||||
|
private final String APK_DES = "apk_des";
|
||||||
|
|
||||||
|
public void setAPKUrl(String apkUrl) {
|
||||||
|
put(APK_URL, apkUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAPKDes(String apkDes) {
|
||||||
|
put(APK_DES, apkDes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAPKUrl() {
|
||||||
|
return getString(APK_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAPKDes() {
|
||||||
|
return getString(APK_DES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApkVer(String apkVer) {
|
||||||
|
put(APK_VER, apkVer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getApkVerNew() {
|
||||||
|
return TextUtils.equals(VersionUtil.getVersion(), getString(APK_VER));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置清晰度
|
* 设置清晰度
|
||||||
|
@ -0,0 +1,194 @@
|
|||||||
|
package com.yunbao.common.views;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
|
import com.lxj.xpopup.core.CenterPopupView;
|
||||||
|
import com.yunbao.common.CommonAppConfig;
|
||||||
|
import com.yunbao.common.R;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
|
import com.yunbao.common.utils.APKDownloadUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* apk更新弹窗
|
||||||
|
*/
|
||||||
|
public class APKUpdateCustomPopup extends CenterPopupView {
|
||||||
|
private TextView updateText, versionImmediateUse;
|
||||||
|
private LinearLayout updateLine;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private Activity mContext;
|
||||||
|
|
||||||
|
public APKUpdateCustomPopup(@NonNull Activity context) {
|
||||||
|
super(context);
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回自定义弹窗的布局
|
||||||
|
@Override
|
||||||
|
protected int getImplLayoutId() {
|
||||||
|
return R.layout.apk_update_custom_popup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||||
|
@Override
|
||||||
|
protected void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
updateText = findViewById(R.id.update_text);
|
||||||
|
versionImmediateUse = findViewById(R.id.version_immediate_use);
|
||||||
|
updateLine = findViewById(R.id.update_line);
|
||||||
|
progressBar = findViewById(R.id.progressBar);
|
||||||
|
versionImmediateUse.setVisibility(VISIBLE);
|
||||||
|
updateLine.setVisibility(GONE);
|
||||||
|
updateText.setText(IMLoginManager.get(getContext()).getAPKDes());
|
||||||
|
ViewClicksAntiShake.clicksAntiShake(versionImmediateUse, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onViewClicks() {
|
||||||
|
//不是谷歌
|
||||||
|
if (!CommonAppConfig.IS_GOOGLE_PLAY) {
|
||||||
|
versionImmediateUse.setVisibility(GONE);
|
||||||
|
updateLine.setVisibility(VISIBLE);
|
||||||
|
downloadAPK(mContext, IMLoginManager.get(getContext()).getAPKUrl(), new APKDownloadUtil.OnUpdateListener() {
|
||||||
|
@Override
|
||||||
|
public void updateFailure(int code, String error) {
|
||||||
|
ToastUtil.show(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
|
||||||
|
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
|
||||||
|
mContext.startActivity(i);
|
||||||
|
mContext.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadAPK(Activity context, String url, APKDownloadUtil.OnUpdateListener listener) {
|
||||||
|
Request request = new Request.Builder().url(url)
|
||||||
|
.addHeader("Accept-Encoding", "identity").build();
|
||||||
|
File downloadFile = new File(context.getCacheDir(), "update_app.apk");
|
||||||
|
try {
|
||||||
|
if (!downloadFile.exists()
|
||||||
|
&& !downloadFile.createNewFile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
new OkHttpClient().newCall(request).enqueue(new Callback() {
|
||||||
|
private Handler handler = new Handler();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call call, IOException e) {
|
||||||
|
// 下载失败
|
||||||
|
handler.post(() -> {
|
||||||
|
listener.updateFailure(-1, e.getMessage());
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call call, Response response) {
|
||||||
|
Looper.prepare();
|
||||||
|
byte[] buf = new byte[2048];
|
||||||
|
int len;
|
||||||
|
try (InputStream inputStream = response.body().byteStream();
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(downloadFile)) {
|
||||||
|
long total = response.body().contentLength();
|
||||||
|
long sum = 0;
|
||||||
|
while ((len = inputStream.read(buf)) != -1) {
|
||||||
|
outputStream.write(buf, 0, len);
|
||||||
|
sum += len;
|
||||||
|
int progress = (int) (sum * 1.0f / total * 100);
|
||||||
|
// 下载中
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
progressBar.setProgress(progress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
outputStream.flush();
|
||||||
|
//启动安装app
|
||||||
|
installApk(context, downloadFile, context.getPackageName() + ".fileprovider");
|
||||||
|
handler.post(() -> dismiss());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
new Handler().post(() -> {
|
||||||
|
listener.updateFailure(-1, e.getMessage());
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安装apk
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
public void installApk(Context context, File file, String authority) {
|
||||||
|
Intent intent = getInstallIntent(context, file, authority);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取安装Intent
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param file
|
||||||
|
* @param authority
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Intent getInstallIntent(Context context, File file, String authority) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||||
|
Uri uriData;
|
||||||
|
String type = "application/vnd.android.package-archive";
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
uriData = FileProvider.getUriForFile(context, authority, file);
|
||||||
|
} else {
|
||||||
|
uriData = Uri.fromFile(file);
|
||||||
|
}
|
||||||
|
intent.setDataAndType(uriData, type);
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
}
|
5
common/src/main/res/drawable/bg_apk_update_btn.xml
Normal file
5
common/src/main/res/drawable/bg_apk_update_btn.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<corners android:radius="13.33dp" />
|
||||||
|
<solid android:color="#0D0D0D" />
|
||||||
|
</shape>
|
21
common/src/main/res/drawable/progress_bg.xml
Normal file
21
common/src/main/res/drawable/progress_bg.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!--设置ProgressBar背景色-->
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape>
|
||||||
|
<!--设置ProgressBar进度条圆角半径-->
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<solid android:color="#E6E6E6" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<!--设置ProgressBar进度条颜色-->
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<clip android:clipOrientation="horizontal">
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<solid android:color="#0D0D0D" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
75
common/src/main/res/layout/apk_update_custom_popup.xml
Normal file
75
common/src/main/res/layout/apk_update_custom_popup.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="310dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="310dp"
|
||||||
|
android:src="@mipmap/update_tip_box" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:layout_marginStart="28dp"
|
||||||
|
android:layout_marginTop="135dp"
|
||||||
|
android:scrollbars="none">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/update_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="更新內容:
|
||||||
|
1、內容內容內容內容內容內容
|
||||||
|
2、內容內容內容內容內容內容
|
||||||
|
3、內容內容內容內容內容
|
||||||
|
4、內容內容內容內容內容"
|
||||||
|
android:textColor="#1B1B1B"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/version_immediate_use"
|
||||||
|
android:layout_width="153.33dp"
|
||||||
|
android:layout_height="26.67dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:background="@drawable/bg_apk_update_btn"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/version_immediate_use"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/update_line"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="9dp"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="40"
|
||||||
|
android:progressDrawable="@drawable/progress_bg" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:text="@string/updating"
|
||||||
|
android:textColor="#8C8C8C"
|
||||||
|
android:textSize="11sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
BIN
common/src/main/res/mipmap-xxhdpi/update_tip_box.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/update_tip_box.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 230 KiB |
@ -994,4 +994,8 @@ Limited ride And limited avatar frame</string>
|
|||||||
<string name="stick_to_choice" >Stick to choice</string>
|
<string name="stick_to_choice" >Stick to choice</string>
|
||||||
<string name="net_hint" >Network prompt</string>
|
<string name="net_hint" >Network prompt</string>
|
||||||
<string name="net_hint2" >The system detects that your network is unstable and insufficient device memory will affect the fluency of your live broadcast. Therefore, it is recommended that you choose fluency and clarity.</string>
|
<string name="net_hint2" >The system detects that your network is unstable and insufficient device memory will affect the fluency of your live broadcast. Therefore, it is recommended that you choose fluency and clarity.</string>
|
||||||
|
<string name="check_the_new_version" >check version</string>
|
||||||
|
<string name="discover_a_new_version" >Update</string>
|
||||||
|
<string name="latest_version" >Latest Version</string>
|
||||||
|
<string name="updating" >updating</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1014,4 +1014,8 @@
|
|||||||
<string name="stick_to_choice" >堅持選擇</string>
|
<string name="stick_to_choice" >堅持選擇</string>
|
||||||
<string name="net_hint" >網絡提示</string>
|
<string name="net_hint" >網絡提示</string>
|
||||||
<string name="net_hint2" >系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。</string>
|
<string name="net_hint2" >系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。</string>
|
||||||
|
<string name="check_the_new_version" >检查新版本</string>
|
||||||
|
<string name="discover_a_new_version" >發現新版本,點此更新</string>
|
||||||
|
<string name="latest_version" >已是最新版本</string>
|
||||||
|
<string name="updating" >更新中</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,7 +5,7 @@ ext {
|
|||||||
minSdkVersion : 21,
|
minSdkVersion : 21,
|
||||||
targetSdkVersion : 31,
|
targetSdkVersion : 31,
|
||||||
versionCode : 402,
|
versionCode : 402,
|
||||||
versionName : "6.4.7"
|
versionName : "6.4.6"
|
||||||
]
|
]
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
//正式
|
//正式
|
||||||
|
@ -19,19 +19,18 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.lxj.xpopup.XPopup;
|
||||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.activity.AbsActivity;
|
import com.yunbao.common.activity.AbsActivity;
|
||||||
import com.yunbao.common.activity.WebViewActivity;
|
import com.yunbao.common.activity.WebViewActivity;
|
||||||
import com.yunbao.common.bean.ConfigBean;
|
|
||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.http.CommonHttpConsts;
|
import com.yunbao.common.http.CommonHttpConsts;
|
||||||
import com.yunbao.common.http.CommonHttpUtil;
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
import com.yunbao.common.http.HttpCallback;
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.interfaces.CommonCallback;
|
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.utils.DialogUitl;
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
@ -40,6 +39,7 @@ import com.yunbao.common.utils.RouteUtil;
|
|||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.VersionUtil;
|
import com.yunbao.common.utils.VersionUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
|
import com.yunbao.common.views.APKUpdateCustomPopup;
|
||||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
@ -99,6 +99,11 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
|
|||||||
data1.setName(WordUtil.getString(R.string.versions));
|
data1.setName(WordUtil.getString(R.string.versions));
|
||||||
list.add(data1);
|
list.add(data1);
|
||||||
|
|
||||||
|
SettingBean data2 = new SettingBean();
|
||||||
|
data2.setId(25);
|
||||||
|
data2.setName(WordUtil.getString(R.string.check_the_new_version));
|
||||||
|
list.add(data2);
|
||||||
|
|
||||||
SettingBean bean = new SettingBean();
|
SettingBean bean = new SettingBean();
|
||||||
bean.setName(WordUtil.getString(R.string.setting_exit));
|
bean.setName(WordUtil.getString(R.string.setting_exit));
|
||||||
bean.setLast(true);
|
bean.setLast(true);
|
||||||
@ -280,6 +285,13 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
|
|||||||
clearCache(position);
|
clearCache(position);
|
||||||
} else if (bean.getId() == 21) {//清除缓存
|
} else if (bean.getId() == 21) {//清除缓存
|
||||||
startActivity(new Intent(SettingActivity.this, MsgSettActivity.class));
|
startActivity(new Intent(SettingActivity.this, MsgSettActivity.class));
|
||||||
|
} else if (bean.getId() == 25) {//版本更新
|
||||||
|
if (!IMLoginManager.get(mContext).getApkVerNew()) {
|
||||||
|
new XPopup.Builder(mContext)
|
||||||
|
.asCustom(new APKUpdateCustomPopup(mContext))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (bean.getId() == 17) {//意见反馈要在url上加版本号和设备号
|
if (bean.getId() == 17) {//意见反馈要在url上加版本号和设备号
|
||||||
|
@ -12,10 +12,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.utils.DeviceUtils;
|
import com.yunbao.common.utils.DeviceUtils;
|
||||||
import com.yunbao.common.utils.LogUtil;
|
import com.yunbao.common.utils.LogUtil;
|
||||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
|
||||||
import com.yunbao.main.BuildConfig;
|
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.bean.SettingBean;
|
import com.yunbao.main.bean.SettingBean;
|
||||||
|
|
||||||
@ -47,17 +46,17 @@ public class SettingAdapter extends RecyclerView.Adapter {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
Object tag = v.getTag();
|
Object tag = v.getTag();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
int position = (int) tag;
|
int position = (int) tag;
|
||||||
SettingBean bean = mList.get(position);
|
SettingBean bean = mList.get(position);
|
||||||
if(bean.getId()==19){
|
if (bean.getId() == 19) {
|
||||||
LogUtil.shareFile(context);
|
LogUtil.shareFile(context);
|
||||||
}
|
|
||||||
if (mOnItemClickListener != null) {
|
|
||||||
mOnItemClickListener.onItemClick(bean, position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (mOnItemClickListener != null) {
|
||||||
|
mOnItemClickListener.onItemClick(bean, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -75,7 +74,7 @@ public class SettingAdapter extends RecyclerView.Adapter {
|
|||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
SettingBean bean = mList.get(position);
|
SettingBean bean = mList.get(position);
|
||||||
if (bean.getId() == 19 || bean.getId() == Constants.SETTING_UPDATE_ID || bean.getId() == Constants.SETTING_CLEAR_CACHE) {
|
if (bean.getId() == 19 || bean.getId() == 25|| bean.getId() == Constants.SETTING_UPDATE_ID || bean.getId() == Constants.SETTING_CLEAR_CACHE) {
|
||||||
return VERSION;
|
return VERSION;
|
||||||
} else if (bean.isLast()) {
|
} else if (bean.isLast()) {
|
||||||
return LAST;
|
return LAST;
|
||||||
@ -147,6 +146,16 @@ public class SettingAdapter extends RecyclerView.Adapter {
|
|||||||
} else if (bean.getId() == 19) {
|
} else if (bean.getId() == 19) {
|
||||||
mText.setText(DeviceUtils.getVersionName(itemView.getContext()));
|
mText.setText(DeviceUtils.getVersionName(itemView.getContext()));
|
||||||
mText.setTextColor(Color.parseColor("#969696"));
|
mText.setTextColor(Color.parseColor("#969696"));
|
||||||
|
} else if (bean.getId() == 25) {
|
||||||
|
if (IMLoginManager.get(itemView.getContext()).getApkVerNew()) {
|
||||||
|
mText.setText(itemView.getContext().getString(R.string.latest_version));
|
||||||
|
mText.setTextColor(Color.parseColor("#969696"));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mText.setText(itemView.getContext().getString(R.string.discover_a_new_version));
|
||||||
|
mText.setTextColor(Color.parseColor("#b3d465"));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mText.setText(mVersionString);
|
mText.setText(mVersionString);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yunbao.main.views;
|
package com.yunbao.main.views;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -38,6 +39,7 @@ import com.yunbao.common.glide.ImgLoader;
|
|||||||
import com.yunbao.common.http.HttpCallback;
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.interfaces.CommonCallback;
|
import com.yunbao.common.interfaces.CommonCallback;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
import com.yunbao.common.utils.SVGAViewUtils;
|
import com.yunbao.common.utils.SVGAViewUtils;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
@ -99,6 +101,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
private boolean firstInto = true;
|
private boolean firstInto = true;
|
||||||
private Banner banner_me;
|
private Banner banner_me;
|
||||||
private LinearLayout lt_advertisement;
|
private LinearLayout lt_advertisement;
|
||||||
|
private View redPoint;
|
||||||
|
|
||||||
public MainMeViewHolder(Context context, ViewGroup parentView) {
|
public MainMeViewHolder(Context context, ViewGroup parentView) {
|
||||||
super(context, parentView);
|
super(context, parentView);
|
||||||
@ -109,9 +112,11 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
return R.layout.view_main_me;
|
return R.layout.view_main_me;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("WrongViewCast")
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
mAvatar = (ImageView) findViewById(R.id.avatar);
|
mAvatar = (ImageView) findViewById(R.id.avatar);
|
||||||
|
redPoint = findViewById(R.id.red_point);
|
||||||
ViewClicksAntiShake.clicksAntiShake(mAvatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
ViewClicksAntiShake.clicksAntiShake(mAvatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onViewClicks() {
|
public void onViewClicks() {
|
||||||
@ -175,6 +180,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
redPoint.setVisibility(IMLoginManager.get(mContext).getApkVerNew() ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -312,7 +318,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
public void onComplete(SVGAVideoEntity videoItem) {
|
public void onComplete(SVGAVideoEntity videoItem) {
|
||||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||||
gift_svga.setImageDrawable(drawable);
|
gift_svga.setImageDrawable(drawable);
|
||||||
SVGAViewUtils.playEndClear(gift_svga,false);
|
SVGAViewUtils.playEndClear(gift_svga, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -441,11 +447,11 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
} else if (bean.getId() == 4) {
|
} else if (bean.getId() == 4) {
|
||||||
url = HtmlConfig.SHOP + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
url = HtmlConfig.SHOP + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||||
WebViewActivity.forward(mContext, url);
|
WebViewActivity.forward(mContext, url);
|
||||||
} else if(bean.getId() == 3) {//我的等级
|
} else if (bean.getId() == 3) {//我的等级
|
||||||
Constants.myIntoIndex=2;
|
Constants.myIntoIndex = 2;
|
||||||
Constants.isTitle = false;
|
Constants.isTitle = false;
|
||||||
ZhuangBanActivity.forward(mContext, url);
|
ZhuangBanActivity.forward(mContext, url);
|
||||||
}else{
|
} else {
|
||||||
WebViewActivity.forward(mContext, url);
|
WebViewActivity.forward(mContext, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,8 +468,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
||||||
} else if (i == R.id.signature) {
|
} else if (i == R.id.signature) {
|
||||||
mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
mContext.startActivity(new Intent(mContext, EditProfileActivity.class));
|
||||||
}
|
} else if (i == R.id.lt_star_coin) {
|
||||||
else if (i == R.id.lt_star_coin) {
|
|
||||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||||
} else if (i == R.id.btn_coin) {
|
} else if (i == R.id.btn_coin) {
|
||||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 0));
|
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 0));
|
||||||
@ -483,8 +488,6 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,18 +476,18 @@
|
|||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginRight="15dp"
|
||||||
android:background="@drawable/bg_me_data"
|
android:background="@drawable/bg_me_data"
|
||||||
android:gravity="center"
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusableInTouchMode="true"
|
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:focusableInTouchMode="false"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -502,11 +502,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:focusableInTouchMode="false"
|
||||||
android:gravity="center|left"
|
android:gravity="center|left"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
android:focusable="false"
|
|
||||||
android:paddingLeft="18dp"
|
android:paddingLeft="18dp"
|
||||||
android:paddingRight="6dp">
|
android:paddingRight="6dp">
|
||||||
|
|
||||||
@ -534,10 +534,10 @@
|
|||||||
android:layout_width="18dp"
|
android:layout_width="18dp"
|
||||||
android:layout_height="18dp"
|
android:layout_height="18dp"
|
||||||
android:layout_marginRight="30dp"
|
android:layout_marginRight="30dp"
|
||||||
|
android:background="@mipmap/icon_more_gray"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:background="@mipmap/icon_more_gray" />
|
android:focusableInTouchMode="false" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -657,6 +657,19 @@
|
|||||||
android:textColor="@color/textColor"
|
android:textColor="@color/textColor"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/red_point"
|
||||||
|
android:layout_width="12dp"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_toEndOf="@id/tv_setting"
|
||||||
|
android:background="@drawable/background_ff5075"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="10dp"
|
||||||
|
android:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user