Commit 89b962a8 authored by feihuaduo's avatar feihuaduo

ygo和竖屏最后卡组同步

parent b70ec2e4
......@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "cn.garymb.ygomobile"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 28
versionCode 350000823
versionName "3.5.0"
......@@ -108,8 +108,10 @@ dependencies {
implementation(name: 'dialogutils2-release', ext: 'aar')
//recyclerview的adapter库
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
//图片选择
implementation 'com.yuyh.imgsel:library:2.0.6'
//跨进程SharedPreferencesPlus工具
implementation 'com.github.zhangliangming:PreferencesProvider:v1.3'
}
......@@ -191,6 +191,12 @@
<service
android:name="cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant"
android:priority="1000" />
<provider
android:authorities="cn.garymb.ygomobile.ui.preference.YGOPreferencesProvider"
android:name="cn.garymb.ygomobile.ui.preference.YGOPreferencesProvider"
android:exported="false"/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
......
......@@ -8,6 +8,8 @@ import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import com.zlm.libs.preferences.PreferencesProviderUtils;
import org.json.JSONArray;
import java.io.File;
......@@ -504,17 +506,29 @@ public class AppsSettings {
return mSharedPreferences.getString(Constants.PREF_DEF_LAST_YDK, null);
}
//获得最后卡组绝对路径
public String getLastDeckPath() {
String path;
if (TextUtils.equals(Constants.CORE_PACK_PATH, getLastCategory())) {
path = getResourcePath() + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
} else if (TextUtils.equals(Constants.WINDBOT_DECK_PATH, getLastCategory())) {
path = getResourcePath() + "/" + Constants.WINDBOT_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
} else if (TextUtils.equals(context.getString(R.string.category_Uncategorized), getLastCategory())) {
path = getResourcePath() + "/" + Constants.CORE_DECK_PATH + "/" + getLastDeckName() + YDK_FILE_EX;
} else {
path = getResourcePath() + "/" + Constants.CORE_DECK_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
}
Log.e("Appsettings", "拼接最后路径" + path);
return path;
}
//保存最后卡组绝对路径、分类、卡组名
public void setLastDeckPath(String path) {
Log.i("我是path", path);
Log.i("我是getCurLastDeckPath", getCurLastDeckPath());
Log.i("我是getLastDeckPath", getLastDeckPath());
Log.e("Appsettings", "设置最后路径" + path);
if (TextUtils.equals(path, getLastDeckPath())) {
//一样
return;
}
//保存最后卡组绝对路径
mSharedPreferences.putString(Constants.PREF_LAST_DECK_PATH, path);
//保存最后分类名
mSharedPreferences.putString(Constants.PREF_LAST_CATEGORY, DeckUtil.getDeckTypeName(path));
//保存最后卡组名
......@@ -523,11 +537,6 @@ public class AppsSettings {
mSharedPreferences.putString(Constants.PREF_LAST_YDK, lastDeckName);
}
//获得最后卡组绝对路径
public String getLastDeckPath() {
return mSharedPreferences.getString(Constants.PREF_LAST_DECK_PATH, "");
}
//获得最后分类名
public String getLastCategory() {
return mSharedPreferences.getString(Constants.PREF_LAST_CATEGORY, Constants.PREF_DEF_LAST_CATEGORY);
......@@ -538,22 +547,6 @@ public class AppsSettings {
return mSharedPreferences.getString(Constants.PREF_LAST_YDK, Constants.PREF_DEF_LAST_YDK);
}
//从获得的key+value里拼接一个绝对路径
public String getCurLastDeckPath() {
String path;
if(TextUtils.equals(Constants.CORE_PACK_PATH, getLastCategory())) {
path = getResourcePath() + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
} else if (TextUtils.equals(Constants.WINDBOT_DECK_PATH, getLastCategory())){
path = getResourcePath() + "/" + Constants.WINDBOT_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
} else if(TextUtils.equals(context.getString(R.string.category_Uncategorized),getLastCategory())){
path = getResourcePath() + "/" + Constants.CORE_DECK_PATH + "/" + getLastDeckName() + YDK_FILE_EX;
} else {
path = getResourcePath() + "/" + Constants.CORE_DECK_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
}
mSharedPreferences.putString(Constants.PREF_LAST_DECK_PATH, path);
return path;
}
public void saveIntSettings(String key, int value) {
mSharedPreferences.putInt(Constants.PREF_START + key, value);
}
......@@ -620,12 +613,11 @@ public class AppsSettings {
public void saveSettings(String key, String value) {
if ("lastdeck".equals(key)) {
Log.i("我是lastdeck的value", value);
Log.e("AppSettings", value);
mSharedPreferences.putString(Constants.PREF_LAST_YDK, value);
} else if ("lastcategory".equals(key)) {
Log.i("我是lastcategory的value", value);
Log.e("AppSettings", value);
mSharedPreferences.putString(Constants.PREF_LAST_CATEGORY, value);
} else {
mSharedPreferences.putString(Constants.PREF_START + key, value);
}
......
......@@ -758,7 +758,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
}
private void shareDeck1() {
//开启绘图缓存
mRecyclerView.setDrawingCacheEnabled(true);
//这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
......
......@@ -13,6 +13,7 @@ import android.widget.Toast;
import com.yuyh.library.imgsel.ISNav;
import com.yuyh.library.imgsel.config.ISListConfig;
import com.yuyh.library.imgsel.ui.ISListActivity;
import com.zlm.libs.preferences.PreferencesProviderUtils;
import java.io.File;
import java.io.IOException;
......@@ -218,8 +219,12 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
private SharedPreferences mSharedPreferences;
private boolean autoSave = false;
private boolean isMultiProess = false;
private String spName;
private Context context;
private SharedPreferencesPlus(Context context, String name, int mode) {
spName = name;
this.context = context;
mSharedPreferences = context.getSharedPreferences(name, mode);
isMultiProess = (mode & Context.MODE_MULTI_PROCESS) == Context.MODE_MULTI_PROCESS;
}
......@@ -252,7 +257,8 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
Editor editor = edit().putString(key, value);
if (autoSave) {
if (isMultiProess) {
editor.commit();
// editor.commit();
PreferencesProviderUtils.putString(context, spName, key, value);
} else {
editor.apply();
}
......@@ -274,7 +280,8 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
Editor editor = edit().putInt(key, value);
if (autoSave) {
if (isMultiProess) {
editor.commit();
// editor.commit();
PreferencesProviderUtils.putInt(context, spName, key, value);
} else {
editor.apply();
}
......@@ -285,7 +292,8 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
Editor editor = edit().putLong(key, value);
if (autoSave) {
if (isMultiProess) {
editor.commit();
// editor.commit();
PreferencesProviderUtils.putLong(context, spName, key, value);
} else {
editor.apply();
}
......@@ -296,7 +304,8 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
Editor editor = edit().putFloat(key, value);
if (autoSave) {
if (isMultiProess) {
editor.commit();
// editor.commit();
PreferencesProviderUtils.putFloat(context, spName, key, value);
} else {
editor.apply();
}
......@@ -307,7 +316,8 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
Editor editor = edit().putBoolean(key, value);
if (autoSave) {
if (isMultiProess) {
editor.commit();
// editor.commit();
PreferencesProviderUtils.putBoolean(context, spName, key, value);
} else {
editor.apply();
}
......@@ -343,7 +353,10 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
@Override
public String getString(String key, String defValue) {
return mSharedPreferences.getString(key, defValue);
if (isMultiProess)
return PreferencesProviderUtils.getString(context, spName, key, defValue);
else
return mSharedPreferences.getString(key, defValue);
}
@Override
......@@ -353,22 +366,34 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
@Override
public int getInt(String key, int defValue) {
return mSharedPreferences.getInt(key, defValue);
if (isMultiProess)
return PreferencesProviderUtils.getInt(context, spName, key, defValue);
else
return mSharedPreferences.getInt(key, defValue);
}
@Override
public long getLong(String key, long defValue) {
return mSharedPreferences.getLong(key, defValue);
if (isMultiProess)
return PreferencesProviderUtils.getLong(context, spName, key, defValue);
else
return mSharedPreferences.getLong(key, defValue);
}
@Override
public float getFloat(String key, float defValue) {
return mSharedPreferences.getFloat(key, defValue);
if (isMultiProess)
return PreferencesProviderUtils.getFloat(context, spName, key, defValue);
else
return mSharedPreferences.getFloat(key, defValue);
}
@Override
public boolean getBoolean(String key, boolean defValue) {
return mSharedPreferences.getBoolean(key, defValue);
if (isMultiProess)
return PreferencesProviderUtils.getBoolean(context, spName, key, defValue);
else
return mSharedPreferences.getBoolean(key, defValue);
}
@Override
......
package cn.garymb.ygomobile.ui.preference;
import com.zlm.libs.preferences.PreferencesProvider;
public class YGOPreferencesProvider extends PreferencesProvider {
@Override
public String getAuthorities() {
return "cn.garymb.ygomobile.ui.preference.YGOPreferencesProvider";
}
}
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