admin
2021-05-22 3595485efbfeb0db8c0e719e34aac022af284754
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.tejia.lijin.app.ui;
 
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
 
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
import com.umeng.analytics.MobclickAgent;
import com.wpc.library.util.common.StringUtils;
import com.tejia.lijin.app.util.clipboard.ClipboardUtil;
import com.tejia.lijin.app.util.clipboard.IClipboardContentListener;
import com.tejia.lijin.app.util.ui.ClipboardContentRecommendUtil;
import com.tejia.lijin.app.util.umengCustomEvent.MainCustomEvent;
 
/**
 * Created by weikou2015 on 2017/2/20.
 */
 
public class BaseActivity extends Activity {
 
    private boolean showRecommend = true;
 
    public void setShowRecommend(boolean recommend) {
        this.showRecommend = recommend;
    }
 
    protected ShapeLoadingDialog loadingDialog = null;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        loadingDialog = new ShapeLoadingDialog.Builder(this).build();
    }
 
    @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) {//非默认值
        Configuration newConfig = new Configuration();
        newConfig.setToDefaults();//设置默认
        res.updateConfiguration(newConfig, res.getDisplayMetrics());
//        }
        return res;
    }
 
    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
        if (!showRecommend)
            return;
        final SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
        ClipboardUtil.getClipboardContent(this, new IClipboardContentListener() {
            @Override
            public void getContent(String content) {
                if ((!StringUtils.isEmpty(content)) && getSharedPreferences("user", MODE_PRIVATE).getString("copy", "0").equalsIgnoreCase("1")) {
                    SharedPreferences.Editor editor = sp.edit();
                    editor.putBoolean("isClipBroadChanged", true);
                    editor.commit();
                }
 
                if ((!this.getClass().getSimpleName().contains("SplashActivity")) && sp.getBoolean("isClipBroadChanged", false)) {
                    getGoodsInfo(content);
                    SharedPreferences.Editor editor = sp.edit();
                    editor.putBoolean("isClipBroadChanged", false);
                    editor.commit();
                }
            }
        });
    }
 
    /**
     * 智能搜索
     */
    private void getGoodsInfo(String description) {
        if (StringUtils.isEmpty(description))
            return;
        MainCustomEvent.rmdTbgoodsRecommend(this);
        ClipboardContentRecommendUtil.getRecommendInfo(description, this);
    }
 
 
    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }
 
}