xz_cultural/app/src/main/java/com/tengshisoft/BaseMyApplication.java
2023-02-23 11:39:03 +08:00

95 lines
2.9 KiB
Java
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tengshisoft;
import android.app.Application;
import android.view.Gravity;
import androidx.multidex.MultiDex;
import com.alibaba.android.arouter.launcher.ARouter;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.sucstepsoft.cm_utils.core.widget.refresh.CustomRefreshHeader;
import com.sucstepsoft.cm_utils.utils.UserLgUtils;
import com.sucstepsoft.cm_utils.utils.toast.ToastUtils;
import com.tengshisoft.cultural.R;
import cn.jiguang.share.android.api.JShareInterface;
import cn.leo.magic.screen.MagicScreenAdapter;
/**
* 作者: adam
* 日期: 2020/4/13 - 4:02 PM
* 邮箱: itgaojian@163.com
* 描述: Application--基类
*/
public class BaseMyApplication extends Application {
private static boolean isLogin = false;
//static 代码段可以防止内存泄露
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) -> new CustomRefreshHeader(context));
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) -> new ClassicsFooter(context));
}
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
ARouter.openDebug();
MagicScreenAdapter.initDesignWidthInDp(1024, true);
ARouter.init(BaseMyApplication.this);
initShare();
initBaiduMap();
ToastUtils.init(this);
ToastUtils.setGravity(Gravity.TOP, 0, 80);
getConfigCityCode();
}
private void getConfigCityCode() {
UserLgUtils.setCurrentCityCode(this.getResources().getString(R.string.CITY_CODE));
UserLgUtils.setCurrentCity(this.getResources().getString(R.string.CITY_NAME));
UserLgUtils.setCurrentCityId(this.getResources().getString(R.string.CITY_ID));
}
private void initShare() {
JShareInterface.init(this);
JShareInterface.setDebugMode(false);
}
/**
* 百度地图初始化
*/
private void initBaiduMap() {
//自4.3.0起百度地图SDK所有接口均支持百度坐标和国测局坐标用此方法设置您使用的坐标类型.
//包括BD09LL和GCJ02两种坐标默认是BD09LL坐标。
SDKInitializer.initialize(BaseMyApplication.this);
SDKInitializer.setCoordType(CoordType.BD09LL);
}
public static BDLocation mCurrentLocation;
public static void setLocation(BDLocation location) {
mCurrentLocation = location;
}
public static BDLocation getCurrentLocation() {
return mCurrentLocation;
}
public static boolean getIsLoging() {
return isLogin;
}
public static void setLogin(boolean login) {
isLogin = login;
}
}