Giter Club home page Giter Club logo

carouselviewproject's People

Contributors

clkasd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

carouselviewproject's Issues

issues regarding blur and highlight code onPageScrolled ?

@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;
}

}

issues regarding nineoldandroids-2.4.0.jar library

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.