forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Back out "Back out "[RN][Android] Convert ReactViewManager, ReactClip…
…pingViewManager to Kotlin"" Summary: Original commit changeset: 9cbd8ab86be3 Original Phabricator Diff: D63076764 Differential Revision: D63129925
- Loading branch information
1 parent
94b7793
commit ce2dce2
Showing
5 changed files
with
470 additions
and
522 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
95 changes: 0 additions & 95 deletions
95
...ve/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewManager.java
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
...tive/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewManager.kt
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,73 @@ | ||
/* | ||
* 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.views.view | ||
|
||
import android.view.View | ||
import com.facebook.react.bridge.UiThreadUtil | ||
import com.facebook.react.uimanager.ReactClippingViewGroupHelper | ||
import com.facebook.react.uimanager.ViewGroupManager | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
|
||
/** | ||
* View manager which handles clipped subviews. Useful for custom views which extends from | ||
* [com.facebook.react.views.view.ReactViewGroup] | ||
*/ | ||
public abstract class ReactClippingViewManager<T : ReactViewGroup> : ViewGroupManager<T>() { | ||
|
||
@ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS) | ||
public open fun setRemoveClippedSubviews(view: T, removeClippedSubviews: Boolean) { | ||
UiThreadUtil.assertOnUiThread() | ||
view.removeClippedSubviews = removeClippedSubviews | ||
} | ||
|
||
override fun addView(parent: T, child: View, index: Int) { | ||
UiThreadUtil.assertOnUiThread() | ||
if (parent.removeClippedSubviews) { | ||
parent.addViewWithSubviewClippingEnabled(child, index) | ||
} else { | ||
parent.addView(child, index) | ||
} | ||
} | ||
|
||
override fun getChildCount(parent: T): Int = | ||
if (parent.removeClippedSubviews) { | ||
parent.allChildrenCount | ||
} else { | ||
parent.childCount | ||
} | ||
|
||
override fun getChildAt(parent: T, index: Int): View? = | ||
if (parent.removeClippedSubviews) { | ||
parent.getChildAtWithSubviewClippingEnabled(index) | ||
} else { | ||
parent.getChildAt(index) | ||
} | ||
|
||
override fun removeViewAt(parent: T, index: Int) { | ||
UiThreadUtil.assertOnUiThread() | ||
if (parent.removeClippedSubviews) { | ||
val child = getChildAt(parent, index) ?: return | ||
if (child.parent != null) { | ||
parent.removeView(child) | ||
} else { | ||
parent.removeViewWithSubviewClippingEnabled(child) | ||
} | ||
} else { | ||
parent.removeViewAt(index) | ||
} | ||
} | ||
|
||
override fun removeAllViews(parent: T) { | ||
UiThreadUtil.assertOnUiThread() | ||
if (parent.removeClippedSubviews) { | ||
parent.removeAllViewsWithSubviewClippingEnabled() | ||
} else { | ||
parent.removeAllViews() | ||
} | ||
} | ||
} |
Oops, something went wrong.