28 |
public static final String TAG = "Side9Pigen"; |
public static final String TAG = "Side9Pigen"; |
29 |
|
|
30 |
//The data needs to be static, since BroadcastReceivers (which WidgetProviders extends) are only valid during onReceive() |
//The data needs to be static, since BroadcastReceivers (which WidgetProviders extends) are only valid during onReceive() |
31 |
private static Side9Data mUsedData; |
private static Side9Data mUsedData; |
|
private static Bitmap mUsedBitmap; |
|
32 |
private static long mTimestamp; |
private static long mTimestamp; |
33 |
|
|
34 |
|
private static String mImagePath; |
35 |
|
|
36 |
final static long UDPATESPAN = 4*60*60*1000; |
final static long UDPATESPAN = 4*60*60*1000; |
37 |
|
|
46 |
public void resetStatics() { |
public void resetStatics() { |
47 |
Log.i(TAG, "resetStatics"); |
Log.i(TAG, "resetStatics"); |
48 |
mUsedData = null; |
mUsedData = null; |
49 |
mUsedBitmap = null; |
mImagePath = null; |
50 |
} |
} |
51 |
|
|
52 |
|
|
61 |
|
|
62 |
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.side9widget); |
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.side9widget); |
63 |
|
|
64 |
if (mUsedBitmap != null) { |
if (mImagePath != null) { |
65 |
views.setImageViewBitmap(R.id.side9picture, mUsedBitmap); |
views.setUri(R.id.side9picture, "setImageURI", Uri.parse("file:/" + mImagePath)); |
66 |
} else { |
} else { |
67 |
views.setImageViewResource(R.id.side9picture, R.drawable.side9logo); |
views.setImageViewResource(R.id.side9picture, R.drawable.side9logo); |
68 |
} |
} |
100 |
|
|
101 |
Log.i(TAG, "onUpdate:"); |
Log.i(TAG, "onUpdate:"); |
102 |
|
|
|
if (mUsedBitmap == null) { //load default view |
|
|
mUsedBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.side9logo); |
|
|
} |
|
|
|
|
103 |
|
|
104 |
|
|
105 |
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
128 |
|
|
129 |
Log.i(TAG, "(Re)loading image:" + newData.url); |
Log.i(TAG, "(Re)loading image:" + newData.url); |
130 |
|
|
131 |
Bitmap image = getImageData(context, newData); |
getImageData(context, newData); |
132 |
|
|
133 |
mUsedData = newData; // if we made it to here without exceptions, save the new data |
mUsedData = newData; // if we made it to here without exceptions, save the new data |
|
mUsedBitmap = image; |
|
134 |
mTimestamp = System.currentTimeMillis(); |
mTimestamp = System.currentTimeMillis(); |
135 |
|
|
136 |
} // endif |
} // endif |
194 |
rescan.putExtra("read-only", false); |
rescan.putExtra("read-only", false); |
195 |
context.sendBroadcast(rescan); |
context.sendBroadcast(rescan); |
196 |
|
|
197 |
|
mImagePath = imageFile.toString(); |
198 |
|
|
199 |
} else { |
} else { |
200 |
Log.i(TAG, "sdcard is not mounted"); |
Log.i(TAG, "sdcard is not mounted"); |
201 |
} |
} |