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
26960122
Commit
26960122
authored
Apr 13, 2025
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加上传功能api调用
parent
4faa559f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
265 additions
and
11 deletions
+265
-11
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
...arymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
+7
-6
mobile/src/main/java/cn/garymb/ygomobile/deck_square/MyDeckDetailDialog.java
...a/cn/garymb/ygomobile/deck_square/MyDeckDetailDialog.java
+141
-0
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/DeckDetail.java
...garymb/ygomobile/deck_square/api_response/DeckDetail.java
+5
-5
mobile/src/main/res/layout/dialog_square_my_deck_detail.xml
mobile/src/main/res/layout/dialog_square_my_deck_detail.xml
+38
-0
mobile/src/main/res/layout/item_my_deck.xml
mobile/src/main/res/layout/item_my_deck.xml
+74
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
View file @
26960122
...
@@ -10,9 +10,13 @@ import androidx.fragment.app.Fragment;
...
@@ -10,9 +10,13 @@ import androidx.fragment.app.Fragment;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
cn.garymb.ygomobile.deck_square.api_response.ApiDeckRecord
;
import
cn.garymb.ygomobile.deck_square.api_response.ApiDeckRecord
;
import
cn.garymb.ygomobile.deck_square.api_response.DeckDetail
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.databinding.FragmentUserOnlineDeckBinding
;
import
cn.garymb.ygomobile.lite.databinding.FragmentUserOnlineDeckBinding
;
//打开页面后,先扫描本地的卡组,读取其是否包含deckId,是的话代表平台上可能有
//之后读取平台上的卡组,与本地卡组列表做比较。
public
class
DeckSquareMyDeckFragment
extends
Fragment
{
public
class
DeckSquareMyDeckFragment
extends
Fragment
{
private
FragmentUserOnlineDeckBinding
binding
;
private
FragmentUserOnlineDeckBinding
binding
;
...
@@ -49,14 +53,11 @@ public class DeckSquareMyDeckFragment extends Fragment {
...
@@ -49,14 +53,11 @@ public class DeckSquareMyDeckFragment extends Fragment {
deckListAdapter
.
setOnItemClickListener
(
deckListAdapter
.
setOnItemClickListener
(
(
adapter
,
view
,
position
)
->
{
(
adapter
,
view
,
position
)
->
{
// Handle item click
// Handle item click
ApiDeckRecord
item
=
(
ApiDeckRecord
)
adapter
.
getItem
(
position
);
DeckDetail
item
=
(
DeckDetail
)
adapter
.
getItem
(
position
);
// Show the dialog
MyDeckDetailDialog
dialog
=
new
MyDeckDetailDialog
(
getContext
(),
item
);
//todo 询问是否删除?
// SquareDeckDetailDialog dialog = new SquareDeckDetailDialog(getContext(), item);
//
dialog.show();
dialog
.
show
();
}
}
);
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/deck_square/MyDeckDetailDialog.java
0 → 100644
View file @
26960122
package
cn.garymb.ygomobile.deck_square
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.Window
;
import
android.widget.Button
;
import
com.google.gson.Gson
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.deck_square.api_response.ApiDeckRecord
;
import
cn.garymb.ygomobile.deck_square.api_response.DeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.DownloadDeckResponse
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
okhttp3.Response
;
public
class
MyDeckDetailDialog
extends
Dialog
{
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
String
deckId
;
private
String
deckName
;
private
Integer
userId
;
public
interface
ActionListener
{
void
onDownloadClicked
();
void
onLikeClicked
();
}
private
ActionListener
listener
;
public
MyDeckDetailDialog
(
Context
context
,
DeckDetail
item
)
{
super
(
context
);
deckId
=
item
.
getDeckId
();
deckName
=
item
.
getDeckName
();
userId
=
item
.
getUserId
();
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
dialog_square_my_deck_detail
);
Button
btnDownload
=
findViewById
(
R
.
id
.
btnDownload
);
Button
btnLike
=
findViewById
(
R
.
id
.
btnLike
);
btnDownload
.
setOnClickListener
(
v
->
{
VUiKit
.
defer
().
when
(()
->
{
DownloadDeckResponse
result
=
null
;
String
url
=
"http://rarnu.xyz:38383/api/mdpro3/deck/"
+
deckId
;
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"ReqSource"
,
"MDPro3"
);
Response
response
=
null
;
try
{
response
=
OkhttpUtil
.
synchronousGet
(
url
,
null
,
headers
);
String
responseBodyString
=
response
.
body
().
string
();
Gson
gson
=
new
Gson
();
// Convert JSON to Java object using Gson
result
=
gson
.
fromJson
(
responseBodyString
,
DownloadDeckResponse
.
class
);
LogUtil
.
i
(
TAG
,
responseBodyString
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
if
(
result
==
null
)
{
return
null
;
}
else
{
return
result
.
getData
();
}
}).
fail
((
e
)
->
{
Log
.
e
(
TAG
,
e
+
""
);
// if (dialog_read_ex.isShowing()) {//关闭异常
// try {
// dialog_read_ex.dismiss();
// } catch (Exception ex) {
//
// }
// }
LogUtil
.
i
(
TAG
,
"square deck detail fail"
);
}).
done
((
deckData
)
->
{
if
(
deckData
!=
null
)
{
String
path
=
AppsSettings
.
get
().
getDeckDir
();
saveFileToPath
(
path
,
deckName
+
".ydk"
,
deckData
.
deckYdk
);
LogUtil
.
i
(
TAG
,
"square deck detail done"
);
YGOUtil
.
showTextToast
(
R
.
string
.
down_complete
);
}
// if (dialog_read_ex.isShowing()) {
// try {
// dialog_read_ex.dismiss();
// } catch (Exception ex) {
// }
// }
});
dismiss
();
});
btnLike
.
setOnClickListener
(
v
->
{
dismiss
();
});
}
public
void
saveFileToPath
(
String
path
,
String
fileName
,
String
content
)
{
try
{
// Create file object
File
file
=
new
File
(
path
,
fileName
);
// Create file output stream
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
// Write content
fos
.
write
(
content
.
getBytes
());
fos
.
flush
();
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/DeckDetail.java
View file @
26960122
...
@@ -22,7 +22,7 @@ public class DeckDetail implements Parcelable {
...
@@ -22,7 +22,7 @@ public class DeckDetail implements Parcelable {
public
String
deckProtector
;
public
String
deckProtector
;
public
String
deckMainSerial
;
public
String
deckMainSerial
;
public
String
deckYdk
;
public
String
deckYdk
;
public
String
userId
;
public
Integer
userId
;
public
String
isPublic
;
public
String
isPublic
;
public
String
isDelete
;
public
String
isDelete
;
...
@@ -41,7 +41,7 @@ public class DeckDetail implements Parcelable {
...
@@ -41,7 +41,7 @@ public class DeckDetail implements Parcelable {
deckProtector
=
in
.
readString
();
deckProtector
=
in
.
readString
();
deckMainSerial
=
in
.
readString
();
deckMainSerial
=
in
.
readString
();
deckYdk
=
in
.
readString
();
deckYdk
=
in
.
readString
();
userId
=
in
.
read
String
();
userId
=
in
.
read
Int
();
isPublic
=
in
.
readString
();
isPublic
=
in
.
readString
();
isDelete
=
in
.
readString
();
isDelete
=
in
.
readString
();
}
}
...
@@ -79,7 +79,7 @@ public class DeckDetail implements Parcelable {
...
@@ -79,7 +79,7 @@ public class DeckDetail implements Parcelable {
dest
.
writeString
(
deckProtector
);
dest
.
writeString
(
deckProtector
);
dest
.
writeString
(
deckMainSerial
);
dest
.
writeString
(
deckMainSerial
);
dest
.
writeString
(
deckYdk
);
dest
.
writeString
(
deckYdk
);
dest
.
write
String
(
userId
);
dest
.
write
Int
(
userId
);
dest
.
writeString
(
isPublic
);
dest
.
writeString
(
isPublic
);
dest
.
writeString
(
isDelete
);
dest
.
writeString
(
isDelete
);
...
@@ -197,11 +197,11 @@ public class DeckDetail implements Parcelable {
...
@@ -197,11 +197,11 @@ public class DeckDetail implements Parcelable {
this
.
deckYdk
=
deckYdk
;
this
.
deckYdk
=
deckYdk
;
}
}
public
String
getUserId
()
{
public
Integer
getUserId
()
{
return
userId
;
return
userId
;
}
}
public
void
setUserId
(
String
userId
)
{
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
...
...
mobile/src/main/res/layout/dialog_square_my_deck_detail.xml
0 → 100644
View file @
26960122
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:padding=
"16dp"
>
<TextView
android:id=
"@+id/tvTitle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:gravity=
"center"
android:text=
"Choose Action"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<Button
android:id=
"@+id/btnDownload"
style=
"@style/Widget.AppCompat.Button.Borderless"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:drawableStart=
"@drawable/ic_download"
android:drawablePadding=
"8dp"
android:text=
"Upload"
/>
<Button
android:id=
"@+id/btnLike"
style=
"@style/Widget.AppCompat.Button.Borderless"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:drawableStart=
"@drawable/ic_like"
android:drawablePadding=
"8dp"
android:text=
"Delete"
/>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/layout/item_my_deck.xml
0 → 100644
View file @
26960122
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/holo_blue_bright"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/deck_info_image"
android:layout_width=
"@dimen/card_width_middle"
android:layout_height=
"@dimen/card_height_middle"
/>
<TextView
android:id=
"@+id/deck_upload_state"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/deck_id"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/deck_info_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<!-- <TextView
android:id="@+id/deck_contributor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />-->
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/deck_contributor"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
<TextView
android:id=
"@+id/deck_last_date"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/text_download_precard"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:background=
"@drawable/ic_like"
android:clickable=
"false"
android:gravity=
"center"
android:textAlignment=
"center"
android:textColor=
"@color/gold"
android:textSize=
"10sp"
/>
<TextView
android:id=
"@+id/deck_like"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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