Android satellite food selection Computer animation.

— > AndroidManifest.xml








In worths Folder

sat_attrs. xml










In Format Folder

sat_main. xml


sat_item_cr. xml


main.xml


res/anim

sat_item_anim_click. xml



sat_item_anticipate_interpolator. xml


sat_item_click_interpolator. xml


sat_item_in_rotate_interpolator. xml


sat_item_out_rotate_interpolator. xml


sat_item_overshoot_interpolator. xml


sat_main_rotate_left. xml


sat_main_rotate_right. xml


ArrayDegreeProvider.java

bundle android.view.satellitemenu;

public course ArrayDegreeProvider executes IDegreeProvider {
.
personal float[] levels;

public ArrayDegreeProvider( float[] levels) {
.
this.degrees = levels;
}

public float[] getDegrees( int matter, float totalDegrees) {
.
if( levels == void|| degrees.length!= matter) {
.
toss brand-new IllegalArgumentException(“Provided delta degrees and the action count are not the same.”-RRB-;
}
return levels;
}
}

DefaultDegreeProvider.java

bundle android.view.satellitemenu;

public course DefaultDegreeProvider executes IDegreeProvider {
.
public float[] getDegrees( int matter, float totalDegrees) {
.
if( matter < 1). { return brand-new float[] {};. } float[] outcome = null;. int tmpCount = 0;. if( matter < 4) { tmpCount = matter +1;. } else { tmpCount = count-1;. } outcome = brand-new float[count];. float delta = totalDegrees/ tmpCount;. for( int index= 0; index< matter; index++) { int tmpIndex = index;. if( matter < 4) { tmpIndex = tmpIndex +1;. } outcome[index] = tmpIndex * delta;. } return outcome;. } }

IDegreeProvider.java

bundle android.view.satellitemenu;

public user interface IDegreeProvider {
.
public float[] getDegrees( int matter, float totalDegrees);
}

LinearDegreeProvider.java

bundle android.view.satellitemenu;

public course LinearDegreeProvider executes IDegreeProvider {
.
public float[] getDegrees( int matter, float totalDegrees) {
.
if( matter < 1) { return brand-new float[] {};. } if( matter == 1) { return brand-new float[] {45};. } float[] outcome = null;. int tmpCount = count-1;. outcome = brand-new float[count];. float delta = totalDegrees/ tmpCount;. for( int index= 0; index< matter; index++) { int tmpIndex = index;. outcome[index] = tmpIndex * delta;. } return outcome;. } }

SatelliteAnimationCreator.java

bundle android.view.satellitemenu;

import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.view.satellitemenu.R;

public course SatelliteAnimationCreator {

.

public fixed Computer animation createItemInAnimation( Context context, int index, lengthy expandDuration, int x, int y) {
.
RotateAnimation turn = brand-new RotateAnimation(720, 0,
Animation.RELATIVE _ TO_SELF, 0.5 f,
Animation.RELATIVE _ TO_SELF, 0.5 f);

rotate.setInterpolator( context, R.anim.sat _ item_in_rotate_interpolator);
rotate.setDuration( expandDuration);

TranslateAnimation convert = brand-new TranslateAnimation( x, 0, y, 0);

lengthy hold-up = 250;
if( expandDuration <= 250){ delay = expandDuration / 3; } long duration = 400; if((expandDuration-delay) > period) {
.
period = expandDuration-delay;
}

translate.setDuration( period);
translate.setStartOffset( hold-up);

translate.setInterpolator( context, R.anim.sat _ item_anticipate_interpolator);

AlphaAnimation alphaAnimation = brand-new AlphaAnimation( 1f, 0f);
long alphaDuration = 10;
if( expandDuration < 10) { alphaDuration = expandDuration/ 10;. } alphaAnimation.setDuration( alphaDuration);. alphaAnimation.setStartOffset(( hold-up + period) - alphaDuration);. AnimationSet animationSet = brand-new AnimationSet( incorrect);. animationSet.setFillAfter( incorrect);. animationSet.setFillBefore( real);. animationSet.setFillEnabled( real);. animationSet.addAnimation( alphaAnimation);. animationSet.addAnimation( turn);. animationSet.addAnimation( convert);. animationSet.setStartOffset(30 * index);. animationSet.start();. animationSet.startNow();. return animationSet;. } public fixed Computer animation createItemOutAnimation( Context context, int index, lengthy expandDuration, int x, int y) { AlphaAnimation alphaAnimation = brand-new AlphaAnimation( 0f, 1f);. long alphaDuration = 60;. if( expandDuration < 60) { alphaDuration = expandDuration/ 4;. } alphaAnimation.setDuration( alphaDuration);. alphaAnimation.setStartOffset( 0 );. TranslateAnimation convert = brand-new TranslateAnimation( 0, x, 0, y);. translate.setStartOffset( 0 );. translate.setDuration( expandDuration);. translate.setInterpolator( context, R.anim.sat _ item_overshoot_interpolator);. RotateAnimation turn = brand-new RotateAnimation( 0f, 360 f,. Animation.RELATIVE _ TO_SELF, 0.5 f,. Animation.RELATIVE _ TO_SELF, 0.5 f);. rotate.setInterpolator( context, R.anim.sat _ item_out_rotate_interpolator);. long period of time = 100;. if( expandDuration <= 150) L_CURLY_B. duration = expandDuration / 3;. R_CURLY_B. rotate.setDuration(expandDuration-duration);. rotate.setStartOffset(duration);. AnimationSet animationSet = new AnimationSet(false);. animationSet.setFillAfter(false);. animationSet.setFillBefore(true);. animationSet.setFillEnabled(true);. //animationSet.addAnimation(alphaAnimation);. //animationSet.addAnimation(rotate);. animationSet.addAnimation(translate);. animationSet.setStartOffset(30*index);. return animationSet;. R_CURLY_B. public static Animation createMainButtonAnimation(Context context) L_CURLY_B. return AnimationUtils.loadAnimation(context, R.anim.sat_main_rotate_left);. R_CURLY_B. public static Animation createMainButtonInverseAnimation(Context context) L_CURLY_B. return AnimationUtils.loadAnimation(context, R.anim.sat_main_rotate_right);. R_CURLY_B. public static Animation createItemClickAnimation(Context context) L_CURLY_B. return AnimationUtils.loadAnimation(context, R.anim.sat_item_anim_click);. R_CURLY_B. public static int getTranslateX(float degree, int distance) L_CURLY_B. return Double.valueOf(distance * Math.cos(Math.toRadians(degree))).intValue();. R_CURLY_B. public static int getTranslateY(float degree, int distance) L_CURLY_B. return Double.valueOf(-1 * distance * Math.sin(Math.toRadians(degree))).intValue();. R_CURLY_B. R_CURLY_B.

SatelliteMenu.java

.

package android.view.satellitemenu;

.

import java.lang.ref.WeakReference;
.
import java.util.ArrayList;
.
import java.util.HashMap;
.
import java.util.List;
.
import java.util.Map;
.
import java.util.concurrent.atomic.AtomicBoolean;

.

import android.content.Context;
.
import android.content.res.TypedArray;
.
import android.graphics.drawable.Drawable;
.
import android.os.Parcel;
.
import android.os.Parcelable;
.
import android.util.AttributeSet;
.
import android.view.LayoutInflater;
.
import android.view.View;
.
import android.view.animation.Animation;
.
import android.widget.FrameLayout;
.
import android.widget.ImageView;
.
import android.widget.TextView;

.

public class SatelliteMenu extends FrameLayout{

.

private static final int DEFAULT_SATELLITE_DISTANCE = 200;
.
private static final float DEFAULT_TOTAL_SPACING_DEGREES = 90f;
.
private static final boolean DEFAULT_CLOSE_ON_CLICK = true;
.
private static final int DEFAULT_EXPAND_DURATION = 400;

.

private Animation mainRotateRight;
.
private Animation mainRotateLeft;

.

private ImageView imgMain;
.
private SateliteClickedListener itemClickedListener;
.
private InternalSatelliteOnClickListener internalItemClickListener;

.

private List menuItems = new ArrayList();
.
private Map viewToItemMap = new HashMap();

.

private AtomicBoolean plusAnimationActive = new AtomicBoolean(false);

.

// ?? how to save/restore?
.
private IDegreeProvider gapDegreesProvider = new DefaultDegreeProvider();

.

//States of these variables are saved
.
private boolean rotated = false;
.
private int measureDiff = 0;
.
//States of these variables are saved – Also configured from XML
.
private float totalSpacingDegree = DEFAULT_TOTAL_SPACING_DEGREES;
.
private int satelliteDistance = DEFAULT_SATELLITE_DISTANCE;
.
private int expandDuration = DEFAULT_EXPAND_DURATION;
.
private boolean closeItemsOnClick = DEFAULT_CLOSE_ON_CLICK;

.

public SatelliteMenu(Context context){
.
super(context);
.
init(context, null, 0);
.
R_CURLY_B.

public SatelliteMenu(Context context, AttributeSet attrs){
.
super(context, attrs);
.
init(context, attrs, 0);
.
R_CURLY_B.

public SatelliteMenu(Context context, AttributeSet attrs, int defStyle){
.
super(context, attrs, defStyle);
.
init(context, attrs, defStyle);
.
R_CURLY_B.

private void init(Context context, AttributeSet attrs, int defStyle){
.
LayoutInflater.from(context).inflate(R.layout.sat_main, this, true);
.
imgMain = (ImageView) findViewById(R.id.sat_main);

.

if(attrs != null){
.
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SatelliteMenu, defStyle, 0);
.
satelliteDistance = typedArray.getDimensionPixelSize(R.styleable.SatelliteMenu_satelliteDistance, DEFAULT_SATELLITE_DISTANCE);
.
totalSpacingDegree = typedArray.getFloat(R.styleable.SatelliteMenu_totalSpacingDegree, DEFAULT_TOTAL_SPACING_DEGREES);
.
closeItemsOnClick = typedArray.getBoolean(R.styleable.SatelliteMenu_closeOnClick, DEFAULT_CLOSE_ON_CLICK);
.
expandDuration = typedArray.getInt(R.styleable.SatelliteMenu_expandDuration, DEFAULT_EXPAND_DURATION);
.
//float satelliteDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics());
.
typedArray.recycle();
.
R_CURLY_B.

mainRotateLeft = SatelliteAnimationCreator.createMainButtonAnimation(context);
.
mainRotateRight = SatelliteAnimationCreator.createMainButtonInverseAnimation(context);

.

Animation.AnimationListener plusAnimationListener = new Animation.AnimationListener(){
.
@Override
.
public void onAnimationStart(Animation animation){
.
R_CURLY_B.

@Override
.
public void onAnimationRepeat(Animation animation){
.
R_CURLY_B.

@Override
.
public void onAnimationEnd(Animation animation){
.
plusAnimationActive.set(false);
.
R_CURLY_B.
R_CURLY_B.;

.

mainRotateLeft.setAnimationListener(plusAnimationListener);
.
mainRotateRight.setAnimationListener(plusAnimationListener);

.

imgMain.setOnClickListener(new View.OnClickListener(){
.
@Override
.
public void onClick(View v){
.
SatelliteMenu.this.onClick();
.
R_CURLY_B.
R_CURLY_B. );

.

internalItemClickListener = new InternalSatelliteOnClickListener(this);
.
R_CURLY_B.

private void onClick(){
.
if (plusAnimationActive.compareAndSet(false, true)){
.
if (!rotated){
.
imgMain.startAnimation(mainRotateLeft);
.
for (SatelliteMenuItem item: menuItems){
.
item.getView().startAnimation(item.getOutAnimation());
.
R_CURLY_B.
R_CURLY_B. else{
.
imgMain.startAnimation(mainRotateRight);
.
for (SatelliteMenuItem item: menuItems){
.
item.getView().startAnimation(item.getInAnimation());
.
R_CURLY_B.
R_CURLY_B.
rotated = !rotated;
.
R_CURLY_B.
R_CURLY_B.

private void openItems(){
.
if (plusAnimationActive.compareAndSet(false, true)){
.
if (!rotated){
.
imgMain.startAnimation(mainRotateLeft);
.
for (SatelliteMenuItem item: menuItems){
.
item.getView().startAnimation(item.getOutAnimation());
.
R_CURLY_B.
R_CURLY_B.
rotated = !rotated;
.
R_CURLY_B.
R_CURLY_B.

private void closeItems(){
.
if (plusAnimationActive.compareAndSet(false, true)){
.
if (rotated){
.
imgMain.startAnimation(mainRotateRight);
.
for (SatelliteMenuItem item: menuItems){
.
item.getView().startAnimation(item.getInAnimation());
.
R_CURLY_B.
R_CURLY_B.
rotated = !rotated;
.
R_CURLY_B.
R_CURLY_B.

public void addItems(List items){

.

menuItems.addAll(items);
.
this.removeView(imgMain);
.
TextView tmpView = new TextView(getContext());
.
tmpView.setLayoutParams(new FrameLayout.LayoutParams(0, 0));

.

float[] degrees = getDegrees(menuItems.size());
.
int index = 0;
.
for (SatelliteMenuItem menuItem: menuItems){
.
int finalX = SatelliteAnimationCreator.getTranslateX(
.
degrees[index], satelliteDistance);
.
int finalY = SatelliteAnimationCreator.getTranslateY(
.
degrees[index], satelliteDistance);

.

ImageView itemView = (ImageView) LayoutInflater.from(getContext())
.
.inflate(R.layout.sat_item_cr, this, false);
.
ImageView cloneView = (ImageView) LayoutInflater.from(getContext())
.
.inflate(R.layout.sat_item_cr, this, false);
.
itemView.setTag(menuItem.getId());
.
cloneView.setVisibility(View.GONE);
.
itemView.setVisibility(View.GONE);

.

cloneView.setOnClickListener(internalItemClickListener);
.
cloneView.setTag(Integer.valueOf(menuItem.getId()));
.
FrameLayout.LayoutParams layoutParams = getLayoutParams(cloneView);
.
layoutParams.bottomMargin = Math.abs(finalY);
.
layoutParams.leftMargin = Math.abs(finalX);
.
cloneView.setLayoutParams(layoutParams);

.

if (menuItem.getImgResourceId() > < =150) { period= expandDuration/ 3;.} rotate.setDuration( expandDuration-duration);. rotate.setStartOffset (period);. AnimationSet animationSet =brand-new AnimationSet( incorrect); . animationSet.setFillAfter( incorrect);. animationSet.setFillBefore( real);. animationSet.setFillEnabled( real); .// animationSet.addAnimation( alphaAnimation);.// animationSet.addAnimation( turn); . animationSet.addAnimation (convert); . animationSet.setStartOffset(30 * index);. return animationSet;.} public fixed Computer animation createMainButtonAnimation( Context context) {return AnimationUtils.loadAnimation( context, R.anim.sat _ main_rotate_left);.} public fixed Computer animation createMainButtonInverseAnimation( Context context) {return AnimationUtils.loadAnimation( context, R.anim.sat _ main_rotate_right );.} public fixed Computer animation createItemClickAnimation( Context context) {return AnimationUtils.loadAnimation( context, R.anim.sat _ item_anim_click); .} public fixed int getTranslateX( float level, int range) {return Double.valueOf( range * Math.cos( Math.toRadians( level))). intValue(); .} public fixed int getTranslateY( float level, int range) {return Double.valueOf( -1 * range * Math.sin( Math.toRadians( level))). intValue();. }}

SatelliteMenu.java

bundle android.view.satellitemenu;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

(****** )import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

public course SatelliteMenu expands FrameLayout {

personal fixed last int DEFAULT_SATELLITE_DISTANCE=200
;
personal fixed last float DEFAULT_TOTAL_SPACING_DEGREES =90 f;
personal fixed last boolean DEFAULT_CLOSE_ON_CLICK=
real;
personal fixed last int
DEFAULT_EXPAND_DURATION=400;

personal Computer animation mainRotateRight;
personal Computer animation mainRotateLeft;

personal ImageView imgMain;
personal SateliteClickedListener itemClickedListener;
personal InternalSatelliteOnClickListener internalItemClickListener;

personal Checklist (************************************************** )menuItems= brand-new ArrayList ();
personal Map viewToItemMap= brand-new HashMap ();

personal AtomicBoolean plusAnimationActive= brand-new AtomicBoolean( incorrect);

//?? just how to save/restore?
personal IDegreeProvider gapDegreesProvider= brand-new DefaultDegreeProvider();

/
/ States of these variables are conserved
personal boolean revolved= incorrect;
personal int measureDiff= 0;
// States of these variables are conserved –
Additionally set up from XML(*********
). personal float totalSpacingDegree= DEFAULT_TOTAL_SPACING_DEGREES;
personal int satelliteDistance= DEFAULT_SATELLITE_DISTANCE;
. personal int expandDuration= DEFAULT_EXPAND_DURATION;
personal boolean closeItemsOnClick= DEFAULT_CLOSE_ON_CLICK;

public SatelliteMenu( Context context) {(*********
). incredibly( context);(********* ). init( context, null, 0);
}

public SatelliteMenu( Context context,
AttributeSet attrs) {
. incredibly( context, attrs);
init( context, attrs, 0);
}

(****** )public SatelliteMenu( Context context, AttributeSet attrs, int defStyle) {
.
incredibly( context, attrs, defStyle);
init( context, attrs, defStyle);
}

personal space init( Context context, AttributeSet attrs, int defStyle) {
LayoutInflater.from( context). blow up( R.layout.sat _ major, this, real);
imgMain=( ImageView) findViewById( R.id.sat _ major);

if( attrs!= null) {
TypedArray typedArray= context.obtainStyledAttributes( attrs, R.styleable.SatelliteMenu, defStyle, 0);
satelliteDistance= typedArray.getDimensionPixelSize( R.styleable.SatelliteMenu _ satelliteDistance, DEFAULT_SATELLITE_DISTANCE);
totalSpacingDegree= typedArray.getFloat( R.styleable.SatelliteMenu _ totalSpacingDegree, DEFAULT_TOTAL_SPACING_DEGREES);
closeItemsOnClick= typedArray.getBoolean (R.styleable.SatelliteMenu _ closeOnClick, DEFAULT_CLOSE_ON_CLICK);
expandDuration= typedArray.getInt( R.styleable.SatelliteMenu _ expandDuration, DEFAULT_EXPAND_DURATION)
;
// float satelliteDistance= TypedValue.applyDimension (TypedValue.COMPLEX _ UNIT_DIP, 170,
getResources(). getDisplayMetrics());
typedArray.recycle();
}(******* ).

mainRotateLeft =SatelliteAnimationCreator.createMainButtonAnimation( context);
mainRotateRight= SatelliteAnimationCreator.createMainButtonInverseAnimation( context);

Animation.AnimationListener plusAnimationListener=
brand-new Animation.AnimationListener() {
@Override
public space onAnimationStart( Animation computer animation) {
}

@Override
public space onAnimationRepeat( Animation computer animation) {
}

@Override
public space onAnimationEnd (Animation computer animation) {
plusAnimationActive.set( incorrect);
}
}
;

mainRotateLeft.setAnimationListener( plusAnimationListener);
mainRotateRight.setAnimationListener( plusAnimationListener);

imgMain.setOnClickListener (brand-new View.OnClickListener() {
@Override
public space onClick( Sight v) {
.
SatelliteMenu.this.onClick();
}
}
);

(****** )internalItemClickListener = brand-new InternalSatelliteOnClickListener (this);
}

personal space onClick() {
. if( plusAnimationActive.compareAndSet( incorrect, real))
{
if(! revolved) {
imgMain.startAnimation (mainRotateLeft);
for (SatelliteMenuItem thing: menuItems) {
item.getView(). startAnimation( item.getOutAnimation());
} (*********
).}
else {
imgMain.startAnimation (mainRotateRight);
for( SatelliteMenuItem thing: menuItems) {
item.getView()
startAnimation( item.getInAnimation() );(********* ).}

}

revolved=! revolved;
}
}

personal space openItems() {
if( plusAnimationActive.compareAndSet( incorrect, real)) {
.
if (! revolved) {
.
imgMain.startAnimation (mainRotateLeft);
for( SatelliteMenuItem thing: menuItems) {
item.getView(). startAnimation( item.getOutAnimation());
}
(*********
).}
revolved=! revolved;
}

.}

personal space closeItems() {
if( plusAnimationActive.compareAndSet( incorrect, real)) {
if( revolved) {
imgMain.startAnimation( mainRotateRight);
for( SatelliteMenuItem thing: menuItems) {

item.getView(). startAnimation( item.getInAnimation());
}
}

revolved=! revolved;
}
}

public space addItems( Checklist things) {

menuItems.addAll (things);
this.removeView( imgMain );(********* ). TextView tmpView= brand-new TextView( getContext());
tmpView.setLayoutParams( brand-new FrameLayout.LayoutParams( 0, 0));

float [] levels= getDegrees (menuItems.size());(********* ). int index= 0;
for (SatelliteMenuItem menuItem: menuItems) {

int finalX= SatelliteAnimationCreator.getTranslateX(
levels (*** ), satelliteDistance);
int finalY= SatelliteAnimationCreator.getTranslateY(
levels[index], satelliteDistance);

ImageView itemView = (ImageView) LayoutInflater.from( getContext())
(*********
)
. blow up (R.layout.sat _ item_cr, this, incorrect);
ImageView cloneView=( ImageView) LayoutInflater.from(
getContext( ))
blow up( R.layout.sat _ item_cr, this, incorrect);(********* ). itemView.setTag (menuItem.getId());
cloneView.setVisibility( View.GONE);
itemView.setVisibility( View.GONE );

cloneView.setOnClickListener( internalItemClickListener);(********* ). cloneView.setTag( Integer.valueOf( menuItem.getId ()));
FrameLayout.LayoutParams layoutParams= getLayoutParams( cloneView);
layoutParams.bottomMargin =Math.abs( finalY);
layoutParams.leftMargin = Math.abs (finalX);
cloneView.setLayoutParams( layoutParams);

if( menuItem.getImgResourceId() > 0
) {
itemView.setImageResource (menuItem.getImgResourceId());
cloneView.setImageResource( menuItem.getImgResourceId());(********* ).}
else if (menuItem.getImgDrawable()!= null) {
itemView.setImageDrawable( menuItem.getImgDrawable());
cloneView.setImageDrawable( menuItem.getImgDrawable())
;(********* ).}

(****** )Computer animation itemOut= SatelliteAnimationCreator.createItemOutAnimation( getContext(), index, expandDuration, finalX, finalY);(********* ). Computer animation itemIn= SatelliteAnimationCreator.createItemInAnimation( getContext(), index, expandDuration, finalX, finalY);
Computer animation itemClick = SatelliteAnimationCreator.createItemClickAnimation (getContext());

menuItem.setView( itemView);
menuItem.setCloneView (cloneView
);
menuItem.setInAnimation( itemIn );
menuItem.setOutAnimation( itemOut);
menuItem.setClickAnimation( itemClick );
menuItem.setFinalX( finalX);(********* ). menuItem.setFinalY( finalY);

itemIn.setAnimationListener (brand-new SatelliteAnimationListener( itemView, real, viewToItemMap ));
itemOut.setAnimationListener( brand-new SatelliteAnimationListener( itemView, incorrect, viewToItemMap))
;(********* ). itemClick.setAnimationListener( brand-new SatelliteItemClickAnimationListener( this, menuItem.getId ()));(******* ).(****** )this.addView( itemView);
this.addView( cloneView);(********* ). viewToItemMap.put( itemView, menuItem );
viewToItemMap.put( cloneView, menuItem);
index++;
}

this.addView (imgMain);
} (******* ).

personal float[] getDegrees( int matter) {
return gapDegreesProvider.getDegrees( matter, totalSpacingDegree);
}

personal space recalculateMeasureDiff () {
int itemWidth =0;
if( menuItems.size () > 0) {
. itemWidth= menuItems.get( 0).
getView() getWidth( );
}
measureDiff=
Float.valueOf( satelliteDistance * 0.2 f ). intValue()
+ itemWidth;
}

personal space resetItems() {
if( menuItems.size() > 0
) {(********* ). Checklist(************************************************** )things= brand-new ArrayList (
menuItems);(********* ). menuItems.clear();
this.removeAllViews();
addItems( things);
}
}

(****** )@Override
secured void onMeasure( int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure (widthMeasureSpec, heightMeasureSpec);
recalculateMeasureDiff( );(******* ).

int totalHeight= imgMain.getHeight( )+ satelliteDistance +measureDiff;
int totalWidth= imgMain.getWidth()+ satelliteDistance+ measureDiff;
setMeasuredDimension( totalWidth, totalHeight);
}

(****** )personal fixed course SatelliteItemClickAnimationListener executes Animation.AnimationListener {
personal WeakReference menuRef;
personal int tag;

public SatelliteItemClickAnimationListener (SatelliteMenu food selection, int tag) {
this.menuRef= brand-new WeakReference (food selection);
this.tag= tag;
}

@Override
public space onAnimationEnd( Animation computer animation) {
(********* ).}

@Override
public space onAnimationRepeat (Computer animation
computer animation) {
}

@Override
public space onAnimationStart (Computer animation
computer animation) {
SatelliteMenu food selection= menuRef.get();
if( food selection!= null & &
menu.closeItemsOnClick) {

menu.close();
if( menu.itemClickedListener!= null) {
menu.itemClickedListener.eventOccured( tag);(********* ).}
}
.}
}

personal fixed course SatelliteAnimationListener executes Animation.AnimationListener {
personal WeakReference viewRef;(********* ). personal boolean isInAnimation;
personal Map viewToItemMap;(******* ).

public SatelliteAnimationListener( Sight sight, boolean isIn, Map viewToItemMap)
{
this.viewRef= brand-new WeakReference(***************************************************** )( sight);
this.isInAnimation = isIn;
this.viewToItemMap= viewToItemMap;
}

@Override
public space onAnimationStart( Animation computer animation) {
if( viewRef! = null ){
Sight sight = viewRef.get ();
if( sight!= null) {
SatelliteMenuItem menuItem= viewToItemMap.get( sight);
if( isInAnimation) {
menuItem.getView() setVisibility( View.VISIBLE);
menuItem.getCloneView(). setVisibility (View.GONE);(********* ).}
else {
menuItem.getCloneView().
setVisibility( View.GONE);(********* ). menuItem.getView(). setVisibility( View.VISIBLE);(********* ).}
}
}

}

@Override
public space onAnimationRepeat( Animation computer animation) {(*********
).}

@Override
public space onAnimationEnd( Animation computer animation) {
if( viewRef! = null) {

Sight sight = viewRef.get();
if( sight! = null ){
SatelliteMenuItem menuItem= viewToItemMap.get( sight);

(****** )if (isInAnimation) {
menuItem.getView().
setVisibility (View.GONE);
menuItem.getCloneView().
setVisibility( View.GONE);(********* ).} else {
menuItem.getCloneView()
setVisibility( View.VISIBLE);
menuItem.getView(). setVisibility( View.GONE);
}
}
}
}
}

public Map getViewToItemMap() {
return viewToItemMap;
}

personal fixed FrameLayout.LayoutParams getLayoutParams( Sight sight) {
return (FrameLayout.LayoutParams) view.getLayoutParams();
}

personal fixed course InternalSatelliteOnClickListener executes View.OnClickListener {
personal WeakReference menuRef;

(****** )public InternalSatelliteOnClickListener( SatelliteMenu food selection)
{
.
this.menuRef= brand-new WeakReference( food selection);
}

@Override(*********
). public space onClick( Sight v) {(*********
). SatelliteMenu food selection= menuRef.get();(********* ). if( food selection!= null) {
SatelliteMenuItem menuItem= menu.getViewToItemMap(). obtain( v);
v.startAnimation( menuItem.getClickAnimation());
}

}
}

/ **
* Establishes the click audience for satellite things.
*
* @param itemClickedListener(*********
). */
public space setOnItemClickedListener( SateliteClickedListener itemClickedListener) {(********* ). this.itemClickedListener= itemClickedListener;
}

/ **
* Specifies the formula to specify the space in between each thing.
* Note: Calling prior to including things is highly suggested.
*
* @param gapDegreeProvider
*/
public space setGapDegreeProvider( IDegreeProvider gapDegreeProvider) {
this.gapDegreesProvider= gapDegreeProvider;
resetItems( );
}

/ **
* Specifies the overall room in between the first and also last thing in levels.
* Note: Calling prior to including things is highly suggested.
*
* @param totalSpacingDegree The level in between first and also last things.
*/(*********
). public space setTotalSpacingDegree( float totalSpacingDegree) {
this.totalSpacingDegree= totalSpacingDegree;
resetItems();
}

/ **(********* ). * Establishes the range of things from the facility in pixels.
* Note: Calling prior to including things is highly suggested.
*
* @param range the range of things to facility in pixels.
*/
public space setSatelliteDistance( int range) {
this.satelliteDistance = range;
resetItems ();(********* ).
}

/ **
* Establishes the period for increasing and also falling down the things in miliseconds.

* Note: Calling prior to including things is highly suggested.(*********
). *
* @param expandDuration the period for increasing and also falling down the things in miliseconds.

*/
public space setExpandDuration( int expandDuration) {
this.expandDuration= expandDuration;
resetItems();
}

/ **
* Establishes the photo source for the facility switch.

*
* @param source The photo source.

*/(*********
). public space setMainImage( int source) {

this.imgMain.setImageResource( source);
}
(******* ).(****** )/ **
* Establishes the photo drawable for the facility switch.
*
* @param source The photo drawable.(********* ). */(*********
). public space setMainImage( Drawable drawable) {
this.imgMain.setImageDrawable (drawable);
}

/ **
* Specifies if the food selection will break down the things when a product is clicked.
Default worth holds true.
*
* @param closeItemsOnClick
*/(*********
). public space setCloseItemsOnClick( boolean closeItemsOnClick) {

this.closeItemsOnClick= closeItemsOnClick;
}

/ **
* The audience course for thing click occasion.
* @author Siyamed SINIR(*********
). */(*********
). public user interface SateliteClickedListener {(********* )./ **
* When a product is clicked, educates with the id of the thing, which is provided while including the things.

*(*********
). * @param id The id of the thing.

*/
public space eventOccured( int id);
}

/ **
* Broaden the food selection things.
*/(*********
). public space increase() {(*********
). openItems();(********* ).}

/ **
* Collapse the food selection things
*/(*********
). public space close() {
closeItems ();
}

@Override
safeguarded Parcelable onSaveInstanceState () {
Parcelable superState= super.onSaveInstanceState ();
SavedState ss= brand-new SavedState( superState);
ss.rotated= revolved;
ss.totalSpacingDegree =totalSpacingDegree;
ss.satelliteDistance= satelliteDistance;
ss.measureDiff = measureDiff;
ss.expandDuration= expandDuration;
ss.closeItemsOnClick= closeItemsOnClick;
return ss;
}

@Override (*********
). secured void onRestoreInstanceState( Parcelable state) {
SavedState ss =( SavedState) state;
revolved = ss.rotated;
totalSpacingDegree= ss.totalSpacingDegree;
satelliteDistance= ss.satelliteDistance;
measureDiff= ss.measureDiff;
expandDuration =ss.expandDuration;
closeItemsOnClick= ss.closeItemsOnClick;

super.onRestoreInstanceState (ss.getSuperState());
}

fixed course SavedState expands BaseSavedState {(*********
). boolean revolved;
personal float totalSpacingDegree;
personal int satelliteDistance;
personal int measureDiff;
personal int expandDuration;
personal boolean closeItemsOnClick;

SavedState(
Parcelable superState) {
(*********
). incredibly( superState);
}

public SavedState( Parcel in) {
incredibly (in);
revolved = Boolean.valueOf( in.readString())
;
totalSpacingDegree= in.readFloat();
satelliteDistance =in.readInt();(********* ). measureDiff= in.readInt();
expandDuration= in.readInt();
closeItemsOnClick= Boolean.valueOf( in.readString());
}

@Override
public int describeContents () {(********* ). return 0;
}

@Override
public space writeToParcel (Shell out, int flags) {

out.writeString (Boolean.toString (revolved));
out.writeFloat (totalSpacingDegree);
out.writeInt (satelliteDistance);
out.writeInt (measureDiff);
out.writeInt (expandDuration);
out.writeString (Boolean.toString (closeItemsOnClick));
}

public fixed last Parcelable.Creator DEVELOPER = brand-new Parcelable.Creator () {
. public SavedState createFromParcel (Parcel in) {
. return brand-new SavedState (in);
}

public SavedState [] newArray (int dimension) {
. return brand-new SavedState [size];
}
.};
}
.}

SatelliteMenuActivity.java

bundle android.view.satellitemenu;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.satellitemenu.SatelliteMenu.SateliteClickedListener;

public course SatelliteMenuActivity expands Task {

.

@Override
public space onCreate (Package savedInstanceState) {
. super.onCreate (savedInstanceState);
setContentView (R.layout.main);

SatelliteMenu food selection = (SatelliteMenu) findViewById (R.id.menu);

Checklist things = brand-new ArrayList ();
items.add (brand-new SatelliteMenuItem (4, R.drawable.ic _ 1));
items.add (brand-new SatelliteMenuItem (4, R.drawable.ic _ 3));
items.add (brand-new SatelliteMenuItem (4, R.drawable.ic _ 4));
items.add (brand-new SatelliteMenuItem (3, R.drawable.ic _ 5));
items.add (brand-new SatelliteMenuItem (2, R.drawable.ic _ 6));
items.add (brand-new SatelliteMenuItem (1, R.drawable.ic _ 2));

menu.addItems (things);

menu.setOnItemClickedListener (brand-new SateliteClickedListener () {

.

public space eventOccured (int id) {
. Log.i (“sat”, “Clicked on ” + id);
}
.});
}
.}

SatelliteMenuItem.java

bundle android.view.satellitemenu;

import android.graphics.drawable.Drawable;
import android.view.animation.Animation;
import android.widget.ImageView;

public course SatelliteMenuItem {
. personal int id;
personal int imgResourceId;
personal Drawable imgDrawable;
personal ImageView sight;
personal ImageView cloneView;
personal Computer animation outAnimation;
personal Computer animation inAnimation;
personal Computer animation clickAnimation;
personal int finalX;
personal int finalY;

public SatelliteMenuItem (int id, int imgResourceId) {
. this.imgResourceId = imgResourceId;
this.id = id;
}

public SatelliteMenuItem (int id, Drawable imgDrawable) {
. this.imgDrawable = imgDrawable;
this.id = id;
}

public int getId () {
. return id;
}

public space setId (int id) {
. this.id = id;
}

public int getImgResourceId () {
. return imgResourceId;
}

public space setImgResourceId (int imgResourceId) {
. this.imgResourceId = imgResourceId;
}

public Drawable getImgDrawable () {
. return imgDrawable;
}

public space setImgDrawable (Drawable imgDrawable) {
. this.imgDrawable = imgDrawable;
}

space setView (ImageView sight) {
. this.view = sight;
}

ImageView getView () {
. return sight;
}

space setInAnimation (Computer animation inAnimation) {
. this.inAnimation = inAnimation;
}

Computer animation getInAnimation () {
. return inAnimation;
}

space setOutAnimation (Computer animation outAnimation) {
. this.outAnimation = outAnimation;
}

Computer animation getOutAnimation () {
. return outAnimation;
}

space setFinalX (int finalX) {
. this.finalX = finalX;
}

space setFinalY (int finalY) {
. this.finalY = finalY;
}

int getFinalX () {
. return finalX;
}

int getFinalY () {
. return finalY;
}

space setCloneView (ImageView cloneView) {
. this.cloneView = cloneView;
}

ImageView getCloneView () {
. return cloneView;
}

space setClickAnimation (Computer animation clickAnim) {
. this.clickAnimation = clickAnim;
}

Computer animation getClickAnimation () {
. return clickAnimation;
}
.}

.