Android Open Source - ponyville-live-android Animation Speed Adapter

From Project

Back to project page ponyville-live-android.


The source code is released under:

Apache License

If you think the Android project ponyville-live-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//w  ww.  j av  a2  s  .c om
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import static butterknife.ButterKnife.findById;

class AnimationSpeedAdapter extends BindableAdapter<Integer> {
  private static final int[] VALUES = {
      1, 2, 3, 5, 10

  public static int getPositionForValue(int value) {
    for (int i = 0; i < VALUES.length; i++) {
      if (VALUES[i] == value) {
        return i;
    return 0; // Default to 1x if something changes.

  AnimationSpeedAdapter(Context context) {

  public int getCount() {
    return VALUES.length;

  public Integer getItem(int position) {
    return VALUES[position];

  public long getItemId(int position) {
    return position;

  public View newView(LayoutInflater inflater, int position, ViewGroup container) {
    return inflater.inflate(android.R.layout.simple_spinner_item, container, false);

  public void bindView(Integer item, int position, View view) {
    TextView tv = findById(view,;
    if (item == 1) {
    } else {
      tv.setText(item + "x slower");

  public View newDropDownView(LayoutInflater inflater, int position, ViewGroup container) {
    return inflater.inflate(android.R.layout.simple_spinner_dropdown_item, container, false);

Java Source Code List