tcking / GiraffePlayer2

out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Apache License 2.0
377 stars 110 forks source link

Not inflating view in fragment under recyclerview #154

Open abbyChandra16 opened 5 years ago

abbyChandra16 commented 5 years ago

Here is my crash log - 2019-03-11 19:25:36.688 8482-8482/com.got.got E/AndroidRuntime: FATAL EXCEPTION: main Process: com.got.got, PID: 8482 android.view.InflateException: Binary XML file line #200: Binary XML file line #200: Error inflating class tcking.github.com.giraffeplayer2.VideoView Caused by: android.view.InflateException: Binary XML file line #200: Error inflating class tcking.github.com.giraffeplayer2.VideoView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.got.got.Adapters.NewsFeedAdapter.onCreateViewHolder(NewsFeedAdapter.kt:129) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854) at android.support.v7.widget.LayoutState.next(LayoutState.java:100) at android.support.v7.widget.StaggeredGridLayoutManager.fill(StaggeredGridLayoutManager.java:1609) at android.support.v7.widget.StaggeredGridLayoutManager.onLayoutChildren(StaggeredGridLayoutManager.java:683) at android.support.v7.widget.StaggeredGridLayoutManager.onLayoutChildren(StaggeredGridLayoutManager.java:605) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3336) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22071) at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1502) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:556) at android.view.View.measure(View.java:22071) at android.support.v4.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.java:641) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22071) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) 2019-03-11 19:25:36.692 8482-8482/com.got.got E/AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22071) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724) at android.view.View.measure(View.java:22071) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2422) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1504) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: java.lang.ClassCastException: com.got.got.Utils.MyApp cannot be cast to android.app.Activity at tcking.github.com.giraffeplayer2.VideoView.init(VideoView.java:79) at tcking.github.com.giraffeplayer2.VideoView.(VideoView.java:62) ... 79 more

tcking commented 5 years ago

can you show me the code how the tcking.github.com.giraffeplayer2.VideoView created in your proejct?

abbyChandra16 commented 5 years ago

yes view.imgPostShareVideo.videoInfo.isPortraitWhenFullScreen = false view.imgPostShareVideo.setVideoPath(post.mediaForPost!!.media!!.location).setFingerprint(post.hashCode())

tcking commented 5 years ago

It seems in onCreateViewHolder you should pass a activity ref instead of the com.got.got.Utils.MyApp to inflate the view,eg:


LayoutInflater.from(parent.getContext()).inflate(your_item_xml, parent, false)
abbyChandra16 commented 5 years ago

yes it worked. Thanks for the help.