@@ -0,0 +1,1758 @@
+package info.izumin.android.bletia;%0A%0Aimport android.os.Handler;%0Aimport android.os.HandlerThread;%0Aimport android.os.Looper;%0Aimport android.os.Message;%0A%0Aimport org.jdeferred.Deferred;%0Aimport org.jdeferred.Promise;%0Aimport org.jdeferred.impl.DeferredObject;%0A%0Aimport java.util.UUID;%0A%0Aimport info.izumin.android.bletia.wrapper.BluetoothGattWrapper;%0A%0A/**%0A * Created by izumin on 9/14/15.%0A */%0Apublic class BleMessageThread extends Handler %7B%0A%0A    private static final int DELAY_MILLIS = 300;%0A%0A    private final HandlerThread mHandlerThread;%0A    private final BluetoothGattWrapper mGattWrapper;%0A    private final BleEventStore mEventStore;%0A%0A    public BleMessageThread(HandlerThread handlerThread, BluetoothGattWrapper gattWrapper, BleEventStore eventStore) %7B%0A        super(handlerThread.getLooper());%0A        mHandlerThread = handlerThread;%0A        mGattWrapper = gattWrapper;%0A        mEventStore = eventStore;%0A    %7D%0A%0A    public void stop() %7B%0A        mHandlerThread.quitSafely();%0A    %7D%0A%0A    public %3CT%3E Promise%3CT, BleStatus, Object%3E sendEvent(BleEvent%3CT%3E event) %7B%0A        Deferred%3CT, BleStatus, Object%3E deferred = new DeferredObject%3C%3E();%0A        Promise%3CT, BleStatus, Object%3E promise = deferred.promise();%0A        event.setDeferred(deferred);%0A%0A        mEventStore.addEvent(event);%0A        dispatchMessage(event.obtainMessage());%0A%0A        return promise;%0A    %7D%0A%0A    @Override%0A    public void handleMessage(Message msg) %7B%0A        UUID uuid = (UUID) msg.getData().getSerializable(BleEvent.KEY_UUID);%0A        BleEvent.Type type = BleEvent.Type.valueOf(msg.what);%0A%0A        if (mEventStore.isRunning(type, uuid)) %7B%0A            sendMessageDelayed(msg, DELAY_MILLIS);%0A            return;%0A        %7D%0A%0A        type.handle(mGattWrapper, mEventStore.runEvent(type, uuid));%0A    %7D%0A%7D%0A

Implement BleMessageThread class