PhotosReceiver.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.polysoft.nafmii.broadcast;
import android.content.Context;
import android.content.Intent;
public class PhotosReceiver extends Receiver<String> {
public static final String ACTION_CAMERA = "com.polysoft.nafmii.action_camera";
public static final String ACTION_ALBUM = "com.polysoft.nafmii.action_album";
protected PhotosReceiver(Context context) {
super(context);
}
public static Receiver<String> getInstance(Context context) {
Receiver<String> receiver = getReceiver(PhotosReceiver.class);
return null != receiver ? receiver : new PhotosReceiver(context.getApplicationContext());
}
public static void sendBroadcastCamera(Context context, String filepath) {
Intent intent = new Intent().setAction(ACTION_CAMERA);
intent.putExtra("data", filepath);
onSendBroadcast(context, intent);
}
public static void sendBroadcastAlbum(Context context, String filepath) {
Intent intent = new Intent().setAction(ACTION_ALBUM);
intent.putExtra("data", filepath);
onSendBroadcast(context, intent);
}
@Override
protected String[] getActions() {
return new String[]{ACTION_CAMERA, ACTION_ALBUM};
}
@Override
protected String onReceiverData(String action, Intent intent) {
if (ACTION_CAMERA.equals(action)) {
return intent.getStringExtra("data");
} else if (ACTION_ALBUM.equals(action)) {
return intent.getStringExtra("data");
}
return null;
}
}