Commit a0f630b0 authored by feihuaduo's avatar feihuaduo

修复刘海高度变量无法共享读取的问题

parent 9f19757f
......@@ -78,6 +78,9 @@ public class YGOMobileActivity extends NativeActivity implements
private Handler handler = new Handler();
private FullScreenUtils mFullScreenUtils;
// public static int notchHeight;
private GameApplication app() {
if (mApp == null) {
synchronized (this) {
......
......@@ -27,6 +27,7 @@ import cn.garymb.ygomobile.utils.SystemUtils;
import static cn.garymb.ygomobile.Constants.CORE_EXPANSIONS;
import static cn.garymb.ygomobile.Constants.CORE_SYSTEM_PATH;
import static cn.garymb.ygomobile.Constants.DEF_PREF_FONT_SIZE;
import static cn.garymb.ygomobile.Constants.DEF_PREF_NOTCH_HEIGHT;
import static cn.garymb.ygomobile.Constants.DEF_PREF_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.DEF_PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE;
......@@ -34,6 +35,7 @@ import static cn.garymb.ygomobile.Constants.PREF_DEF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_FONT_SIZE;
import static cn.garymb.ygomobile.Constants.PREF_IMMERSIVE_MODE;
import static cn.garymb.ygomobile.Constants.PREF_LOCK_SCREEN;
import static cn.garymb.ygomobile.Constants.PREF_NOTCH_HEIGHT;
import static cn.garymb.ygomobile.Constants.PREF_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
......@@ -44,14 +46,14 @@ public class AppsSettings {
private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mScreenHeight, mScreenWidth, mDensity;
public static int notchHeight;
private AppsSettings(Context context) {
this.context = context;
mSharedPreferences = PreferenceFragmentPlus.SharedPreferencesPlus.create(context, context.getPackageName() + ".settings");
mSharedPreferences.setAutoSave(true);
Log.e("YGOMobile", "初始化AppsSettings");
Log.e("YGOMobileLog", "初始化类地址: "+ System.identityHashCode(this));
update(context);
}
......@@ -65,23 +67,6 @@ public class AppsSettings {
return sAppsSettings;
}
//获取刘海高度
public int getNotchHeight() {
return notchHeight;
}
//设置刘海高度
public void setNotchHeight(int notchHeight) {
this.notchHeight = notchHeight;
try {
FileLogUtil.writeAndTime("设置刘海高度"+notchHeight);
FileLogUtil.writeAndTime("当前文件设置刘海高度"+this.notchHeight);
} catch (IOException e) {
e.printStackTrace();
}
}
public File getSystemConfig() {
return new File(getResourcePath(), CORE_SYSTEM_PATH);
}
......@@ -96,7 +81,9 @@ public class AppsSettings {
if (dm != null) {
int height = Math.max(dm.widthPixels, dm.heightPixels);
Log.e("YGOMobileLog","类地址"+System.identityHashCode(this));
int notchHeight=getNotchHeight();
try {
FileLogUtil.writeAndTime("是否沉浸: " + isImmerSiveMode());
......@@ -105,7 +92,6 @@ public class AppsSettings {
FileLogUtil.writeAndTime("界面长: " + dm.heightPixels);
FileLogUtil.writeAndTime("界面宽: " + dm.widthPixels);
FileLogUtil.writeAndTime("刘海长: "+notchHeight);
FileLogUtil.writeAndTime("get刘海长: "+getNotchHeight());
} catch (IOException e) {
e.printStackTrace();
}
......@@ -159,6 +145,14 @@ public class AppsSettings {
return true;// mSharedPreferences.getBoolean(PREF_DECK_DELETE_DILAOG, PREF_DEF_DECK_DELETE_DILAOG);
}
public int getNotchHeight() {
return mSharedPreferences.getInt(PREF_NOTCH_HEIGHT, DEF_PREF_NOTCH_HEIGHT);
}
public void setNotchHeight(int height){
mSharedPreferences.putInt(PREF_NOTCH_HEIGHT, height);
}
public int getFontSize() {
return mSharedPreferences.getInt(PREF_FONT_SIZE, DEF_PREF_FONT_SIZE);
}
......
......@@ -95,6 +95,8 @@ public interface Constants {
String PREF_FONT_SIZE = "pref_settings_font_size";
int DEF_PREF_FONT_SIZE = 14;
String PREF_NOTCH_HEIGHT="pref_notch_height";
int DEF_PREF_NOTCH_HEIGHT=0;
String PREF_ONLY_GAME = "pref_settings_only_game";
boolean DEF_PREF_ONLY_GAME = false;
......
......@@ -55,6 +55,8 @@ import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.GameApplication;
import cn.garymb.ygomobile.YGOMobileActivity;
import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.events.ServerInfoEvent;
......@@ -135,7 +137,6 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//萌卡
StartMycard();
checkNotch();
}
//检查是否有刘海
......@@ -148,8 +149,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
} catch (IOException e) {
e.printStackTrace();
}
// AppsSettings.get().setNotchHeight(notchHeight);
AppsSettings.notchHeight=notchHeight;
AppsSettings.get().setNotchHeight(notchHeight);
}
});
}
......
......@@ -127,7 +127,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
try {
// long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String fileName ="【Demo】" + time+/* timestamp +*/ ".log";
String fileName ="【YGO】" + time+/* timestamp +*/ ".log";
String path = AppsSettings.get().getMobileLogPath() + "/";
FileOutputStream fos = new FileOutputStream(path + fileName);
fos.write(sb.toString().getBytes());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment