|
6 | 6 | import com.reandroid.dex.key.Key; |
7 | 7 | import com.reandroid.dex.sections.SectionList; |
8 | 8 | import com.reandroid.dex.sections.SectionType; |
| 9 | +import com.reandroid.utils.ObjectsUtil; |
9 | 10 |
|
10 | 11 | public class SectionItem extends BlockItem implements EditableItem, SectionTool, UsageMarker { |
11 | 12 |
|
@@ -66,15 +67,17 @@ public boolean isRemoved(){ |
66 | 67 | public void onRemovedInternal() { |
67 | 68 | } |
68 | 69 |
|
69 | | - @SuppressWarnings("unchecked") |
70 | 70 | protected <T1 extends Key> T1 checkKey(T1 newKey){ |
71 | | - Key lastKey = this.mLastKey; |
| 71 | + T1 lastKey = getLastKey(); |
72 | 72 | if(lastKey == null || !lastKey.equals(newKey)){ |
73 | 73 | this.mLastKey = newKey; |
74 | 74 | keyChanged(lastKey); |
75 | 75 | lastKey = newKey; |
76 | 76 | } |
77 | | - return (T1) lastKey; |
| 77 | + return lastKey; |
| 78 | + } |
| 79 | + protected <T1 extends Key> T1 getLastKey() { |
| 80 | + return ObjectsUtil.cast(mLastKey); |
78 | 81 | } |
79 | 82 | protected void keyChanged(Key oldKey){ |
80 | 83 | if(oldKey == null){ |
@@ -126,29 +129,6 @@ public void editInternal(Block user) { |
126 | 129 | public void removeSelf(){ |
127 | 130 | throw new RuntimeException("Not implemented"); |
128 | 131 | } |
129 | | - public boolean equalsKey(SectionItem sectionItem){ |
130 | | - if(sectionItem == this){ |
131 | | - return true; |
132 | | - } |
133 | | - if(sectionItem == null || getSectionType() != sectionItem.getSectionType()){ |
134 | | - return false; |
135 | | - } |
136 | | - Key key = getKey(); |
137 | | - if(key == null){ |
138 | | - return false; |
139 | | - } |
140 | | - return key.equals(sectionItem.getKey()); |
141 | | - } |
142 | | - public boolean equalsKey(Key key){ |
143 | | - if(key == null){ |
144 | | - return false; |
145 | | - } |
146 | | - Key myKey = getKey(); |
147 | | - if(myKey == null){ |
148 | | - return false; |
149 | | - } |
150 | | - return myKey.equals(key); |
151 | | - } |
152 | 132 | public boolean isBlank() { |
153 | 133 | return isRemoved(); |
154 | 134 | } |
|
0 commit comments