Git Product home page Git Product logo

viewpagertransforms's Introduction

CircleCI License Maven Central

ViewPagerTransforms

Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the JazzyViewPager library and owes credit of the animation concepts directly to its source. The purpose of this rewrite is to provide an easier to use and extend implementation of ViewPager animations.

Demo

Getting Started (Gradle / Android Studio)

Add gradle dependency to your application.

implementation 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:2.0.24'

After configuration, instantiate the transformer animation you wish to use and set it as the page transformer.

// Reference (or instantiate) a ViewPager instance and apply a transformer
pager = (ViewPager) findViewById(R.id.container);
pager.setAdapter(mAdapter);
pager.setPageTransformer(true, new RotateUpTransformer());

Creating Custom Transforms

All ViewPagerTransform implementations extend ABaseTransformer providing useful hooks improving readability of animations and basic functionality important when switching between animations. ABaseTransformer provides three lifecycle hooks and two flags for default handling of hiding offscreen fragments and mimicking the default paging functionality of the ViewPager.

Building

This project is built with Gradle using the Gradle Wrapper script.

./gradlew build

Creating Local Versions

You can modify this project and create local packages with via the maven publish plugin used in the build scripts.

./gradlew publishToMavenLocal

viewpagertransforms's People

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  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  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  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

viewpagertransforms's Issues

It does not work onclick listener

I just download your project and change the text view to a image view. after that i added a some piece of code to a change the image of the image view when swapping the screen. it is working. also i added a on click listener on image view to do some processes. but on click listener doesn't working. i added that listener where you change the color of the text view (now where i change the image view resource). so is it possible to add a on click listener?

FlipHorizontal and FlipVertical changes incorrect IMO

Don't have time to do a proper change, test, and pull request so I'm just going to write this issue. If no one fixes, I'll come back to make the change and pull request after my app release.

Problem: those modifications have the side effect that if I change transformations after a vertical or horizontal flip, when I swipe the other direction, the off screen view, which is now on screen, remains hidden.

I believe the framework already (sort of) supported the necessary change to remedy this. For anyone that runs into the problem, make the following change to ABaseTransformer:
if (hideOffscreenPages() && (position <= -1f || position >= 1f)) { page.setVisibility(View.INVISIBLE); page.setAlpha(0f); // page.setEnabled(false); } else { // page.setEnabled(true); page.setAlpha(1f); page.setVisibility(View.VISIBLE); }
And then you can remove the onPostTransform from FlipHorizontal and FlipVertical.

In doing other work I did a limited amount of research on alpha vs visibility. I found a post from Romain Guy saying to use visibility and not alpha to hide/show as it's more efficient. The original defects were due to the framework using alpha to hide. The partial fixes switched to using visibility to prevent interaction with "off screen" pages, as it should be IMO. Problem is the side effect I found. Moving this into the framework itself fixes both these transformations and future transformations.

I left the alpha change in as it's necessary to clean up after some transformations. I don't think the setEnabled is necessary and it's commented out in my copy.

To the original developer that fixed the Flip transformation, thank you! I'd been having a problem being unable to scroll after a transformation and not taking the time to debug. Your fix helped very much.

Switching transformers can cause visual issues

The lack of setting translationX to 0 when paging is enabled can cause some transformers to break such as going from ForegroundToBackgroundTransformer to CubeInTransformer can cause the first transformer to offset the view incorrectly by some amount.

Horizontal/Vertical Page Transformation Causes Previous View to be registered.

So I basically I have two fragments in my viewpager and I wanted the horizontal or vertical flip transformation. For some strange reason when I used either of these transformations, it will change fragments correctly but the touch event will be occurring on the previous fragment. I have a scrollview in the second fragment and it doesn't scroll but I see toasts coming from events in the first fragment.

Other transformations don't seem to cause this issue.

Thanks.

Bug when want to change current position without smooth

How to test bug: add next code in onCreate, run app, choose some transformation and wait for 6 seconds, it will change something but slider won't appear or animation would be frozen (paused at its start)

        // test bug
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mPager.setCurrentItem(4, false);
            }
        }, 6000);
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        int selectedPage = 0;
        if (savedInstanceState != null) {
            mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS);
            selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE);
        }

        final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<>(
                getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1, TRANSFORM_CLASSES);

        setContentView(R.layout.activity_main);

        mAdapter = new PageAdapter(getFragmentManager());

        mPager = (ViewPager) findViewById(R.id.container);
        mPager.setAdapter(mAdapter);
        mPager.setCurrentItem(selectedPage);

        // test bug
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mPager.setCurrentItem(4, false);
            }
        }, 6000);

        final ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setListNavigationCallbacks(actionBarAdapter, this);
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

            //noinspection ResourceType
            actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);

            actionBar.setSelectedNavigationItem(mSelectedItem);
        }

    }

