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

Native Component (Android) not show nothing #24946

Closed
Navidhp opened this issue May 19, 2019 · 2 comments
Closed

Native Component (Android) not show nothing #24946

Navidhp opened this issue May 19, 2019 · 2 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@Navidhp
Copy link

Navidhp commented May 19, 2019

React Native version:59.8

Steps To Reproduce

1.write native component step by step like react native documentation but return nothing (white screen)

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 createNativeModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@OverRide
public List createViewManagers(ReactApplicationContext reactContext) {
return Collections.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);
}
}

@Navidhp Navidhp added the Bug label May 19, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label May 19, 2019
@Esemesek
Copy link
Contributor

Can you format you message correctly (wrap code in ```), add results of react-native info command and provide repository with reproduction of this issue?

@Navidhp
Copy link
Author

Navidhp commented May 31, 2019

@Esemesek i solved this problem with inflate to addView this is my mistake :)

@Navidhp Navidhp closed this as completed May 31, 2019
@facebook facebook locked as resolved and limited conversation to collaborators May 31, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants