I've implemented the whole example from the below link but can't get the position of a particular image focused at center position.
https://github.com/davidschreiber/FancyCoverFlow
So what I should do for this?
I've implemented the below code to my class:
MainActivity.java
this.fancyCoverFlow.setAdapter(new FancyCoverFlowSampleAdapter());
this.fancyCoverFlow.setUnselectedAlpha(1.0f);
this.fancyCoverFlow.setUnselectedSaturation(0);
this.fancyCoverFlow.setUnselectedScale(0);
this.fancyCoverFlow.setSpacing(0);
this.fancyCoverFlow.setMaxRotation(0);
this.fancyCoverFlow.setScaleDownGravity(0.2f);
this.fancyCoverFlow.setActionDistance(FancyCoverFlow.ACTION_DISTANCE_AUTO);
FancyCoverFlowSampleAdapter.class
public class FancyCoverFlowSampleAdapter extends FancyCoverFlowAdapter {
@Override
public int getCount() {
return GlobalFields.arrlistFrames.length;
}
@Override
public Integer getItem(int i) {
return GlobalFields.arrlistFrames[i];
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getCoverFlowItem(int i, View reuseableView, ViewGroup viewGroup) {
ImageView imageView = null;
if (reuseableView != null) {
imageView = (ImageView) reuseableView;
} else {
imageView = new ImageView(viewGroup.getContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setLayoutParams(new FancyCoverFlow.LayoutParams(400, 500));
GlobalFields.i = i;
Log.e("FancyFlow adapter", "Position: " +i);
}
imageView.setImageResource(this.getItem(i));
return imageView;
}
}
I've implemented both the java classes and if I will run this code, on the first position of the image it will display the output like Position: 0 but when I swipe the images from right to left, on the second image position it will give me the output like this Position: 2 whereas this is wrong output.
So it will directly move from position 0 to position 2, so I need your help to make it correct and on click of a button I have to pass this shape or image to the next activity.
Your valuable feedback and additional efforts will be appreciated.
you need to set for setOnItemSelectedListener. Refer below code
this.fancyCoverFlow.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Log.d("fancyFlowCurPos ", String.valueOf(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});