If i wrap a View and the wrapper extends ViewWrapper and also implements DesignerCustomView then whereabouts in the wrapper do i create the wrapped View?
If the wrapper does not implement DesignerCustomView then i'd do something like:
And if i was to implement DesignerCustomView but not extend ViewWrapper then:
Currently my class that extends ViewWrapper and implements DesignerCustomView is:
My comments 'create new View here?' shows where i'm confused.
Whereabouts is best to create the new wrapped View?
Thanks.
If the wrapper does not implement DesignerCustomView then i'd do something like:
B4X:
@BA.ActivityObject
@BA.ShortName("ScannerLiveView")
public class ScannerLiveViewWrapper extends ViewWrapper<ScannerLiveView>{
@Override
public void Initialize(BA ba, String EventName) {
super.Initialize(ba, EventName);
}
@Override
public void innerInitialize(BA ba, String eventName, boolean keepOldObject) {
if(!keepOldObject){
setObject(new ScannerLiveView(ba.context));
keepOldObject=true;
}
super.innerInitialize(ba, eventName, keepOldObject);
}
}
And if i was to implement DesignerCustomView but not extend ViewWrapper then:
B4X:
@BA.ActivityObject
@BA.ShortName("ScannerLiveView")
public class ScannerLiveViewWrapper implements Common.DesignerCustomView {
private ScannerLiveView scannerLiveView;
private void addToParent(ViewGroup viewGroup, @BA.Pixel int left, @BA.Pixel int top, @BA.Pixel int width, @BA.Pixel int height) {
viewGroup.addView(scannerLiveView, new BALayout.LayoutParams(left, top, width, height));
}
@Override
public void DesignerCreateView(PanelWrapper panelWrapper, LabelWrapper labelWrapper, Map map) {
ViewGroup localViewGroup = (ViewGroup) panelWrapper.getObject().getParent();
addToParent(localViewGroup, panelWrapper.getLeft(), panelWrapper.getTop(), panelWrapper.getWidth(), panelWrapper.getHeight());
panelWrapper.RemoveView();
}
@BA.Hide
@Override
public void _initialize(BA ba, Object activityClass, String eventName) {
scannerLiveView=new ScannerLiveView(ba.context);
}
public void Initialize(BA ba, String EventName) {
_initialize(ba, null, EventName);
}
}
Currently my class that extends ViewWrapper and implements DesignerCustomView is:
B4X:
@BA.ActivityObject
@BA.ShortName("ScannerLiveView")
public class ScannerLiveViewWrapper extends ViewWrapper<ScannerLiveView> implements Common.DesignerCustomView {
private void addToParent(ViewGroup viewGroup, @BA.Pixel int left, @BA.Pixel int top, @BA.Pixel int width, @BA.Pixel int height) {
viewGroup.addView(getObject(), new BALayout.LayoutParams(left, top, width, height));
}
@Override
public void DesignerCreateView(PanelWrapper panelWrapper, LabelWrapper labelWrapper, Map map) {
ViewGroup localViewGroup = (ViewGroup) panelWrapper.getObject().getParent();
addToParent(localViewGroup, panelWrapper.getLeft(), panelWrapper.getTop(), panelWrapper.getWidth(), panelWrapper.getHeight());
panelWrapper.RemoveView();
}
@BA.Hide
@Override
// create new View here?
setObject(new ScannerLiveView(ba.context));
}
@Override
public void Initialize(BA ba, String EventName) {
super.Initialize(ba, EventName);
}
@Override
public void innerInitialize(BA ba, String eventName, boolean keepOldObject) {
if(!keepOldObject){
// create new View here?
setObject(new ScannerLiveView(ba.context));
keepOldObject=true;
}
super.innerInitialize(ba, eventName, keepOldObject);
}
}
My comments 'create new View here?' shows where i'm confused.
Whereabouts is best to create the new wrapped View?
Thanks.