-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAdapterFlowLayout.java
More file actions
54 lines (43 loc) · 1.51 KB
/
AdapterFlowLayout.java
File metadata and controls
54 lines (43 loc) · 1.51 KB
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
46
47
48
49
50
51
52
53
54
package com.commit451.adapterflowlayout;
import android.content.Context;
import android.util.AttributeSet;
import com.commit451.adapterlayout.AdapterLayoutDelegate;
import com.wefika.flowlayout.FlowLayout;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/**
* {@link com.wefika.flowlayout.FlowLayout} with {@link androidx.recyclerview.widget.RecyclerView.Adapter} support.
*/
@SuppressWarnings("unused")
public class AdapterFlowLayout extends FlowLayout {
private AdapterLayoutDelegate adapterLayoutDelegate;
public AdapterFlowLayout(Context context) {
super(context);
}
public AdapterFlowLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public AdapterFlowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setAdapter(RecyclerView.Adapter adapter) {
if (adapterLayoutDelegate == null) {
adapterLayoutDelegate = new AdapterLayoutDelegate(this);
}
adapterLayoutDelegate.setAdapter(adapter);
}
@Nullable
public RecyclerView.Adapter getAdapter() {
if (adapterLayoutDelegate != null) {
return adapterLayoutDelegate.getAdapter();
}
return null;
}
@Nullable
public RecyclerView.ViewHolder getViewHolderAt(int index) {
if (adapterLayoutDelegate != null) {
return adapterLayoutDelegate.getViewHolderAt(index);
}
return null;
}
}