Created
June 29, 2015 17:35
-
-
Save evasyuk/c5c4afb9bc5dfac7a155 to your computer and use it in GitHub Desktop.
CircularArrayAdapter
This file contains 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
public class CircularArrayAdapter extends ArrayAdapter | |
{ | |
public static final int HALF_MAX_VALUE = Integer.MAX_VALUE/2; | |
public final int MIDDLE; | |
private T[] objects; | |
public CircularArrayAdapter(Context context, int textViewResourceId, T[] objects) | |
{ | |
super(context, textViewResourceId, objects); | |
this.objects = objects; | |
MIDDLE = HALF_MAX_VALUE - HALF_MAX_VALUE % objects.length; | |
} | |
@Override | |
public int getCount() | |
{ | |
return Integer.MAX_VALUE; | |
} | |
@Override | |
public T getItem(int position) | |
{ | |
return objects[position % objects.length]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment