Search in sources :

Example 1 with ControlCenterv2

use of nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2 in project Gadgetbridge by Freeyourgadget.

the class PebblePairingActivity method pairingFinished.

private void pairingFinished(boolean pairedSuccessfully) {
    LOG.debug("pairingFinished: " + pairedSuccessfully);
    if (!isPairing) {
        // already gone?
        return;
    }
    isPairing = false;
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mPairingReceiver);
    unregisterReceiver(mBondingReceiver);
    if (pairedSuccessfully) {
        Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }
    finish();
}
Also used : ControlCenterv2(nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2) Intent(android.content.Intent)

Example 2 with ControlCenterv2

use of nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2 in project Gadgetbridge by Freeyourgadget.

the class MiBandPairingActivity method pairingFinished.

private void pairingFinished(boolean pairedSuccessfully, GBDeviceCandidate candidate) {
    LOG.debug("pairingFinished: " + pairedSuccessfully);
    if (!isPairing) {
        // already gone?
        return;
    }
    isPairing = false;
    AndroidUtils.safeUnregisterBroadcastReceiver(LocalBroadcastManager.getInstance(this), mPairingReceiver);
    AndroidUtils.safeUnregisterBroadcastReceiver(this, mBondingReceiver);
    if (pairedSuccessfully) {
        // remember the device since we do not necessarily pair... temporary -- we probably need
        // to query the db for available devices in ControlCenter. But only remember un-bonded
        // devices, as bonded devices are displayed anyway.
        String macAddress = deviceCandidate.getMacAddress();
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(macAddress);
        if (device != null && device.getBondState() == BluetoothDevice.BOND_NONE) {
            Prefs prefs = GBApplication.getPrefs();
            prefs.getPreferences().edit().putString(MiBandConst.PREF_MIBAND_ADDRESS, macAddress).apply();
        }
        Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }
    finish();
}
Also used : ControlCenterv2(nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2) BluetoothDevice(android.bluetooth.BluetoothDevice) Intent(android.content.Intent) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs)

Aggregations

Intent (android.content.Intent)2 ControlCenterv2 (nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2)2 BluetoothDevice (android.bluetooth.BluetoothDevice)1 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)1