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

Commit

Permalink
Update ArrayMap to ConcurrentHashMap.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAfc committed Jan 2, 2019
1 parent 10f45e9 commit d26517d
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@

package com.tmall.wireless.virtualviewdemo.vs;

import android.support.v4.util.ArrayMap;
import android.text.TextUtils;

import android.util.Log;

import com.libra.expr.common.StringSupport;
import com.libra.virtualview.common.StringBase;
import com.tmall.wireless.vaf.virtualview.loader.CodeReader;

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

/**
* Created by gujicheng on 17/3/27.
Expand All @@ -45,13 +40,13 @@ public class StringSupportImp extends StringBase implements StringSupport {

final private static String TAG = "StringSupportImp_TMTEST";

private Map<String, Integer> mString2Index = new ArrayMap<>();
private Map<String, Integer> mString2Index = new ConcurrentHashMap<>();

private Map<Integer, String> mIndex2String = new ArrayMap<>();
private Map<Integer, String> mIndex2String = new ConcurrentHashMap<>();

private Map<String, Integer> mSysString2Index = new ArrayMap<>();
private Map<String, Integer> mSysString2Index = new ConcurrentHashMap<>();

private Map<Integer, String> mSysIndex2String = new ArrayMap<>();
private Map<Integer, String> mSysIndex2String = new ConcurrentHashMap<>();

public StringSupportImp() {
for (int i = 0; i < StringBase.STR_ID_SYS_KEY_COUNT; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ org.gradle.jvmargs=-Xmx2048m
GROUP=com.alibaba.android
ARTIFACT=virtualview
VERSION=1
VERSION_NAME=1.3.8.3
VERSION_NAME=1.3.8.4
PACKAGING_TYPE=aar
systemProp.compileSdkVersion=26
systemProp.targetSdkVersion=26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.tmall.wireless.vaf.expr.engine;

import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;

Expand All @@ -37,6 +36,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by gujicheng on 16/9/12.
Expand All @@ -45,7 +45,7 @@ public class NativeObjectManager {
private final static String TAG = "NObjManager_TMTEST";

private List<ViewBase> mViews = new ArrayList<>();
private Map<String, Object> mNativeObjects = new ArrayMap<>();
private Map<String, Object> mNativeObjects = new ConcurrentHashMap<>();
private StringSupport mStringLoader;

public void setStringManager(StringSupport sm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

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

import android.content.Context;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;

import com.tmall.wireless.vaf.virtualview.ViewFactory;
import com.tmall.wireless.vaf.virtualview.core.Layout;
import com.tmall.wireless.vaf.virtualview.core.ViewBase;
Expand All @@ -46,7 +48,7 @@ public class ViewManager {

private ViewFactory mViewFactory = new ViewFactory();

private ArrayMap<String, List<ViewBase>> mViewCache = new ArrayMap<>();
private ConcurrentHashMap<String, List<ViewBase>> mViewCache = new ConcurrentHashMap<>();
private SparseArray<ViewBase> mUuidContainers = new SparseArray<>();

private VafContext mAppContext;
Expand Down Expand Up @@ -81,10 +83,10 @@ public ViewBase getViewFromUuid(int uuid) {
}

public void destroy() {
for (int i = 0; i < mViewCache.size(); ++i) {
List<ViewBase> viewBases = mViewCache.valueAt(i);
for (Map.Entry<String, List<ViewBase>> entry : mViewCache.entrySet()) {
List<ViewBase> viewBases = entry.getValue();
if (null != viewBases) {
for ( int j = 0; j < viewBases.size(); ++j) {
for (int j = 0; j < viewBases.size(); ++j) {
ViewBase viewBase = viewBases.get(j);
viewBase.destroy();
ViewCache viewCache = viewBase.getViewCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

package com.tmall.wireless.vaf.framework.cm;

import android.support.v4.util.ArrayMap;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by gujicheng on 17/4/10.
*/

