Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Native Component (Android) not show nothing #24945

Closed
Navidhp opened this issue May 19, 2019 · 1 comment
Closed

Question: Native Component (Android) not show nothing #24945

Navidhp opened this issue May 19, 2019 · 1 comment
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@Navidhp
Copy link

Navidhp commented May 19, 2019

Dear friend ,
i write sample native component like your document step by step but calling from js return blank screen (show white screen)
react-native version : 0.59.8


VideoPlayerPackage.java
package com.videoPlayer;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.videoPlayer.VideoPlayerManager;
import java.util.Collections;
import java.util.List;

public class VideoPlayerPackage implements ReactPackage {

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}


@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.<ViewManager>singletonList(new VideoPlayerManager());
}

}

VideoPlayerManager.java
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.view.View;

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;

public class VideoPlayerManager extends SimpleViewManager {

private static final String VIDEO_SOURCE = "src";
private static final String PROP_URI = "uri";

@Override
public String getName() {
    return "VideoPlayer";
}


@Override
public VideoPlayerView createViewInstance(ThemedReactContext themedReactContext) {
            return new VideoPlayerView(themedReactContext);
}

@ReactProp(name = VIDEO_SOURCE)
public void setSource(final View videoTest, @Nullable ReadableMap src) {

}

}

VideoPlayerView.java
import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.facebook.react.uimanager.ThemedReactContext;
import com.novincinema.cinemamarket.R;

public class VideoPlayerView extends RelativeLayout {

public VideoPlayerView(Context context) {
    super(context);
    init();
}

public VideoPlayerView(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}

public VideoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init();
}

private void init() {
    inflate(getContext(), R.layout.video_test, this);
}

}

video_test.xml

<LinearLayout
    android:id="@+id/child_layout"
    android:layout_width="100dp"
    android:layout_height="50dp"
    android:background="#ffee11"/>
@Navidhp Navidhp added the Type: Question Issues that are actually questions and not bug reports. label May 19, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label May 19, 2019
@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

👉 Click here if you want to report a reproducible bug or regression in React Native.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: No Template labels May 19, 2019
@facebook facebook locked as resolved and limited conversation to collaborators May 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

2 participants