Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Use ConcurrentHashMap instead of ArrayMap to avoid thread safe problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAfc committed Dec 26, 2018
1 parent 81ab78d commit 10f45e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ org.gradle.jvmargs=-Xmx2048m
GROUP=com.alibaba.android
ARTIFACT=virtualview
VERSION=1
VERSION_NAME=1.3.8.1
VERSION_NAME=1.3.8.3
PACKAGING_TYPE=aar
systemProp.compileSdkVersion=26
systemProp.targetSdkVersion=26
systemProp.buildToolsVersion=26.0.1

Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@
package com.tmall.wireless.vaf.virtualview.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.support.v4.app.ShareCompat.IntentBuilder;
import android.support.v4.util.ArrayMap;
import android.util.Log;
import android.view.View;

import com.libra.TextUtils;
import com.libra.Utils;
import com.libra.virtualview.common.TextBaseCommon;
import com.libra.virtualview.common.ViewBaseCommon;

import org.json.JSONArray;
import org.json.JSONObject;

Expand All @@ -49,7 +54,7 @@ public class ViewCache {

private List<ViewBase> mCacheView = new ArrayList<>();

private ArrayMap<ViewBase, List<Item>> mCacheItem = new ArrayMap<>();
private ConcurrentHashMap<ViewBase, List<Item>> mCacheItem = new ConcurrentHashMap<>();

private Object mComponentData;

Expand Down Expand Up @@ -244,7 +249,6 @@ public void bind(Object jsonObject, boolean isAppend) {
}



break;
case TYPE_STRING:
mView.setAttribute(mKey, Utils.toString(value));
Expand Down Expand Up @@ -314,8 +318,8 @@ public void destroy() {
mCacheView = null;
}
if (mCacheItem != null) {
for (int i = 0, size = mCacheItem.size(); i < size; i++) {
List<Item> items = mCacheItem.valueAt(i);
for (Map.Entry<ViewBase, List<Item>> entry : mCacheItem.entrySet()) {
List<Item> items = entry.getValue();
if (items != null) {
for (int j = 0, length = items.size(); j < length; j++) {
Item item = items.get(j);
Expand Down Expand Up @@ -481,14 +485,14 @@ public Object getValueFromEL(Object jsonObject) {
result = jsonObject;
} else {
if (jsonObject instanceof JSONObject) {
result = ((JSONObject)jsonObject).opt(key);
result = ((JSONObject) jsonObject).opt(key);
} else {
break;
}
}
} else if (node instanceof Integer) {
if (jsonObject instanceof JSONArray) {
result = ((JSONArray)jsonObject).opt(((Integer)node).intValue());
result = ((JSONArray) jsonObject).opt(((Integer) node).intValue());
} else {
break;
}
Expand Down Expand Up @@ -586,23 +590,23 @@ public Object getValueFromEL(Object jsonObject) {
if (conditionValue == null) {
determine = false;
} else if (conditionValue instanceof Boolean) {
determine = ((Boolean)conditionValue).booleanValue();
determine = ((Boolean) conditionValue).booleanValue();
} else if (conditionValue instanceof String) {
if (TextUtils.isEmpty((CharSequence)conditionValue)) {
if (TextUtils.isEmpty((CharSequence) conditionValue)) {
determine = false;
} else {
if (TextUtils.equals((CharSequence)conditionValue, "null")) {
if (TextUtils.equals((CharSequence) conditionValue, "null")) {
determine = false;
} else if (TextUtils.equals(((String)conditionValue).toLowerCase(), "false")) {
} else if (TextUtils.equals(((String) conditionValue).toLowerCase(), "false")) {
determine = false;
}
}
} else if (conditionValue instanceof JSONObject) {
if (((JSONObject)conditionValue).length() == 0) {
if (((JSONObject) conditionValue).length() == 0) {
determine = false;
}
} else if (conditionValue instanceof JSONArray) {
if (((JSONArray)conditionValue).length() == 0) {
if (((JSONArray) conditionValue).length() == 0) {
determine = false;
}
} else if (conditionValue.equals(JSONObject.NULL)) {
Expand All @@ -627,7 +631,7 @@ public Object getValueFromEL(Object jsonObject) {
* so we make Integer.MIN_VALUE as invalid input
*/
public static int parseInt(String s) {
return parseInt(s,10);
return parseInt(s, 10);
}

public static int parseInt(String s, int radix) {
Expand Down Expand Up @@ -673,7 +677,7 @@ public static int parseInt(String s, int radix) {
multmin = limit / radix;
while (i < len) {
// Accumulating negatively avoids surprises near MAX_VALUE
digit = Character.digit(s.charAt(i++),radix);
digit = Character.digit(s.charAt(i++), radix);
if (digit < 0) {
return Integer.MIN_VALUE;
}
Expand Down

0 comments on commit 10f45e9

Please sign in to comment.