Git Product home page Git Product logo

android-coverflow's Introduction

Android-CoverFlow

A beautiful cover flow for android platform , base on ViewPager.

GIF

Thanks

vincent-paing

Build

Step 1. Add the JitPack repository to your build file
allprojects {
	repositories {
			...
			maven { url "https://jitpack.io" }
	}
}
Step 2. Add the dependency
dependencies {
	compile 'com.github.crosswall:Android-Coverflow:release-v1.0.5'
}

Layout.xml

<me.crosswall.lib.coverflow.core.PagerContainer
        android:id="@+id/pager_container"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:background="?attr/colorPrimary">

		<your viewpager.../>

</me.crosswall.lib.coverflow.core.PagerContainer>
 new CoverFlow.Builder()
             .with(viewpager)
             .pagerMargin(0f)
             .scale(0.3f)
             .spaceSize(0f)
             .rotationY(0f)
             .build();
container.setPageItemClickListener(new PageItemClickListener() {
    @Override
    public void onItemClick(View view, int position) {
        //Toast.makeText(context,"position:" + position,Toast.LENGTH_SHORT).show();
      }
    });

Two viewpagers synchronized scrolling.

<rootLayout....
 <me.crosswall.lib.coverflow.core.LinkagePagerContainer
        android:id="@+id/pager_container"
        android:layout_width="match_parent"
        android:layout_height="180dp">
        <android.support.v4.view.LinkagePager
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:layout_gravity="center"/>
  </me.crosswall.lib.coverflow.core.LinkagePagerContainer>
  <android.support.v4.view.LinkagePager
        android:id="@+id/pager"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:velocity="150"/>

</rootLayout>
//init widget
LinkagePager aPager = (LinkagePager)findViewById(R.id.pager_a)
LinkagePager bPager = (LinkagePager)findViewById(R.id.pager_b)
//binding scroll
aPager.setLinkagePager(bPager);
bPager.setLinkagePager(aPager);

To Enable Overlapping

mPagerContainer.setOverlapEnabled(true);

You might want to manually set the first view to be elevated, this can easily be done with this line of code

 //Manually setting the first View to be elevated
    viewPager.post(new Runnable() {
      @Override public void run() {
        Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, 0);
        ViewCompat.setElevation(fragment.getView(), 8.0f);
      }
    });

TODO

  • HorizontalScrollView replace LinkagePager
  • More CoordinatorLayout.Behavior...
  • More Configurations...

Lincense

The MIT License (MIT)

Copyright (c) 2015 Hugo yu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Status API Training Shop Blog About Pricing

android-coverflow's People

Contributors

bryant1410 avatar crosswall avatar lucanicoletti 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  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

android-coverflow's Issues

想平滑的滑动。

if(rotationY!=0){
float realRotationY = Math.min(rotationY,Math.abs(position * rotationY));
page.setRotationY(position < 0f ? realRotationY : - realRotationY);
}
其实我想要一开是315度不动的效果。。但是我想他们滑动平移的时候,不要每个item翻转得太厉害,想平滑的滑动。。我发现改了这里会影响一开始的315度的效果。。。对不起打扰了,还是请教一下。。

The method of setPageItemClickListener not work

In the demo,the following code doesn't work,when I click the item,it doesn't pop-up.
I want to know if it's my method or the code itself is wrong.
Thank you!

        container.setPageItemClickListener(new PageItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                Toast.makeText(NormalActivity.this,"position:" + position,Toast.LENGTH_SHORT).show();
            }
        });

Get NullPointerException

First of all, i initialize an empty list. After call web service, update the list and call notifyDataSetChanged.

Then drag to the third Fragment, will get this issue.

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setElevation(float)' on a null object reference
at android.support.v4.view.ViewCompatLollipop.setElevation(ViewCompatLollipop.java:45)
at android.support.v4.view.ViewCompat$LollipopViewCompatImpl.setElevation(ViewCompat.java:1538)
at android.support.v4.view.ViewCompat.setElevation(ViewCompat.java:2713)
at me.crosswall.lib.coverflow.core.PagerContainer.onPageSelected(PagerContainer.java:126)
at android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1867)
at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:625)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:609)
at android.support.v4.view.ViewPager.onTouchEvent(ViewPager.java:2181)

