Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile-Cn-Ko-En
Commits
89b962a8
Commit
89b962a8
authored
Sep 06, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ygo和竖屏最后卡组同步
parent
b70ec2e4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
42 deletions
+76
-42
mobile/build.gradle
mobile/build.gradle
+4
-2
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+6
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+21
-29
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+0
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
...arymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
+35
-10
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/YGOPreferencesProvider.java
...arymb/ygomobile/ui/preference/YGOPreferencesProvider.java
+10
-0
No files found.
mobile/build.gradle
View file @
89b962a8
...
...
@@ -6,7 +6,7 @@ android {
defaultConfig
{
applicationId
"cn.garymb.ygomobile"
minSdkVersion
1
6
minSdkVersion
1
9
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'
}
mobile/src/main/AndroidManifest.xml
View file @
89b962a8
...
...
@@ -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"
/>
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
89b962a8
...
...
@@ -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
);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
View file @
89b962a8
...
...
@@ -758,7 +758,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
}
private
void
shareDeck1
()
{
//开启绘图缓存
mRecyclerView
.
setDrawingCacheEnabled
(
true
);
//这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/PreferenceFragmentPlus.java
View file @
89b962a8
...
...
@@ -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
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/YGOPreferencesProvider.java
0 → 100644
View file @
89b962a8
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"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment