Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
Commits
aa2fc2d3
Commit
aa2fc2d3
authored
Jul 13, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理方法
parent
29186bc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
+35
-22
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+31
-18
mobile/src/main/res/layout/dialog_cover_select.xml
mobile/src/main/res/layout/dialog_cover_select.xml
+4
-4
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
aa2fc2d3
package
cn.garymb.ygomobile.ui.preference.fragments
;
package
cn.garymb.ygomobile.ui.preference.fragments
;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.graphics.Color
;
import
android.graphics.Color
;
...
@@ -189,20 +190,24 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -189,20 +190,24 @@ public class SettingFragment extends PreferenceFragmentPlus {
dialog
.
setTitle
(
R
.
string
.
card_cover
);
dialog
.
setTitle
(
R
.
string
.
card_cover
);
dialog
.
show
();
dialog
.
show
();
View
viewDialog
=
dialog
.
getContentView
();
View
viewDialog
=
dialog
.
getContentView
();
Button
cover1
=
viewDialog
.
findViewById
(
R
.
id
.
button_cover1
);
ImageView
cover1
=
viewDialog
.
findViewById
(
R
.
id
.
cover1
);
String
cover1_img
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
();
ImageView
cover2
=
viewDialog
.
findViewById
(
R
.
id
.
cover2
);
Button
cover2
=
viewDialog
.
findViewById
(
R
.
id
.
button_cover2
);
setImage
(
getAbsolutePath
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
),
cover1
);
cover1
.
setOnClickListener
((
v
)
->
{
cover1
.
setOnClickListener
((
v
)
->
{
//显示图片对话框?
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
();
showImageDialog
(
preference
,
getString
(
R
.
string
.
card_cover
),
outFile
,
true
,
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
0
],
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
1
]);
});
});
cover2
.
setOnClickListener
((
v
)
->
{
cover2
.
setOnClickListener
((
v
)
->
{
//显示图片对话框?
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER2
).
getAbsolutePath
();
showImageDialog
(
preference
,
getString
(
R
.
string
.
card_cover
),
outFile
,
true
,
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
0
],
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
1
]);
});
});
//显示图片对话框?
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
();
showImageDialog
(
preference
,
getString
(
R
.
string
.
card_cover
),
outFile
,
true
,
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
0
],
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
1
]);
}
else
if
(
SETTINGS_CARD_BG
.
equals
(
key
))
{
}
else
if
(
SETTINGS_CARD_BG
.
equals
(
key
))
{
//显示图片对话框?
//显示图片对话框?
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
();
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
();
...
@@ -262,26 +267,26 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -262,26 +267,26 @@ public class SettingFragment extends PreferenceFragmentPlus {
private
void
showImageDialog
(
Preference
preference
,
String
title
,
String
outFile
,
boolean
isJpeg
,
int
outWidth
,
int
outHeight
)
{
private
void
showImageDialog
(
Preference
preference
,
String
title
,
String
outFile
,
boolean
isJpeg
,
int
outWidth
,
int
outHeight
)
{
int
width
=
getResources
().
getDisplayMetrics
().
widthPixels
;
int
width
=
getResources
().
getDisplayMetrics
().
widthPixels
;
DialogPlus
builder
=
new
DialogPlus
(
getActivity
());
//
DialogPlus builder = new DialogPlus(getActivity());
final
ImageView
imageView
=
new
ImageView
(
getActivity
());
final
ImageView
imageView
=
new
ImageView
(
getActivity
());
FrameLayout
frameLayout
=
new
FrameLayout
(
getActivity
());
FrameLayout
frameLayout
=
new
FrameLayout
(
getActivity
());
imageView
.
setScaleType
(
ImageView
.
ScaleType
.
FIT_CENTER
);
imageView
.
setScaleType
(
ImageView
.
ScaleType
.
FIT_CENTER
);
builder
.
setTitle
(
title
);
//
builder.setTitle(title);
FrameLayout
.
LayoutParams
layoutParams
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
FrameLayout
.
LayoutParams
layoutParams
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
);
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
);
layoutParams
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
;
layoutParams
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
;
frameLayout
.
addView
(
imageView
,
layoutParams
);
frameLayout
.
addView
(
imageView
,
layoutParams
);
builder
.
setContentView
(
frameLayout
);
//
builder.setContentView(frameLayout);
builder
.
setLeftButtonText
(
R
.
string
.
settings
);
//
builder.setLeftButtonText(R.string.settings);
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
//
builder.setLeftButtonListener((dlg, s) -> {
showImageCropChooser
(
preference
,
getString
(
R
.
string
.
dialog_select_image
),
outFile
,
showImageCropChooser
(
preference
,
getString
(
R
.
string
.
dialog_select_image
),
outFile
,
isJpeg
,
outWidth
,
outHeight
);
isJpeg
,
outWidth
,
outHeight
);
dlg
.
dismiss
();
//
dlg.dismiss();
});
//
});
// builder.setOnCancelListener((dlg) -> {
// builder.setOnCancelListener((dlg) -> {
// BitmapUtil.destroy(imageView.getDrawable());
// BitmapUtil.destroy(imageView.getDrawable());
// });
// });
builder
.
show
();
//
builder.show();
File
img
=
new
File
(
outFile
);
File
img
=
new
File
(
outFile
);
if
(
img
.
exists
())
{
if
(
img
.
exists
())
{
Glide
.
with
(
this
).
load
(
img
).
signature
(
new
StringSignature
(
img
.
getName
()
+
img
.
lastModified
()))
Glide
.
with
(
this
).
load
(
img
).
signature
(
new
StringSignature
(
img
.
getName
()
+
img
.
lastModified
()))
...
@@ -291,6 +296,14 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -291,6 +296,14 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
}
}
public
void
setImage
(
String
path
,
ImageView
imageView
){
//图片显示代码
Glide
.
with
(
this
).
load
(
path
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
NONE
)
.
override
(
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
0
],
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
1
])
.
into
(
imageView
);
}
private
void
copyDataBase
(
Preference
preference
,
String
file
)
{
private
void
copyDataBase
(
Preference
preference
,
String
file
)
{
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
Dialog
dlg
=
DialogPlus
.
show
(
getActivity
(),
null
,
getString
(
R
.
string
.
copy_databse
));
Dialog
dlg
=
DialogPlus
.
show
(
getActivity
(),
null
,
getString
(
R
.
string
.
copy_databse
));
...
...
mobile/src/main/res/layout/dialog_cover_select.xml
View file @
aa2fc2d3
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:gravity=
"center_horizontal"
>
android:gravity=
"center_horizontal"
>
<
Button
<
ImageView
android:id=
"@+id/
button_
cover1"
android:id=
"@+id/cover1"
android:layout_width=
"44dp"
android:layout_width=
"44dp"
android:layout_height=
"64dp"
/>
android:layout_height=
"64dp"
/>
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
android:layout_width=
"@dimen/label_width_middle"
android:layout_width=
"@dimen/label_width_middle"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
<
Button
<
ImageView
android:id=
"@+id/
button_
cover2"
android:id=
"@+id/cover2"
android:layout_width=
"44dp"
android:layout_width=
"44dp"
android:layout_height=
"64dp"
/>
android:layout_height=
"64dp"
/>
...
...
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