supportV4

Cannot get property 'supportV4' on extra properties extension as it does not exist

Overlap not work with view

I custom NormalActivity with .pagerMargin(getResources().getDimensionPixelSize(R.dimen.overlap_pager_margin))
and
container.setOverlapEnabled(true);
It don't make overlap for PagerContainer but with FragmentPagerAdapter it work ok

More: If I move viewpager to item 1 when init and use overlap it work not correct (fragment and view)

Is it possible to overlap items?

Hi Crosswall,
you did a great library and probably you saved a lot of time to me.
Is it possible to customize the CoverFlow.Builder() and adding the option for items overlapping?
I'm trying to do something like the attached image.

issue-crosswall

Thanks
Giosk

How to next item when click to any button?

I want to make coverflow with next button. Can you help me to control next action? And second question is how can I focus on second item in viewpager when start. Thank you so much!

Remove android:allowBackup

Great library, works really well.

Would it be possible for you to remove android:allowBackup="true" from the manifest? I'm getting build errors when I add android:allowBackup="false" to my app manifest and tools:replace is not working.

Thanks,
Adam

After call notifyDataSetChanged() problem

After call notifyDataSetChanged(), the scale of item will has some problem(e.g. even the item is not the center one, their scale will become 1.0f, as big as the center one ) but after scroll a little bit, it will become normal. So, any idea of this problem ? Thank you

how to handle tap on central (elevated) item?

hello!
how to handle tap on central (elevated) item?
i'm trying to use your example (pagerContainer.setPageItemClickListener(new PageItemClickListener() ...) but it works for only side elements, not for central.

CardView radius & elevation not visible

The CardView elevation & radius is not visible even in your demo app. I tried setting a higher value, but still there's no corner radius / elevation shadow.

Scroll Issues

I added TextView on each items, that TextView is scrollable by enabling scroll on its attribute, and it happens that it scroll isn't working, you will see it will scrolled once I skip to next item then back to previous page.

Does anyone here experienced this issue?

On initial launch, doesn't transform

On initial fragment launch which contains viewpager. It doesn't transform and after scroll, it works fine.

Here a code in onCreateView() fragment:
homeBinding =
DataBindingUtil.inflate(inflater, R.layout.fragment_home_layout, container, false);
view = homeBinding.getRoot();
mHomeAdapter = new HomePagePagerAdapter(projectList, getActivity(), mConfig);
ViewPager pager = homeBinding.pagerContainer.getViewPager();
pager.setAdapter(mHomeAdapter);
pager.setOffscreenPageLimit(3);
new CoverFlow.Builder()
.with(pager)
.scale(0.3f)
.pagerMargin(-100)
.spaceSize(0f)
.build();

Clicks on Upper LinkagePager in Linkage2 coverflow are reversed

hi
i am beginner developer.

i find a problem.

Clicks on Upper LinkagePager in Linkage2 coverflow. are reversed
And paged in the reverse direction.


I fixed this problem at random.

first, download libaray and import,

second,
modify
onTouchEvent() in LinkagePagerContainer Class in package me.crosswall.lib.coverflow.core

//ev.offsetLocation(mCenter.x - mInitialTouch.x, mCenter.y - mInitialTouch.y); //erase
ev.offsetLocation(mInitialTouch.x - mCenter.x, mCenter.y - mInitialTouch.y); //new

i Modified the two parts of above source and paged in the desired direction.

Failed dependency

compile 'com.github.crosswall:Android-Coverflow:release-v1.0.4'

Dependency is not working.

IllegalAccessError in running app

minSdkVersion 19
targetSdkVersion 30

I imported this lib to my project. But when running my project, i have an issue like this:
java.lang.IllegalAccessError: Method 'void androidx.viewpager.widget.PagerAdapter.setViewPagerObserver(android.database.DataSetObserver)' is inaccessible to class 'androidx.core.view.LinkagePager' (declaration of 'androidx.core.view.LinkagePager' appears in /data/app/~~Hg3GxUqloIVujMjqhSB2hA==/com.mascom.sll-2xKoWGBjqDwuZbvJuSF-ZQ==/base.apk)

So please show me the solution to solve this error ?

kotlin, setPageItemClickListener not works into fragments

