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

Commit

Permalink
Update all Arraymap to ConcurrentHashMap.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAfc committed Jan 2, 2019
1 parent fb1c7d8 commit ac52690
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.os.Build.VERSION;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ChildDrawingOrderCallback;
import android.view.View;
Expand All @@ -54,8 +53,6 @@
import com.tmall.wireless.tangram.op.ParseGroupsOp;
import com.tmall.wireless.tangram.op.ParseSingleComponentOp;
import com.tmall.wireless.tangram.op.ParseSingleGroupOp;
import com.tmall.wireless.tangram.op.TangramOp2;
import com.tmall.wireless.tangram.op.TangramOp3;
import com.tmall.wireless.tangram.structure.BaseCell;
import com.tmall.wireless.tangram.structure.card.VVCard;
import com.tmall.wireless.tangram.support.BannerSupport;
Expand All @@ -68,6 +65,12 @@
import com.tmall.wireless.tangram.util.Predicate;
import com.tmall.wireless.vaf.framework.VafContext;
import com.tmall.wireless.vaf.framework.ViewManager;

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

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
Expand All @@ -76,12 +79,6 @@
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;

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

/**
* {@link O} is the type of data, {@link T} is the array type of data, {@link C} is the class of Group, {@link L} is the class of Component
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
package com.tmall.wireless.tangram;

import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import android.util.SparseArray;
import android.view.View;

import com.tmall.wireless.tangram.dataparser.concrete.BaseCardBinderResolver;
Expand All @@ -38,6 +36,8 @@
import com.tmall.wireless.tangram.structure.card.VVCard;
import com.tmall.wireless.tangram.structure.viewcreator.ViewHolderCreator;

import java.util.concurrent.ConcurrentHashMap;

/**
* The place to register cell and card, all build-in and user cell, card ared registed here finally.
*/
Expand All @@ -47,7 +47,7 @@ public class DefaultResolverRegistry {
final BaseCellBinderResolver mDefaultCellBinderResolver = new BaseCellBinderResolver();
final BaseCardBinderResolver mDefaultCardBinderResolver = new BaseCardBinderResolver(mDefaultCardResolver);

ArrayMap<String, ViewHolderCreator> viewHolderMap = new ArrayMap<>(64);
ConcurrentHashMap<String, ViewHolderCreator> viewHolderMap = new ConcurrentHashMap<>(64);

MVHelper mMVHelper;

Expand Down
14 changes: 7 additions & 7 deletions tangram/src/main/java/com/tmall/wireless/tangram/MVHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
package com.tmall.wireless.tangram;

import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;

import com.alibaba.android.vlayout.VirtualLayoutManager;

import android.os.Build.VERSION;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -63,11 +63,11 @@ public class MVHelper {

private VafContext mVafContext;

private ArrayMap<BaseCell, ArrayMap<Method, Object>> methodMap = new ArrayMap<>(128);
private ArrayMap<Class, Method[]> methodCacheMap = new ArrayMap<>(128);
private ArrayMap<BaseCell, Method> postBindMap = new ArrayMap<>(128);
private ArrayMap<BaseCell, Method> postUnBindMap = new ArrayMap<>(128);
private ArrayMap<BaseCell, Method> cellInitedMap = new ArrayMap<>(128);
private ConcurrentHashMap<BaseCell, ConcurrentHashMap<Method, Object>> methodMap = new ConcurrentHashMap<>(128);
private ConcurrentHashMap<Class, Method[]> methodCacheMap = new ConcurrentHashMap<>(128);
private ConcurrentHashMap<BaseCell, Method> postBindMap = new ConcurrentHashMap<>(128);
private ConcurrentHashMap<BaseCell, Method> postUnBindMap = new ConcurrentHashMap<>(128);
private ConcurrentHashMap<BaseCell, Method> cellInitedMap = new ConcurrentHashMap<>(128);

public MVHelper(MVResolver mvResolver) {
this.mvResolver = mvResolver;
Expand Down Expand Up @@ -188,7 +188,7 @@ private void loadMethod(BaseCell cell, View view) {
return;
}

ArrayMap<Method, Object> paramMap = new ArrayMap<>();
ConcurrentHashMap<Method, Object> paramMap = new ConcurrentHashMap<>();

Method[] methods;
if (methodCacheMap.get(view.getClass()) == null) {
Expand Down
14 changes: 6 additions & 8 deletions tangram/src/main/java/com/tmall/wireless/tangram/MVResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
package com.tmall.wireless.tangram;

import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;

import com.tmall.wireless.tangram.core.service.ServiceManager;
Expand All @@ -36,12 +34,12 @@
import com.tmall.wireless.tangram.structure.BaseCell;
import com.tmall.wireless.tangram.util.Utils;

import org.json.JSONException;
import org.json.JSONObject;

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

/**
* Created by mikeafc on 16/4/26.
Expand All @@ -64,15 +62,15 @@ public class MVResolver {

public static final String KEY_POSITION = "position";

private ArrayMap<String, Class<? extends View>> typeViewMap = new ArrayMap<>(64);
private ConcurrentHashMap<String, Class<? extends View>> typeViewMap = new ConcurrentHashMap<>(64);

private ArrayMap<String, Class<? extends BaseCell>> typeCellMap = new ArrayMap(64);
private ConcurrentHashMap<String, Class<? extends BaseCell>> typeCellMap = new ConcurrentHashMap(64);

private HashMap<String, Card> idCardMap = new HashMap<>();
private ConcurrentHashMap<String, Card> idCardMap = new ConcurrentHashMap<>();

private ArrayMap<BaseCell, View> mvMap = new ArrayMap<>(128);
private ConcurrentHashMap<BaseCell, View> mvMap = new ConcurrentHashMap<>(128);

private ArrayMap<View, BaseCell> vmMap = new ArrayMap<>(128);
private ConcurrentHashMap<View, BaseCell> vmMap = new ConcurrentHashMap<>(128);

private ServiceManager mServiceManager;

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

package com.tmall.wireless.tangram.core.resolver;

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

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

/**
* Created by villadora on 15/8/23.
*/
public abstract class BaseResolver<T, O> implements Resolver<T, O> {

protected ArrayMap<T, String> mMap = new ArrayMap<>(64);
protected ConcurrentHashMap<T, String> mMap = new ConcurrentHashMap<>(64);

protected ArrayMap<String, T> mSparseArray = new ArrayMap<>(64);
protected ConcurrentHashMap<String, T> mSparseArray = new ConcurrentHashMap<>(64);

@Override
public int size() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import com.alibaba.android.vlayout.layout.FixAreaLayoutHelper;
import com.alibaba.android.vlayout.layout.MarginLayoutHelper;

import android.support.v4.util.ArrayMap;

import com.tmall.wireless.tangram.Engine;
import com.tmall.wireless.tangram.MVHelper;
import com.tmall.wireless.tangram.TangramBuilder;
Expand Down Expand Up @@ -69,6 +67,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Basic Card, which will represent LayoutHelpers
Expand Down Expand Up @@ -124,7 +123,7 @@ public abstract class Card extends ComponentLifecycle {
protected BaseCell mFooter;

@NonNull
protected ArrayMap<Range<Integer>, Card> mChildren = new ArrayMap<>();
protected ConcurrentHashMap<Range<Integer>, Card> mChildren = new ConcurrentHashMap<>();

@NonNull
protected List<BaseCell> mCells = new ArrayList<>();
Expand Down Expand Up @@ -580,7 +579,7 @@ public List<BaseCell> getCells() {
}

@NonNull
public ArrayMap<Range<Integer>, Card> getChildren() {
public ConcurrentHashMap<Range<Integer>, Card> getChildren() {
return mChildren;
}

Expand Down Expand Up @@ -1053,8 +1052,8 @@ public JSONArray optJsonArrayParam(String key) {

public Card findChildCardById(String id) {
if (!mChildren.isEmpty()) {
for (int i = 0, size = mChildren.size(); i < size; i++) {
Card card = mChildren.valueAt(i);
for (Map.Entry<Range<Integer>, Card> entry : mChildren.entrySet()) {
Card card = entry.getValue();
if (card != null && card.id.equals(id)) {
return card;
}
Expand All @@ -1063,7 +1062,7 @@ public Card findChildCardById(String id) {
return null;
}

public ArrayMap<Range<Integer>, Card> getChildrenCards() {
public ConcurrentHashMap<Range<Integer>, Card> getChildrenCards() {
return mChildren;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
Expand All @@ -54,6 +53,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand All @@ -66,7 +66,7 @@ public class PojoGroupBasicAdapter extends GroupBasicAdapter<Card, BaseCell> {

private AtomicInteger mTypeId = new AtomicInteger(0);

private final Map<String, Integer> mStrKeys = new ArrayMap<>(64);
private final Map<String, Integer> mStrKeys = new ConcurrentHashMap<>(64);

private MVHelper mMvHelper;

Expand Down Expand Up @@ -255,7 +255,7 @@ protected void diffGroup(SparseArray<Card> added, SparseArray<Card> removed) {
}


private final Map<String, Card> mIdCardCache = new ArrayMap<>(64);
private final Map<String, Card> mIdCardCache = new ConcurrentHashMap<>(64);

@NonNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.json.JSONObject;

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

import java.util.ArrayList;
Expand Down Expand Up @@ -148,7 +147,7 @@ public static Event obtainEvent() {
* returned object's field is filled provided params.
*/
public static Event obtainEvent(String type, String sourceId,
ArrayMap<String, String> args, EventContext eventContext) {
ConcurrentHashMap<String, String> args, EventContext eventContext) {
Event event = EventPool.sharedInstance().acquire();
event.type = type;
event.sourceId = sourceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

package com.tmall.wireless.tangram.eventbus;

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

/**
* Created by longerian on 16/4/26.
Expand All @@ -44,15 +44,15 @@ public class Event {
/**
* TangramOp1 args
*/
public ArrayMap<String, String> args;
public ConcurrentHashMap<String, String> args;

/**
* Context
*/
public EventContext eventContext;

public Event() {
args = new ArrayMap<>();
args = new ConcurrentHashMap<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
package com.tmall.wireless.tangram.structure;

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

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
Expand Down Expand Up @@ -123,9 +123,9 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
*/
public JSONObject extras = new JSONObject();

private ArrayMap<String, Object> bizParaMap = new ArrayMap<>(32);
private ConcurrentHashMap<String, Object> bizParaMap = new ConcurrentHashMap<>(32);

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

@Nullable
public ServiceManager serviceManager;
Expand Down Expand Up @@ -366,9 +366,9 @@ public Object getTag(int key) {
return null;
}

private ArrayMap<View, ClickExposureCellOp> mRxExposureEvents = new ArrayMap<>();
private ConcurrentHashMap<View, ClickExposureCellOp> mRxExposureEvents = new ConcurrentHashMap<>();

private ArrayMap<View, CellExposureObservable> mViewExposureObservables = new ArrayMap<>();
private ConcurrentHashMap<View, CellExposureObservable> mViewExposureObservables = new ConcurrentHashMap<>();

/**
* @param targetView
Expand Down Expand Up @@ -403,9 +403,9 @@ public CellExposureObservable exposure(View targetView) {
return exposure(targetView, rxExposureEvent);
}

private ArrayMap<View, ClickExposureCellOp> mRxClickEvents = new ArrayMap<>();
private ConcurrentHashMap<View, ClickExposureCellOp> mRxClickEvents = new ConcurrentHashMap<>();

private ArrayMap<View, CellClickObservable> mViewClickObservables = new ArrayMap<>();
private ConcurrentHashMap<View, CellClickObservable> mViewClickObservables = new ConcurrentHashMap<>();

/**
* @param view
Expand Down
Loading

0 comments on commit ac52690

Please sign in to comment.