use of com.rideread.rideread.common.adapter.UserMomentsAdapter in project ride-read-android by Ride-Read.
the class UserMomentsActivity method initView.
@Override
public void initView() {
mAMap = mMapViewBg.getMap();
//实例化UiSettings类对象
mUiSettings = mAMap.getUiSettings();
mUiSettings.setZoomControlsEnabled(false);
mAMap.moveCamera(CameraUpdateFactory.zoomTo(1F));
mSelectedUid = getIntent().getIntExtra(SELECTED_UID, UserUtils.getUid());
String username = getIntent().getStringExtra(SELECTED_USERNAME);
if (TextUtils.isEmpty(username)) {
username = "阅圈";
} else {
username = username + "的阅圈";
}
isMyself = mSelectedUid == UserUtils.getUid();
new TitleBuilder(this).setTitleText(isMyself ? getString(R.string.my_circle) : username).IsBack(true).setLeftOnClickListener(v -> finish()).build();
mMoments = new ArrayList<>();
mSwipeRefreshLayout.setOnRefreshListener(() -> {
mPages = 0;
loadUserMoments();
});
mRecycleView.setHasFixedSize(true);
mUserMomentsAdapter = new UserMomentsAdapter(this, mMoments);
// LayoutInflater layoutInflater = getLayoutInflater();
// if (!isMyself) {
// mMomentsHeaderView = layoutInflater.inflate(R.layout.view_user_info, null);
// mUserMomentsAdapter.addHeadView(mMomentsHeaderView);
// }
mRecycleView.setAdapter(mUserMomentsAdapter);
mLayoutManager = new LinearLayoutManager(this);
mRecycleView.setLayoutManager(mLayoutManager);
mRecycleView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
int totalItemCount = mLayoutManager.getItemCount();
// dy>0 表示向下滑动
if (lastVisibleItem >= totalItemCount - 1 && dy > 0) {
if (!isLoadingMore) {
//这里多线程也要手动控制isLoadingMore
loadUserMoments();
}
}
}
});
if (isMyself) {
mViewHeader.setVisibility(View.GONE);
mLlFollowAction.setVisibility(View.GONE);
} else {
mViewHeader.attachTo(mRecycleView);
getUserInfo(mSelectedUid);
}
loadUserMoments();
}
Aggregations