ThemeUtils

本文介绍了一个用于Android应用的主题切换工具类实现。该工具类支持白天和夜间两种主题的切换,并利用SharedPreferences保存当前主题状态。此外,还展示了如何在主题切换后更新数据库中的频道列表。

package com.bwie.topnewsnormal.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.andy.library.ChannelBean;
import com.bwie.topnewsnormal.R;
import com.bwie.topnewsnormal.database.NewsDao;

import java.util.List;

/**
* Created by Shadow on 2017/8/9.
*/

public class ThemeUtils {

static int theme = 0;

public static void OnActivityCreate(Activity activity) {
    switch (theme) {
        case 0:
            activity.setTheme(R.style.DayTheme);
            break;
        case 1:
            activity.setTheme(R.style.NightTheme);
            break;
    }
}

public static void onClick(Activity activity, List<ChannelBean> list) {

    switch (theme) {
        case 0:
            theme = 1;
            activity.getSharedPreferences("nightmode", Context.MODE_PRIVATE).edit().putBoolean("flag", true).commit();
            break;
        case 1:
            theme = 0;
            activity.getSharedPreferences("nightmode", Context.MODE_PRIVATE).edit().putBoolean("flag", false).commit();
            break;
    }
    NewsDao newsDao = new NewsDao(activity);
    newsDao.delete();
    newsDao.add(list);
    activity.finish();
    activity.overridePendingTransition(R.anim.alpha_in, R.anim.alpha_out);
    activity.startActivity(new Intent(activity, activity.getClass()));
}

}

