-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathViewHolderImpl.java
99 lines (85 loc) · 2.03 KB
/
ViewHolderImpl.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.cleveroad.adaptivetablelayout;
import androidx.annotation.NonNull;
import android.view.View;
/**
* {@inheritDoc}
*/
public abstract class ViewHolderImpl implements ViewHolder {
/**
* Holder view
*/
private final View mItemView;
/**
* ViewHolder's table row index
*/
private int mRowIndex;
/**
* ViewHolder's table column index
*/
private int mColIndex;
/**
* ViewHolder's table item type param
*/
private int mItemType;
/**
* ViewHolder's dragging flag
*/
private boolean mIsDragging;
public ViewHolderImpl(@NonNull View itemView) {
mItemView = itemView;
}
@NonNull
@Override
public View getItemView() {
return mItemView;
}
@Override
public int getRowIndex() {
return mRowIndex;
}
@Override
public void setRowIndex(int rowIndex) {
mRowIndex = rowIndex;
}
@Override
public int getColumnIndex() {
return mColIndex;
}
@Override
public void setColumnIndex(int columnIndex) {
mColIndex = columnIndex;
}
@Override
public int getItemType() {
return mItemType;
}
@Override
public void setItemType(int itemType) {
mItemType = itemType;
}
@Override
public int hashCode() {
int result = mItemView.hashCode();
result = 31 * result + mRowIndex;
result = 31 * result + mColIndex;
result = 31 * result + mItemType;
result = 31 * result + (mIsDragging ? 1 : 0);
return result;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ViewHolder)) {
return false;
}
ViewHolder vh = (ViewHolder) obj;
return vh.getColumnIndex() == this.getColumnIndex() && vh.getRowIndex() == this.getRowIndex();
}
@Override
public boolean isDragging() {
return mIsDragging;
}
@Override
public void setIsDragging(boolean isDragging) {
mIsDragging = isDragging;
}
}