use of com.malinskiy.superrecyclerview.SuperRecyclerView 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();
}
use of com.malinskiy.superrecyclerview.SuperRecyclerView in project SuperRecyclerView by Malinskiy.
the class SwipeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vertical_sample);
mRecycler = (SuperRecyclerView) findViewById(R.id.list);
mRecycler.setLayoutManager(new LinearLayoutManager(this));
ArrayList<String> list = new ArrayList<>();
mAdapter = new SwipeAdapter(list);
mRecycler.setAdapter(mAdapter);
mAdapter.setMode(SwipeItemManagerInterface.Mode.Single);
mRecycler.addOnItemTouchListener(new RecyclerUtils.RecyclerItemClickListener(this, new RecyclerUtils.RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(SwipeActivity.this, "Clicked " + position, Toast.LENGTH_SHORT).show();
}
}));
mHandler = new Handler(Looper.getMainLooper());
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mRecycler.setAdapter(mAdapter);
}
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.add("More stuff");
mAdapter.add("More stuff");
mAdapter.add("More stuff");
}
});
}
});
thread.start();
mRecycler.setRefreshListener(this);
mRecycler.setRefreshingColorResources(android.R.color.holo_orange_light, android.R.color.holo_blue_light, android.R.color.holo_green_light, android.R.color.holo_red_light);
mRecycler.setupMoreListener(this, 1);
}
Aggregations