Created
June 5, 2017 11:02
-
-
Save yishai-glide/91ac05ac4e37dce88c7bf0cff4e4eb5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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