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();
|
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();
|
}
|
|
}
|