for example with ZoomOutSliderTransformer slider won't be fully 100% taking all space of layout (you can see white paddings or margin at right and bottom)

screenshot_2017-10-01-18-40-51-795_com toxicbakery viewpager transforms

viewpager PageAdapter

I just started thinking that I used the problem, and then download the Sample write their own Adapter, found that the click event is still a problem

  @Override
        public Object instantiateItem(ViewGroup container, final int position) {
            ImageView img = new ImageView(container.getContext());
            img.setBackgroundResource(image[position]);
            img.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.i("TRANSFORMS", "onClickListener");
                }
            });
            container.addView(img);
            return img;
        }

OnClicklistener has been unable to respond to Log, through the code found ABaseTransformer onPreTransform

        if (hideOffscreenPages()) {
            page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
            page.setEnabled(false);
        } else {
            page.setEnabled(true);
            page.setAlpha(1f);
        }

hideOffscreenPages always returns true ,Then setEnabled (false)

Is it a problem with my use? thanks

support v4 library

I've wanted to import your lib to my project and because it is v13 support I couldn't do it via maven.
It is a shame because there is nothing preventing this from been v4 support, I've already made the changes took less than 10 minutes. you should consider doing the same upon releasing the next version.

video view issue

issue in use it with videoview for display video

when use cubeout transform and display video ,when rotate page it last position video also display in next screen with latest pos video - based on 22f(like if i give 12f it take less portion of screen compare of 22f). because position is used in it
view.setRotationY(22f*position );

Fragments are not visible in some instances.

When scrolling the view pager, fragments are randomly not visible. As I have never seen this happen before I am certain it must be the transformers misbehaving and the use of setVisibility is quite possibly the culprit.

DrawerTransformer is not available in 1.2.32@aar library

Hi, Thank you for nice view pager transforms animation.

I want to try DrawerTransformer but it seems not available when I use this library "com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar"
How to check the latest version of this library ? Thank you

In lollipop devices -> Scrollview not working after viewpager transformation

In lollipop devices I faced many issues..But I want to fix this major issue first.

Issue

  • When first time tab layout loading -> scrollview works. no issue.
  • But after I swipe from first tab to next. All the tab layouts scrollview not working..

Note: In kitkat it working correctly. This issue happen only in lollipop devices.

clicklistner on pager

how to get the data of fragment from view pager. I tried to set onClicklistener in fragment onCreateview like this

textViewPosition.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(getActivity(),textViewPosition.getTag().toString(),Toast.LENGTH_LONG).show();
    }
}); 

but not working,please help....
Thanks in advance

how can set combination of both animation

like ForegroundToBackgroundTransformer and BackgroundToForegroundTransformer animation in one transform

prev and next screen come from background to foreground
thanks in advance

1 to 3 Transformer

Hi, I need a transformer mode that's allow the "slide" from page 1 to page 3... from page 2 to page 10...
Anyone can help?

Examples App is buggy and complicated

