B4X:
package de.donmanfred;
import com.readystatesoftware.viewbadger.BadgeView;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
@Version(0.02f)
@ShortName("Badger")
//@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
//@Events(values={"ListTables(tables As List, ms as Long)"
// ,"QueryResult(data as List, meta As Map)"
// ,"QueryResult2(data as List, meta As Map)"
// ,"BatchResult(batch As Map)"
// ,"ExecResult(meta As Map)"})
@DependsOn(values={"android-viewbadger"})
public class Badger {
private BA app;
private String eventName;
public void Initialize(final BA ba, String event){
app = ba;
eventName = event.toLowerCase(BA.cul);
}
public void AddBadge(final BA ba, View v, String value){
BadgeView badge;
badge = new BadgeView(ba.context , v);
badge.setText(value);
badge.setBadgePosition(BadgeView.POSITION_CENTER);
v.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
return false;
}
});
badge.show();
}
}
When compiling a b4a project i get the error
Parsing code. 0.00
Compiling code. 0.02
Compiling layouts code. 0.00
Generating R file. 0.17
Compiling generated Java code. 0.71
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/readystatesoftware/viewbadger/BadgeView;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:732)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
1 error; aborting
Optimized dexer failed. Switching to Standard dexer.
It is an similar problem like i have with my pdfRenderer2-Library
To to the fact that this library is a short one i think i should start to fix this problem.
I´m using SLC 1.01 and B4A 4.0