admin
2022-03-12 222df7b655c51992580b832f5e06c6772d27d9d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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();
    }
}