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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
longerian committed Dec 12, 2017
2 parents 50fa95d + 96cc8d3 commit 3b56075
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 6 deletions.
29 changes: 29 additions & 0 deletions examples/src/main/assets/data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
[
{
"type": "container-oneColumn",
"items": [
{
"imgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"arrowImgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"title": "标题1",
"type": "vvtest"
},
{
"imgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"arrowImgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"title": "标题2",
"type": "vvtest"
},
{
"imgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"arrowImgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"title": "标题3",
"type": "vvtest"
},
{
"imgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"arrowImgUrl": "https://gw.alicdn.com/tfs/TB1vqF.PpXXXXaRaXXXXXXXXXXX-110-72.png",
"title": "标题4",
"type": "vvtest"
}
]
},
{
"id": "banner1",
"type": 1,
Expand Down
75 changes: 75 additions & 0 deletions examples/src/main/assets/vvtest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2017 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<FrameLayout
flag="flag_exposure|flag_clickable"
action="action"
layoutWidth="match_parent"
layoutHeight="84rp"
background="#FFFFFF">

<NImage
layoutWidth="48rp"
layoutHeight="48rp"
layoutMarginLeft="34rp"
layoutGravity="left|v_center"
src="${imgUrl}"
scaleType="center_crop"
/>
<NText
layoutWidth="wrap_content"
layoutHeight="wrap_content"
layoutMarginLeft="94rp"
text="${title}"
layoutGravity="left|v_center"
textSize="28rp"
textColor="#555555"
/>
<NText
layoutWidth="wrap_content"
layoutHeight="wrap_content"
layoutMarginRight="50rp"
layoutGravity="right|v_center"
textSize="28rp"
text="${subtitle}"
textColor="${subtitleColor}"/>
<NImage
layoutWidth="14rp"
layoutHeight="30rp"
layoutMarginRight="28rp"
layoutGravity="right|v_center"
src="${arrowImgUrl}"
scaleType="center_crop"
/>

<NLine
layoutWidth="680rp"
layoutHeight="1rp"
orientation="H"
layoutGravity="h_center|bottom"
src="${lineImgUrl}"
color="#999999"
/>
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
package com.tmall.wireless.tangram.example;

import com.alibaba.android.vlayout.Range;

import com.libra.Utils;
import com.squareup.picasso.Picasso;
import com.tmall.wireless.tangram.TangramBuilder;
import com.tmall.wireless.tangram.TangramEngine;
Expand All @@ -36,6 +38,7 @@
import com.tmall.wireless.tangram.example.data.TestView;
import com.tmall.wireless.tangram.example.data.TestViewHolder;
import com.tmall.wireless.tangram.example.data.TestViewHolderCell;
import com.tmall.wireless.tangram.example.data.VVTEST;
import com.tmall.wireless.tangram.example.support.SampleClickSupport;
import com.tmall.wireless.tangram.structure.BaseCell;
import com.tmall.wireless.tangram.structure.viewcreator.ViewHolderCreator;
Expand All @@ -44,6 +47,7 @@
import com.tmall.wireless.tangram.support.async.CardLoadSupport;
import com.tmall.wireless.tangram.util.IInnerImageSetter;

import com.tmall.wireless.vaf.framework.VafContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -117,8 +121,12 @@ public <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view,
TestViewHolderCell.class,
new ViewHolderCreator<>(R.layout.item_holder, TestViewHolder.class, TextView.class));
builder.registerCell(199,SingleImageView.class);
builder.registerVirtualView("vvtest");
//Step 4: new engine
engine = builder.build();
engine.setVirtualViewTemplate(VVTEST.BIN);
Utils.setUedScreenWidth(720);
VafContext.loadImageLoader(getApplicationContext());

//Step 5: add card load support if you have card that loading cells async
engine.addCardLoadSupport(new CardLoadSupport(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.tmall.wireless.tangram.example.data;

public class VVTEST{
public static final byte[] BIN = new byte[] {
65, 76, 73, 86, 86, 0, 1, 0, 0, 0, 1, 0, 0, 0, 47, 0, 0, 1, 120, 0, 0, 1, -89, 0, 0, 0, 107, 0, 0, 2, 22, 0, 0, 0, 0, 0, 0, 2, 26, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 6, 118, 118, 116, 101, 115, 116, 1, 106, 0, 0, 1, 3, 0, 47, -1, 108, 0, 0, 0, 48, -80, -104, 85, 46, -1, -1, -1, -1, 119, 112, -84, -68, -1, -1, -1, -1, 1, 92, -43, -16, -15, 0, 0, 0, 84, 0, 0, 1, -85, 47, 126, 54, -85, 47, 126, 54, 0, 0, 0, 0, 9, 2, 30, -57, 11, -60, 0, 0, 0, 33, -112, 17, 87, -92, 0, 0, 0, 6, 3, 74, 110, 125, -97, 0, 0, 0, 34, 92, -43, -16, -15, 0, 0, 0, 48, 119, 112, -84, -68, 0, 0, 0, 48, 0, 0, 1, 0, 1, -67, -28, 53, 18, -122, -102, 0, 0, 1, 0, 0, 7, 4, 30, -57, 11, -60, 0, 0, 0, 33, 92, -43, -16, -15, -1, -1, -1, -2, 119, 112, -84, -68, -1, -1, -1, -2, -64, -101, 46, 54, -1, 85, 85, 85, 2, 74, 110, 125, -97, 0, 0, 0, 94, -60, 45, 58, -50, 0, 0, 0, 28, 0, 0, 1, 0, 54, 69, 45, -46, 56, -16, -68, 0, 0, 1, 0, 0, 7, 3, 30, -57, 11, -60, 0, 0, 0, 34, 92, -43, -16, -15, -1, -1, -1, -2, 119, 112, -84, -68, -1, -1, -1, -2, 2, 3, -73, -105, -124, 0, 0, 0, 50, -60, 45, 58, -50, 0, 0, 0, 28, 0, 0, 2, 0, 54, 69, 45, 112, 44, -76, 110, -64, -101, 46, 54, 82, -82, -60, 73, 0, 0, 1, 0, 0, 9, 2, 30, -57, 11, -60, 0, 0, 0, 34, -112, 17, 87, -92, 0, 0, 0, 6, 3, 3, -73, -105, -124, 0, 0, 0, 28, 92, -43, -16, -15, 0, 0, 0, 30, 119, 112, -84, -68, 0, 0, 0, 14, 0, 0, 1, 0, 1, -67, -28, -59, -45, 13, 95, 0, 0, 1, 0, 0, 13, 3, -86, 50, -11, -48, 0, 0, 0, 1, 30, -57, 11, -60, 0, 0, 0, 20, 5, -89, 47, 99, -1, -103, -103, -103, 2, 92, -43, -16, -15, 0, 0, 0, 1, 119, 112, -84, -68, 0, 0, 2, -88, 0, 0, 1, 0, 1, -67, -28, -58, 27, -121, -122, 0, 0, 1, 1, 0, 0, 0, 6, 112, 44, -76, 110, 0, 11, 36, 123, 115, 117, 98, 116, 105, 116, 108, 101, 125, -46, 56, -16, -68, 0, 8, 36, 123, 116, 105, 116, 108, 101, 125, 53, 18, -122, -102, 0, 9, 36, 123, 105, 109, 103, 85, 114, 108, 125, -59, -45, 13, 95, 0, 14, 36, 123, 97, 114, 114, 111, 119, 73, 109, 103, 85, 114, 108, 125, -58, 27, -121, -122, 0, 13, 36, 123, 108, 105, 110, 101, 73, 109, 103, 85, 114, 108, 125, 82, -82, -60, 73, 0, 16, 36, 123, 115, 117, 98, 116, 105, 116, 108, 101, 67, 111, 108, 111, 114, 125, 0, 0, 0, 0,
};
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
GROUP=com.alibaba.android
ARTIFACT=tangram
VERSION=1
VERSION_NAME=2.0.1
VERSION_NAME=2.0.2
PACKAGING_TYPE=aar
systemProp.compileSdkVersion=23
systemProp.targetSdkVersion=23
Expand Down
2 changes: 1 addition & 1 deletion tangram/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ configurations.all {

dependencies {

compile('com.alibaba.android:vlayout:1.2.6@aar') {
compile('com.alibaba.android:vlayout:1.2.6.1@aar') {
changing = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ protected void renderLayout(BaseCell cell, View view) {
ViewGroup.LayoutParams lp = view.getLayoutParams();

if (lp == null || !(lp instanceof VirtualLayoutManager.LayoutParams)) {
lp = new VirtualLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
if (lp == null) {
lp = new VirtualLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
} else {
lp = new VirtualLayoutManager.LayoutParams(lp.width, lp.height);
}
view.setLayoutParams(lp);
}
if (lp instanceof VirtualLayoutManager.LayoutParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public V createView(Context context, ViewGroup parent) {
} else if (mViewCreator != null) {
v = mViewCreator.create(context, parent);
} else {
v = (V) mMvHelper.getVafContext().getContainerService().getContainer(type, false);
v = (V) mMvHelper.getVafContext().getContainerService().getContainer(type, true);
}
if (v.getId() <= 0) {
v.setId(R.id.TANGRAM_VIEW_CONTAINER_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.tmall.wireless.tangram.support.PageDetectorSupport;
import com.tmall.wireless.vaf.framework.ViewManager;
import java.lang.annotation.Inherited;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -372,13 +373,37 @@ public void removeComponent(BaseCell component) {
@Override
public void insertComponents(int pos, List<BaseCell> components) {
if (mData != null && components != null && !components.isEmpty() && pos > 0) {
for (int i = 0; i < components.size(); i++) {
int newItemSize = components.size();
if (mCards != null) {
List<Pair<Range<Integer>, Card>> newCards = new ArrayList<>();
int clickPos = pos -1;
for (int i = 0, size = mCards.size(); i < size; i++) {
Pair<Range<Integer>, Card> pair = mCards.get(i);
int start = pair.first.getLower().intValue();
int end = pair.first.getUpper().intValue();
if (end < clickPos) {
//do nothing
newCards.add(pair);
} else if (start <= clickPos && clickPos <= end) {
Pair<Range<Integer>, Card> newPair = new Pair<>(Range.create(start, end + newItemSize), pair.second);
newCards.add(newPair);
} else if (clickPos < start) {
Pair<Range<Integer>, Card> newPair = new Pair<>(Range.create(start + newItemSize, end + newItemSize), pair.second);
newCards.add(newPair);
}
}
mCards.clear();
mCards.addAll(newCards);
}
for (int i = 0; i < newItemSize; i++) {
if ((pos + i) < mData.size()) {
mData.add(pos + i, components.get(i));
} else {
mData.add(components.get(i));
}
}
notifyItemRangeInserted(pos, newItemSize);
}
notifyItemRangeInserted(pos, components.size());
}

@Override
Expand Down

0 comments on commit 3b56075

Please sign in to comment.