public class ComContainerTypeMap {
private ArrayMap<String, Integer> mMap = new ArrayMap<String, Integer>();
private ConcurrentHashMap<String, Integer> mMap = new ConcurrentHashMap<String, Integer>();

public void register(String comMap, int containerType) {
if (comMap != null && containerType > -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

package com.tmall.wireless.vaf.virtualview.Helper;

import android.support.v4.util.ArrayMap;
import android.util.Log;
import com.libra.TextUtils;
import com.tmall.wireless.vaf.virtualview.core.IBean;

import java.util.concurrent.ConcurrentHashMap;

/**
* Created by longerian on 2017/7/12.
*
Expand All @@ -40,7 +41,7 @@ public class BeanManager {

private final static String TAG = "BeanManager_TMTEST";

private ArrayMap<String, Class<? extends IBean>> mBeanArrayMap = new ArrayMap<>();
private ConcurrentHashMap<String, Class<? extends IBean>> mBeanArrayMap = new ConcurrentHashMap<>();

public void register(String type, Class<? extends IBean> processor) {
if (null != processor && !TextUtils.isEmpty(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

package com.tmall.wireless.vaf.virtualview.Helper;

import android.support.v4.util.ArrayMap;
import com.libra.TextUtils;

import java.util.concurrent.ConcurrentHashMap;

/**
* Created by longerian on 2017/7/12.
*
Expand All @@ -38,7 +39,7 @@ public class NativeViewManager {

private final static String TAG = "CompactNativeManager_TMTEST";

private ArrayMap<String, Class<?>> mBeanArrayMap = new ArrayMap<>();
private ConcurrentHashMap<String, Class<?>> mBeanArrayMap = new ConcurrentHashMap<>();

public void register(String type, Class<?> processor) {
if (null != processor && !TextUtils.isEmpty(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
package com.tmall.wireless.vaf.virtualview.Helper;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;

/**
* Use for communicate with outside class.
* Created by mikeafc on 2017/8/24.
*/

public class ServiceManager {
private Map<Class<?>, Object> mServices = new ArrayMap<>();
private Map<Class<?>, Object> mServices = new ConcurrentHashMap<>();

public <S> void register(@NonNull Class<S> type, @NonNull S service) {
mServices.put(type, type.cast(service));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

package com.tmall.wireless.vaf.virtualview.core;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import android.support.v4.util.ArrayMap;
import android.support.v4.util.SparseArrayCompat;
import android.util.Log;
import android.view.View;
Expand All @@ -47,7 +47,7 @@ public class ArrayAdapter extends Adapter {
private final static String TAG = "ArrayAdapter_TMTEST";

private AtomicInteger mTypeId = new AtomicInteger(0);
private ArrayMap<String, Integer> mTypeMap = new ArrayMap<>();
private ConcurrentHashMap<String, Integer> mTypeMap = new ConcurrentHashMap<>();
private SparseArrayCompat<String> mId2Types = new SparseArrayCompat<>();
private JSONArray mData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import android.graphics.Bitmap;
import android.graphics.Canvas;
Expand All @@ -36,7 +37,6 @@
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Trace;
import android.support.v4.util.SimpleArrayMap;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
Expand Down Expand Up @@ -166,7 +166,7 @@ public abstract class ViewBase implements IView {
/**
* Map used to store views' tags.
*/
private SimpleArrayMap<String, Object> mKeyedTags;
private ConcurrentHashMap<String, Object> mKeyedTags;

protected ExprCode mClickCode;
protected ExprCode mBeforeLoadDataCode;
Expand Down Expand Up @@ -439,7 +439,7 @@ public Object getTag(String key) {

public void setTag(String key, Object tag) {
if (mKeyedTags == null) {
mKeyedTags = new SimpleArrayMap<>();
mKeyedTags = new ConcurrentHashMap<>();
}

mKeyedTags.put(key, tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@

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;
Expand All @@ -44,6 +34,12 @@
import org.json.JSONArray;
import org.json.JSONObject;

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

/**
* Created by gujicheng on 16/12/6.
*/
Expand Down Expand Up @@ -76,7 +72,7 @@ public static class Item {

public String mAttrEL;

private ArrayMap<Integer, Object> cacheTargetValue = new ArrayMap<>();
private ConcurrentHashMap<Integer, Object> cacheTargetValue = new ConcurrentHashMap<>();

private int mValueType = TYPE_INT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@

package com.tmall.wireless.vaf.virtualview.event;

import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.SparseArray;

import org.json.JSONObject;

import java.util.concurrent.ConcurrentHashMap;

/**
* Created by gujicheng on 17/1/11.
*/

public class ClickProcessorManager {
private final static String TAG = "CliProManager_TMTEST";

private ArrayMap<String, IClickProcessor> mProcessors = new ArrayMap<>();
private ConcurrentHashMap<String, IClickProcessor> mProcessors = new ConcurrentHashMap<>();
private IClickProcessor mDefaultProcessor;

public void register(String type, IClickProcessor p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,19 @@

package com.tmall.wireless.vaf.virtualview.loader;

import android.support.v4.util.ArrayMap;
import android.util.Log;

import android.util.SparseIntArray;
import com.libra.expr.common.ExprCode;
import com.libra.virtualview.common.Common;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by gujicheng on 16/9/12.
*/
public class ExprCodeLoader {
private final static String TAG = "CodeManager_TMTEST";

private ArrayMap<Integer, ExprCode> mCodeMap = new ArrayMap();
private ConcurrentHashMap<Integer, ExprCode> mCodeMap = new ConcurrentHashMap();

public void reset() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package com.tmall.wireless.vaf.virtualview.loader;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.support.v4.util.ArrayMap;
import android.util.Log;
import com.libra.TextUtils;
import com.libra.expr.common.StringSupport;
Expand All @@ -38,18 +38,16 @@
public class StringLoader extends StringBase implements StringSupport {
final private static String TAG = "StringLoader_TMTEST";

private Map<String, Integer> mString2Index = new ArrayMap<>();
private Map<String, Integer> mString2Index = new ConcurrentHashMap<>();

private Map<Integer, String> mIndex2String = new ArrayMap<>();
private Map<Integer, String> mIndex2String = new ConcurrentHashMap<>();

private Map<String, Integer> mSysString2Index = new ArrayMap<>();
private Map<String, Integer> mSysString2Index = new ConcurrentHashMap<>();

private Map<Integer, String> mSysIndex2String = new ArrayMap<>();
private Map<Integer, String> mSysIndex2String = new ConcurrentHashMap<>();

private int mCurPage;



public StringLoader() {
for (int i = 0; i < StringBase.STR_ID_SYS_KEY_COUNT; ++i) {
mSysString2Index.put(SYS_KEYS[i], StringBase.SYS_KEYS_INDEX[i]);
Expand Down Expand Up @@ -144,25 +142,4 @@ public boolean isSysString(int id) {
public boolean isSysString(String string) {
return mSysString2Index.containsKey(string);
}

//private int addNewItem(String str) {
// int ret;
//
// Map<Integer, String> arr = (Map<Integer, String>)mIndex2StringTab[mCurPage];
// if (null == arr) {
// arr = new ArrayMap<>(30);
// mIndex2StringTab[mCurPage] = arr;
// }
// arr.add(str);
//
// Map<String, Integer> map = (Map<String, Integer>)mString2IndexTab[mCurPage];
// if (null == map) {
// map = new HashMap<>();
// mString2IndexTab[mCurPage] = map;
// }
// ret = mCurPage * Common.MAX_PAGE_ITEM_COUNT + map.size();
// map.put(str, ret);
//
// return ret;
//}
}
Loading

0 comments on commit d26517d

Please sign in to comment.