package com.demo.lib.common.activity;
|
|
import android.app.Dialog;
|
import android.content.res.Configuration;
|
import android.content.res.Resources;
|
import android.graphics.Color;
|
import android.os.Bundle;
|
|
|
import com.demo.lib.common.util.ui.LoadingDialogUtil;
|
import com.jaeger.library.StatusBarUtil;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
public class BaseActivity extends FragmentActivity {
|
|
protected Dialog loadingDialog;
|
|
//显示加载
|
protected void showLoading() {
|
if (loadingDialog != null && !loadingDialog.isShowing()) {
|
loadingDialog.show();
|
}
|
}
|
|
//隐藏加载
|
protected void hideLoading() {
|
if (loadingDialog != null && loadingDialog.isShowing()) {
|
loadingDialog.dismiss();
|
}
|
}
|
|
|
@Override
|
protected void onCreate(Bundle arg0) {
|
super.onCreate(arg0);
|
loadingDialog = LoadingDialogUtil.getLoadingDialog(this, "");
|
}
|
|
@Override
|
public void setContentView(int layoutResID) {
|
super.setContentView(layoutResID);
|
//状态栏透明
|
StatusBarUtil.setColorNoTranslucent(this, Color.TRANSPARENT);
|
//状态栏字体深色
|
StatusBarUtil.setLightMode(this);
|
}
|
|
@Override
|
public void onConfigurationChanged(Configuration newConfig) {
|
if (newConfig.fontScale != 1)//非默认值
|
getResources();
|
super.onConfigurationChanged(newConfig);
|
}
|
|
@Override
|
public Resources getResources() {
|
Resources res = super.getResources();
|
if (res.getConfiguration().fontScale != 1.0) {//非默认值
|
Configuration newConfig = new Configuration();
|
newConfig.setToDefaults();//设置默认
|
newConfig.fontScale = 1.0f;
|
res.updateConfiguration(newConfig, res.getDisplayMetrics());
|
}
|
return res;
|
}
|
|
public void onResume() {
|
super.onResume();
|
}
|
|
public void onPause() {
|
super.onPause();
|
}
|
}
|