-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSelectActivity.java
45 lines (36 loc) · 1.24 KB
/
SelectActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.lin.poweradapter.example.select;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import com.lin.poweradapter.example.Analog;
import com.lin.poweradapter.example.AnalogAdapter;
import com.lin.poweradapter.example.DatabaseService;
import com.lin.poweradapter.example.RecyclerViewActivity;
import static com.lin.poweradapter.SelectableAdapter.MODE_SINGLE;
/**
* Created by lin18 on 2017/4/27.
*/
public class SelectActivity extends RecyclerViewActivity<Analog, AnalogAdapter> {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
configure();
adapter.setItems(DatabaseService.getSampleData(300));
adapter.setMode(MODE_SINGLE);
}
@NonNull
@Override
protected AnalogAdapter createAdapter() {
return new AnalogAdapter(this);
}
@Override
public void onItemClick(View v, int position) {
super.onItemClick(v, position);
adapter.toggleSelection(position);
}
@Override
public boolean onItemLongClick(View v, int position) {
showToast("onItemLongClick-> position : " + position + " value : " + adapter.getItem(position).text);
return true;
}
}