use of com.yiw.circledemo.widgets.DivItemDecoration in project CircleDemo by Naoki2015.
the class MainActivity method initView.
@SuppressLint({ "ClickableViewAccessibility", "InlinedApi" })
private void initView() {
initTitle();
initUploadDialog();
recyclerView = (SuperRecyclerView) findViewById(R.id.recyclerView);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DivItemDecoration(2, true));
recyclerView.getMoreProgressView().getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
recyclerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (edittextbody.getVisibility() == View.VISIBLE) {
updateEditTextBodyVisible(View.GONE, null);
return true;
}
return false;
}
});
refreshListener = new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
presenter.loadData(TYPE_PULLREFRESH);
}
}, 2000);
}
};
recyclerView.setRefreshListener(refreshListener);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
Glide.with(MainActivity.this).resumeRequests();
} else {
Glide.with(MainActivity.this).pauseRequests();
}
}
});
circleAdapter = new CircleAdapter(this);
circleAdapter.setCirclePresenter(presenter);
recyclerView.setAdapter(circleAdapter);
edittextbody = (LinearLayout) findViewById(R.id.editTextBodyLl);
editText = (EditText) findViewById(R.id.circleEt);
sendIv = (ImageView) findViewById(R.id.sendIv);
sendIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (presenter != null) {
//发布评论
String content = editText.getText().toString().trim();
if (TextUtils.isEmpty(content)) {
Toast.makeText(MainActivity.this, "评论内容不能为空...", Toast.LENGTH_SHORT).show();
return;
}
presenter.addComment(content, commentConfig);
}
updateEditTextBodyVisible(View.GONE, null);
}
});
setViewTreeObserver();
}
Aggregations