package ir.imageslider.ash;
import android.view.ViewGroup;
import com.smarteist.autoimageslider.SliderView;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.keywords.Common.DesignerCustomView;
import anywheresoftware.b4a.objects.LabelWrapper;
import anywheresoftware.b4a.objects.PanelWrapper;
import anywheresoftware.b4a.objects.ViewWrapper;
@ShortName("ShImageSlider")
@Version(1.0f)
@Author("A.Sh")
@DependsOn(values = {"autoimageslider-1.3.9.aar", "glide-3.6.0.jar", "ShImageSlider.aar"})
public class ShImageSlider extends ViewWrapper<SliderView> implements DesignerCustomView {
private BA ba;
private SliderView sv;
public void Initialize(BA ba, String EventName) {
_initialize(ba, null, EventName);
sv = new SliderView(ba.context);
}
@Hide
public void _initialize(BA ba, Object activityClass, String EventName) {
this.ba = ba;
}
public void DesignerCreateView(PanelWrapper base, LabelWrapper lw, anywheresoftware.b4a.objects.collections.Map props) {
ViewGroup vg = (ViewGroup) base.getObject().getParent();
AddToParent(vg, base.getLeft(), base.getTop(), base.getWidth(), base.getHeight());
sv = new SliderView(ba.context);
base.RemoveView();
}
@Hide
public void AddToParent(ViewGroup Parent, @Pixel int left, @Pixel int top, @Pixel int width, @Pixel int height) {
Parent.addView(sv, new BALayout.LayoutParams(left, top, width, height));
}
public void setLeft(int left) {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
lp.left = left;
sv.getParent().requestLayout();
}
public int getLeft() {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
return lp.left;
}
public void setTop(int top) {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
lp.top = top;
sv.getParent().requestLayout();
}
public int getTop() {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
return lp.top;
}
public void setWidth(int Width) {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
lp.width = Width;
sv.getParent().requestLayout();
}
public int getWidth() {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
return lp.width;
}
public void setHeight(int height) {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
lp.height = height;
sv.getParent().requestLayout();
}
public int getHeight() {
BALayout.LayoutParams lp = (BALayout.LayoutParams) sv.getLayoutParams();
return lp.height;
}
}