update DynamicLayoutInflater to lastest version
This commit is contained in:
@@ -43,7 +43,7 @@ public class ReadOnlyUiObject extends UiObject {
|
||||
|
||||
@Override
|
||||
public String className() {
|
||||
return mNodeInfo.className.toString();
|
||||
return mNodeInfo.className;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +53,7 @@ public class ReadOnlyUiObject extends UiObject {
|
||||
|
||||
@Override
|
||||
public String packageName() {
|
||||
return mNodeInfo.packageName.toString();
|
||||
return mNodeInfo.packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nickandjerry.dynamiclayoutinflator.lib.DynamicLayoutInflator;
|
||||
import com.nickandjerry.dynamiclayoutinflator.lib.DynamicLayoutInflater;
|
||||
import com.nickandjerry.dynamiclayoutinflator.lib.util.Drawables;
|
||||
import com.stardust.autojs.core.ui.widget.JsFrameLayout;
|
||||
import com.stardust.autojs.core.ui.xml.XmlConverter;
|
||||
import com.stardust.util.MapEntries;
|
||||
@@ -22,45 +23,13 @@ import java.util.Map;
|
||||
|
||||
public class ConvertLayoutInflater implements JsLayoutInflater {
|
||||
|
||||
static {
|
||||
DynamicLayoutInflator.createViewRunnables();
|
||||
DynamicLayoutInflator.viewRunnables.put("inputType", new DynamicLayoutInflator.ViewParamRunnable() {
|
||||
|
||||
private final Map<String, Integer> mInputTypes = new MapEntries<String, Integer>()
|
||||
.entry("text", InputType.TYPE_CLASS_TEXT)
|
||||
.entry("number", InputType.TYPE_CLASS_NUMBER)
|
||||
.entry("phone", InputType.TYPE_CLASS_PHONE)
|
||||
.entry("datetime", InputType.TYPE_CLASS_DATETIME)
|
||||
.entry("password", InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT)
|
||||
.entry("email", InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT)
|
||||
.entry("date", InputType.TYPE_DATETIME_VARIATION_DATE | InputType.TYPE_CLASS_DATETIME)
|
||||
.entry("time", InputType.TYPE_DATETIME_VARIATION_TIME | InputType.TYPE_CLASS_DATETIME)
|
||||
.map();
|
||||
|
||||
@Override
|
||||
public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
|
||||
if (!(view instanceof TextView))
|
||||
return;
|
||||
TextView textView = (TextView) view;
|
||||
String[] types = value.split("[|]");
|
||||
int inputType = 0;
|
||||
for (String type : types) {
|
||||
if (mInputTypes.containsKey(type)) {
|
||||
inputType |= mInputTypes.get(type);
|
||||
}
|
||||
}
|
||||
if (inputType != 0)
|
||||
textView.setInputType(inputType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View inflate(Context context, String xml) {
|
||||
try {
|
||||
String androidLayoutXml = XmlConverter.convertToAndroidLayout(xml);
|
||||
JsFrameLayout root = new JsFrameLayout(context);
|
||||
DynamicLayoutInflator.inflate(context, androidLayoutXml, root);
|
||||
new DynamicLayoutInflater(context).inflate(androidLayoutXml, root);
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -7,7 +7,8 @@ import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.nickandjerry.dynamiclayoutinflator.lib.DynamicLayoutInflator;
|
||||
import com.nickandjerry.dynamiclayoutinflator.lib.util.Ids;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/14.
|
||||
@@ -17,7 +18,7 @@ public class JsViewHelper {
|
||||
|
||||
@Nullable
|
||||
public static View findViewByStringId(View view, String id) {
|
||||
View result = DynamicLayoutInflator.findViewByIdString(view, id);
|
||||
View result = view.findViewById(Ids.getIdFromName(id));
|
||||
if (result != null)
|
||||
return result;
|
||||
if (!(view instanceof ViewGroup)) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class XmlConverter {
|
||||
.map("button", JsButton.class.getName())
|
||||
.map("text", JsTextView.class.getName())
|
||||
.map("input", JsEditText.class.getName())
|
||||
.map("image", "ImageView")
|
||||
.map("img", "ImageView")
|
||||
);
|
||||
|
||||
private static final AttributeHandler ATTRIBUTE_HANDLER = new AttributeHandler.AttrNameRouter()
|
||||
|
||||
Reference in New Issue
Block a user