emilsjolander / android-FlipView

A small, easy to use android library for implementing flipping between views as seen in the popular Flipboard application
Apache License 2.0
924 stars 273 forks source link

mAdapter.getItemViewType nullPointException #8

Closed redwind closed 11 years ago

redwind commented 11 years ago

Hi emilsjolander !

I don't know why but i use a conplex layout include textView,ImageView, it's has problem in viewForPage at line final int viewType = mAdapter.getItemViewType(page);

I've tried to set view type in adapter, it's still happend. But if i replace by final int viewType= 0; It's work fine.

another question : i want to add two pages for first and last page, and user only flip 3/4 of view like flipboard do, so what can i do to make it ?

Thanks for your library !

emilsjolander commented 11 years ago

it's has problem in viewForPage

What problem? does it crash?

i want to add two pages for first and last page, and user only flip 3/4 of view like flipboard do, so what can i do to make it ?

I don't know what you mean by this, please explain, link to a video of this if possible.

emilsjolander commented 11 years ago

Saw the title of the issue now. Ok so it crashes. Please post the stacktrace

redwind commented 11 years ago

Thanks for your comment ! This is my stracktrace:

05-10 11:40:03.756: E/AndroidRuntime(3995): FATAL EXCEPTION: main
05-10 11:40:03.756: E/AndroidRuntime(3995): java.lang.NullPointerException
05-10 11:40:03.756: E/AndroidRuntime(3995):     at se.emilsjolander.FlipView.viewForPage(FlipView.java:707)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at se.emilsjolander.FlipView.dispatchDraw(FlipView.java:505)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13680)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13801)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13682)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13680)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13680)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.View.draw(View.java:13801)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2226)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2593)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl.draw(ViewRootImpl.java:2484)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2340)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2142)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.Choreographer.doCallbacks(Choreographer.java:579)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.Choreographer.doFrame(Choreographer.java:548)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.os.Handler.handleCallback(Handler.java:725)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.os.Looper.loop(Looper.java:153)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at android.app.ActivityThread.main(ActivityThread.java:5297)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at java.lang.reflect.Method.invokeNative(Native Method)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at java.lang.reflect.Method.invoke(Method.java:511)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
05-10 11:40:03.756: E/AndroidRuntime(3995):     at dalvik.system.NativeStart.main(Native Method)
05-10 11:40:03.764: E/AppErrorDialog(498): Failed to get ILowStorageHandle instance
redwind commented 11 years ago

I don't know what you mean by this, please explain, link to a video of this if possible.

Sorry about my English :)

My mean, now, user can't flip first page and last page, but i want user can flip about 30 degree for these two pages. If this question is waste of your time, please guide me what i have to try, so i will.

Thanks !

emilsjolander commented 11 years ago

I will look into the crash.

About the "overflip" functionality that i think you are referring to, i decided to use androids standard edgeglow instead as it is more in line with the rest of the android design.

I might add an option for this functionality in the future but can't promise anything. It should be trivial to change the current code to support this though so feel free to do it yourself :)

emilsjolander commented 11 years ago

Have you made any alterations to the libraries code? because i do not understand how the library can crash on those line numbers that are in the crash log you posted. Please paste lines 707 and 505 from FlipView.java in your local copy of the project

redwind commented 11 years ago

Here they are :

View v = getActiveView(page);
postAddView(v);

As what i said before, i use a complex layout as gridlayout for each page, and add item to gridlayout in getView function and I don't set callback for flipview.

emilsjolander commented 11 years ago

could you please post the layout you are using? the one you refer to as complex

redwind commented 11 years ago

Hi emilsjolander ! I have been quite busy in the past time, so now, i continue to my project :). i found that my problem cause by i didn't set setOnFlipListener. i'll try to debug your library to implement "overflip" function :), do you have any suggest for me ? Thank so much !

emilsjolander commented 11 years ago

i am pushing a fix later today or tomorrow which will fix that the flipview crashes when no fliplistener is set. Overflip functionality is coming in this update aswell. See issue #9.

redwind commented 11 years ago

Hi emilsojlander, thanks for your support ! I'm waitting for new update.

Thank you so much !

emilsjolander commented 11 years ago

@redwind the new update is live and ready to use ;)