-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Migrate ViewGroupManager to kotlin #50895
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
be5721e
Migrate ViewGroupManager.java to kotlin
riteshshukla04 13978c9
Resolved comments
riteshshukla04 fdfa775
Revert "delete RCTUIUtils (#49453)"
riteshshukla04 b2304c0
Resolved comments
riteshshukla04 509cc99
Revert "Revert "delete RCTUIUtils (#49453)""
riteshshukla04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
116 changes: 0 additions & 116 deletions
116
...eact-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.java
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
.../react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt
This file contains hidden or 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,83 @@ | ||
/* | ||
* 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.uimanager | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.UiThreadUtil | ||
import java.util.WeakHashMap | ||
|
||
|
||
public abstract class ViewGroupManager<T : ViewGroup> | ||
@JvmOverloads | ||
constructor(reactContext: ReactApplicationContext? = null) : | ||
BaseViewManager<T, LayoutShadowNode>(reactContext), IViewGroupManager<T> { | ||
|
||
public override fun createShadowNodeInstance(): LayoutShadowNode = LayoutShadowNode() | ||
|
||
public override fun getShadowNodeClass(): Class<out LayoutShadowNode> = | ||
LayoutShadowNode::class.java | ||
|
||
public override fun updateExtraData(root: T, extraData: Any) {} | ||
|
||
public override fun addView(parent: T, child: View, index: Int): Unit = | ||
parent.addView(child, index) | ||
|
||
/** | ||
* Convenience method for batching a set of addView calls Note that this adds the views to the | ||
* beginning of the ViewGroup | ||
* | ||
* @param parent the parent ViewGroup | ||
* @param views the set of views to add | ||
*/ | ||
public fun addViews(parent: T, views: List<View>) { | ||
UiThreadUtil.assertOnUiThread() | ||
views.forEachIndexed { i, view -> addView(parent, view, i) } | ||
} | ||
|
||
public override fun getChildCount(parent: T): Int = parent.childCount | ||
|
||
public override fun getChildAt(parent: T, index: Int): View? = parent.getChildAt(index) | ||
|
||
public override fun removeViewAt(parent: T, index: Int) { | ||
UiThreadUtil.assertOnUiThread() | ||
parent.removeViewAt(index) | ||
} | ||
|
||
public fun removeView(parent: T, view: View) { | ||
UiThreadUtil.assertOnUiThread() | ||
|
||
for (i in 0 until getChildCount(parent)) { | ||
riteshshukla04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (getChildAt(parent, i) === view) { | ||
|
||
removeViewAt(parent, i) | ||
break | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns whether this View type needs to handle laying out its own children instead of deferring | ||
* to the standard css-layout algorithm. Returns true for the layout to *not* be automatically | ||
* invoked. Instead onLayout will be invoked as normal and it is the View instance's | ||
* responsibility to properly call layout on its children. Returns false for the default behavior | ||
* of automatically laying out children without going through the ViewGroup's onLayout method. In | ||
* that case, onLayout for this View type must *not* call layout on its children. | ||
*/ | ||
public override fun needsCustomLayoutForChildren(): Boolean = false | ||
riteshshukla04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public companion object { | ||
private val zIndexHash: WeakHashMap<View, Int> = WeakHashMap() | ||
|
||
@JvmStatic | ||
public fun setViewZIndex(view: View, zIndex: Int): Unit = zIndexHash.set(view, zIndex) | ||
|
||
@JvmStatic public fun getViewZIndex(view: View?): Int? = zIndexHash[view] | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.