clkasd / carouselviewproject Goto Github PK
View Code? Open in Web Editor NEWAndroid Carousel view pager example project - NOT MAINTAINED
Android Carousel view pager example project - NOT MAINTAINED
i already have used slidingpanel layout library in my project which has nineoldandroids-2.4.0.jar now once i m trying to use ViewHelpLib.jar then my project is not running and getting error
Unable to execute dex: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
[2015-07-07 14:17:49 - YouInApp] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
when i m not adding ViewHelperLib.jar then its giving me error at these lines //ViewHelper.setAlpha(cur, maxAlpha-0.5f_positionOffset);
//ViewHelper.setAlpha(next, minAlpha+0.5f_positionOffset);
//ViewHelper.setAlpha(prev, minAlpha+0.5f*positionOffset);
in adapter class the error is NPE ..... if i m commenting these lines then i m failed to achieve blur and higlighted effects on pagescroll ..... what steps i needed to take to overcome this situation ?
I'm getting this error an unable to build the project. can i get the complete source code project to generate the jar file myself?
@clkasd When i change the Page margin and the angle for previous and next card unfortunately its overlapping(i.e centre card goes behind the next card). How to bring it to the front?
refer my question
http://stackoverflow.com/questions/32606524/view-in-the-view-pager-overlap-between-previous-and-next-view
http://imgur.com/lkar3Fh my layout should appear like this when i scroll any item that item should appear in center position @clkasd
@clkasd pls look into this issue
i just change your code to SmartFragmentStatePagerAdapter and then write as it is code of all your adapter class in my class but this is strange now my blur and highlight effects are not working in onPageScroll while onPageScroll listener is getting called but its not producing desired result . how to resolve ?
here is th code :
package com.example.carouselViewProject;
import java.util.ArrayList;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.widget.Toast;
import com.nineoldandroids.view.ViewHelper;
public class BottomViewPagerAdapter extends SmartFragmentStatePagerAdapter{
ArrayList invitationArrayList;
public static final String TAG = "BottomViewPagerAdapter";
private float scale;
private boolean IsBlured = false;
private static float minAlpha=0.6f;
private static float maxAlpha=1f;
private static float minDegree=70.0f;
private int lastPage;
private MyLinearLayout cur = null;
private MyLinearLayout next = null;
private MyLinearLayout prev = null;
private MyLinearLayout prevprev = null;
private MyLinearLayout nextnext = null;
private boolean swipedLeft=false;
FragmentManager fm;
Context context;
//public OnPageChangeListener onPageChangeListener;
public static float getMinDegree()
{
return minDegree;
}
public static float getMinAlpha()
{
return minAlpha;
}
public static float getMaxAlpha()
{
return maxAlpha;
}
public BottomViewPagerAdapter(Context context,FragmentManager fm,ArrayList invitationArrayList,boolean drawCenterText) {
super(fm);
this.fm = fm;
this.context = context;
// TODO Auto-generated constructor stub
this.invitationArrayList = invitationArrayList;
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
Log.d(TAG,"getItem called");
/*if(arg0 == 0)
{
return FragmentMap0Position.newInstance(arg0);
}
else
{
return FragmentMapPosition.newInstance(arg0);
}*/
if (position == MainActivity.FIRST_PAGE)
scale = MainActivity.BIG_SCALE;
else
{
scale = MainActivity.SMALL_SCALE;
IsBlured=true;
}
cur = getRootView(position);
next = getRootView(position +1);
prev = getRootView(position -1);
return MyFragment.newInstance(position,scale,IsBlured);
//return null;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
lastPage = invitationArrayList.size()-1;
return invitationArrayList.size();
}
OnPageChangeListener onPageChangeListener = new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// TODO Auto-generated method stub
if(lastPage<=position)
{
swipedLeft=true;
}
else if(lastPage>position)
{
swipedLeft=false;
}
lastPage=position;
Toast.makeText(context,"bottom view pager adapter position:"+position,1000).show();
//currentPagePosition = position;
}
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
// TODO Auto-generated method stub
Log.d(TAG, "onPageScrolled");
//super();
if (positionOffset >= 0f && positionOffset <= 1f)
{
Log.d(TAG, "positionOffset >= 0f && positionOffset <= 1f");
positionOffset=positionOffset*positionOffset;
cur = getRootView(position);
next = getRootView(position +1);
prev = getRootView(position -1);
nextnext=getRootView(position +2);
ViewHelper.setAlpha(cur, maxAlpha-0.5f*positionOffset);
ViewHelper.setAlpha(next, minAlpha+0.5f*positionOffset);
ViewHelper.setAlpha(prev, minAlpha+0.5f*positionOffset);
if(nextnext!=null)
{
//ViewHelper.setAlpha(nextnext, minAlpha);
// ViewHelper.setRotationY(nextnext, -minDegree);
}
if(cur!=null)
{
/* cur.setScaleBoth(MainActivity.BIG_SCALE
- MainActivity.DIFF_SCALE * positionOffset);
ViewHelper.setRotationY(cur, 0);*/
}
if(next!=null)
{
/*next.setScaleBoth(MainActivity.SMALL_SCALE
+ MainActivity.DIFF_SCALE * positionOffset);
ViewHelper.setRotationY(next, -minDegree);*/
}
if(prev!=null)
{
//ViewHelper.setRotationY(prev, minDegree);
}
/*To animate it properly we must understand swipe direction
* this code adjusts the rotation according to direction.
*/
if(swipedLeft)
{
if(next!=null)
//ViewHelper.setRotationY(next, -minDegree+minDegree*positionOffset);
{
}
if(cur!=null)
//ViewHelper.setRotationY(cur, 0+minDegree*positionOffset);
{
}
}
else
{
if(next!=null)
//ViewHelper.setRotationY(next, -minDegree+minDegree*positionOffset);
if(cur!=null)
{
//ViewHelper.setRotationY(cur, 0+minDegree*positionOffset);
}
}
}
if(positionOffset>=1f)
{
Log.d(TAG, "positionOffset >= 1f");
ViewHelper.setAlpha(cur, maxAlpha);
}
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
}
};
private MyLinearLayout getRootView(int position)
{
MyLinearLayout ly;
try {
ly = (MyLinearLayout)
fm.findFragmentByTag(getFragmentTag(position))
.getView().findViewById(R.id.root);
} catch (Exception e) {
// TODO Auto-generated catch block
return null;
}
if(ly!=null)
return ly;
return null;
}
private String getFragmentTag(int position)
{
return "android:switcher:" + MainActivity.pager.getId() + ":" + position;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.