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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
package menion.android.locus.addon.publiclib;
import java.util.ArrayList;
import menion.android.locus.addon.publiclib.geoData.PointsData;
import menion.android.locus.addon.publiclib.utils.DataStorage;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class DisplayData {
private static final String TAG = "TAG";
/**
* Simple way how to send data over intent to Locus. Count that intent in
* Android have some size limits so for larger data, use another method
* @param context actual context
* @param data PointsData object that should be send to Locus
* @param callImport wheather import with this data should be called after Locus starts
* @return true if success
*/
public static boolean sendData(Context context, PointsData data, boolean callImport) {
if (data == null)
return false;
Intent intent = new Intent();
intent.putExtra(LocusConst.EXTRA_POINTS_DATA, data);
return sendData(context, intent, callImport);
}
/**
* Simple way how to send ArrayList<PointsData> object over intent to Locus. Count that
* intent in Android have some size limits so for larger data, use another method
* @param context actual context
* @param data ArrayList of data that should be send to Locus
* @return true if success
*/
public static boolean sendData(Context context, ArrayList<PointsData> data, boolean callImport) {
if (data == null)
return false;
Intent intent = new Intent();
intent.putParcelableArrayListExtra(LocusConst.EXTRA_POINTS_DATA_ARRAY, data);
return sendData(context, intent, callImport);
}
/**
* Way how to send ArrayList<PointsData> object over intent to Locus. Data are
* stored in ContentProvider so don't forget to register it in manifest. More in
* sample application. This is recommended way how to send huge data to Locus
* @param context actual context
* @param data ArrayList of data that should be send to Locus
* @param callImport wheather import with this data should be called after Locus starts
* @return true if success
*/
public static boolean sendDataCursor(Context context, PointsData data, String uri, boolean callImport) {
if (data == null)
return false;
// set data
DataStorage.setData(data);
Intent intent = new Intent();
intent.putExtra(LocusConst.EXTRA_POINTS_CURSOR_URI, uri);
return sendData(context, intent, callImport);
}
/**
* Way how to send ArrayList<PointsData> object over intent to Locus. Data are
* stored in ContentProvider so don't forget to register it in manifest. More in
* sample application. This is recommended way how to send huge data to Locus
* @param context actual context
* @param data ArrayList of data that should be send to Locus
* @return true if success
*/
public static boolean sendDataCursor(Context context, ArrayList<PointsData> data,
String uri, boolean callImport) {
if (data == null)
return false;
// set data
DataStorage.setData(data);
Intent intent = new Intent();
intent.putExtra(LocusConst.EXTRA_POINTS_CURSOR_URI, uri);
return sendData(context, intent, callImport);
}
// private final call to Locus
private static boolean sendData(Context context, Intent intent, boolean callImport) {
// really exist locus?
if (!LocusUtils.isLocusAvailable(context)) {
Log.w(TAG, "Locus is not installed");
return false;
}
// check intent firstly
if (intent == null || (intent.getParcelableArrayListExtra(LocusConst.EXTRA_POINTS_DATA_ARRAY) == null &&
intent.getParcelableExtra(LocusConst.EXTRA_POINTS_DATA) == null &&
intent.getStringExtra(LocusConst.EXTRA_POINTS_CURSOR_URI) == null)) {
Log.w(TAG, "Intent 'null' or not contain any data");
return false;
}
intent.putExtra(LocusConst.EXTRA_CALL_IMPORT, callImport);
// create intent with right calling method
intent.setAction(LocusConst.INTENT_DISPLAY_DATA);
// finally start activity
context.startActivity(intent);
return true;
}
}
|