Commit a0f630b0 authored by feihuaduo's avatar feihuaduo

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

parent 9f19757f
...@@ -78,6 +78,9 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -78,6 +78,9 @@ public class YGOMobileActivity extends NativeActivity implements
private Handler handler = new Handler(); private Handler handler = new Handler();
private FullScreenUtils mFullScreenUtils; private FullScreenUtils mFullScreenUtils;
// public static int notchHeight;
private GameApplication app() { private GameApplication app() {
if (mApp == null) { if (mApp == null) {
synchronized (this) { synchronized (this) {
......
...@@ -27,6 +27,7 @@ import cn.garymb.ygomobile.utils.SystemUtils; ...@@ -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_EXPANSIONS;
import static cn.garymb.ygomobile.Constants.CORE_SYSTEM_PATH; 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_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_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.DEF_PREF_READ_EX; import static cn.garymb.ygomobile.Constants.DEF_PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE; import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE;
...@@ -34,6 +35,7 @@ import static cn.garymb.ygomobile.Constants.PREF_DEF_SENSOR_REFRESH; ...@@ -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_FONT_SIZE;
import static cn.garymb.ygomobile.Constants.PREF_IMMERSIVE_MODE; 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_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_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX; import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH; import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
...@@ -44,14 +46,14 @@ public class AppsSettings { ...@@ -44,14 +46,14 @@ public class AppsSettings {
private Context context; private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences; private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mScreenHeight, mScreenWidth, mDensity; private float mScreenHeight, mScreenWidth, mDensity;
public static int notchHeight;
private AppsSettings(Context context) { private AppsSettings(Context context) {
this.context = context; this.context = context;
mSharedPreferences = PreferenceFragmentPlus.SharedPreferencesPlus.create(context, context.getPackageName() + ".settings"); mSharedPreferences = PreferenceFragmentPlus.SharedPreferencesPlus.create(context, context.getPackageName() + ".settings");
mSharedPreferences.setAutoSave(true); mSharedPreferences.setAutoSave(true);
Log.e("YGOMobile", "初始化AppsSettings"); Log.e("YGOMobileLog", "初始化类地址: "+ System.identityHashCode(this));
update(context); update(context);
} }
...@@ -65,23 +67,6 @@ public class AppsSettings { ...@@ -65,23 +67,6 @@ public class AppsSettings {
return sAppsSettings; 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() { public File getSystemConfig() {
return new File(getResourcePath(), CORE_SYSTEM_PATH); return new File(getResourcePath(), CORE_SYSTEM_PATH);
} }
...@@ -96,7 +81,9 @@ public class AppsSettings { ...@@ -96,7 +81,9 @@ public class AppsSettings {
if (dm != null) { if (dm != null) {
int height = Math.max(dm.widthPixels, dm.heightPixels); int height = Math.max(dm.widthPixels, dm.heightPixels);
Log.e("YGOMobileLog","类地址"+System.identityHashCode(this));
int notchHeight=getNotchHeight();
try { try {
FileLogUtil.writeAndTime("是否沉浸: " + isImmerSiveMode()); FileLogUtil.writeAndTime("是否沉浸: " + isImmerSiveMode());
...@@ -105,7 +92,6 @@ public class AppsSettings { ...@@ -105,7 +92,6 @@ public class AppsSettings {
FileLogUtil.writeAndTime("界面长: " + dm.heightPixels); FileLogUtil.writeAndTime("界面长: " + dm.heightPixels);
FileLogUtil.writeAndTime("界面宽: " + dm.widthPixels); FileLogUtil.writeAndTime("界面宽: " + dm.widthPixels);
FileLogUtil.writeAndTime("刘海长: "+notchHeight); FileLogUtil.writeAndTime("刘海长: "+notchHeight);
FileLogUtil.writeAndTime("get刘海长: "+getNotchHeight());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -159,6 +145,14 @@ public class AppsSettings { ...@@ -159,6 +145,14 @@ public class AppsSettings {
return true;// mSharedPreferences.getBoolean(PREF_DECK_DELETE_DILAOG, PREF_DEF_DECK_DELETE_DILAOG); 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() { public int getFontSize() {
return mSharedPreferences.getInt(PREF_FONT_SIZE, DEF_PREF_FONT_SIZE); return mSharedPreferences.getInt(PREF_FONT_SIZE, DEF_PREF_FONT_SIZE);
} }
......
...@@ -95,6 +95,8 @@ public interface Constants { ...@@ -95,6 +95,8 @@ public interface Constants {
String PREF_FONT_SIZE = "pref_settings_font_size"; String PREF_FONT_SIZE = "pref_settings_font_size";
int DEF_PREF_FONT_SIZE = 14; 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"; String PREF_ONLY_GAME = "pref_settings_only_game";
boolean DEF_PREF_ONLY_GAME = false; boolean DEF_PREF_ONLY_GAME = false;
......
...@@ -55,6 +55,8 @@ import cn.garymb.ygodata.YGOGameOptions; ...@@ -55,6 +55,8 @@ import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.App; import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.AppsSettings; import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants; import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.GameApplication;
import cn.garymb.ygomobile.YGOMobileActivity;
import cn.garymb.ygomobile.YGOStarter; import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.bean.ServerInfo; import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.events.ServerInfoEvent; import cn.garymb.ygomobile.bean.events.ServerInfoEvent;
...@@ -135,23 +137,21 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -135,23 +137,21 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//萌卡 //萌卡
StartMycard(); StartMycard();
checkNotch(); checkNotch();
} }
//检查是否有刘海 //检查是否有刘海
private void checkNotch() { private void checkNotch() {
ScreenUtil.findNotchInformation(HomeActivity.this, new ScreenUtil.FindNotchInformation() { ScreenUtil.findNotchInformation(HomeActivity.this, new ScreenUtil.FindNotchInformation() {
@Override @Override
public void onNotchInformation(boolean isNotch, int notchHeight, int phoneType) { public void onNotchInformation(boolean isNotch, int notchHeight, int phoneType) {
try { try {
FileLogUtil.writeAndTime("检查刘海"+isNotch+" "+notchHeight); FileLogUtil.writeAndTime("检查刘海"+isNotch+" "+notchHeight);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}
AppsSettings.get().setNotchHeight(notchHeight);
} }
// AppsSettings.get().setNotchHeight(notchHeight); });
AppsSettings.notchHeight=notchHeight;
}
});
} }
@Override @Override
......
...@@ -127,7 +127,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler { ...@@ -127,7 +127,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
try { try {
// long timestamp = System.currentTimeMillis(); // long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date()); String time = formatter.format(new Date());
String fileName ="【Demo】" + time+/* timestamp +*/ ".log"; String fileName ="【YGO】" + time+/* timestamp +*/ ".log";
String path = AppsSettings.get().getMobileLogPath() + "/"; String path = AppsSettings.get().getMobileLogPath() + "/";
FileOutputStream fos = new FileOutputStream(path + fileName); FileOutputStream fos = new FileOutputStream(path + fileName);
fos.write(sb.toString().getBytes()); 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