The example is buggy and complicated. Instead of the ListView, which is hard to keep in sync on each page, use an ActionBar spinner and swap out the fragments for colored TextViews identifying the position.

onClick listers wrong reference, not passing focus

Hi, I am using your library, trying to implement FlipHorizontalTransformer

Inside my view pagers I have fragments with buttons, and their onClickLIsteners...but every time I use your library, these listeners start to overlap:

I have 2 pages: On page on i have Button1 and on page 2 i have Button2 (on same sort of relative location)

But when I am on page2 and click to Button2 -> Button1 onClick lister fires up!!!

Its like this page never left screen...its still on top (but hidden)...can you explain how to fix this ?!

Slide vertically

In this demo sliding is horizontal,
Is there any way to slide view up n down instead of left right ?
Animation also be vertical eg.
Vertical stack transformation when I slide up n down..plz help..

FAILED BINDER TRANSACTION !!! in CubeOut Transformer

Can be reproduced in View Pager with 3 Fragments by repeatedly scrolling between first and last page.

mediaPager.setPageTransformer(true, new CubeOutTransformer());

Crash Log

03-01 20:30:07.621 671-671/? E/Parcel: Reading a NULL string not supported here.
03-01 20:30:08.945 23393-23538/com.hiteshsahu.soundrecorder A/OpenGLRenderer: Error: Spot pair overflow!!! used 42, total 28
03-01 20:30:08.945 23393-23539/com.hiteshsahu.soundrecorder A/OpenGLRenderer: Error: Spot pair overflow!!! used 38, total 25
                                                                              
                                                                              --------- beginning of crash
