YorkShen closed pull request #1488: [WEEX-586][Android] add synchronized for
recycle list template layout
URL: https://github.com/apache/incubator-weex/pull/1488
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/android/sdk/src/main/java/com/taobao/weex/ui/component/binding/AsynLayoutTask.java
b/android/sdk/src/main/java/com/taobao/weex/ui/component/binding/AsynLayoutTask.java
index 02a848659a..564c0586d5 100644
---
a/android/sdk/src/main/java/com/taobao/weex/ui/component/binding/AsynLayoutTask.java
+++
b/android/sdk/src/main/java/com/taobao/weex/ui/component/binding/AsynLayoutTask.java
@@ -44,7 +44,12 @@
protected Void doInBackground(Void... params) {
if(templateViewHolder.getHolderPosition() == position){
if(component.getInstance() != null &&
!component.getInstance().isDestroy()) {
- Layouts.doLayoutOnly(component, templateViewHolder);
+ synchronized (templateViewHolder.getTemplateList()){
+ if(templateViewHolder.getTemplateList().isDestoryed()){
+ return null;
+ }
+ Layouts.doLayoutOnly(component, templateViewHolder);
+ }
}
}
return null;
diff --git
a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
index ff56034fca..c6583d0389 100644
---
a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
+++
b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
@@ -1291,36 +1291,37 @@ private void removeFooterOrHeader(WXComponent child) {
@Override
public void destroy() {
-
- if(getHostView() != null){
- if(mAppearChangeRunnable != null) {
- getHostView().removeCallbacks(mAppearChangeRunnable);
- mAppearChangeRunnable = null;
+ synchronized (this){
+ if(getHostView() != null){
+ if(mAppearChangeRunnable != null) {
+ getHostView().removeCallbacks(mAppearChangeRunnable);
+ mAppearChangeRunnable = null;
+ }
+ getHostView().removeCallbacks(listUpdateRunnable);
+ if(getHostView().getInnerView() != null){
+ getHostView().getInnerView().setAdapter(null);
+ }
}
- getHostView().removeCallbacks(listUpdateRunnable);
- if(getHostView().getInnerView() != null){
- getHostView().getInnerView().setAdapter(null);
+ if(cellDataManager.listData != null){
+ cellDataManager.setListData(null);
}
+ if(mStickyHelper != null){
+ mStickyHelper = null;
+ }
+ if(mTemplateViewTypes != null){
+ mTemplateViewTypes.clear();
+ }
+ if(mTemplateSources != null){
+ mTemplateSources.clear();
+ }
+ if(mAppearHelpers != null){
+ mAppearHelpers.clear();
+ }
+ if(mDisAppearWatchList != null){
+ mDisAppearWatchList.clear();
+ }
+ super.destroy();
}
- if(cellDataManager.listData != null){
- cellDataManager.setListData(null);
- }
- if(mStickyHelper != null){
- mStickyHelper = null;
- }
- if(mTemplateViewTypes != null){
- mTemplateViewTypes.clear();
- }
- if(mTemplateSources != null){
- mTemplateSources.clear();
- }
- if(mAppearHelpers != null){
- mAppearHelpers.clear();
- }
- if(mDisAppearWatchList != null){
- mDisAppearWatchList.clear();
- }
- super.destroy();
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services