Commit 3c5b8251 authored by jyx's avatar jyx

代码优化

parent a24c1beb
...@@ -180,7 +180,7 @@ dependencies { ...@@ -180,7 +180,7 @@ dependencies {
// 三方接入 // 三方接入
// leakcanary // leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4' // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
// 极光推送 // 极光推送
implementation 'cn.jiguang.sdk:jpush:3.6.6' implementation 'cn.jiguang.sdk:jpush:3.6.6'
implementation 'cn.jiguang.sdk:jcore:2.3.8' implementation 'cn.jiguang.sdk:jcore:2.3.8'
......
...@@ -172,7 +172,8 @@ object Constant { ...@@ -172,7 +172,8 @@ object Constant {
// share // share
const val SHARE_TITLE = "发现一个二傻子平台,人傻钱多,速来~一起薅死他~~" const val SHARE_TITLE = "发现一个二傻子平台,人傻钱多,速来~一起薅死他~~"
var SHARE_CONTENT = "邀请码【${UserManager.getInstance().codeID}】,共享新模式,快来加入跟我一起赚钱吧" var SHARE_CONTENT = "邀请码【${UserManager.getInstance().codeID}】,共享新模式,快来加入跟我一起赚钱吧"
var SHARE_URL: String = BuildConfig.MainIp + "share/shareFriend.html?ruid=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME") // var SHARE_URL: String = BuildConfig.MainIp + "share/shareFriend.html?ruid=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
var SHARE_URL: String = BuildConfig.MainIp + "wxShare/toShare?shareId=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
// 首页视频时长 单位-秒 // 首页视频时长 单位-秒
const val MAIN_VEDIO_TIME = "main_vedio_time" const val MAIN_VEDIO_TIME = "main_vedio_time"
......
...@@ -3,7 +3,6 @@ package com.mints.goodmoney.manager; ...@@ -3,7 +3,6 @@ package com.mints.goodmoney.manager;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.widget.FrameLayout; import android.widget.FrameLayout;
...@@ -20,7 +19,6 @@ public class TTPreLoadCarrierExpressManager { ...@@ -20,7 +19,6 @@ public class TTPreLoadCarrierExpressManager {
private HandlerThread mHandlerThread; private HandlerThread mHandlerThread;
private Handler mWorkHandler; private Handler mWorkHandler;
private Handler mMainHandler = new Handler(Looper.getMainLooper());
private int mTTPreLoadWhat = 0x3243434; private int mTTPreLoadWhat = 0x3243434;
...@@ -31,7 +29,7 @@ public class TTPreLoadCarrierExpressManager { ...@@ -31,7 +29,7 @@ public class TTPreLoadCarrierExpressManager {
return _inst; return _inst;
} }
public void init() { private void init() {
ttNativeExpressManager = new TTNativeExpressManager(); ttNativeExpressManager = new TTNativeExpressManager();
ttNativeExpressManager.initTTAd(false); ttNativeExpressManager.initTTAd(false);
...@@ -53,6 +51,10 @@ public class TTPreLoadCarrierExpressManager { ...@@ -53,6 +51,10 @@ public class TTPreLoadCarrierExpressManager {
} }
public void onDestroy() { public void onDestroy() {
if (ttNativeExpressManager != null) {
ttNativeExpressManager.onTTAdDestroy();
ttNativeExpressManager = null;
}
if (mHandlerThread != null) { if (mHandlerThread != null) {
mHandlerThread.quit(); mHandlerThread.quit();
mHandlerThread = null; mHandlerThread = null;
...@@ -73,8 +75,7 @@ public class TTPreLoadCarrierExpressManager { ...@@ -73,8 +75,7 @@ public class TTPreLoadCarrierExpressManager {
try { try {
ttFrameLayout = new FrameLayout(context); ttFrameLayout = new FrameLayout(context);
ttNativeExpressManager.getNativeExpressInit(codeId, ttFrameLayout, 340, 0); ttNativeExpressManager.getNativeExpressInit(codeId, ttFrameLayout, 340, 0);
ttNativeExpressManager.setTTNativeExpressManagerListener(view -> mMainHandler.post(() -> { ttNativeExpressManager.setTTNativeExpressManagerListener(view -> {
// 主线程更新UI操作
if (view == null) { if (view == null) {
ttFrameLayout = null; ttFrameLayout = null;
...@@ -87,7 +88,7 @@ public class TTPreLoadCarrierExpressManager { ...@@ -87,7 +88,7 @@ public class TTPreLoadCarrierExpressManager {
ttFrameLayout = null; ttFrameLayout = null;
} }
} }
})); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -98,6 +99,8 @@ public class TTPreLoadCarrierExpressManager { ...@@ -98,6 +99,8 @@ public class TTPreLoadCarrierExpressManager {
* 预加载 信息流 * 预加载 信息流
*/ */
public void loadTtFrameLayout(String codeId) { public void loadTtFrameLayout(String codeId) {
init();
if (mWorkHandler != null) { if (mWorkHandler != null) {
Message msg = Message.obtain(); Message msg = Message.obtain();
msg.what = mTTPreLoadWhat; msg.what = mTTPreLoadWhat;
......
...@@ -13,16 +13,14 @@ public class TTPreLoadExpressManager { ...@@ -13,16 +13,14 @@ public class TTPreLoadExpressManager {
private TTNativeExpressManager ttNativeExpressManager; private TTNativeExpressManager ttNativeExpressManager;
public static TTPreLoadExpressManager getInstance() { public static TTPreLoadExpressManager getInstance() {
if (_inst != null) { if (_inst == null) {
return _inst;
} else {
_inst = new TTPreLoadExpressManager(); _inst = new TTPreLoadExpressManager();
return _inst;
} }
return _inst;
} }
private TTPreLoadExpressManager() { private TTPreLoadExpressManager() {
init(); // init();
} }
private void init() { private void init() {
...@@ -30,6 +28,11 @@ public class TTPreLoadExpressManager { ...@@ -30,6 +28,11 @@ public class TTPreLoadExpressManager {
ttNativeExpressManager.initTTAd(false); ttNativeExpressManager.initTTAd(false);
} }
public void onDestroy(){
ttNativeExpressManager.onTTAdDestroy();
ttNativeExpressManager = null;
}
public FrameLayout getTtFrameLayout() { public FrameLayout getTtFrameLayout() {
return ttFrameLayout; return ttFrameLayout;
} }
...@@ -38,6 +41,8 @@ public class TTPreLoadExpressManager { ...@@ -38,6 +41,8 @@ public class TTPreLoadExpressManager {
* 预加载 信息流 * 预加载 信息流
*/ */
public void loadTtFrameLayout() { public void loadTtFrameLayout() {
init();
Context context = MintsApplication.getContext(); Context context = MintsApplication.getContext();
ttFrameLayout = null; ttFrameLayout = null;
try { try {
......
...@@ -225,8 +225,8 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener { ...@@ -225,8 +225,8 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
e.printStackTrace() e.printStackTrace()
} }
TTPreLoadExpressManager.getInstance().onDestroy()
flAwardAd?.removeAllViews() flAwardAd?.removeAllViews()
vedioAdingManager.setVedioAdingListener(null) vedioAdingManager.setVedioAdingListener(null)
vedioAdingManager.onDestory() vedioAdingManager.onDestory()
......
...@@ -23,9 +23,7 @@ import com.mints.library.utils.CommonUtils ...@@ -23,9 +23,7 @@ import com.mints.library.utils.CommonUtils
import com.mints.library.utils.json.JsonUtil import com.mints.library.utils.json.JsonUtil
import kotlinx.android.synthetic.main.activity_drawcash.* import kotlinx.android.synthetic.main.activity_drawcash.*
import kotlinx.android.synthetic.main.header_layout.* import kotlinx.android.synthetic.main.header_layout.*
import kotlinx.android.synthetic.main.item_fragment_main_my_title.*
import kotlinx.android.synthetic.main.view_title.* import kotlinx.android.synthetic.main.view_title.*
import net.grandcentrix.tray.AppPreferences
import java.math.BigDecimal import java.math.BigDecimal
import java.util.* import java.util.*
......
...@@ -50,6 +50,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie ...@@ -50,6 +50,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
svWalk?.destoryAnim() svWalk?.destoryAnim()
flSubsidykAd?.removeAllViews() flSubsidykAd?.removeAllViews()
TTPreLoadCarrierExpressManager.getInstance().onDestroy()
foodSubsidyPresenter.detachView() foodSubsidyPresenter.detachView()
} }
......
...@@ -72,7 +72,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener { ...@@ -72,7 +72,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
super.onDestroy() super.onDestroy()
TTPreLoadCarrierExpressManager.getInstance().onDestroy()
VedioAdingManager.getInstance(this).setVedioAdingListener(null) VedioAdingManager.getInstance(this).setVedioAdingListener(null)
VedioAdingManager.getInstance(this).onDestory() VedioAdingManager.getInstance(this).onDestory()
} }
......
...@@ -363,31 +363,31 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, View.OnC ...@@ -363,31 +363,31 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, View.OnC
} }
R.id.btn_invite -> { R.id.btn_invite -> {
// 邀请好友 // 邀请好友
// shareImgDialog() shareImgDialog()
if (!UserManager.getInstance().userIsLogin()) { // if (!UserManager.getInstance().userIsLogin()) {
readyGo(LoginActivity::class.java) // readyGo(LoginActivity::class.java)
return // return
} // }
//
if (!ps.getBoolean(Constant.FIRST_SHARE_INVITED, false)) { // if (!ps.getBoolean(Constant.FIRST_SHARE_INVITED, false)) {
// 第一次邀请提示弹框 // // 第一次邀请提示弹框
firstWeChatInvite() // firstWeChatInvite()
} else { // } else {
val wechatSp = Platform.ShareParams() // val wechatSp = Platform.ShareParams()
wechatSp.shareType = Platform.SHARE_WEBPAGE // wechatSp.shareType = Platform.SHARE_WEBPAGE
wechatSp.title = Constant.SHARE_TITLE // wechatSp.title = Constant.SHARE_TITLE
wechatSp.text = Constant.SHARE_CONTENT // wechatSp.text = Constant.SHARE_CONTENT
wechatSp.imageData = ImageUtil.drawableToBitmap(ContextCompat.getDrawable(requireContext(), R.mipmap.ic_launcher)) // wechatSp.imageData = ImageUtil.drawableToBitmap(ContextCompat.getDrawable(requireContext(), R.mipmap.ic_launcher))
wechatSp.url = Constant.SHARE_URL // wechatSp.url = Constant.SHARE_URL
val wechat = ShareSDK.getPlatform(Wechat.NAME) // val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (wechat.isClientValid) { // if (wechat.isClientValid) {
// 执行图文分享 // // 执行图文分享
wechat.share(wechatSp) // wechat.share(wechatSp)
} else { // } else {
showToast("请先安装微信") // showToast("请先安装微信")
} // }
} // }
} }
R.id.tv_right_subtitle -> { R.id.tv_right_subtitle -> {
......
...@@ -75,7 +75,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener { ...@@ -75,7 +75,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
// 奖励页预加载 信息流广告 // 奖励页预加载 信息流广告
TTPreLoadExpressManager.getInstance().loadTtFrameLayout() TTPreLoadExpressManager.getInstance().loadTtFrameLayout()
// 喝水页预加载 信息流广告 // 喝水页预加载 信息流广告
TTPreLoadCarrierExpressManager.getInstance().init() // TTPreLoadCarrierExpressManager.getInstance().init()
// 首次显示权限弹窗 // 首次显示权限弹窗
showPowerDialog() showPowerDialog()
......
...@@ -441,6 +441,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi ...@@ -441,6 +441,7 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
0 -> { 0 -> {
if (!userManager.userIsLogin()) { if (!userManager.userIsLogin()) {
readyGo(LoginActivity::class.java) readyGo(LoginActivity::class.java)
return
} }
if (!ps.getBoolean(Constant.FIRST_SHARE_MY, false)) { if (!ps.getBoolean(Constant.FIRST_SHARE_MY, false)) {
......
...@@ -66,6 +66,10 @@ class ShareDialog(context: Context) : ...@@ -66,6 +66,10 @@ class ShareDialog(context: Context) :
shareWechat() shareWechat()
} }
llDialogShareQq.setOnClickListener {
shareWechatFavoite()
}
tvDialogShareNext.setOnClickListener { tvDialogShareNext.setOnClickListener {
dismiss() dismiss()
} }
......
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
android:textSize="10sp" /> android:textSize="10sp" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<View <View
...@@ -75,7 +74,7 @@ ...@@ -75,7 +74,7 @@
android:layout_height="1px" android:layout_height="1px"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:background="@color/gray" /> android:background="@color/my_color_gray3" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
android:id="@+id/ll_food" android:id="@+id/ll_food"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
...@@ -44,11 +43,11 @@ ...@@ -44,11 +43,11 @@
<FrameLayout <FrameLayout
android:id="@+id/flSubsidykAd" android:id="@+id/flSubsidykAd"
android:layout_width="wrap_content" android:layout_width="340dp"
android:layout_height="wrap_content" android:layout_height="340dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:background="@color/full_transparent"/> android:background="@color/full_transparent" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
...@@ -86,10 +86,10 @@ ...@@ -86,10 +86,10 @@
<FrameLayout <FrameLayout
android:id="@+id/flMorningClockAd" android:id="@+id/flMorningClockAd"
android:layout_width="wrap_content" android:layout_width="340dp"
android:layout_height="wrap_content" android:layout_height="340dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@color/full_transparent"> android:background="@color/full_transparent">
</FrameLayout> </FrameLayout>
......
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
<FrameLayout <FrameLayout
android:id="@+id/flWalkAd" android:id="@+id/flWalkAd"
android:layout_width="wrap_content" android:layout_width="340dp"
android:layout_height="wrap_content" android:layout_height="340dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:background="@color/full_transparent"/> android:background="@color/full_transparent"
android:layout_gravity="center_horizontal" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
<FrameLayout <FrameLayout
android:id="@+id/flWaterAd" android:id="@+id/flWaterAd"
android:layout_width="wrap_content" android:layout_width="340dp"
android:layout_height="wrap_content" android:layout_height="340dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:background="@color/full_transparent" /> android:background="@color/full_transparent" />
......
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