Hi All!
I'm writing extension (instance used is called TEST1) replacing my procedure made of blocks.
I need a method that manipulates list (light blue block) of numbers (dark blue blocks).
For simplicity let's call it ZListy ( List lista, int nr) - method ZListy manipulates list list using some parameter nr.
It will be called like this:
Thanks a lot.
BTW what environment do you use to develop extensions and how do you import appinventor specific classes (I had some problems adding new repo to Android studio- we'll have to try agn).
b rgds
I use VisualCode to write code. As for the compilation, now I use Rush, when I compiled in AppInventor sources. You need to clone the github repository. The java files must be placed in the correct folder.
Dear @Patryk_F ,
How to add appinventor repos to my java project
Maybe you could share with me sample project ?
I'm new to java and:
a) I can build my 1st app in InteliJ without YailDictionary, YailList and other AppInventor sources
b) I can make simple extention using Rush or Niotron (made a few) - but I have no way to debug them if they contain imports from appinventor (as they are not in public repo's)
So the problem is how to add appinventor repos to my java project...
regards, Kuba
YailDictionary is quite simple similar to standard java HashMap.
So until I find proper solution, I will write and debug HashMap and tweak to fancy YailDictionary...
Sample for rookies like me (hopefully without errors):
package com.sample.t2;
import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.util.YailDictionary;
@DesignerComponent(
version = 1,
description = "test 2 extension",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "")
@SimpleObject(external = true)
//Libraries
@UsesLibraries(libraries = "")
//Permissions
@UsesPermissions(permissionNames = "")
public class T2 extends AndroidNonvisibleComponent {
//Activity and Context
private Context context;
private Activity activity;
private YailDictionary ostatnia = new YailDictionary();
private int someValue = 0;
public T2(ComponentContainer container){
super(container.$form());
this.activity = container.$context();
this.context = container.$context();
someValue = 2;
}
@SimpleFunction(description = "Returns Route")
public YailDictionary Testowa (String zMiejsca, String doMiejsca, double odleglosc) {
YailDictionary wyn = new YailDictionary();
YailDictionary wyn2 = new YailDictionary();
wyn2.put("from",zMiejsca);
wyn2.put("to",doMiejsca);
wyn.put("route",wyn2 );
wyn.put("distance",odleglosc);
ostatnia = new YailDictionary (wyn);
return wyn;
}
@SimpleProperty(category = PropertyCategory.BEHAVIOR, description="Previous route")
public YailDictionary Ostatnia () {
return ostatnia;
}
@SimpleProperty
public void Ostatnia(YailDictionary ostatnia) {
this.ostatnia = ostatnia;
}
// SAMPLES
@SimpleFunction(description = "Sample Function Generated by Niotron")
public int TestFunction(int a, int b, String c){
TestEvent2(a+b);
TestEvent3(c);
return a+b;
}
@SimpleEvent(description = "Event no parameters")
public void TestEvent(){
EventDispatcher.dispatchEvent(this, "TestEvent");
}
@SimpleEvent(description = "Event returns result from TestFunction")
public void TestEvent2(int c){
EventDispatcher.dispatchEvent(this, "TestEvent2",c);
}
@SimpleEvent(description = "Event returns string c from TestFunction")
public void TestEvent3(String c){
EventDispatcher.dispatchEvent(this, "TestEvent3",c);
}
}