Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds-android
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
云深项目组
beyond-clouds-android
Commits
4073a6b4
Commit
4073a6b4
authored
Mar 19, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户信息对接完成
parent
688455d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
13 deletions
+50
-13
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/MyFragment.java
+34
-5
app/src/main/res/layout/fragment_my.xml
+12
-6
app/src/main/res/values/strings.xml
+4
-2
No files found.
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/MyFragment.java
View file @
4073a6b4
...
...
@@ -7,12 +7,20 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.Observer
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Priority
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.request.RequestOptions
;
import
javax.inject.Inject
;
import
cn.yunliyunwai.beyondclouds.R
;
import
cn.yunliyunwai.beyondclouds.base.BaseFragment
;
import
cn.yunliyunwai.beyondclouds.databinding.FragmentMyBinding
;
import
cn.yunliyunwai.beyondclouds.util.ContextUtils
;
import
cn.yunliyunwai.beyondclouds.util.GlideRoundTransform
;
import
cn.yunliyunwai.beyondclouds.util.ViewModelUtils
;
import
cn.yunliyunwai.beyondclouds.viewmodel.AuthenticationViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.MyFragmentViewModel
;
...
...
@@ -24,11 +32,6 @@ public class MyFragment extends BaseFragment<MyFragmentViewModel, FragmentMyBind
AuthenticationViewModel
authenticationViewModel
;
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
}
@Override
protected
void
initInject
()
{
ContextUtils
.
getAppComponent
(
requireActivity
()).
inject
(
this
);
}
...
...
@@ -49,4 +52,30 @@ public class MyFragment extends BaseFragment<MyFragmentViewModel, FragmentMyBind
binding
.
setAuthViewModel
(
authenticationViewModel
);
binding
.
setLifecycleOwner
(
this
);
}
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
bindEventListenersAndObservers
();
}
private
void
bindEventListenersAndObservers
()
{
authenticationViewModel
.
getAuthenticationState
().
observe
(
this
,
new
Observer
<
AuthenticationViewModel
.
AuthenticationState
>()
{
@Override
public
void
onChanged
(
AuthenticationViewModel
.
AuthenticationState
authenticationState
)
{
String
userAvatar
=
authenticationViewModel
.
getUserInfo
().
getUserAvatar
();
if
(
authenticationState
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
)
{
RequestOptions
glideRequestOptions
=
new
RequestOptions
()
.
centerCrop
()
.
placeholder
(
R
.
drawable
.
placeholder_rectangle
)
.
error
(
R
.
drawable
.
placeholder_rectangle
)
.
priority
(
Priority
.
HIGH
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
AUTOMATIC
)
.
transform
(
new
GlideRoundTransform
(
26
));
Glide
.
with
(
getContext
()).
load
(
userAvatar
).
apply
(
glideRequestOptions
).
into
(
binding
.
imgUserAvatar
);
}
}
});
}
}
app/src/main/res/layout/fragment_my.xml
View file @
4073a6b4
...
...
@@ -41,8 +41,9 @@
android:layout_marginTop=
"24dp"
android:layout_marginStart=
"11dp"
android:layout_marginLeft=
"11dp"
android:layout_width=
"51dp"
android:layout_height=
"51dp"
android:layout_width=
"52dp"
android:layout_height=
"52dp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:src=
"@drawable/un_sign_in"
/>
<TextView
android:id=
"@+id/txt_user_nick"
...
...
@@ -64,9 +65,10 @@
app:layout_constraintStart_toEndOf=
"@id/img_user_avatar"
android:layout_marginStart=
"12dp"
android:layout_marginLeft=
"12dp"
android:text=
"领取活跃积分"
android:text=
'@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? authViewModel.userInfo.signature : @string/signature_un_login}'
android:textColor=
"#999999"
android:textSize=
"12sp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
...
...
@@ -78,6 +80,7 @@
android:layout_marginEnd=
"11dp"
android:layout_marginRight=
"11dp"
android:layout_width=
"40dp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:layout_height=
"wrap_content"
>
<TextView
android:layout_gravity=
"start|center_vertical"
...
...
@@ -112,6 +115,7 @@
android:layout_marginLeft=
"54dp"
app:layout_constraintHorizontal_chainStyle=
"spread_inside"
android:layout_marginTop=
"28dp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:layout_width=
"wrap_content"
android:layout_height=
"45dp"
>
<TextView
...
...
@@ -123,7 +127,7 @@
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/txt_follow_num"
android:text=
"0"
android:text=
'@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? authViewModel.userInfo.statistics.followedNum : 0}'
android:textColor=
"#333333"
android:textSize=
"18sp"
android:layout_gravity=
"bottom|center_horizontal"
...
...
@@ -138,6 +142,7 @@
app:layout_constraintStart_toEndOf=
"@id/btn_follow_num"
app:layout_constraintEnd_toStartOf=
"@id/btn_fans_num"
android:layout_marginTop=
"28dp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:layout_width=
"wrap_content"
android:layout_height=
"45dp"
>
<TextView
...
...
@@ -149,7 +154,7 @@
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/txt_visit_num"
android:text=
"0"
android:text=
'@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? authViewModel.userInfo.statistics.visitedNum : 0}'
android:textColor=
"#333333"
android:textSize=
"18sp"
android:layout_gravity=
"bottom|center_horizontal"
...
...
@@ -166,6 +171,7 @@
android:layout_marginEnd=
"54dp"
android:layout_marginRight=
"54dp"
android:layout_marginTop=
"28dp"
android:onClick=
"@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? null : NavHandlers::toLogin}"
android:layout_width=
"wrap_content"
android:layout_height=
"45dp"
>
<TextView
...
...
@@ -177,7 +183,7 @@
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/txt_fans_num"
android:text=
"0"
android:text=
'@{authViewModel.authenticationState == AuthenticationState.AUTHENTICATED ? authViewModel.userInfo.statistics.fansNum : 0}'
android:textColor=
"#333333"
android:textSize=
"18sp"
android:layout_gravity=
"bottom|center_horizontal"
...
...
app/src/main/res/values/strings.xml
View file @
4073a6b4
<resources>
<string
name=
"app_name"
>
云里云外
</string>
<!--
fragment_my
.xml start -->
<!--
activity_login
.xml start -->
<string
name=
"click_to_login"
>
点击登录
</string>
<string
name=
"title_login"
>
登录
</string>
<string
name=
"login_way_password"
>
密码登录
</string>
...
...
@@ -20,7 +20,9 @@
<string
name=
"copyright"
>
Copyright © 2019 云里云外开源社区 All Rights Reserved
</string>
<string
name=
"third_party_login"
>
第三方登录
</string>
<string
name=
"to_register"
>
去注册
</string>
<!-- fragment_my.xml end -->
<!-- activity_login.xml end -->
<string
name=
"signature_un_login"
>
领取活跃积分
</string>
<!-- icons start -->
<string
name=
"icon_arrow_right"
>

</string>
...
...
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