增加定位和天气依赖
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package com.ttstd.dialer.activity.main;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -25,6 +29,8 @@ import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.jessyan.autosize.AutoSize;
|
||||
|
||||
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> {
|
||||
private static final String TAG = "MainActivity";
|
||||
protected MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
@@ -150,6 +156,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
registerReceivers();
|
||||
mViewModel.mDesktopSortAppData.observe(this, new Observer<List<AppInfo>>() {
|
||||
@Override
|
||||
public void onChanged(List<AppInfo> appInfos) {
|
||||
@@ -164,10 +171,51 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//修补autozie fragment item大小不一致
|
||||
AutoSize.autoConvertDensityOfGlobal(this);
|
||||
Log.e(TAG, "onResume: ");
|
||||
mViewModel.getOutsideApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.e(TAG, "onDestroy: ");
|
||||
unregisterReceivers();
|
||||
}
|
||||
|
||||
private void registerReceivers() {
|
||||
registerAppChangedReceive();
|
||||
}
|
||||
|
||||
private void unregisterReceivers() {
|
||||
if (mPackageChangedReceiver != null) {
|
||||
unregisterReceiver(mPackageChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private PackageChangedReceiver mPackageChangedReceiver;
|
||||
|
||||
private void registerAppChangedReceive() {
|
||||
if (null == mPackageChangedReceiver) {
|
||||
mPackageChangedReceiver = new PackageChangedReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addDataScheme("package");
|
||||
registerReceiver(mPackageChangedReceiver, filter);
|
||||
}
|
||||
|
||||
private class PackageChangedReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + intent.getAction());
|
||||
}
|
||||
}
|
||||
|
||||
private void setAppList() {
|
||||
Log.e(TAG, "setAppList: mFragments size = " + mFragments.size());
|
||||
mFragments = mFragments.subList(0, mFragmentSize);
|
||||
|
||||
@@ -6,16 +6,15 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.qweather.sdk.view.HeConfig;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.ttstd.dialer.BuildConfig;
|
||||
import com.ttstd.dialer.config.CommonConfig;
|
||||
import com.ttstd.dialer.manager.AppManager;
|
||||
import com.ttstd.dialer.utils.SystemUtils;
|
||||
import com.ttstd.iconloader.IconCacheManager;
|
||||
@@ -55,6 +54,10 @@ public class BaseApplication extends Application {
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
|
||||
HeConfig.init(BuildConfig.QweatherId, BuildConfig.QweatherKey);
|
||||
//切换至免费订阅
|
||||
HeConfig.switchToDevService();
|
||||
|
||||
if (BuildConfig.DEBUG) { // 这两行必须写在init之前,否则这些配置在init过程中将无效
|
||||
ARouter.openLog(); // 打印日志
|
||||
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ttstd.dialer.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.ttstd.dialer.config.CommonConfig;
|
||||
|
||||
public class AppChangedReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "ApkInstallReceiver";
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e(TAG, "onReceive: " + "action = " + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
switch (action) {
|
||||
case Intent.ACTION_PACKAGE_ADDED:
|
||||
Log.e(TAG, "onReceive: added " + packageName);
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_REPLACED:
|
||||
Log.e(TAG, "onReceive: replaced " + packageName);
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_REMOVED:
|
||||
Log.e(TAG, "onReceive: removed " + packageName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user