Skip to content

Commit

Permalink
camera app - fix update from notification
Browse files Browse the repository at this point in the history
  • Loading branch information
matkatz committed Jun 26, 2019
1 parent 33c488e commit 160efb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ class DeviceWatcher extends LrsClass {
private final List<DeviceListener> mAppDeviceListener;

public synchronized void addListener(DeviceListener deviceListener){
if(!mAppDeviceListener.contains(deviceListener))
if(!mAppDeviceListener.contains(deviceListener)) {
mAppDeviceListener.add(deviceListener);
if(getDeviceCount() > 0)
deviceListener.onDeviceAttach();
}
}

public synchronized void removeListener(DeviceListener deviceListener){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
@Override
protected void onResume() {
super.onResume();

if(mPermissionsGrunted) {
RsContext.init(getApplicationContext());
mRsContext.setDevicesChangedCallback(mListener);
validatedDevice();
mRsContext.setDevicesChangedCallback(mDetachedListener);
}
}

@Override
protected void onPause() {
super.onPause();
mRsContext.setDevicesChangedCallback(mAttachListener);
}

private synchronized void validatedDevice(){
if(mUpdating)
return;
Expand Down Expand Up @@ -178,12 +182,20 @@ public void run() {
});
}

private DeviceListener mListener = new DeviceListener() {
private DeviceListener mDetachedListener = new DeviceListener() {
@Override
public void onDeviceAttach() {
validatedDevice();
}

@Override
public void onDeviceDetach() { }
};

private DeviceListener mAttachListener = new DeviceListener() {
@Override
public void onDeviceAttach() { }

@Override
public void onDeviceDetach() {
finish();
Expand Down

0 comments on commit 160efb7

Please sign in to comment.