|
16 | 16 | import com.boylab.protocol.ItemRow; |
17 | 17 |
|
18 | 18 | import java.util.ArrayList; |
| 19 | +import java.util.List; |
19 | 20 |
|
20 | 21 | public class TableViewAdapter extends RecyclerView.Adapter<TableViewAdapter.ScrollViewHolder> { |
21 | 22 |
|
@@ -57,11 +58,12 @@ public void onBindViewHolder(final ScrollViewHolder holder, final int position) |
57 | 58 |
|
58 | 59 | holder.text_TableLeft.setText(itemRow.get(0)); |
59 | 60 | int childCount = holder.layout_TableRow.getChildCount(); |
| 61 | + boolean isFocus = (position == focusRow); |
60 | 62 | for (int i = 0; i < childCount; i++) { |
61 | 63 | FrameLayout itemLayout = (FrameLayout) holder.layout_TableRow.getChildAt(i); |
62 | 64 | TextView text_item = (TextView) itemLayout.getChildAt(0); |
63 | 65 | text_item.setText(itemRow.get(i + 1)); |
64 | | - text_item.setBackgroundColor(position == focusRow ? contentParams.getFoucsColor() : contentParams.getBackgroundColor()); |
| 66 | + text_item.setBackgroundColor(isFocus ? contentParams.getFoucsColor() : contentParams.getBackgroundColor()); |
65 | 67 | } |
66 | 68 |
|
67 | 69 | mSynScrollerview.setOnScrollListener(new SynScrollerLayout.OnItemScrollView() { |
@@ -129,32 +131,22 @@ public void setSynScrollerview(SynScrollerLayout mSynScrollerview) { |
129 | 131 | this.mSynScrollerview = mSynScrollerview; |
130 | 132 | } |
131 | 133 |
|
132 | | - public void setFocusRow(LinearLayout focusView, int focusRow) { |
| 134 | + public void setFocusRow(LinearLayout focusView, final int focusRow) { |
133 | 135 | if (this.focusRow == focusRow){ |
134 | 136 | return; |
135 | 137 | } |
136 | 138 |
|
137 | | - if (cacheLayout != null){ |
138 | | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
139 | | - if (cacheLayout.isAttachedToWindow()){ |
140 | | - int childCount = cacheLayout.getChildCount(); |
141 | | - for (int i = 0; i < childCount; i++) { |
142 | | - FrameLayout itemLayout = (FrameLayout) cacheLayout.getChildAt(i); |
143 | | - TextView childAt = (TextView) itemLayout.getChildAt(0); |
144 | | - childAt.setBackgroundColor(contentParams.getBackgroundColor()); |
145 | | - } |
146 | | - } |
147 | | - } |
148 | | - } |
| 139 | + int oldFocusRow = this.focusRow; |
149 | 140 | this.focusRow = focusRow; |
150 | 141 | this.cacheLayout = focusView; |
151 | 142 |
|
152 | | - int childCount = cacheLayout.getChildCount(); |
153 | | - for (int i = 0; i < childCount; i++) { |
154 | | - FrameLayout itemLayout = (FrameLayout) cacheLayout.getChildAt(i); |
155 | | - TextView childAt = (TextView) itemLayout.getChildAt(0); |
156 | | - childAt.setBackgroundColor(contentParams.getFoucsColor()); |
157 | | - } |
| 143 | + if (oldFocusRow != -1){ |
| 144 | + notifyItemChanged(oldFocusRow, false); |
| 145 | + } |
| 146 | + |
| 147 | + if (this.focusRow != -1){ |
| 148 | + notifyItemChanged(focusRow, true); |
| 149 | + } |
158 | 150 | } |
159 | 151 |
|
160 | 152 | public int getFocusRow() { |
|
0 commit comments