diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c5290d6df..3d7fdd8c3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -895,9 +895,6 @@
-
diff --git a/app/src/main/java/com/yizhuan/erban/UIHelper.java b/app/src/main/java/com/yizhuan/erban/UIHelper.java
index 71ee28f52..953ce08a2 100644
--- a/app/src/main/java/com/yizhuan/erban/UIHelper.java
+++ b/app/src/main/java/com/yizhuan/erban/UIHelper.java
@@ -1,11 +1,8 @@
package com.yizhuan.erban;
import android.app.Activity;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
-import android.provider.Settings;
import com.yizhuan.erban.audio.MyVoiceActivity;
import com.yizhuan.erban.audio.RecordingVoiceActivity;
@@ -36,29 +33,6 @@ import com.yizhuan.xchat_android_library.utils.ResUtil;
* **************************************************************************
*/
public class UIHelper {
-//
-// /**
-// * 登录
-// *
-// * @param context
-// */
-// public static void showLoginAct(Context context) {
-// Intent intent = new Intent(context, LoginActivity.class);
-// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-// intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-// context.startActivity(intent);
-// }
-//
-// /**
-// * 显示 主界面
-// */
-// public static void showMyMainAct(Context context) {
-// Intent intent = new Intent(context, Main2Activity.class);
-// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-// intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-// context.startActivity(intent);
-// }
-
public static void showUserGuideAct(Context mContext) {
mContext.startActivity(new Intent(mContext, UserGuideActivity.class));
@@ -74,11 +48,6 @@ public class UIHelper {
}
-// public static void showUserAvatarUpdateAct(Context mContext) {
-// mContext.startActivity(new Intent(mContext, UserAvatarUpdateActivity.class));
-// }
-
-
//修改用户资料
public static void showUserInfoModifyAct(Context mContext, long userId) {
Intent intent = new Intent(mContext, UserInfoModifyActivity.class);
@@ -172,36 +141,6 @@ public class UIHelper {
CommonWebViewActivity.start(context, cardUrl);
}
-
- /**
- * 启动应用的设置
- *
- * @param context
- */
- public static void startAppSettings(Context context) {
- Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
- intent.setData(Uri.parse("package:" + context.getPackageName()));
- context.startActivity(intent);
- }
-
- private static void startOtherApp(Context context, String pkgName, String launcherActivityName) {
- ComponentName componet = new ComponentName(pkgName, launcherActivityName);
- //pkgName 就是第三方应用的包名
- //launcherActivityName 就是第三方应用的进入的第一个Activity
- Intent intent = new Intent();
- intent.setComponent(componet);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- }
-
- public static void startWeixinApp(Context context) {
- startOtherApp(context, "com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
- }
-
- public static void startQQApp(Context context) {
- startOtherApp(context, "com.tencent.mobileqq", "com.tencent.mobileqq.activity.SplashActivity");
- }
-
public static void openContactUs(Context context) {
CommonWebViewActivity.start(context, UriProvider.IM_SERVER_URL + "/peko/modules/contact/contact.html");
}
diff --git a/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/SelectPayTypeDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/SelectPayTypeDialog.kt
deleted file mode 100644
index 9b05e4833..000000000
--- a/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/SelectPayTypeDialog.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.yizhuan.erban.avroom.firstcharge
-
-import android.annotation.SuppressLint
-import android.os.Bundle
-import android.view.Gravity
-import android.view.View
-import android.view.WindowManager
-import com.yizhuan.erban.R
-import com.yizhuan.erban.base.BaseDialog
-import com.yizhuan.erban.databinding.DialogSelectPayTypeBinding
-import com.yizhuan.xchat_android_core.pay.PayModel
-import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
-import com.yizhuan.xchat_android_library.utils.ResUtil
-import com.yizhuan.xchat_android_library.utils.SingleToastUtil
-
-/**
- * 充值方式选择弹窗
- */
-@ActLayoutRes(R.layout.dialog_select_pay_type)
-class SelectPayTypeDialog : BaseDialog() {
-
- private val chargeProdId by lazy { requireArguments().getString("chargeProdId", "") }
- private val descText by lazy { requireArguments().getString("descText", "") }
- private var removeView: View? = null
-
- companion object {
-
- @JvmStatic
- fun newInstance(chargeProdId: String, descText: String): SelectPayTypeDialog {
- return SelectPayTypeDialog().apply {
- arguments = Bundle().apply {
- putString("chargeProdId", chargeProdId)
- putString("descText", descText)
- }
- }
- }
- }
-
- private var payChannel = ""
-
- override fun onStart() {
- width = WindowManager.LayoutParams.MATCH_PARENT
- gravity = Gravity.BOTTOM
- super.onStart()
- }
-
- @SuppressLint("CheckResult")
- override fun init() {
- PayModel.get().walletInfo
- .compose(bindToLifecycle())
- .subscribe({
- //setWalletData(it)
- }, {
- SingleToastUtil.showToast(it.message)
- it.printStackTrace()
- })
- binding.tvDesc.text = descText
-
- binding.tvConfirm.setOnClickListener {
- if (payChannel.isEmpty()) {
- SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_firstcharge_selectpaytypedialog_01))
- return@setOnClickListener
- }
- dismissAllowingStateLoss()
- }
-
- binding.tvMore.setOnClickListener {
- removeView?.let {
- binding.rg.addView(it)
- binding.tvMore.visibility = View.GONE
- }
- }
-
- binding.ivClose.setOnClickListener {
- dismissAllowingStateLoss()
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/yizhuan/erban/avroom/newuserchargegift/NewUserChargeGiftDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/newuserchargegift/NewUserChargeGiftDialog.kt
deleted file mode 100644
index d7c25d470..000000000
--- a/app/src/main/java/com/yizhuan/erban/avroom/newuserchargegift/NewUserChargeGiftDialog.kt
+++ /dev/null
@@ -1,196 +0,0 @@
-package com.yizhuan.erban.avroom.newuserchargegift
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.content.Intent
-import android.view.Gravity
-import android.view.View
-import android.view.WindowManager
-import androidx.core.view.isVisible
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.netease.nim.uikit.common.util.sys.ScreenUtil
-import com.netease.nim.uikit.common.util.sys.TimeUtil
-import com.trello.rxlifecycle3.android.ActivityEvent
-import com.yizhuan.erban.R
-import com.yizhuan.erban.avroom.firstcharge.SelectPayTypeDialog
-import com.yizhuan.erban.base.BaseViewBindingActivity
-import com.yizhuan.erban.databinding.DialogNewUserChargeGiftBinding
-import com.yizhuan.erban.ui.setting.ModifyPwdActivity
-import com.yizhuan.erban.ui.utils.RVDelegate
-import com.yizhuan.xchat_android_core.pay.PayModel
-import com.yizhuan.xchat_android_core.pay.bean.FirstChargeGoods
-import com.yizhuan.xchat_android_core.pay.bean.FirstChargeReward
-import com.yizhuan.xchat_android_core.pay.event.NewUserChargeEvent
-import com.yizhuan.xchat_android_core.statistic.StatisticManager
-import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
-import com.yizhuan.xchat_android_core.user.UserModel
-import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
-import com.yizhuan.xchat_android_core.utils.toast
-import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
-import com.yizhuan.xchat_android_library.utils.ResUtil
-import com.yizhuan.xchat_android_library.utils.SingleToastUtil
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import org.greenrobot.eventbus.EventBus
-import org.greenrobot.eventbus.Subscribe
-import org.greenrobot.eventbus.ThreadMode
-import java.util.concurrent.TimeUnit
-
-@ActLayoutRes(R.layout.dialog_new_user_charge_gift)
-class NewUserChargeGiftDialog : BaseViewBindingActivity() {
-
- private var goodsList: List? = null
- private var currGoods: FirstChargeGoods? = null
- private lateinit var rewardAdapter: RewardAdapter
- private lateinit var rvDelegate: RVDelegate
-
- companion object {
- @JvmStatic
- fun start(context: Context) {
- val starter = Intent(context, NewUserChargeGiftDialog::class.java)
- context.startActivity(starter)
- }
-
- private const val BIND_CODE_GOLD = 200
- }
-
- @SuppressLint("CheckResult")
- override fun init() {
- //這裏的height用MATCH_PARENT狀態欄會被頂上去,不知道什麽鬼
- val height = ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context)
- window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, height)
- window.setGravity(Gravity.CENTER)
- EventBus.getDefault().register(this)
- binding.rgPlan.setOnCheckedChangeListener { group, checkedId ->
- updateCurrGoods(goodsList?.getOrNull(group.indexOfChild(group.findViewById(checkedId))))
- }
-
- binding.tvCharge.setOnClickListener {
- currGoods?.let {
- SelectPayTypeDialog.newInstance(it.chargeProdId, "¥${it.chargeMoney}")
- .show(this)
- StatisticManager.Instance()
- .onEvent(
- StatisticsProtocol.EVENT_NUGIFT_POP_CLICK,
- ResUtil.getString(R.string.avroom_newuserchargegift_newuserchargegiftdialog_01),
- mapOf("charge_money" to "${it.chargeMoney}元")
- )
- } ?: run {
- "請選擇充值產品!".toast()
- }
- }
-
- rvDelegate = RVDelegate.Builder()
- .setAdapter(RewardAdapter().also { rewardAdapter = it })
- .setLayoutManager(LinearLayoutManager(this, RecyclerView.HORIZONTAL, false))
- .setRecyclerView(binding.recyclerView)
- .build()
-
- dialogManager.showProgressDialog(this)
- PayModel.get().newUserChargeInfo
- .compose(bindToLifecycle())
- .subscribe({
- it.limitFirstChargeTaskList?.let { it1 -> initData(it1) }
- initNewUserCharge(it.limitEndTime)
- dialogManager.dismissDialog()
- }, {
- it.printStackTrace()
- dialogManager.dismissDialog()
- SingleToastUtil.showToast(it.message)
- finish()
- })
-
- binding.viewBg.setOnClickListener {
- //do nothing
- }
- val closeClick = View.OnClickListener {
- finish()
- StatisticManager.Instance()
- .onEvent(StatisticsProtocol.EVENT_NUGIFT_POP_CLOSE_CLICK, "新人專享禮物彈窗關閉點擊")
- }
- binding.root.setOnClickListener(closeClick)
- binding.ivClose.setOnClickListener(closeClick)
- }
-
- @SuppressLint("SetTextI18n")
- private fun initData(goodsList: List) {
- this.goodsList = goodsList
- updateCurrGoods(goodsList.getOrNull(0))
- val planViews = arrayListOf(
- binding.rbPlanA,
- binding.rbPlanB,
- binding.rbPlanC,
- binding.rbPlanD
- )
- var initChecked = false
- planViews.forEachIndexed { index, button ->
- goodsList.getOrNull(index)?.let {
- if (!it.finishCharge && !initChecked) {
- initChecked = true
- button.isChecked = true
- }
- button.isVisible = true
- button.text = "${it.chargeMoney}元"
- } ?: run {
- button.isVisible = false
- }
- }
- }
-
- @SuppressLint("CheckResult", "SetTextI18n")
- private fun initNewUserCharge(limitChargeEndTime: Long) {
- val count = (limitChargeEndTime - CurrentTimeUtils.getCurrentTime()) / 1000 / 60 + 1
- if (count <= 0) return
- Observable.intervalRange(0, count, 0, 1, TimeUnit.MINUTES)
- .compose(bindUntilEvent(ActivityEvent.DESTROY))
- .observeOn(AndroidSchedulers.mainThread())
- .doOnComplete {
- finish()
- }
- .subscribe({
- val residueTime =
- limitChargeEndTime - CurrentTimeUtils.getCurrentTime()
- if (residueTime <= 0) {
- UserModel.get().cacheLoginUserInfo?.isShowLimitCharge = false
- finish()
- } else {
- binding.tvTime.text =
- "限時${TimeUtil.getElapseTimeForNewUserCharge(residueTime)}"
- }
- }, {
- it.printStackTrace()
- })
- }
-
- private fun updateCurrGoods(firstChargeGoods: FirstChargeGoods?) {
- firstChargeGoods?.let {
- currGoods = it
- binding.tvTitle.text = it.chargeProdTitle
- binding.tvCharge.isEnabled = !it.finishCharge
- rewardAdapter.setNewData(it.firstChargeRewardList)
- }
- }
-
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- super.onActivityResult(requestCode, resultCode, data)
- dialogManager.dismissDialog()
- if (resultCode != RESULT_OK) {
- return
- }
- if (requestCode == BIND_CODE_GOLD) {
- ModifyPwdActivity.start(this, ModifyPwdActivity.FOGERT_PAY_PWD)
- }
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- fun onNewUserChargeEvent(event: NewUserChargeEvent?) {
- finish()
- }
-
- override fun onDestroy() {
- super.onDestroy()
- EventBus.getDefault().unregister(this)
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/yizhuan/erban/common/widget/dialog/LoginPopupDialog.java b/app/src/main/java/com/yizhuan/erban/common/widget/dialog/LoginPopupDialog.java
deleted file mode 100644
index 8d25c80d9..000000000
--- a/app/src/main/java/com/yizhuan/erban/common/widget/dialog/LoginPopupDialog.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.yizhuan.erban.common.widget.dialog;
-
-
-import android.app.Dialog;
-import android.content.Context;
-import android.view.Gravity;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-
-import com.yizhuan.erban.R;
-
-
-public class LoginPopupDialog extends Dialog implements OnClickListener {
-
- private ViewGroup mContentView;
- private View mBtnRegister;
- private View mBtnLogin;
- private View mQQLogin;
- private View mSinaLogin;
- private View mWeChatLogin;
-
- private OnLoginPopupDialogListener mL;
-
- public LoginPopupDialog(Context context, final OnLoginPopupDialogListener l) {
- super(context, R.style.Dialog_Fullscreen);
- mL = l;
- mContentView = (ViewGroup) View.inflate(getContext(), R.layout.layout_login_popup_dialog, null);
- //mTvTitle = (TextView) mContentView.findViewById(R.id.tv_title);
- mBtnRegister = mContentView.findViewById(R.id.btn_register);
- mBtnLogin = mContentView.findViewById(R.id.btn_login);
-// mQQLogin = mContentView.findViewById(R.id.qq_login);
-// mSinaLogin = mContentView.findViewById(R.id.sina_login);
-// mWeChatLogin = mContentView.findViewById(R.id.wechat_login);
- mBtnRegister.setOnClickListener(this);
- mBtnLogin.setOnClickListener(this);
-// mQQLogin.setOnClickListener(this);
-// mSinaLogin.setOnClickListener(this);
-// mWeChatLogin.setOnClickListener(this);
-
- setContentView(mContentView);
- setCanceledOnTouchOutside(true);
-
- Window window = getWindow();
- WindowManager.LayoutParams params = window.getAttributes();
- params.height = WindowManager.LayoutParams.WRAP_CONTENT;
- window.setGravity( Gravity.BOTTOM );
- window.setAttributes(params);
- window.setWindowAnimations(R.style.DialogAnimation);
- }
-
- @Override
- public void onClick(View arg0) {
- if(arg0 == mBtnRegister){
- mL.onClickRegister();
- } else if(arg0 == mBtnLogin){
- mL.onClickLogin();
- } else if (arg0 == mQQLogin) {
- mL.onClickQQ();
- } else if (arg0 == mSinaLogin) {
- mL.onClickWeibo();
- } else if (arg0 == mWeChatLogin) {
- mL.onClickWeChat();
- }
- dismiss();
- }
-
- public interface OnLoginPopupDialogListener{
- void onClickRegister();
- void onClickLogin();
- void onClickWeibo();
- void onClickQQ();
- void onClickWeChat();
- void dismissDialog();
- }
-}
diff --git a/app/src/main/res/drawable-xhdpi/ic_wechat_charge.webp b/app/src/main/res/drawable-xhdpi/ic_wechat_charge.webp
deleted file mode 100644
index 0e9470013..000000000
Binary files a/app/src/main/res/drawable-xhdpi/ic_wechat_charge.webp and /dev/null differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_wechat_charge.webp b/app/src/main/res/drawable-xxhdpi/ic_wechat_charge.webp
deleted file mode 100644
index e1dd45022..000000000
Binary files a/app/src/main/res/drawable-xxhdpi/ic_wechat_charge.webp and /dev/null differ
diff --git a/app/src/main/res/layout/dialog_new_user_charge_gift.xml b/app/src/main/res/layout/dialog_new_user_charge_gift.xml
deleted file mode 100644
index ace5190b5..000000000
--- a/app/src/main/res/layout/dialog_new_user_charge_gift.xml
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/dialog_select_pay_type.xml b/app/src/main/res/layout/dialog_select_pay_type.xml
deleted file mode 100644
index 893347ac5..000000000
--- a/app/src/main/res/layout/dialog_select_pay_type.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_login_popup_dialog.xml b/app/src/main/res/layout/layout_login_popup_dialog.xml
deleted file mode 100644
index 2261a7a81..000000000
--- a/app/src/main/res/layout/layout_login_popup_dialog.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/auth/AuthModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/auth/AuthModel.java
index f6d0212a7..b2dcbbce9 100644
--- a/core/src/main/java/com/yizhuan/xchat_android_core/auth/AuthModel.java
+++ b/core/src/main/java/com/yizhuan/xchat_android_core/auth/AuthModel.java
@@ -1202,15 +1202,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
@Field("yiDunToken") String yiDunToken,
@Field("shuMeiDeviceId") String shuMeiDeviceId);
- /**
- * Peko上耳伴老用户用 QQ 登录时,判断 QQ 的 open id 是否存在
- *
- * @return
- */
- @FormUrlEncoded
- @POST("/acc/third/isExistsQqAccount")
- Single> isExistsQqAccount(@Field("qqOpenid") String qqOpenid);
-
/**
* 是否绑定手机
diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/auth/exception/OldMemberException.java b/core/src/main/java/com/yizhuan/xchat_android_core/auth/exception/OldMemberException.java
deleted file mode 100644
index 80c51af99..000000000
--- a/core/src/main/java/com/yizhuan/xchat_android_core/auth/exception/OldMemberException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.yizhuan.xchat_android_core.auth.exception;
-
-import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
-
-/**
- * 当请求 /acc/third/isExistsQqAccount 的时候,如果对应的 openid 不存在数据库里,则
- * 返回 {"code":6616,"message":ResUtil.getString(R.string.auth_exception_oldmemberexception_01)},于是抛出这个
- */
-public class OldMemberException extends Exception {
-
- private ServiceResult data;
- private String openid;
-
- public OldMemberException(ServiceResult data, String openid) {
- super();
- this.data = data;
- this.openid = openid;
- }
-
- public ServiceResult getData() {
- return data;
- }
-
- public String getOpenid() {
- return openid;
- }
-}
diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/share/ShareModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/share/ShareModel.java
index 9414fdc08..c0b0d23c6 100644
--- a/core/src/main/java/com/yizhuan/xchat_android_core/share/ShareModel.java
+++ b/core/src/main/java/com/yizhuan/xchat_android_core/share/ShareModel.java
@@ -308,7 +308,7 @@ public class ShareModel extends BaseModel implements IShareModel {
sp.setText(XChatConstants.SHARE_TEAM_TEXT);
sp.setTitle(XChatConstants.SHARE_TEAM_TITLE + "“" + title + "”");
sp.setImageUrl(teamIcon);
- //QQ空间分享
+
sp.setSite(XChatConstants.SHARE_TEAM_TEXT);
final String siteUrl = shareLink + "?shareUid=" + String.valueOf(AuthModel.get().getCurrentUid())
+ "&familyId=" + familyId;
diff --git a/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/DownloadModel.java b/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/DownloadModel.java
deleted file mode 100644
index 53cea1d2e..000000000
--- a/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/DownloadModel.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.yizhuan.xchat_android_core.community.download;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.liulishuo.okdownload.DownloadSerialQueue;
-import com.liulishuo.okdownload.DownloadTask;
-import com.liulishuo.okdownload.core.cause.EndCause;
-import com.liulishuo.okdownload.core.cause.ResumeFailedCause;
-import com.liulishuo.okdownload.core.listener.DownloadListener1;
-import com.liulishuo.okdownload.core.listener.assist.Listener1Assist;
-import com.yizhuan.xchat_android_core.R;
-import com.yizhuan.xchat_android_core.base.BaseModel;
-import com.yizhuan.xchat_android_library.utils.ResUtil;
-
-import java.io.File;
-
-import io.reactivex.Single;
-
-/**
- * create by lvzebiao @2019/11/22
- */
-public class DownloadModel extends BaseModel implements IDownloadModel {
-
-
- private static final class Helper {
- public static final DownloadModel INSTANCE = new DownloadModel();
- }
-
- public static DownloadModel get() {
- return Helper.INSTANCE;
- }
-
- private DownloadSerialQueue serialQueue;
- private DownloadTask downloadTask;
-
- private DownloadModel() {
- serialQueue = new DownloadSerialQueue();
- }
-
- public Single download(String url, String dir, String fileName) {
- return Single.create(emitter -> {
- downloadTask = new DownloadTask.Builder(url, dir, fileName)
- .setMinIntervalMillisCallbackProcess(100)
- .setPassIfAlreadyCompleted(false)
- .setAutoCallbackToUIThread(true)
- .build();
- serialQueue.setListener(new DownloadListener1() {
- @Override
- public void taskStart(@NonNull DownloadTask task, @NonNull Listener1Assist.Listener1Model model) {
-
- }
-
- @Override
- public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) {
-
- }
-
- @Override
- public void connected(@NonNull DownloadTask task, int blockCount, long currentOffset, long totalLength) {
-
- }
-
- @Override
- public void progress(@NonNull DownloadTask task, long currentOffset, long totalLength) {
-
- }
-
- @Override
- public void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause, @NonNull Listener1Assist.Listener1Model model) {
- if (cause != EndCause.COMPLETED) {
- emitter.onError(new Throwable(ResUtil.getString(R.string.community_download_downloadmodel_01)));
- return;
- }
- File file = new File(dir, fileName);
- if (file.exists()) {
- emitter.onSuccess("");
- return;
- }
- emitter.onError(new Throwable(ResUtil.getString(R.string.community_download_downloadmodel_02)));
- }
- });
- serialQueue.enqueue(downloadTask);
- });
- }
-
-
-}
diff --git a/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/IDownloadModel.java b/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/IDownloadModel.java
deleted file mode 100644
index 7d5bc3b54..000000000
--- a/core/src/model_community/java/com/yizhuan/xchat_android_core/community/download/IDownloadModel.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.yizhuan.xchat_android_core.community.download;
-
-/**
- * create by lvzebiao @2019/11/22
- */
-public interface IDownloadModel {
-
-
-
-}
diff --git a/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/IUpgradeModel.java b/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/IUpgradeModel.java
index a9c03c01d..b41e8b9f5 100644
--- a/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/IUpgradeModel.java
+++ b/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/IUpgradeModel.java
@@ -11,14 +11,6 @@ import io.reactivex.Single;
*/
public interface IUpgradeModel {
- /**
- * 下载最新版本
- *
- * @param downLoadListener
- * @return
- */
- Single downloadNewVersion(UpgradeModel.DownLoadListener downLoadListener);
-
/**
* 获取最新版本信息,后台会根据我们的公参获取到我们的版本号渠道号
*
@@ -26,10 +18,6 @@ public interface IUpgradeModel {
*/
Single checkUpgrade();
- boolean isDownloading();
-
- void stopDownload();
-
void setHasShowDialog(boolean flag);
boolean isHasShowDialog();
diff --git a/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/UpgradeModel.java b/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/UpgradeModel.java
index 0edefd7e2..3e06b02b3 100644
--- a/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/UpgradeModel.java
+++ b/core/src/model_upgrade_app/java/com/yizhuan/xchat_android_core/upgrade/model/UpgradeModel.java
@@ -1,22 +1,5 @@
package com.yizhuan.xchat_android_core.upgrade.model;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.FileProvider;
-
-import com.liulishuo.okdownload.DownloadSerialQueue;
-import com.liulishuo.okdownload.DownloadTask;
-import com.liulishuo.okdownload.core.cause.EndCause;
-import com.liulishuo.okdownload.core.cause.ResumeFailedCause;
-import com.liulishuo.okdownload.core.listener.DownloadListener1;
-import com.liulishuo.okdownload.core.listener.assist.Listener1Assist;
import com.yizhuan.xchat_android_core.R;
import com.yizhuan.xchat_android_core.base.BaseModel;
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
@@ -24,12 +7,6 @@ import com.yizhuan.xchat_android_core.upgrade.bean.NewestVersionInfo;
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
import com.yizhuan.xchat_android_library.net.rxnet.RxNet;
import com.yizhuan.xchat_android_library.utils.ResUtil;
-import com.yizhuan.xchat_android_library.utils.codec.MD5Utils;
-import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Objects;
import io.reactivex.Single;
import io.reactivex.SingleSource;
@@ -45,13 +22,6 @@ public class UpgradeModel extends BaseModel implements IUpgradeModel {
private static final String TAG = "UpgradeModel";
- private NewestVersionInfo newestVersionInfo;
- private DownloadSerialQueue serialQueue;
- private DownloadTask downloadTask;
-
- private DownLoadListener downLoadListener;
- private boolean isDownloading = false;
-
private final Api api;
private static IUpgradeModel model;
@@ -74,133 +44,8 @@ public class UpgradeModel extends BaseModel implements IUpgradeModel {
private UpgradeModel() {
api = RxNet.create(Api.class);
- serialQueue = new DownloadSerialQueue(new DownloadListener1() {
- @Override
- public void taskStart(@NonNull DownloadTask task, @NonNull Listener1Assist.Listener1Model model) {
- Log.e(TAG, "taskStart() called with: task = [" + task + "], model = [" + model + "]");
- if (task.getId() != downloadTask.getId()) {
- return;
- }
- if (downLoadListener == null) {
- return;
- }
- downLoadListener.onStart();
- }
-
- @Override
- public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) {
- Log.e(TAG, "retry() called with: task = [" + task + "], cause = [" + cause + "]");
-
- }
-
- @Override
- public void connected(@NonNull DownloadTask task, int blockCount, long currentOffset, long totalLength) {
- Log.e(TAG, "connected() called with: task = [" + task + "], blockCount = [" + blockCount + "], currentOffset = [" + currentOffset + "], totalLength = [" + totalLength + "]");
- }
-
- @Override
- public void progress(@NonNull DownloadTask task, long currentOffset, long totalLength) {
- Log.e(TAG, "progress() called with: task = [" + task + "], currentOffset = [" + currentOffset + "], totalLength = [" + totalLength + "]");
- if (task.getId() != downloadTask.getId()) {
- return;
- }
- if (downLoadListener == null) {
- return;
- }
- downLoadListener.onProgress(currentOffset, totalLength);
- }
-
- @Override
- public void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause, @NonNull Listener1Assist.Listener1Model model) {
- Log.e(TAG, "taskEnd() called with: task = [" + task + "], cause = [" + cause + "], realCause = [" + realCause + "], model = [" + model + "]");
- if (task.getId() != downloadTask.getId()) {
- return;
- }
- downloadTask = null;
- if (downLoadListener == null) {
- return;
- }
-
- if (cause != EndCause.COMPLETED) {
- if (realCause != null) {
- downLoadListener.onError(ResUtil.getString(R.string.upgrade_model_upgrademodel_01));
- } else {
- downLoadListener.onError(ResUtil.getString(R.string.upgrade_model_upgrademodel_02));
- }
- downLoadListener = null;
- return;
- }
-
- try {
- String downloadFileMD5 = MD5Utils.getFileMD5String(task.getFile());
- if (Objects.equals(downloadFileMD5, newestVersionInfo.getUpdateFileMd5())) {
- downLoadListener.onComplete(task.getFile());
- installApp(task.getFile());
- } else {
- downLoadListener.onError(ResUtil.getString(R.string.upgrade_model_upgrademodel_03));
- }
- downLoadListener = null;
- } catch (IOException e) {
- e.printStackTrace();
- downLoadListener.onError(e.getMessage());
- downLoadListener = null;
- }
-
- }
- });
}
- /**
- * 安装
- */
- private void installApp(File file) {
- try {
- Intent install = new Intent(Intent.ACTION_VIEW);
- install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- Uri contentUri = FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider", file);
- install.setDataAndType(contentUri, "application/vnd.android.package-archive");
- } else {
- install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
- }
- BasicConfig.INSTANCE.getAppContext().startActivity(install);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * 下载新版本
- *
- * @param downLoadListener
- * @return
- */
- @Override
- public Single downloadNewVersion(DownLoadListener downLoadListener) {
- if (null == newestVersionInfo || TextUtils.isEmpty(newestVersionInfo.getUpdateDownloadLink())) {
- return Single.error(new Throwable(ResUtil.getString(R.string.upgrade_model_upgrademodel_04)));
- }
- if (downloadTask != null) {
- return Single.error(new Throwable(ResUtil.getString(R.string.upgrade_model_upgrademodel_05)));
- }
-
- this.downLoadListener = downLoadListener;
- downloadTask = new DownloadTask.Builder(newestVersionInfo.getUpdateDownloadLink(),
- Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS))
- .setFilenameFromResponse(true)
- .setMinIntervalMillisCallbackProcess(100)
- .setPassIfAlreadyCompleted(false)
- .setAutoCallbackToUIThread(true)
- .build();
- serialQueue.enqueue(downloadTask);
-
- return Single.just(ResUtil.getString(R.string.upgrade_model_upgrademodel_06));
- }
-
-
/**
* 获取最新版本信息,后台会根据我们的公参获取到我们的版本号渠道号
*
@@ -210,38 +55,18 @@ public class UpgradeModel extends BaseModel implements IUpgradeModel {
public Single checkUpgrade() {
return api.loadNewestVersion()
.compose(RxHelper.handleSchedulers())
- .flatMap(new Function, SingleSource>() {
- @Override
- public SingleSource apply(ServiceResult respone) throws Exception {
- if (respone.isSuccess() && respone.getData() == null) {
- return Single.error(new Throwable(ResUtil.getString(R.string.upgrade_model_upgrademodel_07)));
- }
- if (respone.isSuccess() && respone.getData() != null) {
- newestVersionInfo = respone.getData();
- return Single.just(respone.getData());
- }
- return Single.error(new Throwable(respone.getMessage()));
+ .flatMap((Function, SingleSource>) respone -> {
+ if (respone.isSuccess() && respone.getData() == null) {
+ return Single.error(new Throwable(ResUtil.getString(R.string.upgrade_model_upgrademodel_07)));
}
+ if (respone.isSuccess() && respone.getData() != null) {
+ return Single.just(respone.getData());
+ }
+ return Single.error(new Throwable(respone.getMessage()));
});
}
- @Override
- public boolean isDownloading() {
- if (downloadTask == null) {
- return false;
- }
- return serialQueue.getWorkingTaskId() != 0;
- }
-
- @Override
- public void stopDownload() {
- if (downloadTask != null) {
- downloadTask.cancel();
- }
- }
-
-
@Override
public void setHasShowDialog(boolean flag) {
this.hasShowDialog = flag;
@@ -252,17 +77,6 @@ public class UpgradeModel extends BaseModel implements IUpgradeModel {
return hasShowDialog;
}
- public interface DownLoadListener {
- public void onStart();
-
- public void onComplete(File file);
-
- public void onProgress(long currentOffset, long totalLength);
-
- public void onError(String reason);
- }
-
-
private interface Api {
/**
* 获取最新版本信息