03-01 20:30:08.945 23393-23539/com.hiteshsahu.soundrecorder A/libc: Fatal signal 6 (SIGABRT) in tid 23539 (hwuiTask2)
03-01 20:30:08.945 23393-23538/com.hiteshsahu.soundrecorder A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 23538 (hwuiTask1)
03-01 20:30:08.998 548-548/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-01 20:30:08.998 548-548/? A/DEBUG: Build fingerprint: 'Letv/Le2_WW/le_s2_ww:6.0.1/IIXOSOP5801910121S/44:user/release-keys'
03-01 20:30:08.998 548-548/? A/DEBUG: Revision: '0'
03-01 20:30:08.998 548-548/? A/DEBUG: ABI: 'arm64'
03-01 20:30:08.998 548-548/? A/DEBUG: pid: 23393, tid: 23539, name: hwuiTask2  >>> com.hiteshsahu.soundrecorder <<<
03-01 20:30:08.998 548-548/? A/DEBUG: signal 6 (SIGABRT), code 0 (SI_USER), fault addr --------
03-01 20:30:09.019 548-548/? A/DEBUG: Abort message: 'Error: Spot pair overflow!!! used 38, total 25'
03-01 20:30:09.019 548-548/? A/DEBUG:     x0   0000000000000000  x1   0000000000005bf3  x2   0000000000000006  x3   0000000000000000
03-01 20:30:09.019 548-548/? A/DEBUG:     x4   0000000000000002  x5   0000000000000081  x6   0000000000000081  x7   0000000000000000
03-01 20:30:09.019 548-548/? A/DEBUG:     x8   0000000000000083  x9   0000007fae517012  x10  0000000000000000  x11  0000007fae516000
03-01 20:30:09.019 548-548/? A/DEBUG:     x12  0000007fae501090  x13  0000000000000001  x14  0000007f926b0128  x15  0000000000000000
03-01 20:30:09.019 548-548/? A/DEBUG:     x16  0000007fb29df6a8  x17  0000007fb29a1b2c  x18  0000007fae516000  x19  0000007f926b1510
03-01 20:30:09.019 548-548/? A/DEBUG:     x20  0000007f926b1450  x21  0000000000000000  x22  0000000000000006  x23  0000000000000026
03-01 20:30:09.019 548-548/? A/DEBUG:     x24  000000000000000c  x25  0000000000000026  x26  000000559eef1990  x27  0000007f926b0790
03-01 20:30:09.019 548-548/? A/DEBUG:     x28  0000000000000026  x29  0000007f926affe0  x30  0000007fb299f2c8
03-01 20:30:09.019 548-548/? A/DEBUG:     sp   0000007f926affe0  pc   0000007fb29a1b34  pstate 0000000000000000
03-01 20:30:09.024 548-548/? A/DEBUG: backtrace:
03-01 20:30:09.024 548-548/? A/DEBUG:     #00 pc 000000000006bb34  /system/lib64/libc.so (tgkill+8)
03-01 20:30:09.024 548-548/? A/DEBUG:     #01 pc 00000000000692c4  /system/lib64/libc.so (pthread_kill+68)
03-01 20:30:09.024 548-548/? A/DEBUG:     #02 pc 00000000000212b8  /system/lib64/libc.so (raise+28)
03-01 20:30:09.024 548-548/? A/DEBUG:     #03 pc 000000000001ba58  /system/lib64/libc.so (abort+60)
03-01 20:30:09.024 548-548/? A/DEBUG:     #04 pc 000000000000d1b0  /system/lib64/libcutils.so (__android_log_assert+236)
03-01 20:30:09.024 548-548/? A/DEBUG:     #05 pc 000000000006ebc8  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #06 pc 0000000000074770  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #07 pc 0000000000075b5c  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #08 pc 000000000006e8dc  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #09 pc 00000000000773a0  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #10 pc 000000000002c24c  /system/lib64/libhwui.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #11 pc 00000000000167b4  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
03-01 20:30:09.024 548-548/? A/DEBUG:     #12 pc 00000000000903cc  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+96)
03-01 20:30:09.024 548-548/? A/DEBUG:     #13 pc 0000000000016004  /system/lib64/libutils.so
03-01 20:30:09.024 548-548/? A/DEBUG:     #14 pc 0000000000068714  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
03-01 20:30:09.024 548-548/? A/DEBUG:     #15 pc 000000000001c604  /system/lib64/libc.so (__start_thread+16)
03-01 20:30:09.238 548-548/? A/DEBUG: Tombstone written to: /data/tombstones/tombstone_00
03-01 20:30:09.238 548-548/? E/DEBUG: AM write failed: Broken pipe
03-01 20:30:09.342 1430-1477/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 60)
03-01 20:30:09.943 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:11.174 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:11.316 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:14.943 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:16.174 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:16.317 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:19.943 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:21.174 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:21.317 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:24.944 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:26.175 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:26.317 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:29.945 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:31.175 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:31.318 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:34.945 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:36.175 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:36.318 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:39.946 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:41.175 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:41.318 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:42.899 671-671/? E/Parcel: Reading a NULL string not supported here.
03-01 20:30:42.899 671-671/? E/Parcel: Reading a NULL string not supported here.
03-01 20:30:44.946 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XTWiFi-PE] unknown deliver target [OS-Agent]
03-01 20:30:46.079 671-671/? E/Parcel: Reading a NULL string not supported here.
03-01 20:30:46.079 671-671/? E/Parcel: Reading a NULL string not supported here.
03-01 20:30:46.175 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]
03-01 20:30:46.319 579-597/? E/QCALOG: [MessageQ] ProcessNewMessage: [XT-CS] unknown deliver target [OS-Agent]

Also found this issue in Android Studio static code analysis

erre

button and swipe controls don't work after more than 4 pages added

I am using FragmentStatePagerAdapter, ViewPager, v4.Fragments and the CubeOutTransformer.
When I use the following code:
CubeOutTransformer ct = new CubeOutTransformer();
mViewPager.setPageTransformer(true,ct);

and add more than 4 pages the Button and gesture controls on the 5 page don't work. When I comment out the above code, the 5th page's controls work fine.
Am I missing something... possible max setting???
Thanks

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.