Hello,

When I want to add setPageItemClickListener to action when I click into screen It not works.

I do into onCreateView :

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        activity?.title = getString(R.string.title_offres)
        val view = inflater.inflate(R.layout.fragment_offres, container, false)

        top5 = view.findViewById(R.id.top5) as PagerContainer

        top5.setOverlapEnabled(true)

        val pager = top5.getViewPager()

        val adapter = Top5Adapter(container!!.context, generateData())

        top5.setOnClickListener {
            v -> { // not works
                Toast.makeText(v.context, "SFSDFSDFSF", Toast.LENGTH_LONG).show()
            }
        }

        pager.adapter =  adapter
        pager.clipChildren = false
        //
        pager.offscreenPageLimit = 5

// NOT WORKS
        top5.setPageItemClickListener(PageItemClickListener { v, position ->
            startActivity(Intent(context, DetailOffreActivity::class.java))
        })

        CoverFlow.Builder().with(pager)
            .scale(0.3f)
            .pagerMargin(resources.getDimensionPixelSize(R.dimen.text_margin).toFloat())
            .spaceSize(0f)
            .build()
        return view
    }

Thansk for help.

How to know when user changes cardview

Hello,

I want to know if theres a way i could know when the user swipes, or moves from one cardview to another.
I tried an setPageItemClickListener(), but that only shows me when the user clicks a card, not when he swipes, or uses the Left and Right button. Is there a way i can catch any user movement?

Your help would be greatly appreciated!! You have my thanks

Disable debug logging for scrolling position?

hi, is there any way in the current version to disable scroll position logging when scrolling the pager? we have a use case where the pager with Coverflow handles a lot of scrolling so constantly logging the scroll position floods the logcat, not to mention impact on perf

The CardView elevation is not visible .

I tried setting a cardview inside fragment with PagerContainer and viewpager, but there's no elevation shadow .
I tried same setting in any other view, there's no problem.

Bug with scrolling - item jumps to finger position.

I am experiencing a strange bug with scrolling.

I am using:
compile 'com.github.crosswall:Android-Coverflow:release-v1.0.4'

When I have more than two items in the coverflow, and a middle item is selected- for example, if there are three items, and the 2nd one is in the center- when I attempt to scroll, the center item jumps to where my finger touches down.

This makes scrolling very jarring. The items on the edge scroll correctly, but the item in the center leaps to my finger's location. It also prevents me from tapping on the items on the side.

My OnCreate:

     PagerContainer container = (PagerContainer) findViewById(R.id.pager_container);
       container.setOverlapEnabled(false);
       final ViewPager pager = container.getViewPager();
       pager.setOffscreenPageLimit(5);


       pager.setAdapter(new MyPagerAdapter());
       pager.setClipChildren(true);
       new CoverFlow.Builder()
               .with(pager)
               .scale(0.2f)
               .pagerMargin(0f)
               .spaceSize(0f)
               .build();


       if (pager.getAdapter().getCount() > 1) {
           pager.setCurrentItem(pager.getAdapter().getCount() / 2);
       }

My adapter:

private class MyPagerAdapter extends PagerAdapter {

        @Override
        public Object instantiateItem(ViewGroup container, int position) {

            View view = LayoutInflater.from(CoverflowActivity.this).inflate(R.layout.twitch_card_small,null);
            ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
            Picasso.with(LiveStreamActivity.this).load(mItems().get(position).getImage()).fit().into(imageView);

            //add text here!
            container.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View)object);
        }

        @Override
        public int getCount() {
            int size = getItems().size();
            return size;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return (view == object);
        }
    }

My XML:

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="130dp"
            android:orientation="vertical">


                <me.crosswall.lib.coverflow.core.PagerContainer
                    android:id="@+id/pager_container"
                    android:layout_width="match_parent"
                    android:layout_height="125dp"
                    android:background="@color/colorBlack">

                    <android.support.v4.view.ViewPager
                        android:id="@+id/overlap_pager"
                        android:layout_width="125dp"
                        android:layout_height="125dp"
                        android:layout_gravity="center"
                        android:clipToPadding="true"/>


                </me.crosswall.lib.coverflow.core.PagerContainer>
        </LinearLayout>

Any ideas?

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.