Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyMessageIntentService.java

Issue 2552143002: Refactor Nearby Message listener (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.app.IntentService; 7 import android.app.IntentService;
8 import android.content.Intent; 8 import android.content.Intent;
9 9
10 import com.google.android.gms.nearby.Nearby; 10 import com.google.android.gms.nearby.Nearby;
11 import com.google.android.gms.nearby.messages.Message;
12 import com.google.android.gms.nearby.messages.MessageListener; 11 import com.google.android.gms.nearby.messages.MessageListener;
13 12
14 /** 13 /**
15 * Service that handles intents from Nearby. 14 * Service that handles intents from Nearby.
16 */ 15 */
17 public class NearbyMessageIntentService extends IntentService { 16 public class NearbyMessageIntentService extends IntentService {
18 private static final MessageListener MESSAGE_LISTENER = new MessageListener( ) { 17 private static final MessageListener MESSAGE_LISTENER =
19 @Override 18 PhysicalWebBleClient.getInstance().createBackgroundMessageListener() ;
20 public void onFound(Message message) {
21 String url = PhysicalWebBleClient.getInstance().getUrlFromMessage(me ssage);
22 if (url != null) {
23 UrlManager.getInstance().addUrl(new UrlInfo(url));
24 }
25 }
26 19
27 @Override
28 public void onLost(Message message) {
29 String url = PhysicalWebBleClient.getInstance().getUrlFromMessage(me ssage);
30 if (url != null) {
31 UrlManager.getInstance().removeUrl(new UrlInfo(url));
32 }
33 }
34 };
35 20
36 public NearbyMessageIntentService() { 21 public NearbyMessageIntentService() {
37 super(NearbyMessageIntentService.class.getSimpleName()); 22 super(NearbyMessageIntentService.class.getSimpleName());
38 setIntentRedelivery(true); 23 setIntentRedelivery(true);
39 } 24 }
40 25
41 @Override 26 @Override
42 protected void onHandleIntent(Intent intent) { 27 protected void onHandleIntent(Intent intent) {
43 Nearby.Messages.handleIntent(intent, MESSAGE_LISTENER); 28 Nearby.Messages.handleIntent(intent, MESSAGE_LISTENER);
44 } 29 }
45 } 30 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698