Line 282775: 08-05 17:58:18.787 18414 18414 W Zygote : Unable to open libbeluga.so: dlopen failed: library "libbeluga.so" not found. Line 282779: 08-05 17:58:18.789 18414 18414 I Zygote : seccomp disabled by setenforce 0 Line 282790: 08-05 17:58:18.794 18414 18414 I service.atsmod: Late-enabling -Xcheck:jni Line 282872: 08-05 17:58:18.816 18414 18414 I service.atsmod: Unquickening 15 vdex files! Line 282945: 08-05 17:58:18.833 1104 22303 D ActivityManager: Set 18414 com.adayo.service.atsmode adj 0: exec-service Line 282991: 08-05 17:58:18.849 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@16b1f32: old config is {1.0 ?mcc?mnc [zh_CN] ldltr ?swdp ?wdp ?hdp 160dpi ?lsize ?long ?ldr ?wideColorGamut ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/? winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=null mWindowingMode=undefined mDisplayWindowingMode=undefined mActivityType=undefined mAlwaysOnTop=undefined mRotation=undefined}} old compat is {160dpi always-compat} Line 283000: 08-05 17:58:18.850 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@16b1f32: new config is {1.0 ?mcc?mnc [zh_CN] ldltr sw1080dp w1920dp h936dp 160dpi xlrg long land car finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1920, 1080) mAppBounds=Rect(0, 0 - 1920, 1000) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1339} new compat is {160dpi always-compat} Line 283001: 08-05 17:58:18.851 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@16b1f32: final config is {1.0 ?mcc?mnc [zh_CN] ldltr sw1080dp w1920dp h936dp 160dpi xlrg long land car finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1920, 1080) mAppBounds=Rect(0, 0 - 1920, 1000) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1339} final compat is {160dpi always-compat} Line 283031: 08-05 17:58:18.860 18414 18414 I service.atsmod: The ClassLoaderContext is a special shared library. Line 283035: 08-05 17:58:18.861 18414 18414 D nativeloader: classloader namespace configured for unbundled vendor apk. library_path=/vendor/app/ATSMode/lib/arm64:/vendor/app/ATSMode/ATSMode.apk!/lib/arm64-v8a:/vendor/lib64 Line 283037: 08-05 17:58:18.865 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@d6e53fa: old config is {1.0 ?mcc?mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?ldr ?wideColorGamut ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/? winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=null mWindowingMode=undefined mDisplayWindowingMode=undefined mActivityType=undefined mAlwaysOnTop=undefined mRotation=undefined}} old compat is {160dpi always-compat} Line 283038: 08-05 17:58:18.865 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@d6e53fa: new config is {1.0 ?mcc?mnc [zh_CN] ldltr sw1080dp w1920dp h936dp 160dpi xlrg long land car finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1920, 1080) mAppBounds=Rect(0, 0 - 1920, 1000) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1339} new compat is {160dpi always-compat} Line 283039: 08-05 17:58:18.865 18414 18414 I Resources: **** Updating config of android.content.res.ResourcesImpl@d6e53fa: final config is {1.0 ?mcc?mnc [zh_CN] ldltr sw1080dp w1920dp h936dp 160dpi xlrg long land car finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1920, 1080) mAppBounds=Rect(0, 0 - 1920, 1000) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1339} final compat is {160dpi always-compat} Line 283051: 08-05 17:58:18.874 18414 18414 D NetworkSecurityConfig: No Network Security Config specified, using platform default Line 283065: 08-05 17:58:18.879 18414 18414 D NetworkSecurityConfig: No Network Security Config specified, using platform default Line 283120: 08-05 17:58:18.900 18414 18414 D ATS_SWITCH_MODE: lambda$new$10(ATSControlService.java:345)init System service conection result = true Line 283124: 08-05 17:58:18.901 18414 18414 D ATS_SWITCH_MODE: connectCarService(CarServiceManager.java:220)[[==== connectCarService() Begin Line 283128: 08-05 17:58:18.903 18414 18414 D ATS_SWITCH_MODE: connectCarService(CarServiceManager.java:224)[[==== connectCarService() mCar =========== android.car.Car@9133420 Line 283132: 08-05 17:58:18.905 18414 18414 D ATS_SWITCH_MODE: connectCarService(CarServiceManager.java:227)[[==== connectCarService() end Line 283133: 08-05 17:58:18.905 18414 18414 D ATS_SWITCH_MODE: initConfig(ATSControlService.java:307)ATSControlService Started! Line 283169: 08-05 17:58:18.920 18414 18414 D AAOP_DeviceService: <init>(AAOP_DeviceServiceManager.java:37)AAOP_DeviceServiceManager BcmManager() begin Line 283173: 08-05 17:58:18.920 18414 18414 D AAOP_DeviceService: getServiceConnection(AAOP_DeviceServiceManager.java:74)AAOP_DeviceServiceManager getServiceConnection() begin Line 283182: 08-05 17:58:18.921 18414 18414 D ServiceOperation: serviceConnected AAOP_SERVICE_DEVICE, flag: true Line 283186: 08-05 17:58:18.921 18414 18414 D ServiceOperation: serviceConnected AAOP_SERVICE_DEVICE, mServiceConnectListeners size: 0 Line 283191: 08-05 17:58:18.921 18414 18414 D AAOP_DeviceService: getServiceConnection(AAOP_DeviceServiceManager.java:113)AAOP_DeviceServiceManager getServiceConnection() end ret = true Line 283196: 08-05 17:58:18.921 18414 18414 D AAOP_DeviceService: <init>(AAOP_DeviceServiceManager.java:43)AAOP_DeviceServiceManager BcmManager() end Line 283200: 08-05 17:58:18.921 18414 18414 D DEMO_AudioManager: new AudioManager adjust type: 0, volMax: 39, volMin: 0 Line 283212: 08-05 17:58:18.924 18414 18414 E ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant). Line 283216: 08-05 17:58:18.931 18414 18414 I service.atsmode: type=1400 audit(0.0:64913): avc: denied { call } for scontext=u:r:system_app:s0 tcontext=u:r:hal_fgecomservice_default:s0 tclass=binder permissive=1 Line 283223: 08-05 17:58:18.937 18414 18414 I android_os_HwBinder: HwBinder: Starting thread pool for getting: android.hardware.fgecomservice@1.0::IFgeComService/default Line 283235: 08-05 17:58:18.941 18414 18414 E ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant). Line 283251: 08-05 17:58:18.944 18414 18414 D ATS_SWITCH_MODE: initView(ModeSwitchVideoView.kt:69)init view by modeSwitchVideoView Line 283255: 08-05 17:58:18.949 18414 18414 I [LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@d98f13(com.adayo.service.atsmode.-$$Lambda$ATSControlService$4_X7albmyNSNYqqccJFIzWvtmdI@1ebe550) on owner: com.adayo.service.atsmode.ATSControlService@7cf21d9 with key: ATS_requested_mode Line 283259: 08-05 17:58:18.949 18414 18414 I [LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@22f444e(com.adayo.service.atsmode.-$$Lambda$ATSControlService$4D0kxYppS8OoeVuB8flJRTq4DhA@744096f) on owner: com.adayo.service.atsmode.ATSControlService@7cf21d9 with key: ATS_confirmed_mode Line 283263: 08-05 17:58:18.949 18414 18414 I [LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@2aebb05(com.adayo.service.atsmode.-$$Lambda$ATSControlService$fO2qS2WoPIByTLaz3YnRTMsEgJc@c3f575a) on owner: com.adayo.service.atsmode.ATSControlService@7cf21d9 with key: ATS_reset_counter Line 283267: 08-05 17:58:18.949 18414 18414 I [LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@f570e68(com.adayo.service.atsmode.-$$Lambda$ATSControlService$Ghir-lAaMGIbvTauu8gkl9U40yQ@ae50281) on owner: com.adayo.service.atsmode.ATSControlService@7cf21d9 with key: single_pedal_switcher Line 283269: 08-05 17:58:18.950 18414 18414 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1669 android.content.ContextWrapper.startService:720 com.adayo.service.atsmode.ATSControlService.onCreate:165 android.app.ActivityThread.handleCreateService:4196 android.app.ActivityThread.access$1500:237 Line 283271: 08-05 17:58:18.952 18414 18414 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1748 android.content.ContextWrapper.bindService:756 com.adayo.service.atsmode.ATSControlService.onCreate:167 android.app.ActivityThread.handleCreateService:4196 android.app.ActivityThread.access$1500:237 Line 283283: 08-05 17:58:18.956 18414 18414 D ATS_SWITCH_MODE: onStartCommand(ATSControlService.java:176)ATSControlService ServiceStartCommand Line 283285: 08-05 17:58:18.956 18414 18414 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1748 android.content.ContextWrapper.bindService:756 com.adayo.service.atsmode.ATSControlService.onStartCommand:179 android.app.ActivityThread.handleServiceArgs:4330 android.app.ActivityThread.access$1800:237 Line 283296: 08-05 17:58:18.959 18414 18414 D ATS_SWITCH_MODE: lambda$new$10(ATSControlService.java:345)init System service conection result = true Line 283308: 08-05 17:58:18.960 18414 18414 D ATS_SWITCH_MODE: onServiceConnected(CarServiceManager.java:164)[[==== mCar.isConnected() = true Line 283430: 08-05 17:58:18.992 18414 18414 D ATS_SWITCH_MODE: onServiceConnected(CarServiceManager.java:169)[[==== success to connect car service ====]] Line 283435: 08-05 17:58:18.993 18414 18414 D ATS_SWITCH_MODE: onStartCommand(ATSControlService.java:176)ATSControlService ServiceStartCommand Line 283437: 08-05 17:58:18.993 18414 18414 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1748 android.content.ContextWrapper.bindService:756 com.adayo.service.atsmode.ATSControlService.onStartCommand:179 android.app.ActivityThread.handleServiceArgs:4330 android.app.ActivityThread.access$1800:237 Line 283442: 08-05 17:58:18.996 18414 18414 D ATS_SWITCH_MODE: lambda$new$10(ATSControlService.java:345)init System service conection result = true Line 283444: 08-05 17:58:18.997 1104 1670 D ActivityManager: Set 18414 com.adayo.service.atsmode adj 500: started-services Line 283459: 08-05 17:58:18.999 18414 18414 D ATS_SWITCH_MODE: onServiceConnected(ATSControlService.java:145)connect with com.adayo.service.atsmode.ATSRemoteGuardService$ATSRemoteBinder Line 283460: 08-05 17:58:18.999 18414 18414 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1748 android.content.ContextWrapper.bindService:756 com.adayo.service.atsmode.ATSControlService$1.onServiceConnected:146 android.app.LoadedApk$ServiceDispatcher.doConnected:1978 android.app.LoadedApk$ServiceDispatcher$RunConnection.run:2010 Line 283487: 08-05 17:58:19.006 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557846278,__getValue=0 Line 283488: 08-05 17:58:19.006 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283489: 08-05 17:58:19.006 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557845040,__getValue=255 Line 283490: 08-05 17:58:19.006 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283491: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557845041,__getValue=255 Line 283492: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283493: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557842951,__getValue=2 Line 283494: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283495: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557842952,__getValue=2 Line 283496: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283497: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557848092,__getValue=2 Line 283498: 08-05 17:58:19.007 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283499: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557846066,__getValue=0 Line 283500: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283502: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557846067,__getValue=0 Line 283503: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283504: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557846068,__getValue=0 Line 283505: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283506: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557846069,__getValue=0 Line 283507: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:248)isOnPowerMode=false,return !!!!!!!!!! Line 283508: 08-05 17:58:19.008 18414 18414 D ATS_SWITCH_MODE: onChangeEvent(CarServiceManager.java:234)___propertyId=557845078,__getValue=2 Line 291572: 08-05 17:58:21.943 18414 18440 E ATS_SWITCH_MODE: lambda$initConfig$7$ATSControlService(ATSControlService.java:295)ATSControlService init carModelConfig ====>>5,configuration ====>>2 Line 291573: 08-05 17:58:21.944 18414 18440 E ATS_SWITCH_MODE: setCarModelConfig(ATSContainerView.java:166)ATSContainerView init carModelConfig byte value is ====>>5 Line 291574: 08-05 17:58:21.944 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:268)SvgPathView init carModelConfig ====>> B60VS Line 291577: 08-05 17:58:21.946 18414 18440 E ATS_SWITCH_MODE: setConfiguration(ATSContainerView.java:268)ATSContainerView init configuration byte value is ====>>2 Line 291701: 08-05 17:58:21.999 18414 18445 E ATS_SWITCH_MODE: lambda$initConfig$7$ATSControlService(ATSControlService.java:295)ATSControlService init carModelConfig ====>>5,configuration ====>>2 Line 291703: 08-05 17:58:21.999 18414 18445 E ATS_SWITCH_MODE: setCarModelConfig(ATSContainerView.java:166)ATSContainerView init carModelConfig byte value is ====>>5 Line 291704: 08-05 17:58:21.999 18414 18445 E ATS_SWITCH_MODE: setConfiguration(ATSContainerView.java:185)ATSContainerView init configuration byte value is ====>>2 Line 291818: 08-05 17:58:22.032 18414 18450 E ATS_SWITCH_MODE: lambda$initConfig$7$ATSControlService(ATSControlService.java:295)ATSControlService init carModelConfig ====>>5,configuration ====>>2 Line 291822: 08-05 17:58:22.032 18414 18450 E ATS_SWITCH_MODE: setCarModelConfig(ATSContainerView.java:166)ATSContainerView init carModelConfig byte value is ====>>5 Line 291823: 08-05 17:58:22.032 18414 18450 E ATS_SWITCH_MODE: setConfiguration(ATSContainerView.java:185)ATSContainerView init configuration byte value is ====>>2 Line 291878: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> conf Line 291882: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> snow Line 291894: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> eco Line 291898: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> sport Line 291902: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> wad Line 291903: 08-05 17:58:22.083 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> rock Line 291905: 08-05 17:58:22.084 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> mud Line 291909: 08-05 17:58:22.084 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> sand Line 291913: 08-05 17:58:22.084 18414 18498 E ATS_SWITCH_MODE: run(SvgPathView.java:325)SvgPathView path bean data ====>> cross Line 296386: 08-05 17:58:23.902 18414 18437 I service.atsmod: Waiting for a blocking GC ProfileSaver Line 296394: 08-05 17:58:23.911 18414 18437 I service.atsmod: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 9.057ms Line 346558: 08-05 17:58:42.899 1648 1928 I Process : Sending signal. PID: 18414 SIG: 9 Line 346562: 08-05 17:58:42.899 1648 1928 I Process : Sending signal. PID: 18414 SIG: 9 Line 347141: 08-05 17:58:42.923 376 376 I Zygote : Process 18414 exited due to signal 9 (Killed) Line 347152: 08-05 17:58:42.924 1104 1155 I libprocessgroup: Successfully killed process cgroup uid 1000 pid 18414 in 0ms
最新发布
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值