Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
5cbcfc05
Commit
5cbcfc05
authored
2 years ago
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refresh article to be continue
Took 14 minutes
parent
46dfcf97
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
38 deletions
+103
-38
build.gradle
m-article/build.gradle
+4
-0
ArticleHomeFragment.kt
m-article/src/main/java/fragment/ArticleHomeFragment.kt
+64
-9
article_fragment_layout.xml
m-article/src/main/res/layout/article_fragment_layout.xml
+35
-29
No files found.
m-article/build.gradle
View file @
5cbcfc05
...
...
@@ -82,6 +82,10 @@ dependencies {
implementation
"androidx.lifecycle:lifecycle-extensions:2.0.0"
implementation
"androidx.lifecycle:lifecycle-runtime:2.0.0"
implementation
'io.github.scwang90:refresh-layout-kernel:2.0.5'
//核心必须依赖
implementation
'io.github.scwang90:refresh-header-radar:2.0.5'
//雷达刷新头
implementation
'io.github.scwang90:refresh-footer-ball:2.0.5'
//球脉冲加载
api
rootProject
.
ext
.
dependencies
[
"ydl-user-router"
]
if
(
rootProject
.
ext
.
dev_mode
){
...
...
This diff is collapsed.
Click to expand it.
m-article/src/main/java/fragment/ArticleHomeFragment.kt
View file @
5cbcfc05
package
fragment
import
adapter.ArticleHomeItemAdapter
import
android.annotation.SuppressLint
import
android.content.Context
import
android.os.Bundle
import
android.view.View
import
android.widget.LinearLayout
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.scwang.smart.refresh.footer.BallPulseFooter
import
com.scwang.smart.refresh.header.BezierRadarHeader
import
com.scwang.smart.refresh.layout.SmartRefreshLayout
import
com.scwang.smart.refresh.layout.wrapper.RefreshFooterWrapper
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydl_router.manager.YDLRouterManager
...
...
@@ -19,11 +24,16 @@ import io.reactivex.schedulers.Schedulers
class
ArticleHomeFragment
:
BaseFragment
()
{
private
lateinit
var
mSmartRefreshLayout
:
SmartRefreshLayout
private
lateinit
var
mLvArticleContent
:
RecyclerView
private
lateinit
var
mLlEmptyLayout
:
LinearLayout
private
var
isRefreshing
:
Boolean
=
false
private
var
isLoadingMore
:
Boolean
=
false
private
var
mCurrentPage
=
0
private
var
mHasMore
=
true
private
var
mTotalPage
=
0
private
var
mTagId
:
Int
=
0
private
lateinit
var
mAdapter
:
ArticleHomeItemAdapter
...
...
@@ -34,9 +44,15 @@ class ArticleHomeFragment : BaseFragment() {
}
override
fun
initDataAndEvent
()
{
mSmartRefreshLayout
=
rootView
.
findViewById
(
R
.
id
.
smart_refresh_layout
)
mLvArticleContent
=
rootView
.
findViewById
(
R
.
id
.
rv_article_content
)
mLlEmptyLayout
=
rootView
.
findViewById
(
R
.
id
.
ll_empty
)
mSmartRefreshLayout
.
setRefreshHeader
(
BezierRadarHeader
(
activity
))
mSmartRefreshLayout
.
setRefreshFooter
(
BallPulseFooter
(
activity
))
mSmartRefreshLayout
.
autoRefresh
()
mAdapter
=
ArticleHomeItemAdapter
(
activity
as
Context
)
mAdapter
.
setOnItemClickListener
(
object
:
ArticleHomeItemAdapter
.
OnItemClickListener
{
override
fun
onItemClick
(
articleBean
:
ArticleBean
)
{
...
...
@@ -47,11 +63,28 @@ class ArticleHomeFragment : BaseFragment() {
LinearLayoutManager
(
activity
,
RecyclerView
.
VERTICAL
,
false
)
mLvArticleContent
.
adapter
=
mAdapter
if
(
mTagId
==
0
){
getRecommendArticleList
()
}
else
{
getArticleList
()
isRefreshing
=
true
mSmartRefreshLayout
.
setOnRefreshListener
{
isRefreshing
=
true
if
(
mTagId
==
0
){
getRecommendArticleList
()
}
else
{
getArticleList
(
isRefreshing
=
true
,
isLoadMore
=
false
)
}
it
.
finishRefresh
()
}
mSmartRefreshLayout
.
setOnLoadMoreListener
{
isLoadingMore
=
true
if
(
mTagId
==
0
){
getRecommendArticleList
()
}
else
{
getArticleList
(
isRefreshing
=
false
,
isLoadMore
=
true
)
}
it
.
finishLoadMore
()
}
}
override
fun
initDataAndEventLazy
()
{
...
...
@@ -62,6 +95,7 @@ class ArticleHomeFragment : BaseFragment() {
return
R
.
layout
.
article_fragment_layout
}
@SuppressLint
(
"CheckResult"
)
private
fun
getRecommendArticleList
(
loadMore
:
Boolean
=
false
)
{
ArticleHttp
.
getInstance
().
getRecommendArticleList
(
perPageRows
=
10
,
page
=
mCurrentPage
...
...
@@ -91,10 +125,15 @@ class ArticleHomeFragment : BaseFragment() {
}
private
fun
getArticleList
(
loadMore
:
Boolean
=
false
)
{
@SuppressLint
(
"CheckResult"
)
private
fun
getArticleList
(
isRefreshing
:
Boolean
=
true
,
isLoadMore
:
Boolean
=
false
)
{
ArticleHttp
.
getInstance
().
getArticleList
(
perPageRows
=
10
,
page
=
mCurrentPage
,
tagId
=
mTagId
page
=
if
(
isRefreshing
)
{
1
}
else
{
mCurrentPage
+
1
},
tagId
=
mTagId
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
@@ -107,11 +146,19 @@ class ArticleHomeFragment : BaseFragment() {
mLlEmptyLayout
.
visibility
=
View
.
GONE
mLvArticleContent
.
visibility
=
View
.
VISIBLE
mCurrentPage
=
it
.
data
.
currentPage
mTotalPage
=
it
.
data
.
totalPage
mSmartRefreshLayout
.
setEnableLoadMore
(
mCurrentPage
<
mTotalPage
)
val
articles
=
it
.
data
.
list
if
(
articles
!=
null
)
{
mAdapter
.
setData
(
articles
)
if
(
isRefreshing
){
mAdapter
.
setData
(
articles
)
}
else
{
mAdapter
.
addData
(
articles
)
}
}
}
}
else
{
mLlEmptyLayout
.
visibility
=
View
.
VISIBLE
...
...
@@ -120,6 +167,14 @@ class ArticleHomeFragment : BaseFragment() {
}
}
private
fun
refreshOrLoadingComplete
()
{
if
(
isLoadingMore
)
{
isLoadingMore
=
false
}
if
(
isRefreshing
)
{
isRefreshing
=
false
}
}
companion
object
{
...
...
This diff is collapsed.
Click to expand it.
m-article/src/main/res/layout/article_fragment_layout.xml
View file @
5cbcfc05
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:tools=
"http://schemas.android.com/tools"
>
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:tools=
"http://schemas.android.com/tools"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_article_content"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingTop=
"20dp"
android:clipToPadding=
"false"
/>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id=
"@+id/smart_refresh_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:visibility=
"gone"
android:gravity=
"center"
tools:visibility=
"visible"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_article_content"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingTop=
"20dp"
android:clipToPadding=
"false"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/platform_ydlcommon_blank"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"14dp"
android:text=
"暂无相应记录"
android:textColor=
"#b2b2b2"
/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:visibility=
"gone"
android:gravity=
"center"
tools:visibility=
"visible"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/platform_ydlcommon_blank"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"14dp"
android:text=
"暂无相应记录"
android:textColor=
"#b2b2b2"
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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