Created
October 31, 2018 14:28
-
-
Save AppWerft/5a36d0415299c2cce8607eea9e4bea7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.appwerft.disto; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Timer; | |
import java.util.TimerTask; | |
import org.appcelerator.kroll.KrollDict; | |
import org.appcelerator.kroll.KrollFunction; | |
import org.appcelerator.kroll.KrollProxy; | |
import org.appcelerator.kroll.annotations.Kroll; | |
import org.appcelerator.kroll.common.Log; | |
import org.appcelerator.titanium.TiApplication; | |
import android.app.Activity; | |
import android.bluetooth.BluetoothDevice; | |
import android.content.Context; | |
import android.os.Bundle; | |
import ch.leica.sdk.Devices.Device; | |
import ch.leica.sdk.Devices.Device.ConnectionState; | |
import ch.leica.sdk.Devices.DeviceManager; | |
import ch.leica.sdk.ErrorHandling.ErrorObject; | |
@Kroll.proxy(creatableInModule = TidistoModule.class, propertyAccessors = { "onFound" }) | |
public class DeviceManagerProxy extends KrollProxy implements | |
DeviceManager.FoundAvailableDeviceListener { | |
private DeviceManager deviceManager; | |
private Context ctx; | |
public static final String LCAT = TidistoModule.LCAT; | |
@Override | |
public void onAvailableDeviceFound(final Device device) { | |
Log.i(LCAT,"Model: " + device.getModel() + " Name: "+ device.getDeviceName()); | |
} | |
public DeviceManagerProxy() { | |
super(); | |
} | |
@Override | |
public void handleCreationDict( | |
@Kroll.argument(optional = true) KrollDict opts) { | |
super.handleCreationDict(opts); | |
ctx = TiApplication.getInstance().getApplicationContext(); | |
deviceManager = DeviceManager.getInstance(ctx); | |
deviceManager.registerReceivers(ctx); | |
} | |
@Kroll.method | |
public void findAvailableDevices() { | |
deviceManager.setFoundAvailableDeviceListener(this); | |
deviceManager.setErrorListener(this); | |
try { | |
deviceManager.findAvailableDevices(ctx); | |
} catch (PermissionException e) { | |
Log.e(LCAT, "Missing permission: " + e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment