Skip to content

Commit

Permalink
list changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aslamanver committed Jul 7, 2022
1 parent 87e643a commit a060f4b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
6 changes: 3 additions & 3 deletions p2psdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish {
repoName = 'android'
groupId = 'com.aslam'
artifactId = 'p2p'
publishVersion = '1.2.3'
publishVersion = '1.2.4'
desc = 'P2P library provides instant integration (PnP) support for WIFI-Direct P2P for any Android projects plus it remembers the recently connected device and reconnects it automatically when it is available.'
website = 'https://github.com/aslamanver/p2p'
}
Expand All @@ -18,8 +18,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 123
versionName "1.2.3"
versionCode 124
versionName "1.2.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
30 changes: 27 additions & 3 deletions p2psdk/src/main/java/com/aslam/p2p/services/P2PService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.net.wifi.p2p.WifiP2pDevice;
import android.net.wifi.p2p.WifiP2pInfo;

import androidx.annotation.CallSuper;

import com.aslam.p2p.R;

import java.util.ArrayList;
Expand All @@ -15,13 +17,15 @@ public class P2PService extends BaseForegroundService implements P2PControllerLi
private final List<P2PControllerListener> controllerListeners = new ArrayList<>();

@Override
@CallSuper
public void onCreate() {
super.onCreate();
p2pController = new P2PController(this, this);
p2pController.registerConnection();
}

@Override
@CallSuper
public void onDestroy() {
super.onDestroy();
p2pController.destroy();
Expand All @@ -34,15 +38,15 @@ protected ServiceBuilder serviceBuilder() {
return serviceBuilder.build(notification);
}

public P2PController getP2PController() {
public final P2PController getP2PController() {
return p2pController;
}

public void addListener(P2PControllerListener controllerListener) {
public final void addListener(P2PControllerListener controllerListener) {
controllerListeners.add(controllerListener);
}

public void removeListener(P2PControllerListener controllerListener) {
public final void removeListener(P2PControllerListener controllerListener) {
if (controllerListener == null) {
controllerListeners.clear();
} else {
Expand All @@ -51,104 +55,119 @@ public void removeListener(P2PControllerListener controllerListener) {
}

@Override
@CallSuper
public void onDiscoverChanged(int state) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDiscoverChanged(state);
}
}

@Override
@CallSuper
public void onP2PStateChanged(int state) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onP2PStateChanged(state);
}
}

@Override
@CallSuper
public void onDeviceChanged(WifiP2pDevice device) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceChanged(device);
}
}

@Override
@CallSuper
public void onConnectionInfoAvailable(WifiP2pInfo info) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onConnectionInfoAvailable(info);
}
}

@Override
@CallSuper
public void onDeviceNameChanged(int state) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceNameChanged(state);
}
}

@Override
@CallSuper
public void onGroupCreated(int state) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onGroupCreated(state);
}
}

@Override
@CallSuper
public void onGroupRemoved(int state) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onGroupRemoved(state);
}
}

@Override
@CallSuper
public void onDeviceConnected(WifiP2pDevice device) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceConnected(device);
}
}

@Override
@CallSuper
public void onDeviceNotConnected(int reason) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceNotConnected(reason);
}
}

@Override
@CallSuper
public void onDeviceDisconnected(WifiP2pDevice device) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceDisconnected(device);
}
}

@Override
@CallSuper
public void onDeviceNotDisconnected(int reason) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onDeviceNotDisconnected(reason);
}
}

@Override
@CallSuper
public void onSocketServerStarted() {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketServerStarted();
}
}

@Override
@CallSuper
public void onSocketServerNewConnection(String host) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketServerNewConnection(host);
}
}

@Override
@CallSuper
public void onSocketServerConnectionClosed(String host, int code, String reason, boolean remote) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketServerConnectionClosed(host, code, reason, remote);
}
}

@Override
@CallSuper
public void onSocketServerMessage(String host, String message) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketServerMessage(host, message);
Expand All @@ -158,34 +177,39 @@ public void onSocketServerMessage(String host, String message) {
//

@Override
@CallSuper
public void onPeersChanged(List<WifiP2pDevice> peers) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onPeersChanged(peers);
}
}

@Override
@CallSuper
public void onSocketClientOpened(String host) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketClientOpened(host);
}
}

@Override
@CallSuper
public void onSocketClientClosed(String host, int code, String reason, boolean remote) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketClientClosed(host, code, reason, remote);
}
}

@Override
@CallSuper
public void onSocketClientMessage(String host, String message) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onSocketClientMessage(host, message);
}
}

@Override
@CallSuper
public void onConsoleLog(String message) {
for (P2PControllerListener controllerListener : controllerListeners) {
controllerListener.onConsoleLog(message);
Expand Down

0 comments on commit a060f4b

Please sign in to comment.