Commit 8a4c3b5d authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 0b5c6d63
......@@ -128,10 +128,6 @@
android:name=".ui.activitys.AboutusActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.AwardActivity"
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.activitys.LoadingActivity"
android:exported="false"
......
......@@ -10,6 +10,8 @@ public class AppConfig {
public static boolean app_updateing = false;
public static boolean mainShowHalfAd = false;
public static int fragmentClickFlag = 0;
public static int riskPercentage = 0;
public static String gromoreId = "";
public static int awardRedpkg = 0;
public static int awardYuanbao = 0;
......
......@@ -13,6 +13,7 @@ import com.duben.dayplaylet.utils.ToastUtil
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import com.duben.library.utils.json.JsonUtil
import com.google.gson.JsonObject
import java.lang.ref.WeakReference
/**
......@@ -39,7 +40,7 @@ object AlipayAuthManager {
// 获取alipay_open_id,调支付时作为参数extern_token 的value
// 传入,则支付账户为该授权账户
UserManager.getInstance().alipaySet = true
println("mcg -->>>>> authinfo="+JsonUtil.toJson(authResult))
println("mcg -->>>>> authinfo=" + JsonUtil.toJson(authResult))
authListener?.authSuccess()
commitAlipayAutoInfo(JsonUtil.toJson(authResult))
} else {
......@@ -54,10 +55,11 @@ object AlipayAuthManager {
private fun commitAlipayAutoInfo(info: String) {
val vo = HashMap<String, Any>()
vo.put("authInfo", info)
vo.put("user_id", UserManager.getInstance().userID)
vo.put("result", info)
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.cancelCollect(vo),
.call(baseApplication.loanService.reportAlipayMsg(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onError(e: Throwable) {
......@@ -76,19 +78,20 @@ object AlipayAuthManager {
authListener = listener
val weakReference = WeakReference(activity)
println("mcg -->>>>> 开始授权")
val vo = HashMap<String, Any>()
vo.put("user_id", UserManager.getInstance().userID)
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.getAlipayAuthUrl(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onError(e: Throwable) {
}
// val baseApplication = MintsApplication.getContext() as MintsApplication
// AppHttpManager.getInstance(baseApplication)
// .call(baseApplication.loanService.homeV1Types,
// object : BaseSubscriber<BaseResponse<Any>>() {
// override fun onError(e: Throwable) {
//
// }
//
//
// override fun onNext(t: BaseResponse<Any>) {
// if (t.status == 200) {
val authInfo = ""
override fun onNext(t: BaseResponse<JsonObject>) {
if (t.status == 200) {
val data = t.data
val authInfo = data["url"].asString
val authRunnable = Runnable { // 构造AuthTask 对象
val authTask = AuthTask(weakReference.get())
// 调用授权接口,获取授权结果
......@@ -102,11 +105,11 @@ object AlipayAuthManager {
// 必须异步调用
val authThread = Thread(authRunnable)
authThread.start()
// } else {
// ToastUtil.show(MintsApplication.getContext(), t.message)
// }
// }
// })
} else {
ToastUtil.show(MintsApplication.getContext(), t.message)
}
}
})
}
private var authListener: AuthListener? = null
......
......@@ -11,6 +11,16 @@ public class UserBean implements Serializable {
private UserMsgBean userMsg;
private int riskPercentage;
public int getRiskPercentage() {
return riskPercentage;
}
public void setRiskPercentage(int riskPercentage) {
this.riskPercentage = riskPercentage;
}
public UserMsgBean getUserMsg() {
return userMsg;
}
......
......@@ -283,48 +283,6 @@ public class TrackPresenter extends BaseTrackPresenter {
});
}
public void saveTerminalInfo() {
HashMap<String, Object> vo = new HashMap<>();
DeviceInfo deviceInfo = DeviceInfo.Companion.getInstance();
String macAddress = deviceInfo.getMacAddress();
String mac = macAddress.replace(":", "");
vo.put("androidid", deviceInfo.getAndroidId(null));
vo.put("mac", mac);
vo.put("mac1", macAddress);
vo.put("os", "android");
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", new DeviceUuidFactory().getDeviceUuid());
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
vo.put("oaid", MintsApplication.OAID);
vo.put("imei", deviceInfo.getIMEI());
vo.put("shumeiId", ShumeiManager.getInstance().getShumeiDeviceId());
AppHttpManager.getInstance(loanApplication)
.call(loanService.saveTerminalInfo(vo),
new BaseSubscriber<BaseResponse<Object>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
switch (baseResponse.getStatus()) {
case 200: {
getMyInfo();
}
}
}
});
}
public void commitVedio(HashMap<String, Object> vo) {
AppHttpManager.getInstance(loanApplication)
.call(loanService.reportIndex(vo),
......@@ -453,6 +411,8 @@ public class TrackPresenter extends BaseTrackPresenter {
AppConfig.awardRedpkg = data.get("coin").getAsInt();
AppConfig.awardYuanbao = data.get("di").getAsInt();
}
}
} catch (Exception e) {
e.printStackTrace();
......@@ -478,7 +438,7 @@ public class TrackPresenter extends BaseTrackPresenter {
@Override
public void onNext(BaseResponse<JsonObject> baseResponse) {
if (baseResponse.getStatus() != 200) {
ToastUtil.show(MintsApplication.getContext(), baseResponse.getMessage());
ToastUtil.showLong(MintsApplication.getContext(), baseResponse.getMessage());
}
}
});
......
......@@ -329,6 +329,18 @@ public interface LoanService {
@POST("na/addTag")
Observable<BaseResponse<Object>> riskCmtInfo(@Body Map<String, Object> vo);
/**
* 支付宝获取授权
*/
@POST("api/user/getAlipayAuthUrl")
Observable<BaseResponse<JsonObject>> getAlipayAuthUrl(@Body Map<String, Object> vo);
/**
* 风控标记
*/
@POST("api/user/reportAlipayMsg")
Observable<BaseResponse<Object>> reportAlipayMsg(@Body Map<String, Object> vo);
/**
* 默认http工厂
*/
......
package com.duben.dayplaylet.ui.activitys
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import com.duben.dayplaylet.R
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.mvp.model.CoinMsgBean
import com.duben.dayplaylet.mvp.presenters.AwardPresenter
import com.duben.dayplaylet.mvp.views.AwardView
import com.duben.dayplaylet.ui.activitys.base.BaseActivity
import com.duben.dayplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import com.duben.dayplaylet.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.duben.library.utils.nodoubleclick.AntiShake
import java.math.BigDecimal
/**
* 奖励弹窗
*/
class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
private val awardPresenter by lazy { AwardPresenter() }
private var mTimer: CountDownTimerSupport? = null
companion object {
const val REDPACKET = "REDPACKET"
const val YUANBAO = "YUANBAO"
const val CARRIERTYPE = "CARRIERTYPE"
}
private var redPacket = 0.0
private var yuanbao = 0
private var carrierType = ""
override fun getContentViewLayoutID() = R.layout.activity_award
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
redPacket = it.getDouble(REDPACKET, 0.0)
if (redPacket == 0.0) {
redPacket=AppConfig.awardRedpkg.toDouble()
}
yuanbao = it.getInt(YUANBAO, 0)
if (yuanbao == 0) {
yuanbao = AppConfig.awardYuanbao
}
carrierType = it.getString(carrierType, "")
}
}
override fun initViewsAndEvents() {
awardPresenter.attachView(this)
initListener()
startTime()
}
private fun initListener() {
// tv_nine_know_next.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
if (!this@AwardActivity.isFinishing) {
// if (AntiShake.check(icAwardBg?.id)) return
awardPresenter.getCoinMsg()
}
}
override fun finish() {
super.finish()
hideLoading()
AppConfig.awardRedpkg = 0
AppConfig.awardYuanbao = 0
AppConfig.gromoreId = ""
overridePendingTransition(0, R.anim.scale_out)
}
override fun onDestroy() {
AppConfig.awardRedpkg = 0
AppConfig.awardYuanbao = 0
AppConfig.gromoreId = ""
mTimer?.stop()
mTimer = null
awardPresenter.detachView()
super.onDestroy()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(
keyCode,
event
)
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
// R.id.tv_nine_know_next -> {
// finish()
// }
}
}
/**
* 弹窗倒计时
*/
private fun startTime() {
mTimer = CountDownTimerSupport(3000L, 1000L)
mTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener {
override fun onTick(millisUntilFinished: Long) {
if (!this@AwardActivity.isFinishing) {
// 防止时时获取不到金币 , 倒计时延迟展示
if (millisUntilFinished == 1000L && (AppConfig.awardRedpkg > 0 || AppConfig.awardYuanbao > 0)) {
//
}
}
}
override fun onFinish() {
if (!this@AwardActivity.isFinishing) {
}
}
})
mTimer?.start()
}
override fun getUserTaskMsgSuc(data: CoinMsgBean) {
if (!this@AwardActivity.isFinishing) {
val sumCoin = data.coin.toString()
val allcoinBig = BigDecimal(sumCoin)
val rateBig = BigDecimal("10000")
val cashStr = allcoinBig.divide(rateBig).setScale(2, BigDecimal.ROUND_DOWN).toString()
// 更新金币数
// UserManager.getInstance().userGold = data.coin.toString()
}
}
}
\ No newline at end of file
......@@ -128,7 +128,9 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (AppConfig.mainShowHalfAd) {
AppConfig.mainShowHalfAd = false
Handler(Looper.getMainLooper()).postDelayed({
HalfScreenManager.getInstance().showAd(requireActivity(), null)
}, 200)
}
}
}
......@@ -291,6 +293,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (AppConfig.fragmentClickFlag != Constant.FRAGMENT_CLICK_ONE) return
this.userInfo = user.userMsg
AppConfig.riskPercentage = user.riskPercentage
UserManager.getInstance().saveUserInfo(user)
tv_cash.text = "${FormatUtil.getCashFormaet(user.userMsg.coin)}元"
......@@ -529,7 +532,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败" + resultStatus)
showToast("支付宝授权失败 " + resultStatus)
}
})
}
......
......@@ -32,15 +32,14 @@ import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.express.MyExpressManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.DPHolder
import com.duben.dayplaylet.mvp.model.MusicBean
import com.duben.dayplaylet.mvp.presenters.MusicPresenter
import com.duben.dayplaylet.mvp.views.MusicView
import com.duben.dayplaylet.ui.activitys.NineActivity
import com.duben.dayplaylet.ui.activitys.MainActivity
import com.duben.dayplaylet.ui.activitys.NineActivity
import com.duben.dayplaylet.ui.activitys.SongAwardActivity
import com.duben.dayplaylet.ui.fragment.base.LazyLoadBaseFragment
import com.duben.dayplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
......@@ -637,13 +636,6 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
}, 800)
}, 100)
}
HalfScreenManager.getInstance().preLoadAd(requireActivity())
mainHandler.postDelayed({
HalfScreenManager.getInstance().showAd(requireActivity(), null)
cl_reward.visibility = View.GONE
}, 1500)
}
override fun reportAddCoinMsgSuc(coin: Int, di: Int) {
......@@ -670,8 +662,6 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
}
private fun awardVideo(carrierType: String) {
HalfScreenManager.getInstance().preLoadAd(requireActivity())
AdManager.instance.showAd(requireActivity(), carrierType,
object : AdStatusListener {
var canFail = false
......
......@@ -180,8 +180,6 @@ class RedpkgFragment : LazyLoadBaseFragment(), View.OnClickListener, RedpkgView
private fun awardVideo(carrierType: String, cash: Double, unitId: String = "") {
mCarrierType = carrierType
HalfScreenManager.getInstance().preLoadAd(requireActivity())
AdManager.instance.showAd(requireActivity(), carrierType,
object : AdStatusListener {
var canFail = false
......@@ -378,8 +376,6 @@ class RedpkgFragment : LazyLoadBaseFragment(), View.OnClickListener, RedpkgView
}
private fun showRedPkgAwardDialog(cash: Int, showBtn: Boolean) {
HalfScreenManager.getInstance().preLoadAd(requireActivity())
mRedPkgAwardDialog =
RedPkgAwardDialog(
requireContext(),
......@@ -395,7 +391,6 @@ class RedpkgFragment : LazyLoadBaseFragment(), View.OnClickListener, RedpkgView
awardVideo(Constant.CARRIERTYPE_REWARD_HONGBAO_MORE, 0.0)
}
R.id.ib_close -> {
HalfScreenManager.getInstance().showAd(requireActivity(), null)
}
else -> {}
}
......
......@@ -33,9 +33,7 @@
android:layout_marginTop="110dp"
android:layout_marginRight="20dp"
android:background="@drawable/shape_bg_task"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_award_redpkg"
......@@ -44,9 +42,9 @@
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingLeft="8dp"
android:paddingTop="16dp"
android:paddingRight="10dp"
android:paddingRight="8dp"
android:paddingBottom="6dp">
<ImageView
......@@ -70,6 +68,7 @@
android:paddingLeft="18dp"
android:paddingTop="3dp"
android:paddingRight="18dp"
android:singleLine="true"
android:paddingBottom="3dp"
android:text="+10"
android:textColor="@color/red"
......@@ -111,6 +110,7 @@
android:gravity="center"
android:paddingLeft="18dp"
android:paddingTop="3dp"
android:singleLine="true"
android:paddingRight="18dp"
android:paddingBottom="3dp"
android:text="+10"
......
......@@ -18,11 +18,11 @@
android:orientation="vertical">
<ImageView
android:layout_marginTop="10dp"
android:id="@+id/iv_award_quit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_draw_quit" />
......@@ -33,9 +33,7 @@
android:layout_marginTop="90dp"
android:layout_marginRight="20dp"
android:background="@drawable/shape_bg_task"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_award_redpkg"
......@@ -71,6 +69,7 @@
android:paddingTop="3dp"
android:paddingRight="18dp"
android:paddingBottom="3dp"
android:singleLine="true"
android:text="+10"
android:textColor="@color/red"
android:textSize="18sp"></TextView>
......@@ -122,6 +121,7 @@
android:paddingTop="3dp"
android:paddingRight="18dp"
android:paddingBottom="3dp"
android:singleLine="true"
android:text="+10"
android:textColor="@color/red"
android:textSize="18sp"></TextView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment