Rush • A new and improved way of building extensions

Thats pretty cool. I would recommend using mason for generating project template. This way you would be able to separate template logic.

1 Like

Rush does not support the helper blocks as of now. I haven’t started working on it yet since there’s already a lot on my plate, but they will be available as a part of the next release. If someone’s willing to contribute I’d really appreciate that. :pray:

3 Likes

Hello @Taifun
Like i told before rush doesn’t support that , there are problem to import this :point_down:

import com.google.appinventor.components.common.OptionList;
import com.google.appinventor.components.common.Default;

We appreciate your effort, keep it up :heart:

3 Likes

Hi, I am new to extension creation.
I am facing a problem when I try to build it.
Here the error
image

Here Other things
image

image

image

NOTE: I’m using VS code.
Please help me to solve it
Thank you :heart:

You have whitespace in your PC’s default username (IT SPACE) and Rush doesn’t quite get along with spaces in file paths. However, you can fix this yourself, read the below post:

This isn’t related to your issue but I’d suggest you use IntelliJ IDEA. VS Code fails to index extension libraries in Rush projects, bombarding you with all sorts of false errors. I want to fix this in a future update, but for now, it’s best to use IntelliJ (or Android Studio).

After following this guide I have another issue.

I already have android studio but I don’t know how to use rush on it.

You have JDK 18 on your PATH. Remove it, install JDK 8, and change JDK_HOME env var.

2 Likes

Can you please share the download url.

Currently

image

** Still have the same problem :pensive:**
image

Make sure that you have restarted the terminal. If it still shows the same error, try building with the -r flag, this will invalidate the caches and build the extension afresh.

2 Likes

After rush build -r

:slightly_frowning_face: :slightly_frowning_face:

It looks like for some reason, Rush is still picking JDK 18 to compile your source files. Are you sure you restarted your terminal? If yes, can you try restarting your computer and then building with the -r flag again?

Now only show build faild
image

It’s most likely that your Java installation doesn’t have a JDK (even if the folder says otherwise). Try running javac -version in terminal to confirm this, if it says program not found then you don’t have JDK installed.

You can re-download the correct JDK installer from the link posted earlier in this topic, or try this:

3 Likes

Solved the problem. Thanks @Shreyash to help

if using ide maker extension work but when using rush
i got error with rush what is defferent?

package alfi;

import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ScrollView;

import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;

import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.Component;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.VerticalScrollArrangement;


public class Vsrollhandler extends AndroidNonvisibleComponent implements Component {
    public static final int VERSION = 3;

    private final ComponentContainer container;

    private static final String LOG_TAG = "VerticalScrollHandler";

    private int oldScrollY = 0;

    private boolean userControl = true;

    private boolean scrollBarEnabled = true;

    private boolean fadingEdgeEnabled = true;

    private int overScrollMode = 1;

    private ScrollView scrollView = null;

    public Vsrollhandler(ComponentContainer container) {
        super(container.$form());
        this.container = container;
        Context context = (Context) container.$context();
        Log.d("VerticalScrollHandler", "VerticalScrollHandler Created");
    }

    private float deviceDensity() {
        return this.container.$form().deviceDensity();
    }

    private int px2dx(int px) {
        return Math.round(px * deviceDensity());
    }

    private int dx2px(int dx) {
        return Math.round(dx / deviceDensity());
    }

    private float dx2px(float dx) {
        return dx / deviceDensity();
    }

    @SimpleFunction
    public void RegisterScrollView(VerticalScrollArrangement verticalScrollArrangement) {
        this.scrollView = (ScrollView)verticalScrollArrangement.getView();
        this.scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            public void onScrollChanged() {
                Vsrollhandler.this.onScroll();
            }
        });
        this.scrollView.setOnTouchListener(new View.OnTouchListener() {
            private boolean touchDownDetected = false;

            private int touchDownScrollY = 0;

            private int touchDownPointerId;

            private float touchDownPointerY;

            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getActionMasked();
                if (action == 0) {
                    onTouchDown(event);
                } else if (action == 2) {
                    if (onMove(event))
                        return true;
                } else if (action == 1 || action == 3) {
                    onTouchUp(event);
                }
                return !Vsrollhandler.this.UserControl();
            }

            private void onTouchDown(MotionEvent event) {
                Vsrollhandler.this.TouchDown();
                this.touchDownDetected = true;
                this.touchDownScrollY = Vsrollhandler.this.dx2px(Vsrollhandler.this.scrollView.getScrollY());
                this.touchDownPointerId = Vsrollhandler.this.dx2px(event.getPointerId(0));
                this.touchDownPointerY = Vsrollhandler.this.dx2px(event.getY(0));
            }

            private boolean onMove(MotionEvent event) {
                if (this.touchDownDetected == true) {
                    int currentScrollY = Vsrollhandler.this.dx2px(Vsrollhandler.this.scrollView.getScrollY());
                    float currentPointerY = Vsrollhandler.this.dx2px(event.getY(event.findPointerIndex(this.touchDownPointerId)));
                    if (this.touchDownScrollY <= 0 && currentScrollY <= 0)
                        return Vsrollhandler.this.OverScrollDown(currentPointerY - this.touchDownPointerY);
                    int max = Vsrollhandler.this.MaxScrollPosition();
                    if (this.touchDownScrollY >= max && currentScrollY >= max)
                        return Vsrollhandler.this.OverScrollUp(this.touchDownPointerY - currentPointerY);
                } else {
                    onTouchDown(event);
                    return onMove(event);
                }
                return false;
            }

            private void onTouchUp(MotionEvent event) {
                Vsrollhandler.this.TouchUp();
                this.touchDownDetected = false;
            }
        });
        OverScrollMode(OverScrollMode());
        ScrollBarEnabled(ScrollBarEnabled());
        FadingEdgeEnabled(FadingEdgeEnabled());
    }

    @SimpleEvent
    public void ReachTop() {
        EventDispatcher.dispatchEvent(this, "ReachTop", new Object[0]);
    }

    @SimpleEvent
    public void ReachBottom() {
        EventDispatcher.dispatchEvent(this, "ReachBottom", new Object[0]);
    }

    @SimpleEvent
    public void ScrollChanged(int scrollY) {
        EventDispatcher.dispatchEvent(this, "ScrollChanged", new Object[] { Integer.valueOf(scrollY) });
        if (scrollY == 0) {
            ReachTop();
        } else if (MaxScrollPosition() - ScrollPosition() <= 0) {
            ReachBottom();
        }
    }

    public void onScroll() {
        int scrollY = dx2px(this.scrollView.getScrollY());
        if (scrollY < 0)
            scrollY = 0;
        if (this.oldScrollY != scrollY) {
            ScrollChanged(scrollY);
            this.oldScrollY = scrollY;
        }
    }

    @SimpleEvent
    public void TouchDown() {
        EventDispatcher.dispatchEvent(this, "TouchDown", new Object[0]);
    }

    @SimpleEvent
    public void TouchUp() {
        EventDispatcher.dispatchEvent(this, "TouchUp", new Object[0]);
    }

    @SimpleEvent
    public boolean OverScrollDown(float displacement) {
        if (displacement > 0.0F)
            return EventDispatcher.dispatchEvent(this, "OverScrollDown", new Object[] { Float.valueOf(displacement) });
        return false;
    }

    @SimpleEvent
    public boolean OverScrollUp(float displacement) {
        if (displacement > 0.0F)
            return EventDispatcher.dispatchEvent(this, "OverScrollUp", new Object[] { Float.valueOf(displacement) });
        return false;
    }

    @SimpleProperty
    public boolean UserControl() {
        return this.userControl;
    }

    @SimpleProperty
    public void UserControl(boolean enable) {
        this.userControl = enable;
    }
    @DesignerProperty(editorType = "boolean", defaultValue = "True")


    @SimpleProperty
    public boolean ScrollBarEnabled() {
        return this.scrollBarEnabled;
    }

    @SimpleProperty
    public void ScrollBarEnabled(boolean enabled) {
        this.scrollBarEnabled = enabled;
        if (this.scrollView != null)
            this.scrollView.setVerticalScrollBarEnabled(enabled);
    }
    @DesignerProperty(editorType = "boolean", defaultValue = "True")


    @SimpleProperty
    public boolean FadingEdgeEnabled() {
        return this.fadingEdgeEnabled;
    }

    @SimpleProperty
    public void FadingEdgeEnabled(boolean enabled) {
        this.fadingEdgeEnabled = enabled;
        if (this.scrollView != null)
            this.scrollView.setVerticalFadingEdgeEnabled(enabled);
    }
    @DesignerProperty(editorType = "boolean", defaultValue = "True")


    @SimpleProperty
    public int OverScrollMode() {
        return this.overScrollMode;
    }

    @SimpleProperty(description = "Can be:\n 0: ALWAYS\n1: OVER SCROLL IF CONTENT SCROLLS\n2: NEVER")
    public void OverScrollMode(int mode) {
        if (mode != 0 && mode != 1 && mode != 2)
            mode = 1;
        this.overScrollMode = mode;
    }
    @DesignerProperty(editorType = "non_negative_integer", defaultValue = "1")

    @SimpleProperty
    public int ScrollPosition() {
        int dxPosition = dx2px(this.scrollView.getScrollY());
        if (dxPosition < 0)
            return 0;
        if (dxPosition > MaxScrollPosition())
            return MaxScrollPosition();
        return dxPosition;
    }
    @SimpleProperty
    public int MaxScrollPosition() {
        View view = this.scrollView.getChildAt(this.scrollView.getChildCount() - 1);
        return dx2px(view.getBottom() - this.scrollView.getHeight());
    }

    @SimpleFunction
    public void ScrollTop() {
        if (this.scrollView == null)
            return;
        this.scrollView.fullScroll(33);
    }

    @SimpleFunction
    public void ScrollBottom() {
        if (this.scrollView == null)
            return;
        this.scrollView.fullScroll(130);
    }

    @SimpleFunction
    public void ArrowScrollUpward() {
        if (this.scrollView == null)
            return;
        this.scrollView.arrowScroll(33);
    }

    @SimpleFunction
    public void ArrowScrollDownward() {
        if (this.scrollView == null)
            return;
        this.scrollView.arrowScroll(130);
    }

    @SimpleFunction
    public void PageScrollUpward() {
        if (this.scrollView == null)
            return;
        this.scrollView.pageScroll(33);
    }

    @SimpleFunction
    public void PageScrollDownward() {
        if (this.scrollView == null)
            return;
        this.scrollView.pageScroll(130);
    }

    @SimpleFunction
    public void ScrollTo(int px) {
        if (this.scrollView == null)
            return;
        this.scrollView.scrollTo(0, px2dx(px));
    }

    @SimpleFunction
    public void ScrollBy(int px) {
        if (this.scrollView == null)
            return;
        this.scrollView.scrollBy(0, px2dx(px));
    }

    @SimpleFunction
    public void SmoothScrollTo(int px) {
        if (this.scrollView == null)
            return;
        this.scrollView.smoothScrollTo(0, px2dx(px));
    }

    @SimpleFunction
    public void SmoothScrollBy(int px) {
        if (this.scrollView == null)
            return;
        this.scrollView.smoothScrollBy(0, px2dx(px));
    }
}

erro Annotation@SimpleEventcan't be used on element "ReachTop". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "ReachBottom". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "ScrollChanged". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "TouchDown". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "TouchUp". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "OverScrollDown". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleEventcan't be used on element "OverScrollUp". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "RegisterScrollView". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ScrollTop". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ScrollBottom". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ArrowScrollUpward". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ArrowScrollDownward". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "PageScrollUpward". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "PageScrollDownward". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ScrollTo". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "ScrollBy". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimpleFunctioncan't be used on element "SmoothScrollTo". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimplePropertycan't be used on element "ScrollPosition". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@SimplePropertycan't be used on element "MaxScrollPosition". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@DesignerPropertycan't be used on element "ScrollBarEnabled". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@DesignerPropertycan't be used on element "FadingEdgeEnabled". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@DesignerPropertycan't be used on element "OverScrollMode". It can only be used on members of class "alfi.Alfi".
│ erro Annotation@DesignerPropertycan't be used on element "ScrollPosition". It can only be used on members of class "alfi.Alfi".
└ failed