feat: appbar attributes
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.stardust.autojs.core.ui.attribute;
|
||||
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.autojs.core.ui.inflater.ResourceParser;
|
||||
|
||||
public class AppbarAttributes extends ViewAttributes {
|
||||
public AppbarAttributes(ResourceParser resourceParser, View view) {
|
||||
super(resourceParser, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRegisterAttrs() {
|
||||
super.onRegisterAttrs();
|
||||
registerPixelAttr("elevation", getView()::setTargetElevation);
|
||||
registerBooleanAttr("expanded", getView()::setExpanded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppBarLayout getView() {
|
||||
return (AppBarLayout) super.getView();
|
||||
}
|
||||
}
|
||||
@@ -351,10 +351,18 @@ public class ViewAttributes {
|
||||
this::parseDrawable, applier)));
|
||||
}
|
||||
|
||||
protected void registerPixelAttr(String name, ValueApplier<Float> applier) {
|
||||
registerAttr(name, this::parseDimensionToPixel, applier);
|
||||
}
|
||||
|
||||
protected void registerIntPixelAttr(String name, ValueApplier<Integer> applier) {
|
||||
registerAttr(name, this::parseDimensionToIntPixel, applier);
|
||||
}
|
||||
|
||||
protected void registerIdAttr(String name, ValueApplier<Integer> applier) {
|
||||
registerAttr(name, Ids::parse, applier);
|
||||
}
|
||||
|
||||
protected void registerBooleanAttr(String name, ValueApplier<Boolean> applier) {
|
||||
registerAttr(name, Boolean::parseBoolean, applier);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.stardust.autojs.core.ui.attribute;
|
||||
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stardust.autojs.core.ui.inflater.ResourceParser;
|
||||
|
||||
@@ -17,6 +20,8 @@ public class ViewAttributesFactory {
|
||||
|
||||
static {
|
||||
sViewAttributesCreators.put(ImageView.class, ImageViewAttributes::new);
|
||||
sViewAttributesCreators.put(AppBarLayout.class, AppbarAttributes::new);
|
||||
sViewAttributesCreators.put(TextView.class, TextViewAttributes::new);
|
||||
}
|
||||
|
||||
public static void put(Class<? extends View> clazz, ViewAttributesCreator creator) {
|
||||
|
||||
@@ -30,6 +30,12 @@ import java.util.Map;
|
||||
|
||||
public class TextViewInflater<V extends TextView> extends BaseViewInflater<V> {
|
||||
|
||||
private static final int LEFT = 0;
|
||||
private static final int TOP = 1;
|
||||
private static final int RIGHT = 2;
|
||||
private static final int BOTTOM = 3;
|
||||
|
||||
|
||||
private static final ValueMapper<Integer> AUTO_LINK_MASKS = new ValueMapper<Integer>("autoLink")
|
||||
.map("all", Linkify.ALL)
|
||||
.map("email", Linkify.EMAIL_ADDRESSES)
|
||||
@@ -368,6 +374,18 @@ public class TextViewInflater<V extends TextView> extends BaseViewInflater<V> {
|
||||
mAutoText = false;
|
||||
}
|
||||
|
||||
private void setDrawable(V view, int d) {
|
||||
Drawable[] drawables = view.getCompoundDrawables();
|
||||
view.setCompoundDrawables(
|
||||
mDrawableLeft != null ? mDrawableLeft : drawables[0],
|
||||
mDrawableTop != null ? mDrawableTop : drawables[1],
|
||||
mDrawableRight != null ? mDrawableRight : drawables[2],
|
||||
mDrawableBottom != null ? mDrawableBottom : drawables[3]
|
||||
);
|
||||
mDrawableLeft = mDrawableBottom = mDrawableRight = mDrawableTop = null;
|
||||
}
|
||||
|
||||
|
||||
private void setDrawables(V view) {
|
||||
Drawable[] drawables = view.getCompoundDrawables();
|
||||
view.setCompoundDrawables(
|
||||
|
||||
Reference in New Issue
Block a user