| | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.res.Configuration; |
| | | import android.os.Build; |
| | | import android.os.LocaleList; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Locale; |
| | | import java.util.Objects; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | |
| | | private Boolean isLogEnabled = true; |
| | | //三方sdk初始化标识 |
| | | private Boolean isInitThirdSDK = false; |
| | | //三方sdk初始化标识 |
| | | /** |
| | | * 三方sdk初始化标识 |
| | | * 在StartActivity里面初始化三方SDK的标识 |
| | | */ |
| | | public Boolean isStartInitThirdSDK = false; |
| | | //声明一个当前应用的实例 |
| | | private static HDLApp mHDLApp; |
| | | //声明一个公共的信息映射,可当作全局变量使用; |
| | |
| | | // //9.初始化网络工具 |
| | | // NetWorkUtil.init(this); |
| | | initAutoSize(); |
| | | //初始化极光推送 |
| | | initJPush(); |
| | | // //初始化极光推送 |
| | | // initJPush(); |
| | | initHDLLinkPMSdk(); |
| | | HDLLinkLocalSdk.getInstance().init(getInstance()); |
| | | initSocket(); |
| | |
| | | */ |
| | | private void initHDLLinkPMSdk() { |
| | | //1.初始化SDK |
| | | HDLLinkPMSdk.initWithAppKey(getInstance(), AppConfigManage.getAppKey(), AppConfigManage.getAppSecret(), AppConfigManage.getAPPRegionUrl()); |
| | | HDLLinkPMSdk.initWithAppKey(this, AppConfigManage.getAppKey(), AppConfigManage.getAppSecret(), AppConfigManage.getAPPRegionUrl()); |
| | | //2.设置打印 |
| | | HDLLinkPMSdk.setLogEnabled(isLogEnabled); |
| | | if (TextUtils.isEmpty(UserConfigManage.getInstance().getCurrentAppLanguage())) { |
| | |
| | | private void initJPush() { |
| | | JPushInterface.setDebugMode(true); |
| | | JPushInterface.init(getBaseContext()); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | super.attachBaseContext(base); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 支持中英文切换 |
| | | */ |
| | | public Context getAppLocaleContext() { |
| | | try { |
| | | Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | Configuration configuration = getResources().getConfiguration(); |
| | | configuration.setLocale(locale); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | configuration.setLocales(new LocaleList(locale)); |
| | | } |
| | | return createConfigurationContext(configuration); |
| | | } catch (Exception e) { |
| | | return this; |
| | | } |
| | | } |
| | | } |