Android Open Source - carousel-android Carousel Item






From Project

Back to project page carousel-android.

License

The source code is released under:

The Code Project Open License (CPOL) 1.02 Preamble This License governs Your use of the Work. This License is intended to allow developers to use the Source Code and Executable Files provided as par...

If you think the Android project carousel-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

package fr.rolandl.carousel;
/*w w w .  ja  v a2 s  .com*/
import android.content.Context;
import android.graphics.Matrix;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

/**
 * @author Igor Kushnarev, Ludovic Roland
 * @since 2014.12.19
 */
//Inspired by http://www.codeproject.com/Articles/146145/Android-D-Carousel
public abstract class CarouselItem<T>
    extends FrameLayout
    implements Comparable<CarouselItem<?>>
{

  private int index;

  private float currentAngle;

  private float itemX;

  private float itemY;

  private float itemZ;

  private boolean drawn;

  private Matrix matrix;

  public CarouselItem(Context context, int layoutId)
  {
    super(context);

    final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setLayoutParams(params);

    final LayoutInflater inflater = LayoutInflater.from(context);
    final View view = inflater.inflate(layoutId, this, true);

    extractView(view);
  }

  public void setIndex(int index)
  {
    this.index = index;
  }

  public int getIndex()
  {
    return index;
  }

  public void setCurrentAngle(float currentAngle)
  {
    this.currentAngle = currentAngle;
  }

  public float getCurrentAngle()
  {
    return currentAngle;
  }

  public void setItemX(float x)
  {
    this.itemX = x;
  }

  public float getItemX()
  {
    return itemX;
  }

  public void setItemY(float y)
  {
    this.itemY = y;
  }

  public float getItemY()
  {
    return itemY;
  }

  public void setItemZ(float z)
  {
    this.itemZ = z;
  }

  public float getItemZ()
  {
    return itemZ;
  }

  public void setDrawn(boolean drawn)
  {
    this.drawn = drawn;
  }

  public boolean isDrawn()
  {
    return drawn;
  }

  public Matrix getCIMatrix()
  {
    return matrix;
  }

  void setCIMatrix(Matrix mMatrix)
  {
    this.matrix = mMatrix;
  }

  @Override
  public int compareTo(CarouselItem<?> another)
  {
    return (int) (another.itemZ - this.itemZ);
  }

  public abstract void extractView(View view);

  public abstract void update(T arg0);

}




Java Source Code List

fr.rolandl.carousel.CarouselAdapter.java
fr.rolandl.carousel.CarouselBaseAdapter.java
fr.rolandl.carousel.CarouselItem.java
fr.rolandl.carousel.CarouselSpinner.java
fr.rolandl.carousel.Carousel.java
fr.rolandl.carousel.Rotator.java
fr.rolandl.sample.carousel.MainActivity.java
fr.rolandl.sample.carousel.adapter.MyAdapter.java
fr.rolandl.sample.carousel.bo.Photo.java