use of com.knight.wanandroid.module_home.module_adapter.HomeArticleAdapter in project wanandroid by KnightAndroid.
the class HomeRecommendFragment method initView.
@Override
protected void initView(Bundle savedInstanceState) {
mDatabind.setClick(new ProxyClick());
EventBus.getDefault().register(this);
mSkeletonScreen = Skeleton.bind(mDatabind.flTest).load(R.layout.activity_home_skeleton).duration(1200).angle(0).show();
bindHeadView();
mTopArticleAdapter = new TopArticleAdapter(new ArrayList<>());
SetInitCustomView.initSwipeRecycleview(home_top_article_rv, new LinearLayoutManager(getActivity()), mTopArticleAdapter, false);
mOfficialAccountAdapter = new OfficialAccountAdapter(new ArrayList<>());
mHomeArticleAdapter = new HomeArticleAdapter(new ArrayList<>());
SetInitCustomView.initSwipeRecycleview(mDatabind.homeRecommendArticleBody, new LinearLayoutManager(getActivity()), mHomeArticleAdapter, true);
topArticleFootView = LayoutInflater.from(getActivity()).inflate(R.layout.home_toparticle_foot, null);
topArticleFootView.findViewById(R.id.home_ll_seemorearticles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HomeArticleLogic.getInstance().setArrowAnimate(mTopArticleAdapter, topArticleFootView.findViewById(R.id.home_iv_toparticlearrow), isShowOnlythree);
isShowOnlythree = !isShowOnlythree;
}
});
mDatabind.homeIconFab.setBackgroundTintList(ColorUtils.createColorStateList(CacheUtils.getThemeColor(), CacheUtils.getThemeColor()));
initTopAdapterClick();
initOfficialAccountClick();
initArticleListener();
initTwoLevel();
mDatabind.homeRefreshLayout.setOnMultiListener(new SimpleMultiListener() {
@Override
public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) {
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
lazyLoadData();
}
@Override
public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
if (oldState == RefreshState.TwoLevel) {
mDatabind.homeTwoLevelContent.animate().alpha(0).setDuration(0);
} else if (oldState == RefreshState.TwoLevelReleased) {
openTwoLevel = true;
mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_bottom));
} else if (oldState == RefreshState.TwoLevelFinish) {
openTwoLevel = false;
mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_up));
}
}
});
mDatabind.homeTwoLevelHeader.setOnTwoLevelListener(new OnTwoLevelListener() {
@Override
public boolean onTwoLevel(@NonNull RefreshLayout refreshLayout) {
mDatabind.homeTwoLevelContent.animate().alpha(1).setDuration(1000);
return true;
}
});
mDatabind.homeTwoLevelHeader.setEnablePullToCloseTwoLevel(false);
mDatabind.homeRefreshLayout.setEnableLoadMore(true);
mDatabind.homeRefreshLayout.setOnLoadMoreListener(this);
}
use of com.knight.wanandroid.module_home.module_adapter.HomeArticleAdapter in project wanandroid by KnightAndroid.
the class HomeArticlesFragment method initView.
@Override
protected void initView(Bundle savedInstanceState) {
EventBus.getDefault().register(this);
mHomeArticleAdapter = new HomeArticleAdapter(new ArrayList<>());
SetInitCustomView.initSwipeRecycleview(mDatabind.homeArticleBody, new LinearLayoutManager(getActivity()), mHomeArticleAdapter, true);
mDatabind.homeArticleBody.setAdapter(mHomeArticleAdapter);
mDatabind.homeArticleFreshlayout.setOnLoadMoreListener(this);
mDatabind.homeArticleFreshlayout.setOnRefreshListener(this);
mHomeArticleAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
ARouterUtils.startWeb(mHomeArticleAdapter.getData().get(position).getLink(), mHomeArticleAdapter.getData().get(position).getTitle(), mHomeArticleAdapter.getData().get(position).getId(), mHomeArticleAdapter.getData().get(position).isCollect(), mHomeArticleAdapter.getData().get(position).getEnvelopePic(), mHomeArticleAdapter.getData().get(position).getDesc(), mHomeArticleAdapter.getData().get(position).getChapterName(), TextUtils.isEmpty(mHomeArticleAdapter.getData().get(position).getAuthor()) ? mHomeArticleAdapter.getData().get(position).getShareUser() : mHomeArticleAdapter.getData().get(position).getAuthor());
}
});
mHomeArticleAdapter.addChildClickViewIds(R.id.home_icon_collect);
mHomeArticleAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
@LoginCheck
@Override
public void onItemChildClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
if (view.getId() == R.id.home_icon_collect) {
if (mHomeArticleAdapter.getData().get(position).isCollect()) {
mPresenter.requestCancelCollectArticle(mHomeArticleAdapter.getData().get(position).getId(), position);
} else {
mPresenter.requestCollectArticle(mHomeArticleAdapter.getData().get(position).getId(), position);
}
}
}
});
// 反馈文章链接错误
mHomeArticleAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
FeedBackDialog.newInstance(mHomeArticleAdapter.getData().get(position).getId()).showAllowingStateLoss(getParentFragmentManager(), "feedbackDialog");
return false;
}
});
loadLoading(mDatabind.llHome);
}
Aggregations