mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
store / retrieve instanceHandle from View
Reviewed By: shergin, achen1 Differential Revision: D8074014 fbshipit-source-id: aee0d41e0e9da44e8748f47da04dcd76dbe96d8d
This commit is contained in:
1 parent
54acf3a431
commit
40c7248345
6 files changed
+88
-10
No files matched your search
+39
-1
@@ -7,7 +7,9 @@
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
@@ -17,6 +19,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.PopupMenu;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.animation.Animation;
|
||||
import com.facebook.react.animation.AnimationListener;
|
||||
@@ -114,13 +117,26 @@ public class NativeViewHierarchyManager {
|
||||
mLayoutAnimationEnabled = enabled;
|
||||
}
|
||||
|
||||
public synchronized void updateInstanceHandle(int tag, long instanceHandle) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
try {
|
||||
updateInstanceHandle(resolveView(tag), instanceHandle);
|
||||
} catch (IllegalViewOperationException e) {
|
||||
Log.e(TAG, "Unable to update properties for view tag " + tag, e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateProperties(int tag, ReactStylesDiffMap props) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
try {
|
||||
ViewManager viewManager = resolveViewManager(tag);
|
||||
View viewToUpdate = resolveView(tag);
|
||||
viewManager.updateProperties(viewToUpdate, props);
|
||||
|
||||
if (props != null) {
|
||||
viewManager.updateProperties(viewToUpdate, props);
|
||||
}
|
||||
} catch (IllegalViewOperationException e) {
|
||||
Log.e(TAG, "Unable to update properties for view tag " + tag, e);
|
||||
}
|
||||
@@ -197,6 +213,28 @@ public class NativeViewHierarchyManager {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.DONUT)
|
||||
private void updateInstanceHandle(View viewToUpdate, long instanceHandle) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
viewToUpdate.setTag(R.id.view_tag_instance_handle, instanceHandle);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@TargetApi(Build.VERSION_CODES.DONUT)
|
||||
public long getInstanceHandle(int targetTag) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
View view = mTagsToViews.get(targetTag);
|
||||
if (view == null) {
|
||||
throw new IllegalArgumentException("Unable to find view for tag: " + targetTag);
|
||||
}
|
||||
Long tag = (Long) view.getTag(R.id.view_tag_instance_handle);
|
||||
if (tag == null) {
|
||||
throw new IllegalArgumentException("Unable to find instanceHandle for tag: " + targetTag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
private void updateLayout(View viewToUpdate, int x, int y, int width, int height) {
|
||||
if (mLayoutAnimationEnabled &&
|
||||
mLayoutAnimator.shouldAnimateLayout(viewToUpdate)) {
|
||||
|
||||
Reference in new issue
Block a user