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
841b9f94
Commit
841b9f94
authored
Mar 20, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新栏目加载方式-工具用户登录状态加载
parent
8389aa75
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
90 additions
and
16 deletions
+90
-16
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/DynamicFragment.java
+16
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/HomeFragment.java
+16
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/ProjectFragment.java
+17
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/QAFragment.java
+17
-0
app/src/main/java/cn/yunliyunwai/beyondclouds/util/CategoryViewpagerUtils.java
+0
-2
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/DynamicFragmentViewModel.java
+20
-10
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/HomeFragmentViewModel.java
+1
-1
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/ProjectFragmentViewModel.java
+1
-1
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/QAFragmentViewModel.java
+1
-1
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/common/CategoryViewModel.java
+1
-1
No files found.
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/DynamicFragment.java
View file @
841b9f94
...
...
@@ -8,6 +8,7 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
...
...
@@ -25,6 +26,7 @@ import cn.yunliyunwai.beyondclouds.ui.common.RefreshableFragment;
import
cn.yunliyunwai.beyondclouds.ui.common.listener.OnNavigationReselectedListener
;
import
cn.yunliyunwai.beyondclouds.util.CategoryViewpagerUtils
;
import
cn.yunliyunwai.beyondclouds.util.ContextUtils
;
import
cn.yunliyunwai.beyondclouds.viewmodel.AuthenticationViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.DynamicFragmentViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.DynamicListFragmentViewModel
;
...
...
@@ -34,6 +36,9 @@ public class DynamicFragment extends BaseFragment<DynamicFragmentViewModel, Frag
@Inject
ViewModelProvider
.
Factory
factory
;
@Inject
AuthenticationViewModel
authenticationViewModel
;
@Override
protected
void
initInject
()
{
ContextUtils
.
getAppComponent
(
requireActivity
()).
inject
(
this
);
...
...
@@ -53,6 +58,17 @@ public class DynamicFragment extends BaseFragment<DynamicFragmentViewModel, Frag
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
authenticationViewModel
.
getAuthenticationState
().
observe
(
this
,
new
Observer
<
AuthenticationViewModel
.
AuthenticationState
>()
{
@Override
public
void
onChanged
(
AuthenticationViewModel
.
AuthenticationState
authenticationState
)
{
if
(
authenticationState
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
)
{
viewModel
.
loadCategories
(
true
);
}
else
{
viewModel
.
loadCategories
(
false
);
}
}
});
CategoryViewpagerUtils
.
bindViewPager
(
this
,
new
FragmentFactory
()
{
@Override
public
Fragment
create
()
{
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/HomeFragment.java
View file @
841b9f94
...
...
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
...
...
@@ -29,6 +30,7 @@ import cn.yunliyunwai.beyondclouds.ui.popup.PopupAddMenu;
import
cn.yunliyunwai.beyondclouds.util.CategoryViewpagerUtils
;
import
cn.yunliyunwai.beyondclouds.util.ContextUtils
;
import
cn.yunliyunwai.beyondclouds.util.DimensionUtils
;
import
cn.yunliyunwai.beyondclouds.viewmodel.AuthenticationViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.BlogListFragmentViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.HomeFragmentViewModel
;
...
...
@@ -37,6 +39,9 @@ public class HomeFragment extends BaseFragment<HomeFragmentViewModel, FragmentHo
@Inject
ViewModelProvider
.
Factory
factory
;
@Inject
AuthenticationViewModel
authenticationViewModel
;
@Override
protected
void
initInject
()
{
((
BeyondApplication
)(
requireActivity
().
getApplication
())).
getAppComponent
().
inject
(
this
);
...
...
@@ -61,7 +66,18 @@ public class HomeFragment extends BaseFragment<HomeFragmentViewModel, FragmentHo
return
new
BlogListFragment
();
}
},
binding
.
magicIndicator
,
binding
.
viewPager
,
viewModel
,
false
);
viewModel
.
loadCategories
(
authenticationViewModel
.
getAuthenticationState
().
getValue
()
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
);
authenticationViewModel
.
getAuthenticationState
().
observe
(
this
,
new
Observer
<
AuthenticationViewModel
.
AuthenticationState
>()
{
@Override
public
void
onChanged
(
AuthenticationViewModel
.
AuthenticationState
authenticationState
)
{
if
(
authenticationState
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
)
{
viewModel
.
loadCategories
(
true
);
}
else
{
viewModel
.
loadCategories
(
false
);
}
}
});
PopupAddMenu
popupAddMenu
=
new
PopupAddMenu
(
getContext
());
binding
.
searchBar
.
setRightIconClickListener
(
new
View
.
OnClickListener
()
{
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/ProjectFragment.java
View file @
841b9f94
...
...
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
...
...
@@ -27,6 +28,7 @@ import cn.yunliyunwai.beyondclouds.ui.common.RefreshableFragment;
import
cn.yunliyunwai.beyondclouds.ui.common.listener.OnNavigationReselectedListener
;
import
cn.yunliyunwai.beyondclouds.util.CategoryViewpagerUtils
;
import
cn.yunliyunwai.beyondclouds.util.ContextUtils
;
import
cn.yunliyunwai.beyondclouds.viewmodel.AuthenticationViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.ProjectFragmentViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.ProjectListFragmentViewModel
;
...
...
@@ -36,6 +38,9 @@ public class ProjectFragment extends BaseFragment<ProjectFragmentViewModel, Frag
@Inject
ViewModelProvider
.
Factory
factory
;
@Inject
AuthenticationViewModel
authenticationViewModel
;
@Override
protected
void
initInject
()
{
((
BeyondApplication
)(
requireActivity
().
getApplication
())).
getAppComponent
().
inject
(
this
);
...
...
@@ -54,6 +59,18 @@ public class ProjectFragment extends BaseFragment<ProjectFragmentViewModel, Frag
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
authenticationViewModel
.
getAuthenticationState
().
observe
(
this
,
new
Observer
<
AuthenticationViewModel
.
AuthenticationState
>()
{
@Override
public
void
onChanged
(
AuthenticationViewModel
.
AuthenticationState
authenticationState
)
{
if
(
authenticationState
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
)
{
viewModel
.
loadCategories
(
true
);
}
else
{
viewModel
.
loadCategories
(
false
);
}
}
});
CategoryViewpagerUtils
.
bindViewPager
(
this
,
new
FragmentFactory
()
{
@Override
public
Fragment
create
()
{
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/ui/main/QAFragment.java
View file @
841b9f94
...
...
@@ -8,6 +8,7 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
...
...
@@ -26,6 +27,7 @@ import cn.yunliyunwai.beyondclouds.ui.common.listener.OnNavigationReselectedList
import
cn.yunliyunwai.beyondclouds.util.CategoryViewpagerUtils
;
import
cn.yunliyunwai.beyondclouds.util.ContextUtils
;
import
cn.yunliyunwai.beyondclouds.util.ViewModelUtils
;
import
cn.yunliyunwai.beyondclouds.viewmodel.AuthenticationViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.QAFragmentViewModel
;
import
cn.yunliyunwai.beyondclouds.viewmodel.QuestionListFragmentViewModel
;
...
...
@@ -35,6 +37,9 @@ public class QAFragment extends BaseFragment<QAFragmentViewModel, FragmentQaBind
@Inject
ViewModelProvider
.
Factory
factory
;
@Inject
AuthenticationViewModel
authenticationViewModel
;
@Override
protected
void
initInject
()
{
ContextUtils
.
getAppComponent
(
requireActivity
()).
inject
(
this
);
...
...
@@ -53,6 +58,18 @@ public class QAFragment extends BaseFragment<QAFragmentViewModel, FragmentQaBind
@Override
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
authenticationViewModel
.
getAuthenticationState
().
observe
(
this
,
new
Observer
<
AuthenticationViewModel
.
AuthenticationState
>()
{
@Override
public
void
onChanged
(
AuthenticationViewModel
.
AuthenticationState
authenticationState
)
{
if
(
authenticationState
==
AuthenticationViewModel
.
AuthenticationState
.
AUTHENTICATED
)
{
viewModel
.
loadCategories
(
true
);
}
else
{
viewModel
.
loadCategories
(
false
);
}
}
});
CategoryViewpagerUtils
.
bindViewPager
(
this
,
new
FragmentFactory
()
{
@Override
public
Fragment
create
()
{
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/util/CategoryViewpagerUtils.java
View file @
841b9f94
...
...
@@ -25,7 +25,6 @@ public class CategoryViewpagerUtils {
magicIndicator
.
setNavigator
(
commonNavigator
);
ViewPagerHelper
.
bind
(
magicIndicator
,
viewPager
);
viewModel
.
loadCategories
();
viewModel
.
getCategories
()
.
observe
(
fragment
.
getViewLifecycleOwner
(),
...
...
@@ -42,7 +41,6 @@ public class CategoryViewpagerUtils {
magicIndicator
.
setNavigator
(
commonNavigator
);
ViewPagerHelper
.
bind
(
magicIndicator
,
viewPager
);
viewModel
.
loadCategories
();
viewModel
.
getCategories
()
.
observe
(
activity
,
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/DynamicFragmentViewModel.java
View file @
841b9f94
...
...
@@ -14,15 +14,25 @@ public class DynamicFragmentViewModel extends CategoryViewModel {
}
@Override
public
void
loadCategories
()
{
refreshCategories
(
Arrays
.
asList
(
CommonCategory
.
latest
(),
CommonCategory
.
recommend
(),
CommonCategory
.
follow
(),
CommonCategory
.
my
(),
CommonCategory
.
words
(),
CommonCategory
.
photos
(),
CommonCategory
.
videos
()
));
public
void
loadCategories
(
boolean
authenticated
)
{
if
(
authenticated
)
{
refreshCategories
(
Arrays
.
asList
(
CommonCategory
.
latest
(),
CommonCategory
.
recommend
(),
CommonCategory
.
follow
(),
CommonCategory
.
my
(),
CommonCategory
.
words
(),
CommonCategory
.
photos
(),
CommonCategory
.
videos
()
));
}
else
{
refreshCategories
(
Arrays
.
asList
(
CommonCategory
.
latest
(),
CommonCategory
.
recommend
(),
CommonCategory
.
words
(),
CommonCategory
.
photos
(),
CommonCategory
.
videos
()));
}
}
}
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/HomeFragmentViewModel.java
View file @
841b9f94
...
...
@@ -22,7 +22,7 @@ public class HomeFragmentViewModel extends CategoryViewModel {
}
@Override
public
void
loadCategories
()
{
public
void
loadCategories
(
boolean
authenticated
)
{
List
<
CommonCategory
>
commonCategories
=
new
ArrayList
<>(
Arrays
.
asList
(
CommonCategory
.
recommend
(),
CommonCategory
.
latest
()));
blogRepository
.
loadCategoriesFromCache
().
observeForever
(
new
Observer
<
List
<
BlogCategory
>>()
{
@Override
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/ProjectFragmentViewModel.java
View file @
841b9f94
...
...
@@ -23,7 +23,7 @@ public class ProjectFragmentViewModel extends CategoryViewModel {
}
@Override
public
void
loadCategories
()
{
public
void
loadCategories
(
boolean
authenticated
)
{
List
<
CommonCategory
>
commonCategories
=
new
ArrayList
<>(
Arrays
.
asList
(
CommonCategory
.
recommend
(),
CommonCategory
.
latest
()));
projectRepository
.
loadCategoriesFromCache
().
observeForever
(
new
Observer
<
List
<
ProjectCategory
>>()
{
@Override
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/QAFragmentViewModel.java
View file @
841b9f94
...
...
@@ -22,7 +22,7 @@ public class QAFragmentViewModel extends CategoryViewModel {
}
@Override
public
void
loadCategories
()
{
public
void
loadCategories
(
boolean
authenticated
)
{
List
<
CommonCategory
>
commonCategories
=
new
ArrayList
<>(
Arrays
.
asList
(
CommonCategory
.
latest
()));
questionRepository
.
loadCategoriesFromCache
().
observeForever
(
new
Observer
<
List
<
QuestionCategory
>>()
{
@Override
...
...
app/src/main/java/cn/yunliyunwai/beyondclouds/viewmodel/common/CategoryViewModel.java
View file @
841b9f94
...
...
@@ -20,5 +20,5 @@ public abstract class CategoryViewModel extends ViewModel {
return
categories
;
}
public
abstract
void
loadCategories
();
public
abstract
void
loadCategories
(
boolean
authenticated
);
}
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