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
3b4df2ad
Commit
3b4df2ad
authored
Jan 13, 2020
by
严久程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态主页、三个分类切换时不在顶部的问题
parent
6760ab4d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
41 deletions
+83
-41
config.gradle
config.gradle
+1
-1
TrendsListInteractor.java
m-dynamic/src/main/java/com/yidianling/dynamic/trendList/TrendsListInteractor.java
+1
-1
TrendsHomeVpAdapter.java
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/TrendsHomeVpAdapter.java
+5
-5
TrendsContentListFragment.java
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/content/TrendsContentListFragment.java
+61
-26
TrendsCotentListAdapter.java
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/content/TrendsCotentListAdapter.java
+5
-1
dynamic_fragment_trend_list_in.xml
m-dynamic/src/main/res/layout/dynamic_fragment_trend_list_in.xml
+3
-2
dynamic_looper_item.xml
m-dynamic/src/main/res/layout/dynamic_looper_item.xml
+7
-5
No files found.
config.gradle
View file @
3b4df2ad
ext
{
kotlin_version
=
"1.3.21"
dev_mode
=
fals
e
dev_mode
=
tru
e
ydl_app
=
[
appName
:
"心理咨询壹点灵"
,
...
...
m-dynamic/src/main/java/com/yidianling/dynamic/trendList/TrendsListInteractor.java
View file @
3b4df2ad
...
...
@@ -122,7 +122,7 @@ public class TrendsListInteractor {
// LogUtil.i("get Response: " + trendsListBean.toString());
if
(
callBack
!=
null
)
{
//更新缓存
updateCache
(
tab
,
trendsListBean
);
//
updateCache(tab,trendsListBean);
callBack
.
onTrendsListFetched
(
trendsListBean
);
}
},
throwable
->
{
...
...
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/TrendsHomeVpAdapter.java
View file @
3b4df2ad
...
...
@@ -10,7 +10,7 @@ import android.support.v4.app.FragmentPagerAdapter;
public
class
TrendsHomeVpAdapter
extends
FragmentPagerAdapter
{
public
final
static
int
dataSize
=
3
;
public
final
static
int
dataSize
=
3
;
private
Fragment
[]
mFragments
;
private
String
[]
titles
=
new
String
[]{
"推荐"
,
"最新"
,
"关注"
,
"待回答"
,
"我回答的"
...
...
@@ -25,8 +25,8 @@ public class TrendsHomeVpAdapter extends FragmentPagerAdapter {
mFragments
=
fragments
;
}
public
void
setDatas
(
Fragment
[]
fragments
){
mFragments
=
fragments
;
public
void
setDatas
(
Fragment
[]
fragments
)
{
mFragments
=
fragments
;
}
@Override
...
...
@@ -39,12 +39,12 @@ public class TrendsHomeVpAdapter extends FragmentPagerAdapter {
@Override
public
int
getCount
()
{
return
mFragments
!=
null
&&
mFragments
.
length
>
0
?
mFragments
.
length
:
0
;
return
mFragments
!=
null
&&
mFragments
.
length
>
0
?
mFragments
.
length
:
0
;
}
@Override
public
CharSequence
getPageTitle
(
int
position
)
{
if
(
mFragments
.
length
>
0
)
{
if
(
mFragments
.
length
>
0
)
{
return
titles
[
position
];
}
return
super
.
getPageTitle
(
position
);
...
...
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/content/TrendsContentListFragment.java
View file @
3b4df2ad
...
...
@@ -23,7 +23,6 @@ import com.ydl.ydlcommon.base.BaseFragment;
import
com.ydl.ydlcommon.utils.BuryPointUtils
;
import
com.ydl.ydlcommon.utils.SharedPreferencesEditor
;
import
com.ydl.ydlcommon.view.WrapContentLinearLayoutManager
;
import
com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.dynamic.R
;
...
...
@@ -45,6 +44,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.schedulers.Schedulers
;
;
/**
* @author Jim
* @描述:
...
...
@@ -78,6 +78,7 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
private
TrendsCotentListAdapter
mRcvAdapter
;
private
List
<
TrendsListBean
.
Trend
>
trendsDatas
;
private
RecyclerView
.
OnScrollListener
mScrollListener
;
private
int
lastVisibleItem
=
0
;
public
static
TrendsContentListFragment
newInstance
(
int
tabType
,
int
topicId
,
String
trendType
,
String
trendUserid
)
{
TrendsContentListFragment
fragment
=
new
TrendsContentListFragment
();
...
...
@@ -179,36 +180,70 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
trendsRcv
.
setAdapter
(
mRcvAdapter
);
trendsRcv
.
setLayoutManager
(
layoutManager
);
trendsRcv
.
getItemAnimator
().
setChangeDuration
(
0
);
//解决局部刷新闪屏
mScrollListener
=
new
EndlessRecyclerViewScrollListener
(
layoutManager
)
{
mRcvAdapter
.
addFooterView
(
getFooterView
());
// mScrollListener = new DynamicRecyclerViewScrollListener(layoutManager) {
// @Override
// public void onLoadMore(int page, int totalItemsCount, @org.jetbrains.annotations.Nullable RecyclerView view) {
// LogUtil.e("tab=" + tab + ",onLoadMore");
// LogUtil.e("tab=" + tab + ",==数据长度:" + mRcvAdapter.getDatas().size());
// if (!isRefresh) {
// resetState();
// last_id = getLastId();
// LogUtil.i("loadMore last id: " + last_id + " page: " + page);
// TrendsContentListFragment.this.page++;
// switchDataToFetch();
// }
// }
//
// @Override
// protected void onScrollDown() {
// LogUtil.e("tab=" + tab + ",onScrollDown");
//// ((TrendsHomeFragment) getParentFragment()).onScrollDown();
// }
//
// @Override
// protected void onScrollUp() {
// LogUtil.e("tab=" + tab + ",onScrollUp");
//// ((TrendsHomeFragment) getParentFragment()).onScrollUp();
// }
//
// @Override
// public void onScrollTop() {
// LogUtil.e("tab=" + tab + ",onScrollTop");
//// ((TrendsHomeFragment) getParentFragment()).onScrollTop();
// }
// };
mScrollListener
=
new
RecyclerView
.
OnScrollListener
()
{
@Override
public
void
onLoadMore
(
int
page
,
int
totalItemsCount
,
@org
.
jetbrains
.
annotations
.
Nullable
RecyclerView
view
)
{
public
void
onScrollStateChanged
(
RecyclerView
recyclerView
,
int
newState
)
{
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
)
{
LogUtil
.
e
(
"tab===停止滑动"
+
System
.
currentTimeMillis
());
}
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
//停止滚动
&&
lastVisibleItem
>=
(
mRcvAdapter
.
getItemCount
()
-
mRcvAdapter
.
getFootersCount
())
//最后一个显示的item序号大于适配器item数量,即显示了footer
&&
mRcvAdapter
.
getFooterState
()
==
TrendsCotentListAdapter
.
FOOTRE_STATE_LOAD_MORE
)
{
LogUtil
.
e
(
"tab="
+
tab
+
",onLoadMore"
);
LogUtil
.
e
(
"tab="
+
tab
+
",==数据长度:"
+
mRcvAdapter
.
getDatas
().
size
());
if
(!
isRefresh
)
{
resetState
(
);
LogUtil
.
e
(
"tab===加载数据"
+
System
.
currentTimeMillis
()
);
last_id
=
getLastId
();
LogUtil
.
i
(
"loadMore last id: "
+
last_id
+
" page: "
+
page
);
TrendsContentListFragment
.
this
.
page
++;
switchDataToFetch
();
}
}
@Override
protected
void
onScrollDown
()
{
// ((TrendsHomeFragment) getParentFragment()).onScrollDown();
}
@Override
protected
void
onScrollUp
()
{
// ((TrendsHomeFragment) getParentFragment()).onScrollUp();
}
@Override
public
void
onScrollTop
()
{
// ((TrendsHomeFragment) getParentFragment()).onScrollTop();
public
void
onScrolled
(
RecyclerView
recyclerView
,
int
dx
,
int
dy
)
{
lastVisibleItem
=
layoutManager
.
findLastVisibleItemPosition
();
}
};
trendsRcv
.
addOnScrollListener
(
mScrollListener
);
mRcvAdapter
.
addFooterView
(
getFooterView
());
}
private
void
doLikeAction
(
View
view
,
int
position
,
List
<
TrendsListBean
.
Trend
>
mDatas
)
{
...
...
@@ -222,7 +257,7 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
}
}
private
void
localData
(){
private
void
localData
()
{
if
(
mPresenter
!=
null
)
{
mPresenter
.
localData
(
tab
);
}
...
...
@@ -297,7 +332,7 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
}
SharedPreferencesEditor
.
putString
(
"trend_state"
,
""
);
LogUtil
.
d
(
"trendType "
+
trendType
);
localData
();
//
localData();
fetchTrendsList
();
}
...
...
@@ -391,8 +426,8 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
@Override
public
void
showBanner
(
List
<
TrendsListBean
.
Banner
>
banner
)
{
//更新banner数据
if
(
getParentFragment
()
instanceof
TrendsHomeFragment
){
((
TrendsHomeFragment
)
getParentFragment
()).
setBannerData
(
banner
);
if
(
getParentFragment
()
instanceof
TrendsHomeFragment
)
{
((
TrendsHomeFragment
)
getParentFragment
()).
setBannerData
(
banner
);
}
}
...
...
@@ -400,16 +435,16 @@ public class TrendsContentListFragment extends BaseFragment implements ITrendsLi
public
void
showTrendsListView
(
List
<
TrendsListBean
.
Trend
>
data
)
{
isTrendsListLoading
=
false
;
showLoadSuccessView
();
if
(
page
==
1
){
if
(
null
==
trendsDatas
){
if
(
page
==
1
)
{
if
(
null
==
trendsDatas
)
{
trendsDatas
=
new
ArrayList
();
}
else
{
}
else
{
trendsDatas
.
clear
();
}
if
(
null
!=
data
){
if
(
null
!=
data
)
{
trendsDatas
.
addAll
(
data
);
}
mRcvAdapter
.
setDatas
(
trendsDatas
,
mRcvAdapter
.
FOOTRE_STATE_
INIT
);
mRcvAdapter
.
setDatas
(
trendsDatas
,
mRcvAdapter
.
FOOTRE_STATE_
LOAD_MORE
);
mRcvAdapter
.
notifyDataSetChanged
();
return
;
}
...
...
m-dynamic/src/main/java/com/yidianling/dynamic/trendsHome/content/TrendsCotentListAdapter.java
View file @
3b4df2ad
...
...
@@ -77,7 +77,7 @@ public class TrendsCotentListAdapter extends RecyclerView.Adapter<BaseViewHolder
public
TrendsCotentListAdapter
(
Context
context
,
List
<
TrendsListBean
.
Trend
>
datas
)
{
mContext
=
context
;
mDatas
=
datas
;
footerState
=
FOOTRE_STATE_
INIT
;
footerState
=
FOOTRE_STATE_
LOAD_MORE
;
}
public
void
setDatas
(
List
<
TrendsListBean
.
Trend
>
datas
)
{
...
...
@@ -89,6 +89,10 @@ public class TrendsCotentListAdapter extends RecyclerView.Adapter<BaseViewHolder
this
.
footerState
=
footerState
;
}
public
int
getFooterState
()
{
return
footerState
;
}
public
void
addDatas
(
List
<
TrendsListBean
.
Trend
>
datas
,
int
footerState
)
{
this
.
footerState
=
footerState
;
if
(
mDatas
==
null
)
{
...
...
m-dynamic/src/main/res/layout/dynamic_fragment_trend_list_in.xml
View file @
3b4df2ad
<?xml version="1.0" encoding="utf-8"?>
<
FrameLayout
<
RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:descendantFocusability=
"blocksDescendants"
android:background=
"@color/dynamic_white"
>
<android.support.v7.widget.RecyclerView
...
...
@@ -44,4 +45,4 @@
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</
FrameLayout>
</
RelativeLayout>
m-dynamic/src/main/res/layout/dynamic_looper_item.xml
View file @
3b4df2ad
...
...
@@ -12,14 +12,16 @@
android:layout_gravity=
"center"
android:layout_marginLeft=
"15dp"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:layout_marginRight=
"15dp"
android:textColor=
"#999999"
android:paddingBottom=
"5dp"
android:layout_marginBottom=
"5dp"
android:background=
"@drawable/dynamic_bg_radius_white_20"
android:ellipsize=
"end"
android:maxLines=
"1"
android:paddingLeft=
"15dp"
android:paddingTop=
"5dp"
android:paddingRight=
"5dp"
android:background=
"@drawable/dynamic_bg_radius_white_20"
tools:text=
"置顶 xxxxxx"
/>
android:paddingBottom=
"5dp"
android:textColor=
"#999999"
tools:text=
"置顶 xxxxxx"
/>
</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