Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28476

How to expose a Leanback fragment inside a React Native UI component?

$
0
0

I am trying to expose the VideoSupportFragment inside a React Native UI component. I have used the solution presented here. Like so:

public class LeanbackExoplayerViewManager extends ViewGroupManager<FrameLayout> {

    private static final String REACT_CLASS = "RCTVideo";
    @NonNull
    @Override
    public String getName() {
        return REACT_CLASS;
    }

    @NonNull
    @Override
    protected FrameLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
        final FrameLayout view = new FrameLayout(reactContext);
        PlaybackVideoFragment fragment = new PlaybackVideoFragment();
        FragmentActivity activity = (FragmentActivity) reactContext.getCurrentActivity();
        activity.getSupportFragmentManager()
                .beginTransaction()
                .add(fragment, "My_TAG")
                .commit();
        activity.getSupportFragmentManager().executePendingTransactions();
        addView(view, fragment.getView(), 0);
        return view;
    }
}

This calls the fragment but the classes in the leanback library cannot find the resources present in the library. And gives an error when inflating the layout files. This fragment works perfectly when run on its own.

2019-11-22 12:01:32.121 8740-8740/com.videoproject E/unknown:ReactNative: Exception in native call
    android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class <unknown>
    Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
    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 com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
        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.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at androidx.leanback.widget.PlaybackTransportRowPresenter.createRowViewHolder(PlaybackTransportRowPresenter.java:684)
        at androidx.leanback.widget.RowPresenter.onCreateViewHolder(RowPresenter.java:326)
        at androidx.leanback.widget.ItemBridgeAdapter.onCreateViewHolder(ItemBridgeAdapter.java:363)
        at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
        at androidx.leanback.widget.GridLayoutManager.getViewForPosition(GridLayoutManager.java:1086)
        at androidx.leanback.widget.GridLayoutManager$2.createItem(GridLayoutManager.java:1614)
        at androidx.leanback.widget.SingleRow.appendVisibleItems(SingleRow.java:113)
        at androidx.leanback.widget.Grid.appendOneColumnVisibleItems(Grid.java:389)
        at androidx.leanback.widget.GridLayoutManager.appendOneColumnVisibleItems(GridLayoutManager.java:1840)
        at androidx.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:2277)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
        at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
        at android.view.View.layout(View.java:19586)
        at android.view.ViewGroup.layout(ViewGroup.java:6053)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at android.view.View.layout(View.java:19586)
        at android.view.ViewGroup.layout(ViewGroup.java:6053)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at android.view.View.layout(View.java:19586)
        at android.view.ViewGroup.layout(ViewGroup.java:6053)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at android.view.View.layout(View.java:19586)
        at android.view.ViewGroup.layout(ViewGroup.java:6053)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:251)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:219)
        at com.facebook.react.uimanager.UIViewOperationQueue$UpdateLayoutOperation.execute(UIViewOperationQueue.java:154)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:779)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:888)
        at com.f

And another:

2019-11-22 12:12:40.728 20319-20319/com.videoproject E/unknown:ReactNative: Exception in native call
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference
        at androidx.leanback.widget.PlaybackControlsRow$ClosedCaptioningAction.<init>(PlaybackControlsRow.java:726)
        at androidx.leanback.widget.PlaybackControlsRow$ClosedCaptioningAction.<init>(PlaybackControlsRow.java:711)
        at com.brentvatne.exoplayer.leanback.VideoPlayerGlue.<init>(VideoPlayerGlue.java:46)
        at com.brentvatne.exoplayer.leanback.PlaybackVideoFragment.initializePlayer(PlaybackVideoFragment.java:180)
        at com.brentvatne.exoplayer.leanback.PlaybackVideoFragment.onStart(PlaybackVideoFragment.java:123)

Viewing all articles
Browse latest Browse all 28476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>