crosswall / Android-Coverflow

A beautiful coverflow lib for android
Other
910 stars 164 forks source link

Fix a rare case where fragment.getView return null when view is still… #6

Closed vincent-paing closed 8 years ago

vincent-paing commented 8 years ago
crosswall commented 8 years ago

thanks @vincent-paing , i will quick build it

crosswall commented 8 years ago

and i think should better compatibility mode

Object object = mPager.getAdapter().instantiateItem(mPager, loopCounter);
                    //Elevate the Center View if it's the selected position and de-elevate the left and right fragment

                    if(object instanceof Fragment){
                        Fragment fragment = (Fragment) object;
                        if (loopCounter == position) {
                            ViewCompat.setElevation(fragment.getView(), 8.0f);
                        } else {
                            ViewCompat.setElevation(fragment.getView(), 0.0f);
                        }
                    }else{
                        View view = (View) object;
                        if (loopCounter == position) {
                            ViewCompat.setElevation(view, 8.0f);
                        } else {
                            ViewCompat.setElevation(view, 0.0f);
                        }
                    }
vincent-paing commented 8 years ago

Yeah it looks better since it will be compatible without FragmentPagerAdapter too 👍

crosswall commented 8 years ago

Hi @vincent-paing ,Maybe you can write a demo, let more people learn to use

vincent-paing commented 8 years ago

@crosswall Sure, I'll do a demo