am dcafbc3b: am 02c6b367: Merge "Remove deprecated API usage" into lmp-mr1-dev

* commit 'dcafbc3b0cc6f2a7a2d70a6f887025a8ed447afd':
  Remove deprecated API usage
This commit is contained in:
Yigit Boyar
2014-11-21 22:04:08 +00:00
committed by Android Git Automerger
4 changed files with 17 additions and 9 deletions

View File

@@ -124,8 +124,12 @@ public class AnimatedRecyclerView extends Activity {
public void itemClicked(View view) {
ViewGroup parent = (ViewGroup) view;
MyViewHolder holder = (MyViewHolder) mRecyclerView.getChildViewHolder(parent);
final int position = holder.getAdapterPosition();
if (position == RecyclerView.NO_POSITION) {
return;
}
mAdapter.toggleExpanded(holder);
mAdapter.notifyItemChanged(holder.getPosition());
mAdapter.notifyItemChanged(position);
}
public void deleteItem(View view) {
@@ -240,7 +244,7 @@ public class AnimatedRecyclerView extends Activity {
if (lastVisibleView != null) {
RecyclerView.LayoutParams lastParams =
(RecyclerView.LayoutParams) lastVisibleView.getLayoutParams();
int lastPosition = lastParams.getViewPosition();
int lastPosition = lastParams.getViewLayoutPosition();
final List<RecyclerView.ViewHolder> previousViews = recycler.getScrapList();
count = previousViews.size();
for (int i = 0; i < count; ++i) {
@@ -250,7 +254,7 @@ public class AnimatedRecyclerView extends Activity {
if (params.isItemRemoved()) {
continue;
}
int position = params.getViewPosition();
int position = params.getViewLayoutPosition();
int newTop;
if (position < mFirstPosition) {
newTop = view.getHeight() * (position - mFirstPosition);

View File

@@ -84,11 +84,10 @@ abstract public class BaseLayoutManagerActivity<T extends RecyclerView.LayoutMan
vh.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int pos = vh.getPosition();
if (pos + 1 < getItemCount()) {
final int pos = vh.getAdapterPosition();
if (pos != RecyclerView.NO_POSITION && pos + 1 < getItemCount()) {
swap(pos, pos + 1);
}
notifyItemChanged(pos);
}
});
return vh;

View File

@@ -119,11 +119,13 @@ public class GridLayoutManagerActivity extends BaseLayoutManagerActivity<GridLay
vh.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int pos = vh.getPosition();
final int pos = vh.getAdapterPosition();
if (pos == RecyclerView.NO_POSITION) {
return;
}
if (pos + 1 < getItemCount()) {
swap(pos, pos + 1);
}
notifyItemChanged(pos);
}
});
return vh;

View File

@@ -56,7 +56,10 @@ public class RecyclerViewActivity extends Activity {
vh.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int pos = vh.getPosition();
final int pos = vh.getAdapterPosition();
if (pos == RecyclerView.NO_POSITION) {
return;
}
if (pos + 1 < getItemCount()) {
swap(pos, pos + 1);
}