mirror of
https://github.com/alibaba/Tangram-Android.git
synced 2026-10-17 05:07:05 +08:00
Update all Arraymap to ConcurrentHashMap.
This commit is contained in:
@@ -28,7 +28,6 @@ import android.content.Context;
|
||||
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;
|
||||
@@ -54,8 +53,6 @@ import com.tmall.wireless.tangram.op.ParseComponentsOp;
|
||||
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;
|
||||
@@ -68,6 +65,12 @@ import com.tmall.wireless.tangram.util.Preconditions;
|
||||
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;
|
||||
@@ -76,12 +79,6 @@ import io.reactivex.functions.Consumer;
|
||||
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
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -38,6 +36,8 @@ import com.tmall.wireless.tangram.structure.BaseCell;
|
||||
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.
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -188,7 +188,7 @@ public class MVHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayMap<Method, Object> paramMap = new ArrayMap<>();
|
||||
ConcurrentHashMap<Method, Object> paramMap = new ConcurrentHashMap<>();
|
||||
|
||||
Method[] methods;
|
||||
if (methodCacheMap.get(view.getClass()) == null) {
|
||||
|
||||
@@ -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;
|
||||
@@ -36,12 +34,12 @@ import com.tmall.wireless.tangram.dataparser.concrete.Style;
|
||||
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.
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -30,8 +30,6 @@ import com.alibaba.android.vlayout.layout.BaseLayoutHelper;
|
||||
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;
|
||||
@@ -69,6 +67,7 @@ import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Basic Card, which will represent LayoutHelpers
|
||||
@@ -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<>();
|
||||
@@ -580,7 +579,7 @@ public abstract class Card extends ComponentLifecycle {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ArrayMap<Range<Integer>, Card> getChildren() {
|
||||
public ConcurrentHashMap<Range<Integer>, Card> getChildren() {
|
||||
return mChildren;
|
||||
}
|
||||
|
||||
@@ -1053,8 +1052,8 @@ public abstract class Card extends ComponentLifecycle {
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1063,7 +1062,7 @@ public abstract class Card extends ComponentLifecycle {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayMap<Range<Integer>, Card> getChildrenCards() {
|
||||
public ConcurrentHashMap<Range<Integer>, Card> getChildrenCards() {
|
||||
return mChildren;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -38,7 +38,6 @@ import com.tmall.wireless.tangram.structure.BaseCell;
|
||||
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;
|
||||
@@ -54,6 +53,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
@@ -255,7 +255,7 @@ public class PojoGroupBasicAdapter extends GroupBasicAdapter<Card, BaseCell> {
|
||||
}
|
||||
|
||||
|
||||
private final Map<String, Card> mIdCardCache = new ArrayMap<>(64);
|
||||
private final Map<String, Card> mIdCardCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,6 @@ package com.tmall.wireless.tangram.eventbus;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -148,7 +147,7 @@ public class BusSupport implements IDispatcherDelegate {
|
||||
* 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;
|
||||
|
||||
@@ -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.
|
||||
@@ -44,7 +44,7 @@ public class Event {
|
||||
/**
|
||||
* TangramOp1 args
|
||||
*/
|
||||
public ArrayMap<String, String> args;
|
||||
public ConcurrentHashMap<String, String> args;
|
||||
|
||||
/**
|
||||
* Context
|
||||
@@ -52,7 +52,7 @@ public class Event {
|
||||
public EventContext eventContext;
|
||||
|
||||
public Event() {
|
||||
args = new ArrayMap<>();
|
||||
args = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -366,9 +366,9 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
|
||||
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
|
||||
@@ -403,9 +403,9 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
|
||||
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
|
||||
|
||||
@@ -26,10 +26,9 @@ package com.tmall.wireless.tangram.structure.card;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v4.util.SimpleArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.alibaba.android.vlayout.LayoutHelper;
|
||||
import com.alibaba.android.vlayout.Range;
|
||||
@@ -37,19 +36,19 @@ import com.alibaba.android.vlayout.layout.BaseLayoutHelper;
|
||||
import com.alibaba.android.vlayout.layout.GridLayoutHelper;
|
||||
import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper;
|
||||
import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle;
|
||||
|
||||
import android.view.View;
|
||||
import com.tmall.wireless.tangram.MVHelper;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.Card;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.Style;
|
||||
import com.tmall.wireless.tangram.structure.BaseCell;
|
||||
|
||||
import com.tmall.wireless.tangram.support.CardSupport;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Card perform grid layout
|
||||
@@ -102,28 +101,28 @@ public class GridCard extends Card {
|
||||
if (anchorCard == null) {
|
||||
return;
|
||||
}
|
||||
ArrayMap<Range<Integer>, Card> newChildren = new ArrayMap<>();
|
||||
ConcurrentHashMap<Range<Integer>, Card> newChildren = new ConcurrentHashMap<>();
|
||||
boolean startOffset = false;
|
||||
for (int i = 0, size = mChildren.size(); i < size; i++) {
|
||||
Range<Integer> key = mChildren.keyAt(i);
|
||||
Card child = mChildren.valueAt(i);
|
||||
for (Map.Entry<Range<Integer>, Card> entry : mChildren.entrySet()) {
|
||||
Range<Integer> key = entry.getKey();
|
||||
Card child = entry.getValue();
|
||||
if (child == anchorCard) {
|
||||
Range<Integer> newKey = Range.create(key.getLower().intValue(),
|
||||
key.getUpper().intValue() + offset);
|
||||
key.getUpper().intValue() + offset);
|
||||
newChildren.put(newKey, child);
|
||||
startOffset = true;
|
||||
continue;
|
||||
}
|
||||
if (startOffset) {
|
||||
Range<Integer> newKey = Range.create(key.getLower().intValue() + offset,
|
||||
key.getUpper().intValue() + offset);
|
||||
key.getUpper().intValue() + offset);
|
||||
newChildren.put(newKey, child);
|
||||
} else {
|
||||
newChildren.put(key, child);
|
||||
}
|
||||
}
|
||||
mChildren.clear();
|
||||
mChildren.putAll((SimpleArrayMap<? extends Range<Integer>, ? extends Card>)newChildren);
|
||||
mChildren.putAll(newChildren);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,9 +192,9 @@ public class GridCard extends Card {
|
||||
}
|
||||
|
||||
private void convertChildLayoutHelper(@Nullable RangeGridLayoutHelper gridHelper, GridCard parentCard) {
|
||||
for (int i = 0, size = parentCard.getChildren().size(); i < size; i++) {
|
||||
Range<Integer> range = parentCard.getChildren().keyAt(i);
|
||||
Card child = parentCard.getChildren().valueAt(i);
|
||||
for (Map.Entry<Range<Integer>, Card> entry : parentCard.getChildren().entrySet()) {
|
||||
Range<Integer> range = entry.getKey();
|
||||
Card child = entry.getValue();
|
||||
Style style = child.style;
|
||||
if (style instanceof GridStyle && child instanceof GridCard) {
|
||||
final GridStyle gridStyle = (GridStyle) style;
|
||||
@@ -228,9 +227,9 @@ public class GridCard extends Card {
|
||||
|
||||
rangeStyle.setBgColor(style.bgColor);
|
||||
rangeStyle.setMargin(style.margin[Style.MARGIN_LEFT_INDEX], style.margin[Style.MARGIN_TOP_INDEX],
|
||||
style.margin[Style.MARGIN_RIGHT_INDEX], style.margin[Style.MARGIN_BOTTOM_INDEX]);
|
||||
style.margin[Style.MARGIN_RIGHT_INDEX], style.margin[Style.MARGIN_BOTTOM_INDEX]);
|
||||
rangeStyle.setPadding(style.padding[Style.MARGIN_LEFT_INDEX], style.padding[Style.MARGIN_TOP_INDEX],
|
||||
style.padding[Style.MARGIN_RIGHT_INDEX], style.padding[Style.MARGIN_BOTTOM_INDEX]);
|
||||
style.padding[Style.MARGIN_RIGHT_INDEX], style.padding[Style.MARGIN_BOTTOM_INDEX]);
|
||||
if (!TextUtils.isEmpty(style.bgImgUrl)) {
|
||||
if (serviceManager != null && serviceManager.getService(CardSupport.class) != null) {
|
||||
final CardSupport support = serviceManager.getService(CardSupport.class);
|
||||
|
||||
@@ -33,13 +33,12 @@ import com.tmall.wireless.tangram.structure.BaseCell;
|
||||
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Created by longerian on 17/1/27.
|
||||
@@ -51,7 +50,7 @@ public class SlideCard extends WrapperCard implements SwipeCard {
|
||||
|
||||
public static final String KEY_PAGE_COUNT = "pageCount";
|
||||
|
||||
private ArrayMap<String, String> args = new ArrayMap<String, String>();
|
||||
private ConcurrentHashMap<String, String> args = new ConcurrentHashMap<String, String>();
|
||||
|
||||
private int mIndex;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ package com.tmall.wireless.tangram.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import com.tmall.wireless.tangram.ext.BannerListener;
|
||||
import com.tmall.wireless.tangram.support.RxBannerScrolledListener.ScrollEvent;
|
||||
import io.reactivex.Observable;
|
||||
@@ -38,11 +38,11 @@ import io.reactivex.Observable;
|
||||
*/
|
||||
public class BannerSupport {
|
||||
|
||||
private ArrayMap<String, List<BannerListener>> mSelectedListenerArrayMap = new ArrayMap<>();
|
||||
private ConcurrentHashMap<String, List<BannerListener>> mSelectedListenerArrayMap = new ConcurrentHashMap<>();
|
||||
|
||||
private ArrayMap<String, List<BannerListener>> mScrolledListenerArrayMap = new ArrayMap<>();
|
||||
private ConcurrentHashMap<String, List<BannerListener>> mScrolledListenerArrayMap = new ConcurrentHashMap<>();
|
||||
|
||||
private ArrayMap<String, List<BannerListener>> mScrollStateListenerArrayMap = new ArrayMap<>();
|
||||
private ConcurrentHashMap<String, List<BannerListener>> mScrollStateListenerArrayMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Deprecated
|
||||
private List<BannerListener> listeners = new ArrayList<BannerListener>();
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.Card;
|
||||
@@ -80,8 +79,8 @@ public abstract class ExposureSupport {
|
||||
private static final int MODIFIERS_IGNORE = Modifier.ABSTRACT | Modifier.STATIC | BRIDGE
|
||||
| SYNTHETIC;
|
||||
|
||||
private final Map<Class<?>, OnTraceMethod> mOnTraceMethods = new ArrayMap<>();
|
||||
private final Map<Class<?>, OnTraceMethod> mOnExposureMethods = new ArrayMap<>();
|
||||
private final Map<Class<?>, OnTraceMethod> mOnTraceMethods = new ConcurrentHashMap<>();
|
||||
private final Map<Class<?>, OnTraceMethod> mOnExposureMethods = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean optimizedMode;
|
||||
|
||||
|
||||
@@ -24,13 +24,16 @@
|
||||
|
||||
package com.tmall.wireless.tangram.support;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tmall.wireless.tangram.support.HandlerTimer.TimerStatus;
|
||||
import com.tmall.wireless.tangram.support.TimerSupport.OnTickListener;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
@@ -55,57 +58,57 @@ public class RxTimer implements ITimer {
|
||||
|
||||
private Observable<Long> mIntervalObservable;
|
||||
|
||||
private ArrayMap<OnTickListener, Disposable> tickCache = new ArrayMap<>();
|
||||
private ConcurrentHashMap<OnTickListener, Disposable> tickCache = new ConcurrentHashMap<>();
|
||||
|
||||
public RxTimer(long interval) {
|
||||
this.mInterval = interval;
|
||||
this.mStatus = TimerStatus.Waiting;
|
||||
this.mIntervalObservable = Observable
|
||||
.interval(0, this.mInterval, TimeUnit.MILLISECONDS)
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
mStatus = TimerStatus.Running;
|
||||
Log.d("RxTimerSupportTest", "accept " + disposable + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.doOnDispose(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
mStatus = TimerStatus.Paused;
|
||||
Log.d("RxTimerSupportTest", "on dispose " + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.doOnTerminate(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
mStatus = TimerStatus.Stopped;
|
||||
Log.d("RxTimerSupportTest", "on terminate " + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.share();
|
||||
.interval(0, this.mInterval, TimeUnit.MILLISECONDS)
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
mStatus = TimerStatus.Running;
|
||||
Log.d("RxTimerSupportTest", "accept " + disposable + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.doOnDispose(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
mStatus = TimerStatus.Paused;
|
||||
Log.d("RxTimerSupportTest", "on dispose " + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.doOnTerminate(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
mStatus = TimerStatus.Stopped;
|
||||
Log.d("RxTimerSupportTest", "on terminate " + " status " + mStatus);
|
||||
}
|
||||
})
|
||||
.share();
|
||||
}
|
||||
|
||||
public void register(final int interval, @NonNull final OnTickListener onTickListener, boolean intermediate) {
|
||||
Disposable disposable = this.mIntervalObservable.delaySubscription(intermediate ? 0 : interval * mInterval, TimeUnit.MILLISECONDS).skipWhile(
|
||||
|
||||
new Predicate<Long>() {
|
||||
@Override
|
||||
public boolean test(Long aLong) throws Exception {
|
||||
return pause;
|
||||
}
|
||||
}).observeOn(
|
||||
AndroidSchedulers.mainThread()).subscribe(new Consumer<Long>() {
|
||||
new Predicate<Long>() {
|
||||
@Override
|
||||
public boolean test(Long aLong) throws Exception {
|
||||
return pause;
|
||||
}
|
||||
}).observeOn(
|
||||
AndroidSchedulers.mainThread()).subscribe(new Consumer<Long>() {
|
||||
|
||||
@Override
|
||||
public void accept(Long count) throws Exception {
|
||||
Log.d("RxTimerSupportTest", "accept " + " value " + count);
|
||||
if (count % interval == 0) {
|
||||
if (onTickListener != null) {
|
||||
onTickListener.onTick();
|
||||
}
|
||||
@Override
|
||||
public void accept(Long count) throws Exception {
|
||||
Log.d("RxTimerSupportTest", "accept " + " value " + count);
|
||||
if (count % interval == 0) {
|
||||
if (onTickListener != null) {
|
||||
onTickListener.onTick();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
tickCache.put(onTickListener, disposable);
|
||||
}
|
||||
@@ -148,8 +151,8 @@ public class RxTimer implements ITimer {
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
for (int i = 0, size = tickCache.size(); i < size; i++) {
|
||||
Disposable disposable = tickCache.valueAt(i);
|
||||
for (Map.Entry<OnTickListener, Disposable> entry : tickCache.entrySet()) {
|
||||
Disposable disposable = entry.getValue();
|
||||
disposable.dispose();
|
||||
}
|
||||
tickCache.clear();
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.Cell;
|
||||
@@ -66,7 +65,7 @@ public abstract class SimpleClickSupport {
|
||||
|
||||
private static final int MODIFIERS_IGNORE = Modifier.ABSTRACT | Modifier.STATIC | BRIDGE | SYNTHETIC;
|
||||
|
||||
private final Map<Class<?>, OnClickMethod> mOnClickMethods = new ArrayMap<>();
|
||||
private final Map<Class<?>, OnClickMethod> mOnClickMethods = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean optimizedMode;
|
||||
|
||||
|
||||
@@ -24,20 +24,16 @@
|
||||
|
||||
package com.tmall.wireless.tangram.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.tmall.wireless.tangram.TangramBuilder;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -51,7 +47,7 @@ public class Utils {
|
||||
private static final Pattern REGEX_2 = Pattern.compile("(\\d+)-(\\d+)(_?q\\d+)?(\\.[jpg|png|gif])");
|
||||
|
||||
public static <K, V> Map<K, V> newMap(K k1, V v1, K k2, V v2) {
|
||||
ArrayMap<K, V> map = new ArrayMap<>();
|
||||
ConcurrentHashMap<K, V> map = new ConcurrentHashMap<>();
|
||||
map.put(k1, v1);
|
||||
map.put(k2, v2);
|
||||
return map;
|
||||
@@ -116,7 +112,7 @@ public class Utils {
|
||||
return Float.NaN;
|
||||
}
|
||||
|
||||
private static ArrayMap<String, Pair<Integer, Integer>> imageSizeMap = new ArrayMap<>();
|
||||
private static ConcurrentHashMap<String, Pair<Integer, Integer>> imageSizeMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
||||
Reference in New Issue
Block a user