Skip to content

Instantly share code, notes, and snippets.

@yishai-glide
Created June 5, 2017 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yishai-glide/91ac05ac4e37dce88c7bf0cff4e4eb5b to your computer and use it in GitHub Desktop.
Save yishai-glide/91ac05ac4e37dce88c7bf0cff4e4eb5b to your computer and use it in GitHub Desktop.
mList.setOnScrollListener(new OnScrollListener() {
List<ViewPropertyAnimator> animations = new ArrayList<ViewPropertyAnimator>();
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE) {
int firstVisiblePosition = view.getFirstVisiblePosition();
int lastVisiblePosition = view.getLastVisiblePosition();
for(int i = lastVisiblePosition; i >= firstVisiblePosition; i--) {
final View v = view.getChildAt(i - firstVisiblePosition);
Object tag = v.getTag();
if (tag instanceof ThreadListAdapter.AdViewHolder) {
v.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_bright));
ImageView iv = (ImageView) v.findViewById(R.id.nativeAdIcon);
if (iv != null) {
ViewPropertyAnimator animator = iv.animate().rotationY(180F).setDuration(1500).withEndAction(new Runnable() {
@Override
public void run() {
v.setBackgroundColor(getResources().getColor(android.R.color.transparent));
}
});
animations.add(animator);
animator.start();
Log.d(TAG, "animating for position: " + i);
}
}
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment