Skip to content

Instantly share code, notes, and snippets.

@philippb
Created November 7, 2015 03:10
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 philippb/d9d025fc5af8f1e6152e to your computer and use it in GitHub Desktop.
Save philippb/d9d025fc5af8f1e6152e to your computer and use it in GitHub Desktop.
private ListView mListView;
private ArrayAdapter mListAdapter;
private final AlphaAnimation mFadeOut = new AlphaAnimation(1.0f, 0.3f);
private final AlphaAnimation mFadeIn = new AlphaAnimation(0.3f, 1.0f);
public class OnFolderOverflowSelectedListener implements OnClickListner {
// Stuff from above
public void onClick(View v) {
// All the stuff above
// Dim out all the other list items if they exist
int firstPos = mListView.getFirstVisiblePosition() - mListView.getHeaderViewsCount();
final int ourPos = mListAdapter.getPosition(mAlbum) - firstPos;
int count = mListView.getChildCount();
for (int i = 0; i <= count; i++) {
if (i == ourPos) {
continue;
}
final View child = mListView.getChildAt(i);
if (child != null) {
child.clearAnimation();
child.startAnimation(mFadeOut);
}
}
// Make sure to bring them back to normal after the menu is gone
popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu popupMenu) {
int count = mListView.getChildCount();
for (int i = 0; i <= count; i++) {
if (i == ourPos) {
continue;
}
final View v = mListView.getChildAt(i);
if (v != null) {
v.clearAnimation();
v.startAnimation(mFadeIn);
}
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment