mirror of
https://github.com/alibaba/Tangram-Android.git
synced 2026-10-18 05:40:45 +08:00
Add interface for render service to supple component info.
This commit is contained in:
@@ -67,10 +67,10 @@ public class DemoListActivity extends ListActivity {
|
||||
bizItems.put("name", "自定义数据解析");
|
||||
bizItems.put("class", TangramDataParserActivity.class.getName());
|
||||
list.add(bizItems);
|
||||
// HashMap<String, String> tangram3Items = new HashMap<String, String>();
|
||||
// tangram3Items.put("name", "Tangram 3.0 (beta)");
|
||||
// tangram3Items.put("class", Tangram3Activity.class.getName());
|
||||
// list.add(tangram3Items);
|
||||
HashMap<String, String> tangram3Items = new HashMap<String, String>();
|
||||
tangram3Items.put("name", "Tangram 3.0 (beta)");
|
||||
tangram3Items.put("class", Tangram3Activity.class.getName());
|
||||
list.add(tangram3Items);
|
||||
ListAdapter listAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1});
|
||||
setListAdapter(listAdapter);
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ org.gradle.jvmargs=-Xmx1536M
|
||||
GROUP=com.alibaba.android
|
||||
ARTIFACT=tangram
|
||||
VERSION=1
|
||||
VERSION_NAME=3.5.0
|
||||
VERSION_NAME=3.5.1
|
||||
PACKAGING_TYPE=aar
|
||||
systemProp.compileSdkVersion=26
|
||||
systemProp.targetSdkVersion=26
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.tmall.wireless.tangram3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -144,4 +143,19 @@ public class ComponentRenderManager {
|
||||
public Map<String, ComponentInfo> getComponentInfoMap() {
|
||||
return componentInfoMap;
|
||||
}
|
||||
|
||||
public ComponentInfo supplementComponentInfo(String cellType) {
|
||||
ComponentInfo componentInfo = null;
|
||||
if (componentInfoMap.containsKey(cellType)) {
|
||||
componentInfo = componentInfoMap.get(cellType);
|
||||
} else {
|
||||
for (ElementRenderService renderService : renderServiceMap.values()) {
|
||||
componentInfo = renderService.supplementComponentInfo(cellType);
|
||||
if (componentInfo != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return componentInfo;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.tmall.wireless.tangram3.TangramEngine;
|
||||
import com.tmall.wireless.tangram3.dataparser.concrete.ComponentInfo;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ElementRenderService {
|
||||
@@ -21,6 +20,17 @@ public abstract class ElementRenderService {
|
||||
|
||||
abstract public void unmountView(JSONObject json, View view);
|
||||
|
||||
/**
|
||||
* Tangram would call this method to ask renderService supple component info
|
||||
* when the data json does not have a component info.
|
||||
*
|
||||
* @param cellType
|
||||
* @return
|
||||
*/
|
||||
public ComponentInfo supplementComponentInfo(String cellType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract public void destroy();
|
||||
|
||||
abstract public String getSDKBizName();
|
||||
|
||||
+7
-6
@@ -683,11 +683,12 @@ public class PojoDataParser extends DataParser<JSONObject, JSONArray> {
|
||||
checkCardResolverAndMVHelper(serviceManager);
|
||||
|
||||
String cellType = parseCellType(data);
|
||||
if (mvHelper.renderManager().getComponentInfoMap().containsKey(cellType)) {
|
||||
if (componentInfoMap == null) {
|
||||
componentInfoMap = new HashMap<>();
|
||||
}
|
||||
componentInfoMap.put(cellType, mvHelper.renderManager().getComponentInfoMap().get(cellType));
|
||||
if (componentInfoMap == null) {
|
||||
componentInfoMap = new HashMap<>();
|
||||
}
|
||||
ComponentInfo componentInfo = mvHelper.renderManager().supplementComponentInfo(cellType);
|
||||
if (componentInfo != null) {
|
||||
componentInfoMap.put(cellType, componentInfo);
|
||||
}
|
||||
|
||||
BaseCell cell = createCell(parent, mvHelper, data, serviceManager, componentInfoMap);
|
||||
@@ -797,7 +798,7 @@ public class PojoDataParser extends DataParser<JSONObject, JSONArray> {
|
||||
}
|
||||
|
||||
protected BaseCell createCell(@Nullable Card parent, @NonNull MVHelper resolver, @NonNull JSONObject cellData,
|
||||
@NonNull ServiceManager serviceManager, Map<String, ComponentInfo> componentInfoMap) {
|
||||
@NonNull ServiceManager serviceManager, Map<String, ComponentInfo> componentInfoMap) {
|
||||
BaseCell cell = null;
|
||||
String cellType = parseCellType(cellData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user