am 882beee7: am db120dbb: am 8c433780: Update Support7Demos for new RecyclerView additions

* commit '882beee7b60b827754867f252e9fa5f3a290eff2':
  Update Support7Demos for new RecyclerView additions
This commit is contained in:
Adam Powell
2014-02-13 12:02:22 -08:00
committed by Android Git Automerger

View File

@@ -103,7 +103,7 @@ public class RecyclerViewActivity extends Activity {
for (int i = 0; mFirstPosition + i < count && top < parentBottom; i++, top = bottom) { for (int i = 0; mFirstPosition + i < count && top < parentBottom; i++, top = bottom) {
View v = recycler.getViewForPosition(adapter, mFirstPosition + i); View v = recycler.getViewForPosition(adapter, mFirstPosition + i);
addView(v, i); addView(v, i);
measureChild(v, 0, 0); measureChildWithMargins(v, 0, 0);
bottom = top + v.getMeasuredHeight(); bottom = top + v.getMeasuredHeight();
v.layout(left, top, right, bottom); v.layout(left, top, right, bottom);
} }
@@ -143,7 +143,7 @@ public class RecyclerViewActivity extends Activity {
mFirstPosition--; mFirstPosition--;
View v = recycler.getViewForPosition(adapter, mFirstPosition); View v = recycler.getViewForPosition(adapter, mFirstPosition);
addView(v, 0); addView(v, 0);
measureChild(v, 0, 0); measureChildWithMargins(v, 0, 0);
final int bottom = topView.getTop(); // TODO decorated top? final int bottom = topView.getTop(); // TODO decorated top?
final int top = bottom - v.getMeasuredHeight(); final int top = bottom - v.getMeasuredHeight();
v.layout(left, top, right, bottom); v.layout(left, top, right, bottom);
@@ -164,7 +164,7 @@ public class RecyclerViewActivity extends Activity {
mFirstPosition + getChildCount()); mFirstPosition + getChildCount());
final int top = getChildAt(getChildCount() - 1).getBottom(); final int top = getChildAt(getChildCount() - 1).getBottom();
addView(v); addView(v);
measureChild(v, 0, 0); measureChildWithMargins(v, 0, 0);
final int bottom = top + v.getMeasuredHeight(); final int bottom = top + v.getMeasuredHeight();
v.layout(left, top, right, bottom); v.layout(left, top, right, bottom);
} else { } else {
@@ -196,7 +196,7 @@ public class RecyclerViewActivity extends Activity {
View v = recycler.getViewForPosition(adapter, mFirstPosition); View v = recycler.getViewForPosition(adapter, mFirstPosition);
final int bottom = getChildAt(0).getTop(); // TODO decorated top? final int bottom = getChildAt(0).getTop(); // TODO decorated top?
addView(v, 0); addView(v, 0);
measureChild(v, 0, 0); measureChildWithMargins(v, 0, 0);
final int top = bottom - v.getMeasuredHeight(); final int top = bottom - v.getMeasuredHeight();
v.layout(left, top, right, bottom); v.layout(left, top, right, bottom);
if (v.isFocusable()) { if (v.isFocusable()) {
@@ -211,7 +211,7 @@ public class RecyclerViewActivity extends Activity {
View v = recycler.getViewForPosition(adapter, mFirstPosition + getChildCount()); View v = recycler.getViewForPosition(adapter, mFirstPosition + getChildCount());
final int top = getChildAt(getChildCount() - 1).getBottom(); final int top = getChildAt(getChildCount() - 1).getBottom();
addView(v); addView(v);
measureChild(v, 0, 0); measureChildWithMargins(v, 0, 0);
final int bottom = top + v.getMeasuredHeight(); final int bottom = top + v.getMeasuredHeight();
v.layout(left, top, right, bottom); v.layout(left, top, right, bottom);
if (v.isFocusable()) { if (v.isFocusable()) {
@@ -256,7 +256,7 @@ public class RecyclerViewActivity extends Activity {
} }
} }
class MyAdapter extends RecyclerView.Adapter { class MyAdapter extends RecyclerView.Adapter<ViewHolder> {
private int mBackground; private int mBackground;
private ArrayList<String> mValues; private ArrayList<String> mValues;
@@ -270,7 +270,7 @@ public class RecyclerViewActivity extends Activity {
} }
@Override @Override
public RecyclerView.ViewHolder createViewHolder(ViewGroup parent, int viewType) { public ViewHolder createViewHolder(ViewGroup parent, int viewType) {
final ViewHolder h = new ViewHolder(new TextView(RecyclerViewActivity.this)); final ViewHolder h = new ViewHolder(new TextView(RecyclerViewActivity.this));
h.textView.setMinimumHeight(128); h.textView.setMinimumHeight(128);
h.textView.setFocusable(true); h.textView.setFocusable(true);
@@ -283,7 +283,7 @@ public class RecyclerViewActivity extends Activity {
final String t = mValues.get(pos); final String t = mValues.get(pos);
mValues.set(pos, mValues.get(pos + 1)); mValues.set(pos, mValues.get(pos + 1));
mValues.set(pos + 1, t); mValues.set(pos + 1, t);
notifyDataSetChanged(); notifyItemRangeChanged(pos, 2);
} }
} }
}); });
@@ -291,8 +291,8 @@ public class RecyclerViewActivity extends Activity {
} }
@Override @Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) { public void bindViewHolder(ViewHolder holder, int position) {
((ViewHolder) holder).textView.setText(mValues.get(position)); holder.textView.setText(mValues.get(position));
} }
@Override @Override