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
be768178
Commit
be768178
authored
Jul 28, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 我的动态列表 KotlinNullPointerException 问题修复
parent
448abcc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
101 deletions
+103
-101
TrendsListFragment.kt
m-dynamic/src/main/java/com/yidianling/dynamic/trendList/TrendsListFragment.kt
+103
-101
No files found.
m-dynamic/src/main/java/com/yidianling/dynamic/trendList/TrendsListFragment.kt
View file @
be768178
...
@@ -8,16 +8,16 @@ import android.annotation.SuppressLint
...
@@ -8,16 +8,16 @@ import android.annotation.SuppressLint
import
android.content.Intent
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Handler
import
android.os.Handler
import
androidx.interpolator.view.animation.FastOutLinearInInterpolator
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.LinearLayout
import
android.widget.LinearLayout
import
android.widget.TextView
import
android.widget.TextView
import
androidx.interpolator.view.animation.FastOutLinearInInterpolator
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import
com.ydl.webview.H5Params
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydlcommon.utils.BuryPointUtils
import
com.ydl.ydlcommon.utils.BuryPointUtils
...
@@ -25,8 +25,8 @@ import com.ydl.ydlcommon.utils.SharedPreferencesEditor
...
@@ -25,8 +25,8 @@ import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import
com.ydl.ydlcommon.view.WrapContentLinearLayoutManager
import
com.ydl.ydlcommon.view.WrapContentLinearLayoutManager
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.dynamic.bean.DynamicConstants
import
com.yidianling.dynamic.R
import
com.yidianling.dynamic.R
import
com.yidianling.dynamic.bean.DynamicConstants
import
com.yidianling.dynamic.common.net.DynamicApiUtils
import
com.yidianling.dynamic.common.net.DynamicApiUtils
import
com.yidianling.dynamic.model.*
import
com.yidianling.dynamic.model.*
import
com.yidianling.dynamic.publishTrend.PublishTrendActivity
import
com.yidianling.dynamic.publishTrend.PublishTrendActivity
...
@@ -35,15 +35,12 @@ import com.yidianling.dynamic.topic.AllTopicActivity
...
@@ -35,15 +35,12 @@ import com.yidianling.dynamic.topic.AllTopicActivity
import
com.yidianling.dynamic.trendList.adapter.RecommendTopAdapter
import
com.yidianling.dynamic.trendList.adapter.RecommendTopAdapter
import
com.yidianling.dynamic.trendList.adapter.RecommendTopicListAdapter
import
com.yidianling.dynamic.trendList.adapter.RecommendTopicListAdapter
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter.FOOTER_STATE_NO_DATA
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter.*
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter.FOOTRE_STATE_LOAD_MORE
import
com.yidianling.dynamic.trendList.adapter.TrendsListAdapter.FOOTRE_STATE_INIT
import
com.yidianling.dynamic.trendsDetail.TrendsDetailActivity
import
com.yidianling.dynamic.trendsDetail.TrendsDetailActivity
import
com.yidianling.dynamic.trendsHome.TrendsHomeFragment
import
com.yidianling.dynamic.trendsHome.TrendsHomeFragment
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
kotlinx.android.synthetic.main.dynamic_fragment_trends_list.*
import
kotlinx.android.synthetic.main.dynamic_fragment_trends_list.*
import
java.util.*
/**
/**
...
@@ -113,9 +110,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -113,9 +110,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
LinearLayoutManager
(
activity
)
LinearLayoutManager
(
activity
)
mRecommendTopAdapter
=
RecommendTopAdapter
<
TrendsListBean
.
ExtData
>(
activity
)
mRecommendTopAdapter
=
RecommendTopAdapter
<
TrendsListBean
.
ExtData
>(
activity
)
mRecommendTopRcv
=
view
.
findViewById
<
View
>(
R
.
id
.
recy_top
)
as
RecyclerView
mRecommendTopRcv
=
view
.
findViewById
<
View
>(
R
.
id
.
recy_top
)
as
RecyclerView
mRecommendTopRcv
!!
.
layoutManager
=
linearLayoutManager
mRecommendTopRcv
?
.
layoutManager
=
linearLayoutManager
mRecommendTopRcv
!!
.
adapter
=
mRecommendTopAdapter
mRecommendTopRcv
?
.
adapter
=
mRecommendTopAdapter
mRecommendTopRcv
!!
.
visibility
=
View
.
GONE
mRecommendTopRcv
?
.
visibility
=
View
.
GONE
return
view
return
view
}
}
...
@@ -123,7 +120,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -123,7 +120,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
get
()
{
get
()
{
if
(
tab
==
1
&&
trendType
==
TREND_TYPE_DEFAULT
)
{
if
(
tab
==
1
&&
trendType
==
TREND_TYPE_DEFAULT
)
{
headers
=
arrayOf
(
headerView
,
recommendTopHeaderView
)
headers
=
arrayOf
(
headerView
,
recommendTopHeaderView
)
return
headers
!!
.
size
return
headers
?.
size
?:
0
}
}
return
0
return
0
}
}
...
@@ -151,15 +148,18 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -151,15 +148,18 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
private
val
lastId
:
Int
private
val
lastId
:
Int
get
()
{
get
()
{
var
id
:
String
?
=
"0"
var
id
:
String
?
=
"0"
if
(
trendsDatas
!=
null
&&
trendsDatas
!!
.
size
>
0
)
{
trendsDatas
?.
let
{
trendsDatas
->
LogUtil
.
i
(
"TAG get last content: "
+
trendsDatas
!!
[
trendsDatas
!!
.
size
-
1
].
toString
())
if
(
trendsDatas
.
size
>
0
)
{
id
=
trendsDatas
!!
[
trendsDatas
!!
.
size
-
1
].
id
LogUtil
.
i
(
"TAG get last content: "
+
trendsDatas
[
trendsDatas
.
size
].
toString
())
return
if
(
id
==
null
||
id
==
""
)
{
id
=
trendsDatas
[
trendsDatas
.
size
-
1
].
id
0
return
if
(
id
==
null
||
id
==
""
)
{
}
else
{
0
Integer
.
valueOf
(
id
)
}
else
{
Integer
.
valueOf
(
id
)
}
}
}
}
}
return
0
return
0
}
}
...
@@ -194,12 +194,12 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -194,12 +194,12 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
private
fun
initViews
()
{
private
fun
initViews
()
{
if
(
trendType
==
TREND_TYPE_USER_TREND
||
trendType
==
TREND_TYPE_TOPIC_TREND
)
{
if
(
trendType
==
TREND_TYPE_USER_TREND
||
trendType
==
TREND_TYPE_TOPIC_TREND
)
{
trends_lastr_swl
!!
.
isEnabled
=
false
trends_lastr_swl
?
.
isEnabled
=
false
trends_rcv
!!
.
isNestedScrollingEnabled
=
false
trends_rcv
?
.
isNestedScrollingEnabled
=
false
}
else
{
}
else
{
trends_lastr_swl
!!
.
setViewGroup
(
trends_rcv
)
trends_lastr_swl
?
.
setViewGroup
(
trends_rcv
)
trends_lastr_swl
!!
.
setOnRefreshListener
(
this
)
trends_lastr_swl
?
.
setOnRefreshListener
(
this
)
trends_lastr_swl
!!
.
setColorSchemeResources
(
R
.
color
.
platform_main_theme
)
trends_lastr_swl
?
.
setColorSchemeResources
(
R
.
color
.
platform_main_theme
)
}
}
initRecyclerView
()
initRecyclerView
()
}
}
...
@@ -225,7 +225,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -225,7 +225,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
private
fun
initRecyclerView
()
{
private
fun
initRecyclerView
()
{
trendsDatas
=
ArrayList
<
TrendsListBean
.
Trend
>()
trendsDatas
=
ArrayList
<
TrendsListBean
.
Trend
>()
mRcvAdapter
=
TrendsListAdapter
(
activity
,
trendsDatas
)
mRcvAdapter
=
TrendsListAdapter
(
activity
,
trendsDatas
)
mRcvAdapter
!!
.
setOnItemClickListener
(
object
:
TrendsListAdapter
.
OnItemClickListener
{
mRcvAdapter
?
.
setOnItemClickListener
(
object
:
TrendsListAdapter
.
OnItemClickListener
{
override
fun
onItemLikeClick
(
override
fun
onItemLikeClick
(
view
:
View
,
view
:
View
,
position
:
Int
,
position
:
Int
,
...
@@ -235,11 +235,11 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -235,11 +235,11 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
}
}
override
fun
onItemClick
(
id
:
Int
,
commentCount
:
Int
,
position
:
Int
)
{
override
fun
onItemClick
(
id
:
Int
,
commentCount
:
Int
,
position
:
Int
)
{
val
trend
=
trendsDatas
!!
[
position
-
mRcvAdapter
!!
.
headersCount
]
val
trend
=
trendsDatas
?.
get
(
position
-
(
mRcvAdapter
?.
headersCount
?:
0
))
if
(
trend
.
isAd
==
1
)
{
if
(
trend
?
.
isAd
==
1
)
{
//广告跳转H5
//广告跳转H5
NewH5Activity
.
start
(
context
,
H5Params
(
trend
.
url
,
null
,
trend
.
share
))
NewH5Activity
.
start
(
context
,
H5Params
(
trend
?.
url
,
null
,
trend
?
.
share
))
DynamicApiUtils
.
adClickCount
(
Command
.
AdClickCount
(
trend
.
focId
))
DynamicApiUtils
.
adClickCount
(
Command
.
AdClickCount
(
trend
?
.
focId
))
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
objectBaseResponse
->
.
subscribe
({
objectBaseResponse
->
...
@@ -250,9 +250,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -250,9 +250,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
return
return
}
}
BuryPointUtils
.
getInstance
().
createMap
()
BuryPointUtils
.
getInstance
().
createMap
()
.
put
(
"dynamic_ID"
,
trend
.
id
)
.
put
(
"dynamic_ID"
,
trend
?
.
id
)
.
put
(
"dynamic_name"
,
trend
.
title
)
.
put
(
"dynamic_name"
,
trend
?
.
title
)
.
put
(
"dynamic_type"
,
trend
.
topicTitle
)
.
put
(
"dynamic_type"
,
trend
?
.
topicTitle
)
.
burryPoint
(
"Dynamic_click"
)
.
burryPoint
(
"Dynamic_click"
)
TrendsDetailActivity
.
startForResult
(
TrendsDetailActivity
.
startForResult
(
this
@TrendsListFragment
,
this
@TrendsListFragment
,
...
@@ -266,11 +266,11 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -266,11 +266,11 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
override
fun
onItemCommentClick
(
id
:
Int
,
commentCount
:
Int
,
position
:
Int
)
{
override
fun
onItemCommentClick
(
id
:
Int
,
commentCount
:
Int
,
position
:
Int
)
{
BuryPointUtils
.
getInstance
().
createMap
()
BuryPointUtils
.
getInstance
().
createMap
()
.
put
(
"dynamic_name"
,
trendsDatas
!!
[
position
-
mRcvAdapter
!!
.
headersCount
]
.
title
)
.
put
(
"dynamic_name"
,
trendsDatas
?.
get
(
position
-
(
mRcvAdapter
?.
headersCount
?:
0
))
?
.
title
)
.
put
(
"dynamic_ID"
,
trendsDatas
!!
[
position
-
mRcvAdapter
!!
.
headersCount
]
.
id
)
.
put
(
"dynamic_ID"
,
trendsDatas
?.
get
(
position
-
(
mRcvAdapter
?.
headersCount
?:
0
))
?
.
id
)
.
put
(
.
put
(
"dynamic_type"
,
"dynamic_type"
,
trendsDatas
!!
[
position
-
mRcvAdapter
!!
.
headersCount
]
.
topicTitle
trendsDatas
?.
get
(
position
-
(
mRcvAdapter
?.
headersCount
?:
0
))
?
.
topicTitle
)
)
.
burryPoint
(
"Comment_dynamic"
)
.
burryPoint
(
"Comment_dynamic"
)
TrendsDetailActivity
.
startForResult
(
TrendsDetailActivity
.
startForResult
(
...
@@ -286,9 +286,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -286,9 +286,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
val
layoutManager
=
val
layoutManager
=
WrapContentLinearLayoutManager
(
activity
,
WrapContentLinearLayoutManager
.
VERTICAL
,
false
)
WrapContentLinearLayoutManager
(
activity
,
WrapContentLinearLayoutManager
.
VERTICAL
,
false
)
// LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
// LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
trends_rcv
!!
.
adapter
=
mRcvAdapter
trends_rcv
?
.
adapter
=
mRcvAdapter
trends_rcv
!!
.
layoutManager
=
layoutManager
trends_rcv
?
.
layoutManager
=
layoutManager
trends_rcv
!!
.
itemAnimator
?.
changeDuration
=
0
//解决局部刷新闪屏
trends_rcv
?
.
itemAnimator
?.
changeDuration
=
0
//解决局部刷新闪屏
mScrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
mScrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
)
super
.
onScrollStateChanged
(
recyclerView
,
newState
)
...
@@ -313,22 +313,22 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -313,22 +313,22 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
super
.
onScrolled
(
recyclerView
,
dx
,
dy
)
super
.
onScrolled
(
recyclerView
,
dx
,
dy
)
try
{
try
{
if
(!
recyclerView
!!
.
canScrollVertically
(-
1
))
{
if
(!
recyclerView
?
.
canScrollVertically
(-
1
))
{
//滑到顶部,隐藏按钮
//滑到顶部,隐藏按钮
image_scroll_top
!!
.
animate
()
.
cancel
()
image_scroll_top
?.
animate
()
?
.
cancel
()
image_scroll_top
!!
.
animate
()
image_scroll_top
?
.
animate
()
.
scaleX
(
0f
)
?
.
scaleX
(
0f
)
.
scaleY
(
0f
)
?
.
scaleY
(
0f
)
.
alpha
(
0f
)
?
.
alpha
(
0f
)
.
setDuration
(
200
)
?
.
setDuration
(
200
)
.
setInterpolator
(
FastOutLinearInInterpolator
())
?
.
setInterpolator
(
FastOutLinearInInterpolator
())
.
setListener
(
object
:
AnimatorListenerAdapter
()
{
?
.
setListener
(
object
:
AnimatorListenerAdapter
()
{
private
var
mCancelled
:
Boolean
=
false
private
var
mCancelled
:
Boolean
=
false
@SuppressLint
(
"RestrictedApi"
)
@SuppressLint
(
"RestrictedApi"
)
override
fun
onAnimationStart
(
animation
:
Animator
)
{
override
fun
onAnimationStart
(
animation
:
Animator
)
{
if
(
image_scroll_top
!=
null
)
{
if
(
image_scroll_top
!=
null
)
{
image_scroll_top
!!
.
visibility
=
View
.
VISIBLE
image_scroll_top
?
.
visibility
=
View
.
VISIBLE
}
}
mCancelled
=
false
mCancelled
=
false
}
}
...
@@ -340,7 +340,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -340,7 +340,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
@SuppressLint
(
"RestrictedApi"
)
@SuppressLint
(
"RestrictedApi"
)
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
if
(!
mCancelled
&&
image_scroll_top
!=
null
)
{
if
(!
mCancelled
&&
image_scroll_top
!=
null
)
{
image_scroll_top
!!
.
visibility
=
View
.
INVISIBLE
image_scroll_top
?
.
visibility
=
View
.
INVISIBLE
}
}
}
}
})
})
...
@@ -360,21 +360,23 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -360,21 +360,23 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
}
}
}
}
trends_rcv
!!
.
addOnScrollListener
(
mScrollListener
!!
)
mScrollListener
?.
let
{
listener
->
mRcvAdapter
!!
.
addFooterView
(
footerView
)
trends_rcv
?.
addOnScrollListener
(
listener
)
}
mRcvAdapter
?.
addFooterView
(
footerView
)
if
(
headerCount
>
0
)
{
if
(
headerCount
>
0
)
{
for
(
i
in
headers
!!
.
indices
)
{
for
(
i
in
headers
?.
indices
!!
)
{
mRcvAdapter
!!
.
addHeaderView
(
headers
!!
[
i
]
)
mRcvAdapter
?.
addHeaderView
(
headers
?.
get
(
i
)
)
}
}
}
}
}
}
private
fun
doLikeAction
(
view
:
View
,
position
:
Int
,
mDatas
:
List
<
TrendsListBean
.
Trend
>)
{
private
fun
doLikeAction
(
view
:
View
,
position
:
Int
,
mDatas
:
List
<
TrendsListBean
.
Trend
>)
{
if
(
DynamicIn
.
loginByOneKeyLogin
(
mActivity
!!
,
true
)
)
{
if
(
mActivity
?.
let
{
DynamicIn
.
loginByOneKeyLogin
(
it
,
true
)
}
==
true
)
{
if
(!
isDoLikeAction
)
{
if
(!
isDoLikeAction
)
{
isDoLikeAction
=
true
isDoLikeAction
=
true
mPresenter
!!
.
doLikeAction
(
mPresenter
?
.
doLikeAction
(
view
,
view
,
position
,
position
,
Integer
.
valueOf
(
mDatas
[
position
].
id
),
Integer
.
valueOf
(
mDatas
[
position
].
id
),
...
@@ -388,21 +390,21 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -388,21 +390,21 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
LogUtil
.
i
(
"TAG get param: tab: $tab page: $page topicId: $topic_id lastId: $last_id"
)
LogUtil
.
i
(
"TAG get param: tab: $tab page: $page topicId: $topic_id lastId: $last_id"
)
if
(!
isTrendsListLoading
)
{
if
(!
isTrendsListLoading
)
{
isTrendsListLoading
=
true
isTrendsListLoading
=
true
mPresenter
!!
.
fetchUserTrendsList
(
userid
,
page
,
tab
)
mPresenter
?
.
fetchUserTrendsList
(
userid
,
page
,
tab
)
}
}
}
}
private
fun
fetchTrendsList
()
{
private
fun
fetchTrendsList
()
{
if
(!
isTrendsListLoading
)
{
if
(!
isTrendsListLoading
)
{
isTrendsListLoading
=
true
isTrendsListLoading
=
true
mPresenter
!!
.
fetchPhpTrendsInfo
(
tab
,
page
,
topic_id
,
last_id
)
mPresenter
?
.
fetchPhpTrendsInfo
(
tab
,
page
,
topic_id
,
last_id
)
}
}
}
}
private
fun
fetchRecommendTopicList
()
{
private
fun
fetchRecommendTopicList
()
{
if
(
tab
==
1
&&
!
isTopicLoading
&&
trendType
==
TREND_TYPE_DEFAULT
)
{
if
(
tab
==
1
&&
!
isTopicLoading
&&
trendType
==
TREND_TYPE_DEFAULT
)
{
isTopicLoading
=
true
isTopicLoading
=
true
mPresenter
!!
.
fetchTopicListInfo
(
2
,
0
)
mPresenter
?
.
fetchTopicListInfo
(
2
,
0
)
}
}
}
}
...
@@ -426,17 +428,17 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -426,17 +428,17 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
}
}
private
fun
showLoadSuccessView
()
{
private
fun
showLoadSuccessView
()
{
if
(
trend_list_no_datas_rel
!!
.
visibility
!=
View
.
GONE
)
{
if
(
trend_list_no_datas_rel
?
.
visibility
!=
View
.
GONE
)
{
trend_list_no_datas_rel
!!
.
visibility
=
View
.
GONE
trend_list_no_datas_rel
?
.
visibility
=
View
.
GONE
}
}
}
}
private
fun
showErrorView
()
{
private
fun
showErrorView
()
{
if
(
page
==
1
)
{
if
(
page
==
1
)
{
trend_list_no_datas_rel
!!
.
visibility
=
View
.
VISIBLE
trend_list_no_datas_rel
?
.
visibility
=
View
.
VISIBLE
}
else
{
}
else
{
trend_list_no_datas_rel
!!
.
visibility
=
View
.
GONE
trend_list_no_datas_rel
?
.
visibility
=
View
.
GONE
}
}
}
}
...
@@ -446,7 +448,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -446,7 +448,7 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
Handler
().
postDelayed
({
Handler
().
postDelayed
({
page
=
1
page
=
1
last_id
=
0
last_id
=
0
trends_lastr_swl
!!
.
isRefreshing
=
true
trends_lastr_swl
?
.
isRefreshing
=
true
switchDataToFetch
()
switchDataToFetch
()
},
200
)
},
200
)
}
}
...
@@ -486,10 +488,10 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -486,10 +488,10 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
fun
scrollToTop
()
{
fun
scrollToTop
()
{
if
(
firstVisibleItem
>
10
)
{
if
(
firstVisibleItem
>
10
)
{
trends_rcv
!!
.
scrollToPosition
(
10
)
trends_rcv
?
.
scrollToPosition
(
10
)
trends_rcv
!!
.
smoothScrollToPosition
(
0
)
trends_rcv
?
.
smoothScrollToPosition
(
0
)
}
else
{
}
else
{
trends_rcv
!!
.
smoothScrollToPosition
(
0
)
trends_rcv
?
.
smoothScrollToPosition
(
0
)
}
}
}
}
...
@@ -497,10 +499,10 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -497,10 +499,10 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
super
.
onDestroyView
()
super
.
onDestroyView
()
LogUtil
.
d
(
"fragmentlist onDestroy() $tab"
)
LogUtil
.
d
(
"fragmentlist onDestroy() $tab"
)
if
(
mPresenter
!=
null
)
{
if
(
mPresenter
!=
null
)
{
mPresenter
!!
.
onDestroy
()
mPresenter
?
.
onDestroy
()
}
}
if
(
image_scroll_top
!=
null
)
{
if
(
image_scroll_top
!=
null
)
{
image_scroll_top
!!
.
animate
()
.
cancel
()
image_scroll_top
?.
animate
()
?
.
cancel
()
}
}
}
}
...
@@ -528,21 +530,21 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -528,21 +530,21 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
if
(
str
.
size
==
3
)
if
(!
TextUtils
.
isEmpty
(
str
[
2
]))
str
[
2
]
else
""
else
""
if
(
str
.
size
==
3
)
if
(!
TextUtils
.
isEmpty
(
str
[
2
]))
str
[
2
]
else
""
else
""
comments
.
add
(
comment
)
comments
.
add
(
comment
)
}
}
mRcvAdapter
!!
.
datas
[
position
-
headerCount
]
.
comments
=
comments
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?
.
comments
=
comments
mRcvAdapter
!!
.
datas
[
position
-
headerCount
]
.
commentsCount
=
commentCount
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?
.
commentsCount
=
commentCount
mRcvAdapter
!!
.
notifyItemChanged
(
position
)
mRcvAdapter
?
.
notifyItemChanged
(
position
)
}
else
{
}
else
{
mRcvAdapter
!!
.
datas
[
position
-
headerCount
].
comments
.
clear
()
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?.
comments
?
.
clear
()
mRcvAdapter
!!
.
datas
[
position
-
headerCount
]
.
commentsCount
=
commentCount
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?
.
commentsCount
=
commentCount
mRcvAdapter
!!
.
notifyItemChanged
(
position
)
mRcvAdapter
?
.
notifyItemChanged
(
position
)
}
}
}
}
LogUtil
.
d
(
"resultcode: $resultCode position: $position likestate: $likestate"
)
LogUtil
.
d
(
"resultcode: $resultCode position: $position likestate: $likestate"
)
if
(
likestate
!=
0
)
{
if
(
likestate
!=
0
)
{
mRcvAdapter
!!
.
datas
[
position
-
headerCount
]
.
zanCount
=
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?
.
zanCount
=
mRcvAdapter
!!
.
datas
[
position
-
headerCount
].
zanCount
+
(
mRcvAdapter
!!
.
datas
[
position
-
headerCount
].
isZan
-
likestate
)
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?.
zanCount
?:
0
+
(
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?.
isZan
?:
0
-
likestate
)
mRcvAdapter
!!
.
datas
[
position
-
headerCount
]
.
isZan
=
likestate
mRcvAdapter
?.
datas
?.
get
(
position
-
headerCount
)
?
.
isZan
=
likestate
mRcvAdapter
!!
.
notifyItemChanged
(
position
)
mRcvAdapter
?
.
notifyItemChanged
(
position
)
}
}
}
}
}
}
...
@@ -554,8 +556,8 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -554,8 +556,8 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
override
fun
hideLoadingView
()
{}
override
fun
hideLoadingView
()
{}
override
fun
hideRefreshProgress
()
{
override
fun
hideRefreshProgress
()
{
if
(
trends_lastr_swl
!!
.
isRefreshing
&&
!
isTopicLoading
)
{
if
(
trends_lastr_swl
?.
isRefreshing
==
true
&&
!
isTopicLoading
)
{
trends_lastr_swl
!!
.
isRefreshing
=
false
trends_lastr_swl
?
.
isRefreshing
=
false
}
}
}
}
...
@@ -569,39 +571,39 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -569,39 +571,39 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
return
return
}
}
if
(
page
==
1
)
{
if
(
page
==
1
)
{
trendsDatas
!!
.
clear
()
trendsDatas
?
.
clear
()
}
}
LogUtil
.
i
(
"get datas $data"
)
LogUtil
.
i
(
"get datas $data"
)
showLoadSuccessView
()
showLoadSuccessView
()
if
(
data
.
size
>=
eachPageDataNum
)
{
if
(
data
.
size
>=
eachPageDataNum
)
{
trendsDatas
!!
.
addAll
(
data
)
trendsDatas
?
.
addAll
(
data
)
mRcvAdapter
!!
.
setDatas
(
trendsDatas
,
FOOTRE_STATE_LOAD_MORE
)
mRcvAdapter
?
.
setDatas
(
trendsDatas
,
FOOTRE_STATE_LOAD_MORE
)
if
(
page
==
1
)
{
if
(
page
==
1
)
{
mRcvAdapter
!!
.
notifyDataSetChanged
()
mRcvAdapter
?
.
notifyDataSetChanged
()
return
return
}
}
mRcvAdapter
!!
.
notifyItemRangeInserted
(
mRcvAdapter
?
.
notifyItemRangeInserted
(
trendsDatas
!!
.
size
+
headerCount
-
data
.
size
,
trendsDatas
?.
size
?:
0
+
headerCount
-
data
.
size
,
data
.
size
data
.
size
)
)
}
else
{
}
else
{
LogUtil
.
i
(
"get datas no more data$data"
)
LogUtil
.
i
(
"get datas no more data$data"
)
trendsDatas
!!
.
addAll
(
data
)
trendsDatas
?
.
addAll
(
data
)
if
(
trendsDatas
==
null
||
trendsDatas
!!
.
size
==
0
)
{
if
(
trendsDatas
==
null
||
trendsDatas
?
.
size
==
0
)
{
mRcvAdapter
!!
.
setDatas
(
trendsDatas
,
FOOTRE_STATE_INIT
)
mRcvAdapter
?
.
setDatas
(
trendsDatas
,
FOOTRE_STATE_INIT
)
if
(
page
==
1
)
{
if
(
page
==
1
)
{
mRcvAdapter
!!
.
notifyDataSetChanged
()
mRcvAdapter
?
.
notifyDataSetChanged
()
}
}
trend_list_no_datas_rel
!!
.
visibility
=
View
.
VISIBLE
trend_list_no_datas_rel
?
.
visibility
=
View
.
VISIBLE
return
return
}
}
mRcvAdapter
!!
.
setDatas
(
trendsDatas
,
FOOTER_STATE_NO_DATA
)
mRcvAdapter
?
.
setDatas
(
trendsDatas
,
FOOTER_STATE_NO_DATA
)
if
(
page
==
1
)
{
if
(
page
==
1
)
{
mRcvAdapter
!!
.
notifyDataSetChanged
()
mRcvAdapter
?
.
notifyDataSetChanged
()
return
return
}
}
mRcvAdapter
!!
.
notifyItemRangeInserted
(
mRcvAdapter
?
.
notifyItemRangeInserted
(
trendsDatas
!!
.
size
+
headerCount
-
data
.
size
,
trendsDatas
?.
size
?:
0
+
headerCount
-
data
.
size
,
data
.
size
data
.
size
)
)
}
}
...
@@ -617,8 +619,8 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -617,8 +619,8 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
isTopicLoading
=
false
isTopicLoading
=
false
if
(
topicListDatas
.
list
!=
null
&&
topicListDatas
.
list
.
size
>
0
)
{
if
(
topicListDatas
.
list
!=
null
&&
topicListDatas
.
list
.
size
>
0
)
{
recommendTopicDatas
=
topicListDatas
.
list
recommendTopicDatas
=
topicListDatas
.
list
mRecommendTopicListAdapter
!!
.
setDatas
(
recommendTopicDatas
)
mRecommendTopicListAdapter
?
.
setDatas
(
recommendTopicDatas
)
mRecommendTopicListAdapter
!!
.
notifyDataSetChanged
()
mRecommendTopicListAdapter
?
.
notifyDataSetChanged
()
}
}
}
}
...
@@ -672,9 +674,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
...
@@ -672,9 +674,9 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
override
fun
showTopTrendsView
(
extDatas
:
List
<
TrendsListBean
.
ExtData
>?)
{
override
fun
showTopTrendsView
(
extDatas
:
List
<
TrendsListBean
.
ExtData
>?)
{
if
(
extDatas
!=
null
&&
extDatas
.
size
>
0
)
{
//置顶信息
if
(
extDatas
!=
null
&&
extDatas
.
size
>
0
)
{
//置顶信息
mRecommendTopRcv
!!
.
visibility
=
View
.
VISIBLE
mRecommendTopRcv
?
.
visibility
=
View
.
VISIBLE
mRecommendTopAdapter
!!
.
setExtData
(
extDatas
)
mRecommendTopAdapter
?
.
setExtData
(
extDatas
)
mRecommendTopAdapter
!!
.
notifyDataSetChanged
()
mRecommendTopAdapter
?
.
notifyDataSetChanged
()
}
}
}
}
...
...
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