Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加移除通知监听者接口 #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ apply plugin: 'com.jfrog.bintray'
version="1.4.0"

android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
compileSdkVersion 25
buildToolsVersion '25.0.3'

resourcePrefix "bluetoothkit_"

defaultConfig {
minSdkVersion 9
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public void notify(String mac, UUID service, UUID character, BleNotifyResponse r
mClient.notify(mac, service, character, response);
}

@Override
public void unnotify(String mac, UUID service, UUID character, BleNotifyResponse response) {
BluetoothLog.v(String.format("unnotify %s: service = %s, character = %s", mac, service, character));

response = ProxyUtils.getUIProxy(response);
mClient.unnotify(mac, service, character, response);
}

@Override
public void unnotify(String mac, UUID service, UUID character, BleUnnotifyResponse response) {
BluetoothLog.v(String.format("unnotify %s: service = %s, character = %s", mac, service, character));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,22 @@ protected void onAsyncResponse(int code, Bundle data) {
});
}

@Override
public void unnotify(String mac, UUID service, UUID character, BleNotifyResponse response) {
checkRuntime(true);
if (response == null) {
return;
}
HashMap<String, List<BleNotifyResponse>> listenerMap = mNotifyResponses.get(mac);
if (listenerMap != null) {
String key = generateCharacterKey(service, character);
List<BleNotifyResponse> reponseList = listenerMap.get(key);
if (reponseList != null) {
reponseList.remove(response);
}
}
}

@Override
public void unnotify(final String mac, final UUID service, final UUID character, final BleUnnotifyResponse response) {
Bundle args = new Bundle();
Expand Down Expand Up @@ -414,7 +430,7 @@ protected void onAsyncResponse(int code, Bundle data) {

@Override
public void unindicate(String mac, UUID service, UUID character, BleUnnotifyResponse response) {
unnotify(mac, service, character, response);
unnotify(mac, service, character, response);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public interface IBluetoothClient {

void notify(String mac, UUID service, UUID character, BleNotifyResponse response);

void unnotify(String mac, UUID service, UUID character, BleNotifyResponse response);

void unnotify(String mac, UUID service, UUID character, BleUnnotifyResponse response);

void indicate(String mac, UUID service, UUID character, BleNotifyResponse response);
Expand Down