30 |
private static Side9Data usedData; |
private static Side9Data usedData; |
31 |
private static Bitmap usedBitmap; |
private static Bitmap usedBitmap; |
32 |
private static long timestamp; |
private static long timestamp; |
33 |
|
private static boolean reloadData; |
34 |
|
|
35 |
final static long UDPATESPAN = 4*60*60*1000; |
final static long UDPATESPAN = 4*60*60*1000; |
36 |
|
|
70 |
getSharedPreferences(Side9WidgetProvider.TAG, Context.MODE_PRIVATE). |
getSharedPreferences(Side9WidgetProvider.TAG, Context.MODE_PRIVATE). |
71 |
getBoolean(Side9Config.PREFS_SHOWCAPTION, false); |
getBoolean(Side9Config.PREFS_SHOWCAPTION, false); |
72 |
|
|
73 |
if (showcaption == true) { |
if (showcaption == true && usedData != null) { |
74 |
views.setTextViewText(R.id.caption, " " + usedData.caption + " "); |
views.setTextViewText(R.id.caption, " " + usedData.caption + " "); |
75 |
views.setViewVisibility(R.id.caption, View.VISIBLE); |
views.setViewVisibility(R.id.caption, View.VISIBLE); |
76 |
} else { |
} else { |
114 |
|
|
115 |
if (System.currentTimeMillis() > (timestamp+UDPATESPAN) ) { |
if (System.currentTimeMillis() > (timestamp+UDPATESPAN) ) { |
116 |
Log.i(TAG, "time elapsed, force XML reload"); |
Log.i(TAG, "time elapsed, force XML reload"); |
117 |
usedData = null; |
reloadData = true; |
118 |
} |
} |
119 |
|
|
120 |
try { |
try { |
121 |
Side9Data newData = Side9Xml.loadXml(); |
Side9Data newData = Side9Xml.loadXml(); |
122 |
|
|
123 |
if (! newData.equals(usedData)) { |
if (! newData.equals(usedData) || reloadData == true) { |
124 |
|
|
125 |
|
|
126 |
Log.i(TAG, "(Re)loading image:" + newData.url); |
Log.i(TAG, "(Re)loading image:" + newData.url); |
130 |
usedData = newData; // if we made it to here without exceptions, save the new data |
usedData = newData; // if we made it to here without exceptions, save the new data |
131 |
usedBitmap = image; |
usedBitmap = image; |
132 |
timestamp = System.currentTimeMillis(); |
timestamp = System.currentTimeMillis(); |
133 |
|
reloadData = false; |
134 |
|
|
135 |
} // endif |
} // endif |
136 |
|
|