mirror of
https://github.com/alibaba/Tangram-Android.git
synced 2026-10-17 05:07:05 +08:00
Merge branch 'develop'
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@
|
||||
GROUP=com.alibaba.android
|
||||
ARTIFACT=tangram
|
||||
VERSION=1
|
||||
VERSION_NAME=2.0.5
|
||||
VERSION_NAME=2.0.6
|
||||
PACKAGING_TYPE=aar
|
||||
systemProp.compileSdkVersion=23
|
||||
systemProp.targetSdkVersion=23
|
||||
|
||||
+44
-10
@@ -83,25 +83,54 @@ configurations.all {
|
||||
|
||||
dependencies {
|
||||
|
||||
compile('com.alibaba.android:vlayout:1.2.7@aar') {
|
||||
changing = true
|
||||
if (project.hasProperty('vlayoutDevMode')) {
|
||||
println 'compile with vlayout source code'
|
||||
compile (project(':vlayout')) {
|
||||
exclude group: 'com.android.support', module: 'recyclerview-v7'
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
}
|
||||
} else {
|
||||
compile('com.alibaba.android:vlayout:1.2.9@aar') {
|
||||
changing = true
|
||||
}
|
||||
}
|
||||
|
||||
compile 'com.android.support:recyclerview-v7:23.1.1@aar'
|
||||
compile 'com.android.support:support-v4:23.1.1@aar'
|
||||
compile 'com.android.support:support-annotations:23.1.1'
|
||||
compile 'com.alibaba.android:ultraviewpager:1.0.6.5@aar'
|
||||
|
||||
if (project.hasProperty('ultraViewPagerDevMode')) {
|
||||
println 'compile with ultraViewPager source code'
|
||||
compile project(':ultraviewpager')
|
||||
} else {
|
||||
compile 'com.alibaba.android:ultraviewpager:1.0.6.5@aar'
|
||||
}
|
||||
|
||||
compile('me.everything:overscroll-decor-android:1.0.1@aar') {
|
||||
transitive true
|
||||
exclude group: 'com.android.support', module: 'recyclerview-v7'
|
||||
}
|
||||
compile('com.alibaba.android:virtualview:1.0.5@aar') {
|
||||
transitive true
|
||||
exclude group: 'com.android.support', module: 'appcompat-v7'
|
||||
exclude group: 'com.tmall.android', module: 'tmallandroid_mui'
|
||||
exclude group: 'com.google.android', module: 'support-v7-recyclerview'
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
|
||||
if (project.hasProperty('virtualViewDevMode')) {
|
||||
println 'compile with virtualview source code'
|
||||
compile(project(':virtualview')) {
|
||||
|
||||
exclude group: 'com.android.support', module: 'appcompat-v7'
|
||||
exclude group: 'com.tmall.android', module: 'tmallandroid_mui'
|
||||
exclude group: 'com.google.android', module: 'support-v7-recyclerview'
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
}
|
||||
} else {
|
||||
compile('com.alibaba.android:virtualview:1.0.5@aar') {
|
||||
transitive true
|
||||
exclude group: 'com.android.support', module: 'appcompat-v7'
|
||||
exclude group: 'com.tmall.android', module: 'tmallandroid_mui'
|
||||
exclude group: 'com.google.android', module: 'support-v7-recyclerview'
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -115,3 +144,8 @@ deployConfig = rootProject.file('jcenterDeploy.gradle')
|
||||
if (deployConfig.exists()) {
|
||||
apply from: rootProject.file('jcenterDeploy.gradle')
|
||||
}
|
||||
|
||||
deployConfig = rootProject.file('deploy.gradle')
|
||||
if (deployConfig.exists()) {
|
||||
apply from: rootProject.file('deploy.gradle')
|
||||
}
|
||||
@@ -31,10 +31,12 @@ 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.util.Pair;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.alibaba.android.vlayout.LayoutViewFactory;
|
||||
import com.alibaba.android.vlayout.Range;
|
||||
import com.alibaba.android.vlayout.VirtualLayoutManager;
|
||||
import com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams;
|
||||
import com.alibaba.android.vlayout.extend.InnerRecycledViewPool;
|
||||
@@ -45,6 +47,7 @@ import com.tmall.wireless.tangram.dataparser.IAdapterBuilder;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.BaseCardBinderResolver;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinder;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.Card;
|
||||
import com.tmall.wireless.tangram.dataparser.concrete.CardResolver;
|
||||
import com.tmall.wireless.tangram.eventbus.BusSupport;
|
||||
import com.tmall.wireless.tangram.structure.BaseCell;
|
||||
@@ -80,15 +83,15 @@ public class BaseTangramEngine<T, C, L> implements ServiceManager {
|
||||
|
||||
private final VirtualLayoutManager mLayoutManager;
|
||||
|
||||
protected GroupBasicAdapter<C, ?> mGroupBasicAdapter;
|
||||
protected GroupBasicAdapter<C, L> mGroupBasicAdapter;
|
||||
|
||||
private final DataParser<T, C, L> mDataParser;
|
||||
|
||||
private final IAdapterBuilder<C, ?> mAdapterBuilder;
|
||||
private final IAdapterBuilder<C, L> mAdapterBuilder;
|
||||
|
||||
public BaseTangramEngine(@NonNull final Context context,
|
||||
@NonNull final DataParser<T, C, L> dataParser,
|
||||
@NonNull final IAdapterBuilder<C, ?> adapterBuilder) {
|
||||
@NonNull final IAdapterBuilder<C, L> adapterBuilder) {
|
||||
//noinspection ConstantConditions
|
||||
Preconditions.checkArgument(context != null, "context is null");
|
||||
this.mContext = context;
|
||||
@@ -358,6 +361,94 @@ public class BaseTangramEngine<T, C, L> implements ServiceManager {
|
||||
this.mGroupBasicAdapter.replaceGroup(position, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a card at target card position
|
||||
* @param position the position of card in group
|
||||
*/
|
||||
public void removeData(int position) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
this.mGroupBasicAdapter.removeGroup(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the target card from list
|
||||
* @param data Target card
|
||||
*/
|
||||
public void removeData(C data) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
this.mGroupBasicAdapter.removeGroup(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param card
|
||||
* @return card ragne of given instance
|
||||
*/
|
||||
public Range<Integer> getCardRange(Card card) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.getCardRange(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get card range by id
|
||||
* @param id card id
|
||||
* @return range instance
|
||||
*/
|
||||
public Range<Integer> getCardRange(String id) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.getCardRange(id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param position cell's adapter position
|
||||
* @return the card index of given cell's position
|
||||
*/
|
||||
public int findCardIdxFor(int position) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.findCardIdxFor(position);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cell cell object
|
||||
* @return the card index of given cell object
|
||||
*/
|
||||
public int findCardIdxFor(L cell) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.findCardIdxFor(cell);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id card id
|
||||
* @return card instance
|
||||
*/
|
||||
public Card getCardById(String id) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.getCardById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type cell's type
|
||||
* @return last appearance position
|
||||
*/
|
||||
public int findLastPositionOfCell(String type) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.findLastPositionOfCell(type);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type cell's type
|
||||
* @return first appearance position
|
||||
*/
|
||||
public int findFirstPositionOfCell(String type) {
|
||||
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
|
||||
return this.mGroupBasicAdapter.findFirstPositionOfCell(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse original data with type {@link T} into model data list with type {@link C}
|
||||
* @param data Original data.
|
||||
|
||||
@@ -388,10 +388,10 @@ public class MVHelper {
|
||||
|
||||
if (lp instanceof ViewGroup.MarginLayoutParams) {
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) lp;
|
||||
layoutParams.topMargin = cell.style.margin[MARGIN_TOP_INDEX] >= 0 ? cell.style.margin[MARGIN_TOP_INDEX] : 0;
|
||||
layoutParams.leftMargin = cell.style.margin[MARGIN_LEFT_INDEX] >= 0 ? cell.style.margin[MARGIN_LEFT_INDEX] : 0;
|
||||
layoutParams.bottomMargin = cell.style.margin[MARGIN_BOTTOM_INDEX] >= 0 ? cell.style.margin[MARGIN_BOTTOM_INDEX] : 0;
|
||||
layoutParams.rightMargin = cell.style.margin[MARGIN_RIGHT_INDEX] >= 0 ? cell.style.margin[MARGIN_RIGHT_INDEX] : 0;
|
||||
layoutParams.topMargin = cell.style.margin[MARGIN_TOP_INDEX];
|
||||
layoutParams.leftMargin = cell.style.margin[MARGIN_LEFT_INDEX];
|
||||
layoutParams.bottomMargin = cell.style.margin[MARGIN_BOTTOM_INDEX];
|
||||
layoutParams.rightMargin = cell.style.margin[MARGIN_RIGHT_INDEX];
|
||||
}
|
||||
|
||||
// reset translation animation before reused
|
||||
|
||||
@@ -152,6 +152,7 @@ public class MVResolver {
|
||||
if (!TextUtils.isEmpty(reuseId)) {
|
||||
cell.typeKey = reuseId;
|
||||
}
|
||||
cell.position = json.optInt(KEY_POSITION, -1);
|
||||
parseBizParams(cell, json);
|
||||
cell.parseWith(json);
|
||||
cell.parseWith(json, resolver);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TangramEngine extends BaseTangramEngine<JSONArray, Card, BaseCell>
|
||||
|
||||
public TangramEngine(@NonNull Context context,
|
||||
@NonNull DataParser<JSONArray, Card, BaseCell> dataParser,
|
||||
@NonNull IAdapterBuilder<Card, ?> adapterBuilder) {
|
||||
@NonNull IAdapterBuilder<Card, BaseCell> adapterBuilder) {
|
||||
super(context, dataParser, adapterBuilder);
|
||||
this.register(DataParser.class, dataParser);
|
||||
mTangramExprSupport = new TangramExprSupport();
|
||||
|
||||
+44
-1
@@ -344,6 +344,16 @@ public abstract class GroupBasicAdapter<L, C> extends VirtualLayoutAdapter<Binde
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cell cell object
|
||||
* @return the card index of given cell object
|
||||
*/
|
||||
public int findCardIdxFor(C cell) {
|
||||
int position = mData.indexOf(cell);
|
||||
return findCardIdxFor(position);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get type of card
|
||||
@@ -354,7 +364,35 @@ public abstract class GroupBasicAdapter<L, C> extends VirtualLayoutAdapter<Binde
|
||||
@Deprecated
|
||||
public abstract int getCardType(L card);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get card range by id
|
||||
* @param id card id
|
||||
* @return range instance
|
||||
*/
|
||||
public abstract Range<Integer> getCardRange(String id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id card id
|
||||
* @return card instance
|
||||
*/
|
||||
public abstract Card getCardById(String id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type cell's type
|
||||
* @return last appearance position
|
||||
*/
|
||||
public abstract int findLastPositionOfCell(String type);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type cell's type
|
||||
* @return first appearance position
|
||||
*/
|
||||
public abstract int findFirstPositionOfCell(String type);
|
||||
|
||||
/**
|
||||
* Get type of card in String type
|
||||
*
|
||||
* @param card
|
||||
@@ -362,6 +400,11 @@ public abstract class GroupBasicAdapter<L, C> extends VirtualLayoutAdapter<Binde
|
||||
*/
|
||||
public abstract String getCardStringType(L card);
|
||||
|
||||
/**
|
||||
* Get Tangram cell type from recyclerView's item type
|
||||
* @param viewType
|
||||
* @return cell type in Tangram
|
||||
*/
|
||||
public abstract String getCellTypeFromItemType(int viewType);
|
||||
|
||||
/**
|
||||
|
||||
+48
@@ -277,6 +277,7 @@ public class PojoGroupBasicAdapter extends GroupBasicAdapter<Card, BaseCell> {
|
||||
return layoutHelpers;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int findFirstPositionOfCell(int type) {
|
||||
List<BaseCell> data = getComponents();
|
||||
int targetPosition = -1;
|
||||
@@ -293,6 +294,24 @@ public class PojoGroupBasicAdapter extends GroupBasicAdapter<Card, BaseCell> {
|
||||
return targetPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findFirstPositionOfCell(String type) {
|
||||
List<BaseCell> data = getComponents();
|
||||
int targetPosition = -1;
|
||||
if (type == null || data == null || data.isEmpty()) {
|
||||
targetPosition = -1;
|
||||
} else {
|
||||
for (int i = 0, size = data.size(); i < size; i++) {
|
||||
if (type.equals(data.get(i).stringType)) {
|
||||
targetPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return targetPosition;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int findLastPositionOfCell(int type) {
|
||||
List<BaseCell> data = getComponents();
|
||||
int targetPosition = -1;
|
||||
@@ -309,6 +328,35 @@ public class PojoGroupBasicAdapter extends GroupBasicAdapter<Card, BaseCell> {
|
||||
return targetPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findLastPositionOfCell(String type) {
|
||||
List<BaseCell> data = getComponents();
|
||||
int targetPosition = -1;
|
||||
if (type == null || data == null || data.isEmpty()) {
|
||||
targetPosition = -1;
|
||||
} else {
|
||||
for (int i = data.size() - 1; i >= 0; i--) {
|
||||
if (type.equals(data.get(i).stringType)) {
|
||||
targetPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return targetPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card getCardById(String id) {
|
||||
List<Card> cards = getGroups();
|
||||
for (int i = 0, size = cards.size(); i < size; i++) {
|
||||
if (cards.get(i).id.equals(id)) {
|
||||
return cards.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Range<Integer> getCardRange(String id) {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
return Range.create(0, 0);
|
||||
|
||||
@@ -96,11 +96,65 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
|
||||
@Nullable
|
||||
public String id;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String action;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String pageParam;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String scm;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String spm;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String syncIds;
|
||||
|
||||
/**
|
||||
* the natural position this cell in its parent
|
||||
*/
|
||||
public int pos;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String title;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String subTitle;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public int titleColor = -1;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public int subTitleColor = -1;
|
||||
|
||||
/**
|
||||
* position that assigned from server side
|
||||
*/
|
||||
@@ -132,6 +186,18 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
|
||||
|
||||
private ArrayMap<String, Object> bizParaMap = new ArrayMap<>(32);
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public String imgUrl;
|
||||
|
||||
/**
|
||||
* do not use it, would be removed in future
|
||||
*/
|
||||
//@Deprecated
|
||||
//public float urlRatio = Float.NaN;
|
||||
|
||||
private ArrayMap<Integer, Integer> innerClickMap = new ArrayMap<>();
|
||||
|
||||
@Nullable
|
||||
@@ -218,64 +284,79 @@ public class BaseCell<V extends View> extends ComponentLifecycle implements View
|
||||
}
|
||||
|
||||
public Object optParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.opt(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.opt(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public long optLongParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optLong(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optLong(key);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int optIntParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optInt(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optInt(key);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String optStringParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optString(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optString(key);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public double optDoubleParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optDouble(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optDouble(key);
|
||||
}
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
public boolean optBoolParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optBoolean(key);
|
||||
}
|
||||
return style != null && style.extras != null && style.extras.optBoolean(key);
|
||||
}
|
||||
|
||||
public JSONObject optJsonObjectParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optJSONObject(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optJSONObject(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public JSONArray optJsonArrayParam(String key) {
|
||||
if (extras.has(key))
|
||||
if (extras.has(key)) {
|
||||
return extras.optJSONArray(key);
|
||||
if (style != null && style.extras != null)
|
||||
}
|
||||
if (style != null && style.extras != null) {
|
||||
return style.extras.optJSONArray(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user