Commit 07483780 authored by jyx's avatar jyx

代码优化

parent 92581452
......@@ -8,6 +8,7 @@ import cn.jpush.android.api.BasicPushNotificationBuilder
import cn.jpush.android.api.JPushInterface
import com.downloader.PRDownloader
import com.downloader.PRDownloaderConfig
import com.mints.flowbox.manager.YlVideoManager
import com.mob.MobSDK
/**
......@@ -60,6 +61,8 @@ class InitAppService : IntentService("InitializeService") {
// PR下载附件
initPRDownloader()
// 一览视频
YlVideoManager.init(MintsApplication.getContext())
}
/**
......
......@@ -33,6 +33,7 @@ import com.mints.flowbox.manager.MiitHelper;
import com.mints.flowbox.manager.ad.OwManager;
import com.mints.flowbox.manager.ad.TzManager;
import com.mints.flowbox.manager.ad.WnManager;
import com.mints.flowbox.manager.ad.XmManager;
import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.net.LoanService;
import com.mints.flowbox.ui.activitys.ApkActivity;
......@@ -103,6 +104,8 @@ public class MintsApplication extends BaseApp {
// TODO 加ua字段
initKeepAlive();
// XmManager.INSTANCE.init(this);
// 三方配置
// thirdConfig();
}
......@@ -398,6 +401,30 @@ public class MintsApplication extends BaseApp {
*/
private void thirdConfig() {
if (!getProcessName(this).contains(":")) {
System.out.println("mints ------------> MainProgress <------------");
XmManager.INSTANCE.init(this);
// 天卓珊瑚
TzManager.INSTANCE.initTz(this);
// 自定义logger
bindLogger();
// 子线程初始化三方SDK
String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid());
if (processName != null) {
// 判断onCreate方法执行是否在当前应用的application上
boolean defaultProcess = TextUtils.equals(processName, Constant.MINTS_PKG_NAME);
if (defaultProcess) {
InitAppService.Companion.start(this); //初始化数据
}
}
}
System.out.println("mints ------------> thirdConfig <------------");
// 初始化toast
......@@ -411,22 +438,6 @@ public class MintsApplication extends BaseApp {
// 闪电盒子
WnManager.INSTANCE.initWn(this);
// 天卓珊瑚
TzManager.INSTANCE.initTz(this);
// 自定义logger
bindLogger();
// 子线程初始化三方SDK
String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid());
if (processName != null) {
// 判断onCreate方法执行是否在当前应用的application上
boolean defaultProcess = TextUtils.equals(processName, Constant.MINTS_PKG_NAME);
if (defaultProcess) {
InitAppService.Companion.start(this); //初始化数据
}
}
}
/**
......
......@@ -5,10 +5,12 @@ import android.os.Message;
import com.bytedance.msdk.adapter.util.WeakHandler;
import com.mints.flowbox.MintsApplication;
import com.mints.flowbox.ad.express.ExpressManager;
import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.manager.TrackManager;
import com.mints.flowbox.ui.activitys.BoostActivity;
import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.utils.LogUtil;
/**
* 描述:应用外广告定时器
......@@ -24,6 +26,7 @@ public class AlarmManager implements WeakHandler.IHandler {
public static final int APP_OUT_CLEAR_MINTER = 10;//单位-分钟,应用外清理
public static final long ONE_MINTER_Interval = 60 * 1000;//60秒
public static final long TEN_SECOND_Interval = 10 * 1000;//10秒
public static final int MSG1 = 1001;
private volatile int curTime = 1;//每分钟变一次
......@@ -65,10 +68,16 @@ public class AlarmManager implements WeakHandler.IHandler {
// 防止userTime超出Integer范围
if (userTime < 20) userTime++;
LogUtil.d("BBBBB" + curTime);
// 固定时间增长
exeActionForTime(curTime);
// 用户操作按时间增长
userActionForTime(userTime);
if (mHandler != null) {
mHandler.sendEmptyMessageDelayed(MSG1, ONE_MINTER_Interval);
}
}
}
......@@ -80,12 +89,16 @@ public class AlarmManager implements WeakHandler.IHandler {
private void userActionForTime(int userTime) {
if (userTime % APP_OUT_CLEAR_MINTER == 0) {
LogUtil.d("AAAA -> " + userTime);
// 应用在前台时,不弹出应用外广告
if (ForegroundOrBackground.isForeground()) {
if (ForegroundOrBackground.isForeground2()) {
this.resetUserActionTime();
return;
}
// 预加载信息流
ExpressManager.INSTANCE.loadExpress();
//用户关闭界面后10分钟调用
Intent intent = new Intent(MintsApplication.getContext(), BoostActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
......
......@@ -7,7 +7,8 @@ import androidx.core.content.ContextCompat
import com.bumptech.glide.load.resource.gif.GifDrawable
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.inscreen.InsertScreenAdManager
import com.mints.flowbox.ad.wifi.WifiAdManager
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.ui.activitys.base.BaseActivity
import com.mints.library.utils.GlideUtils
import kotlinx.android.synthetic.main.activity_speed_fast.*
......@@ -28,7 +29,7 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
private var mTimer: Timer? = null
private var mStep = 0
private var insertScreenAdManager: InsertScreenAdManager? = null
private var mWifiAdManager: WifiAdManager? = null
override fun getContentViewLayoutID() = R.layout.activity_speed_fast
......@@ -37,8 +38,20 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
override fun initViewsAndEvents() {
initView()
insertScreenAdManager = InsertScreenAdManager()
insertScreenAdManager?.loadInterstitial(this)
mWifiAdManager = WifiAdManager()
mWifiAdManager?.loadWifiAd(this)
mWifiAdManager?.setWifiAdStatusListener(object : WifiAdStatusListener {
override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
finish()
}
})
}
fun startTimer() {
......@@ -71,7 +84,7 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
tv_progress.visibility = View.INVISIBLE
// 动画结束后 展示插屏广告
insertScreenAdManager?.showInterstitial()
mWifiAdManager?.showInterstitial()
if (iv_gif.drawable is GifDrawable) {
val drawable = iv_gif.drawable as GifDrawable
......@@ -100,6 +113,8 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
tv_tab.text = topStr[0]
tv_progress.text = speedStr[0]
GlideUtils.loadImageViewBitMap(this, R.drawable.wifi_speed, iv_gif)
btn.setOnClickListener(this)
}
......@@ -142,8 +157,8 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
}
override fun onDestroy() {
insertScreenAdManager?.onDestroy()
insertScreenAdManager = null
mWifiAdManager?.onDestroy()
mWifiAdManager = null
fl_ad?.removeAllViews()
// 预加载信息流
......
......@@ -39,9 +39,10 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
override fun initViewsAndEvents() {
if (!AppConfig.isXmlyInit) {
XmManager.init(MintsApplication.getContext())
// XmManager.init(MintsApplication.getContext())
// 一览视频
YlVideoManager.init(MintsApplication.getContext())
AppConfig.isXmlyInit = true
}
initView()
......
......@@ -87,6 +87,8 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
if (!TextUtils.isEmpty(UserManager.getInstance().userID)) {
(requireActivity() as MainActivity).refreshHall()
} else {
(requireActivity() as MainActivity).userLogin(Constant.FRAGMENT_CLICK_THREE)
}
}
}
......@@ -344,15 +346,15 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
// bundle.putInt(Constant.SCAN_TYPE, 1)
// readyGo(CleanActivity::class.java, bundle)
// } else {
// 预加载信息流
ExpressManager.loadExpress()
// 预加载信息流
ExpressManager.loadExpress()
val bundle = Bundle()
bundle.putString(
IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_CLEAN
)
readyGo(IncreasespeedActivity::class.java, bundle)
val bundle = Bundle()
bundle.putString(
IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_CLEAN
)
readyGo(IncreasespeedActivity::class.java, bundle)
// }
}
R.id.tv_save_battery -> { // 超强省电
......
......@@ -8,6 +8,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Movie;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff.Mode;
......@@ -22,7 +23,10 @@ import com.mints.flowbox.common.Constant;
import com.mints.library.utils.TLog;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* 图片util
......@@ -196,7 +200,6 @@ public class ImageUtil {
// e.printStackTrace();
// }
// }
public static Bitmap getBitmap(Context context, String name) {
Bitmap bitmap = null;
try {
......@@ -219,5 +222,29 @@ public class ImageUtil {
return bitmap;
}
/**
* 获取gif第一帧
*
* @param url
* @return
*/
public static Bitmap loadGifFirstBitmap(String url) {
Bitmap bitmap = null;
try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
InputStream is = urlConnection.getInputStream();
Movie movie = Movie.decodeStream(is);
//Bitmap.Config.ARGB_8888 这里是核心,如果出现图片显示不正确,就换编码试试
bitmap = Bitmap.createBitmap(movie.width(), movie.height(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
movie.draw(canvas, 0, 0);
canvas.save();
} catch (IOException e) {
e.printStackTrace();
} finally {
return bitmap;
}
}
}
......@@ -73,6 +73,11 @@ public class GlideUtils {
Glide.with(mContext).load(drawable).into(imageView);
}
//加载Gif
public static void loadImageViewBitMap(Context mContext, int drawable, ImageView imageView) {
Glide.with(mContext).asBitmap().load(drawable).into(imageView);
}
//加载Gif
public static void loadImageViewGifUrl(Context mContext, ImageView view, String url) {
RequestOptions options = (new RequestOptions())
......@@ -125,7 +130,7 @@ public class GlideUtils {
}, delay);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
......
......@@ -7,7 +7,7 @@
<View
android:layout_width="match_parent"
android:layout_height="280dp"
android:background="@drawable/shape_bg_speed" />
android:background="#8275DF" />
<LinearLayout
android:layout_width="match_parent"
......
......@@ -41,9 +41,7 @@
android:id="@+id/iv_gif"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="center"
android:src="@drawable/wifi_speed"
android:visibility="visible" />
android:layout_gravity="center" />
</FrameLayout>
......
......@@ -118,6 +118,7 @@
android:hint="输入密码"
android:inputType="textPassword"
android:padding="10dp"
android:textSize="12sp"
app:layout_constraintTop_toBottomOf="@id/textView11" />
<Button
......@@ -135,8 +136,7 @@
android:id="@+id/tv_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="2dp"
android:padding="10dp"
android:text="取消"
android:textSize="16sp"
......
......@@ -15,7 +15,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:text="WIFI开关未开启"
android:textColor="@color/black"
android:textSize="18sp" />
......@@ -29,7 +29,7 @@
<Button
android:id="@+id/btn"
android:layout_width="140dp"
android:layout_height="46dp"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_main"
......
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