-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ComponentWithState in Android (#34911)
Summary: Pull Request resolved: #34911 This diff adds the Same component with state added in the previous diff for iOS ## Changelog [Android][Added] - ComponentWithState Reviewed By: cortinico Differential Revision: D40108233 fbshipit-source-id: b5bd1d1bdd7053920f737772c85034e4c5aed26a
- Loading branch information
1 parent
1a9cceb
commit b24f60f
Showing
10 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...id/app/src/main/java/com/facebook/react/uiapp/componentWithState/NativeViewWithState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.uiapp.component; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
import androidx.annotation.Nullable; | ||
import com.facebook.drawee.view.SimpleDraweeView; | ||
import com.facebook.react.bridge.ReadableMap; | ||
|
||
class NativeViewWithState extends SimpleDraweeView { | ||
|
||
public NativeViewWithState(Context context) { | ||
super(context); | ||
} | ||
|
||
void setImageSource(@Nullable ReadableMap source) { | ||
String uri = source != null ? source.getString("uri") : null; | ||
Uri imageUri = Uri.parse(uri); | ||
this.setImageURI(imageUri); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...src/main/java/com/facebook/react/uiapp/componentWithState/NativeViewWithStateManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.uiapp.component; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.module.annotations.ReactModule; | ||
import com.facebook.react.uimanager.SimpleViewManager; | ||
import com.facebook.react.uimanager.ThemedReactContext; | ||
import com.facebook.react.uimanager.ViewManagerDelegate; | ||
import com.facebook.react.uimanager.annotations.ReactProp; | ||
import com.facebook.react.viewmanagers.RNTNativeComponentWithStateManagerDelegate; | ||
import com.facebook.react.viewmanagers.RNTNativeComponentWithStateManagerInterface; | ||
|
||
/** View manager for {@link NativeViewVithState} components. */ | ||
@ReactModule(name = NativeViewWithStateManager.REACT_CLASS) | ||
public class NativeViewWithStateManager extends SimpleViewManager<NativeViewWithState> | ||
implements RNTNativeComponentWithStateManagerInterface<NativeViewWithState> { | ||
|
||
public static final String REACT_CLASS = "RNTNativeComponentWithState"; | ||
|
||
private final ViewManagerDelegate<NativeViewWithState> mDelegate = | ||
new RNTNativeComponentWithStateManagerDelegate<>(this); | ||
|
||
@Nullable | ||
@Override | ||
protected ViewManagerDelegate<NativeViewWithState> getDelegate() { | ||
return mDelegate; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return REACT_CLASS; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected NativeViewWithState createViewInstance(@NonNull ThemedReactContext reactContext) { | ||
return new NativeViewWithState(reactContext); | ||
} | ||
|
||
@Override | ||
@ReactProp(name = "imageSource") | ||
public void setImageSource(NativeViewWithState view, @Nullable ReadableMap value) { | ||
view.setImageSource(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters