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
68536a0a
Commit
68536a0a
authored
Jun 04, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将登录整合进我的云卡组
parent
a402f265
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
251 additions
and
52 deletions
+251
-52
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
...arymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
+133
-8
mobile/src/main/res/layout/fragment_deck_square_my_deck.xml
mobile/src/main/res/layout/fragment_deck_square_my_deck.xml
+118
-44
No files found.
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
View file @
68536a0a
package
cn.garymb.ygomobile.deck_square
;
package
cn.garymb.ygomobile.deck_square
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ProgressBar
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.Fragment
;
...
@@ -11,21 +17,30 @@ import androidx.recyclerview.widget.GridLayoutManager;
...
@@ -11,21 +17,30 @@ import androidx.recyclerview.widget.GridLayoutManager;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.deck_square.api_response.
OnlineDeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.
LoginResponse
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.databinding.FragmentDeckSquareMyDeckBinding
;
import
cn.garymb.ygomobile.lite.databinding.FragmentDeckSquareMyDeckBinding
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.YGODeckDialogUtil
;
import
cn.garymb.ygomobile.utils.YGODeckDialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
//打开页面后,先扫描本地的卡组,读取其是否包含deckId,是的话代表平台上可能有
//打开页面后,先扫描本地的卡组,读取其是否包含deckId,是的话代表平台上可能有
//之后读取平台上的卡组,与本地卡组列表做比较。
//之后读取平台上的卡组,与本地卡组列表做比较。
public
class
DeckSquareMyDeckFragment
extends
Fragment
{
public
class
DeckSquareMyDeckFragment
extends
Fragment
implements
PrivacyDialogFragment
.
PrivacyAgreementListener
{
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
FragmentDeckSquareMyDeckBinding
binding
;
private
FragmentDeckSquareMyDeckBinding
binding
;
private
MyDeckListAdapter
deckListAdapter
;
private
MyDeckListAdapter
deckListAdapter
;
private
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
;
//通知外部调用方,(如调用本fragment的activity)
private
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
;
//通知外部调用方,(如调用本fragment的activity)
private
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
;
private
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
;
private
ProgressBar
progressBar
;
private
EditText
etUsername
,
etPassword
;
private
Button
btnLogin
,
btnCancel
;
boolean
privacAgree
=
false
;
LoginDialog
loginDialog
=
null
;
public
DeckSquareMyDeckFragment
(
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
,
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
)
{
public
DeckSquareMyDeckFragment
(
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
,
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
)
{
this
.
onDeckMenuListener
=
onDeckMenuListener
;
this
.
onDeckMenuListener
=
onDeckMenuListener
;
...
@@ -33,13 +48,59 @@ public class DeckSquareMyDeckFragment extends Fragment {
...
@@ -33,13 +48,59 @@ public class DeckSquareMyDeckFragment extends Fragment {
}
}
@Override
@Override
public
View
onCreateView
(
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
@NonNull
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
binding
=
FragmentDeckSquareMyDeckBinding
.
inflate
(
inflater
,
container
,
false
);
binding
=
FragmentDeckSquareMyDeckBinding
.
inflate
(
inflater
,
container
,
false
);
binding
.
llMainUi
.
setVisibility
(
View
.
GONE
);
binding
.
mcLoginBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(!
DeckSquareApiUtil
.
needLogin
())
{
return
;
}
if
(
privacAgree
)
{
//如果不同意隐私协议,log提示用户,
loginDialog
=
new
LoginDialog
(
getContext
(),
new
LoginDialog
.
LoginListener
()
{
@Override
public
void
notifyResult
(
boolean
success
,
LoginResponse
response
)
{
// Handle login logic
if
(
success
)
{
binding
.
llMainUi
.
setVisibility
(
View
.
VISIBLE
);
LogUtil
.
i
(
TAG
,
"login success"
+
SharedPreferenceUtil
.
getServerToken
());
refreshBtn
();
//response.token;
}
else
{
YGOUtil
.
showTextToast
(
"登录失败:"
);
}
}
});
loginDialog
.
show
();
}
else
{
YGOUtil
.
showTextToast
(
"登录内容需要用户同意协议"
);
showPrivacyDialog
();
}
}
});
//其实仅仅是清除掉本机的token
binding
.
mcLogoutBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
SharedPreferenceUtil
.
deleteServerToken
();
binding
.
llMainUi
.
setVisibility
(
View
.
GONE
);
refreshBtn
();
}
});
etUsername
=
binding
.
etUsername
;
etPassword
=
binding
.
etPassword
;
btnLogin
=
binding
.
btnLogin
;
btnLogin
.
setOnClickListener
(
v
->
attemptLogin
());
progressBar
=
binding
.
progressBar
;
refreshBtn
();
deckListAdapter
=
new
MyDeckListAdapter
(
R
.
layout
.
item_my_deck
);
deckListAdapter
=
new
MyDeckListAdapter
(
R
.
layout
.
item_my_deck
);
GridLayoutManager
linearLayoutManager
=
new
GridLayoutManager
(
getContext
(),
3
);
GridLayoutManager
linearLayoutManager
=
new
GridLayoutManager
(
getContext
(),
3
);
binding
.
listMyDeckInfo
.
setLayoutManager
(
linearLayoutManager
);
binding
.
listMyDeckInfo
.
setLayoutManager
(
linearLayoutManager
);
...
@@ -90,4 +151,68 @@ public class DeckSquareMyDeckFragment extends Fragment {
...
@@ -90,4 +151,68 @@ public class DeckSquareMyDeckFragment extends Fragment {
binding
=
null
;
binding
=
null
;
}
}
private
void
attemptLogin
()
{
String
username
=
etUsername
.
getText
().
toString
().
trim
();
String
password
=
etPassword
.
getText
().
toString
().
trim
();
if
(
username
.
isEmpty
()
||
password
.
isEmpty
())
{
Toast
.
makeText
(
getContext
(),
"Please enter both username and password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
progressBar
.
setVisibility
(
View
.
VISIBLE
);
btnLogin
.
setEnabled
(
false
);
VUiKit
.
defer
().
when
(()
->
{
LogUtil
.
d
(
TAG
,
"start fetch"
);
LoginResponse
result
=
DeckSquareApiUtil
.
login
(
username
,
password
);
SharedPreferenceUtil
.
setServerToken
(
result
.
token
);
SharedPreferenceUtil
.
setServerUserId
(
result
.
user
.
id
);
return
result
;
}).
fail
((
e
)
->
{
Log
.
e
(
TAG
,
e
+
""
);
LogUtil
.
i
(
TAG
,
"login fail"
);
binding
.
llMainUi
.
setVisibility
(
View
.
GONE
);
}).
done
((
result
)
->
{
if
(
result
!=
null
)
{
LogUtil
.
i
(
TAG
,
"login done"
);
binding
.
llMainUi
.
setVisibility
(
View
.
VISIBLE
);
binding
.
llDialogLogin
.
setVisibility
(
View
.
GONE
);
YGOUtil
.
showTextToast
(
"Login success!"
);
}
else
{
LogUtil
.
i
(
TAG
,
"login fail2"
);
}
});
}
public
void
refreshBtn
()
{
if
(
DeckSquareApiUtil
.
getLoginData
()
!=
null
)
{
binding
.
mcLoginBtn
.
setText
(
"已登录"
);
}
else
{
binding
.
mcLoginBtn
.
setText
(
"登录"
);
}
}
private
void
showPrivacyDialog
()
{
PrivacyDialogFragment
dialog
=
new
PrivacyDialogFragment
();
dialog
.
setPrivacyAgreementListener
(
this
);
dialog
.
show
(
getChildFragmentManager
(),
"PrivacyDialog"
);
}
@Override
public
void
onAgree
()
{
privacAgree
=
true
;
}
@Override
public
void
onDisagree
()
{
privacAgree
=
false
;
}
}
}
mobile/src/main/res/layout/fragment_deck_square_my_deck.xml
View file @
68536a0a
...
@@ -5,6 +5,76 @@
...
@@ -5,6 +5,76 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<LinearLayout
android:id=
"@+id/ll_dialog_login"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:padding=
"16dp"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:gravity=
"center"
android:text=
"Login"
android:textSize=
"20sp"
android:textStyle=
"bold"
/>
<EditText
android:id=
"@+id/et_username"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:hint=
"Username"
android:inputType=
"text"
/>
<EditText
android:id=
"@+id/et_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:hint=
"Password"
android:inputType=
"textPassword"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:weightSum=
"2"
>
<Button
android:id=
"@+id/btn_cancel"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"4dp"
android:layout_weight=
"1"
android:text=
"Cancel"
/>
<Button
android:id=
"@+id/btn_login"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"4dp"
android:layout_weight=
"1"
android:backgroundTint=
"@color/colorPrimary"
android:text=
"Login"
/>
</LinearLayout>
<ProgressBar
android:id=
"@+id/progressBar"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:visibility=
"gone"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_main_ui"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<EditText
<EditText
android:id=
"@+id/et_my_deck_input_deck_name"
android:id=
"@+id/et_my_deck_input_deck_name"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -39,26 +109,30 @@
...
@@ -39,26 +109,30 @@
android:layout_margin=
"5dp"
android:layout_margin=
"5dp"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<View
<Button
android:layout_width=
"0dp"
android:id=
"@+id/mc_logout_btn"
android:layout_height=
"1dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:background=
"@color/holo_blue_light"
/>
android:text=
"注销"
/>
<Button
android:id=
"@+id/mc_login_btn"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"登录"
/>
<ImageButton
<ImageButton
android:id=
"@+id/refresh_data"
android:id=
"@+id/refresh_data"
android:layout_width=
"wrap_cont
ent"
android:layout_width=
"match_par
ent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:layout_weight=
"1"
android:layout_margin=
"5dp"
android:layout_margin=
"5dp"
android:background=
"@drawable/ic_radius_bg"
android:background=
"@drawable/ic_radius_bg"
android:src=
"@drawable/ic_refresh"
/>
android:src=
"@drawable/ic_refresh"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"1dp"
android:layout_weight=
"1"
android:background=
"@color/holo_blue_light"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
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