Permalink
Browse files

v1.9 json parser, pending intent stop working after sometime

  • Loading branch information...
Carles Sentis
Carles Sentis committed Aug 6, 2012
1 parent ce7d15a commit a79d3676c6aabc385402e88ecd041f0c4baf83cd
View
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codeskraps.lolo"
- android:versionCode="9"
- android:versionName="1.8" >
+ android:versionCode="10"
+ android:versionName="1.9" >
<!-- Remember to update the info code version -->
View
@@ -4,7 +4,7 @@
* <b>Git:</b> https://github.com/091labs/lo-lo
* <b>Author:</b> 091 Labs members
* <b>License:</b> GNU GPL v3
-* <b>Latest Version:</b> 1.8
+* <b>Latest Version:</b> 1.9
* <b>Release Date:</b> 2012
== General Infromation
@@ -32,6 +32,10 @@ Install from Google Play
== ChangeLog
+<b>v.1.9</>
+* On touch event stopped working after sometime has been fixed
+* Get lolo json parser been fixed
+
<b>v1.8</b>
* Added - Custom interval update
View
@@ -54,7 +54,7 @@
<string name="prefsCat_Info">Information</string>
- <string name="prefsInfo_Title">091 Labs lo-lo v1.8</string>
+ <string name="prefsInfo_Title">091 Labs lo-lo v1.9</string>
<string name="prefsInfo_summary">GNU GPL License v3 - 2012</string>
<!-- About -->
@@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
StringBuilder sb = new StringBuilder();
sb.append("091 Labs is a collaborative community space based in Galway City, Ireland. It is a shared physical space for any and all creative projects: art, woodwork, software, photography and electronics – to name but a few. Our aim is to provide Galway with a place for people to work and collaborate on creative projects, to learn and to share their knowledge. We welcome all skill levels and all creative ideas.<br /><br />");
sb.append("<h2><font color='red'>lo-lo</font></h2>");
- sb.append("This is a way for members and the general public when the Labs on or labs off.<br /><br />");
+ sb.append("This is a way for members and the general public to know when the Labs are open or close. Labs on, labs off.<br /><br />");
sb.append("<font color='#AAAAAA'>Website:</font> 091labs.com<br />");
sb.append("<font color='#AAAAAA'>Email:</font> info@091labs.com<br />");
String version = getString(R.string.prefsInfo_Title);
@@ -1,244 +0,0 @@
-/*
- * lo-lo Copyright (C) 091 Labs 2012 info@091labs.com
- *
- * lo-lo is free software: you can
- * redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later
- * version.
-
- * lo-lo is distributed in the hope that it
- * will be useful, but WITHOUT ANY WARRANTY; without
- * even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
-
- * You should have received a copy of the GNU
- * General Public License along with this program.
- * If not, see http://www.gnu.org/licenses.
- */
-
-package com.codeskraps.lolo;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.List;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.app.Service;
-import android.appwidget.AppWidgetManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.os.IBinder;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.View;
-import android.widget.RemoteViews;
-
-import com.codeskraps.lolo.RSSXmlParser.Entry;
-
-public class UpdateWidgetService extends Service {
- private static final String TAG = UpdateWidgetService.class.getSimpleName();
-
- private static Context context = null;
- private static Intent intent = null;
- private static Handler handler;
- private static boolean lolo;
- private Thread downloadThread;
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (BuildConfig.DEBUG == true)
- Log.d(TAG, "onStartCommand");
-
- UpdateWidgetService.intent = intent;
- UpdateWidgetService.context = getApplicationContext();
-
- handler = new Handler();
-
- if (Utils.isNetworkAvailable(getApplicationContext())) {
- ComponentName provider = new ComponentName(context, LoloProvider.class);
- AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
- int[] appWidgets = appWidgetManager.getAppWidgetIds(provider);
-
- if (appWidgets.length > 0) {
- for (int widgetId : appWidgets) {
- RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
- R.layout.widget);
- remoteViews.setViewVisibility(R.id.prgBar, View.VISIBLE);
- appWidgetManager.updateAppWidget(widgetId, remoteViews);
- }
- } else
- Log.d(TAG, "No widgets installed");
-
- downloadThread = new MyThread();
- downloadThread.start();
-
- // new DownloadXmlTask().execute();
- } else {
- Log.d(TAG, "No network connection");
- }
-
- stopSelf();
-
- return super.onStartCommand(intent, flags, startId);
- }
-
- static private class MyThread extends Thread {
- @Override
- public void run() {
- try {
- lolo = Utils.getLolo();
- } catch (IOException e) {
- Log.e(TAG, e.getMessage());
- } finally {
- handler.post(new MyRunnable());
- }
- }
- }
-
- static private class MyRunnable implements Runnable {
- public void run() {
- ComponentName provider = new ComponentName(context, LoloProvider.class);
- AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
- int[] appWidgets = appWidgetManager.getAppWidgetIds(provider);
-
- if (appWidgets.length > 0) {
- for (int widgetId : appWidgets) {
-
- RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
- R.layout.widget);
-
- if (lolo) {
- remoteViews.setImageViewResource(R.id.imgLolo, R.drawable.open);
- Log.d(TAG, "The labs is open");
- } else {
- remoteViews.setImageViewResource(R.id.imgLolo, R.drawable.closed);
- Log.d(TAG, "The labs is close");
- }
-
- Calendar c = Calendar.getInstance();
-
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(context);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putString(PrefsActivity.LAST_SYNC, DateFormat.getDateTimeInstance()
- .format(c.getTime()));
- editor.commit();
-
- boolean showSync = prefs.getBoolean(PrefsActivity.SHOW_SYNC, true);
- if (showSync) {
- boolean hour24 = prefs.getBoolean(PrefsActivity.HOUR24, true);
- String hours = new String();
- if (hour24) {
- hours = new String("");
- if (c.get(Calendar.HOUR_OF_DAY) < 10)
- hours += "0";
- hours += c.get(Calendar.HOUR_OF_DAY);
- } else {
- hours = new String("");
- if (c.get(Calendar.HOUR) < 10)
- hours += "0";
- hours += c.get(Calendar.HOUR);
- }
-
- String minutes = new String("");
- if (c.get(Calendar.MINUTE) < 10)
- minutes += "0";
- minutes += c.get(Calendar.MINUTE);
-
- String lastSync = String.format("%s:%s\n", hours, minutes);
- Log.d(TAG, "lastSnync:" + lastSync);
- remoteViews.setTextViewText(R.id.txtSync, lastSync);
- remoteViews.setViewVisibility(R.id.txtSync, View.VISIBLE);
- } else {
- remoteViews.setViewVisibility(R.id.txtSync, View.GONE);
- }
-
- remoteViews.setViewVisibility(R.id.prgBar, View.GONE);
-
- appWidgetManager.updateAppWidget(widgetId, remoteViews);
- }
- } else {
- Log.d(TAG, "No widgets installed");
- }
- }
- }
-
- // Implementation of AsyncTask used to download XML feed from
- // stackoverflow.com.
- private class DownloadXmlTask extends AsyncTask<String, Void, String> {
-
- @Override
- protected String doInBackground(String... urls) {
- try {
- return loadXmlFromNetwork("http://stackoverflow.com/feeds/tag?tagnames=android&sort=newest");
- } catch (IOException e) {
- return e.getMessage();
- } catch (XmlPullParserException e) {
- return e.getMessage();
- }
- }
-
- @Override
- protected void onPostExecute(String result) {
- Log.d(TAG, result);
- }
- }
-
- // Uploads XML from stackoverflow.com, parses it, and combines it with
- // HTML markup. Returns HTML string.
- private String loadXmlFromNetwork(String urlString) throws XmlPullParserException, IOException {
- InputStream stream = null;
- RSSXmlParser rssXmlParser = new RSSXmlParser();
- List<Entry> entries = null;
-
- try {
- stream = downloadUrl(urlString);
- entries = rssXmlParser.parse(stream);
- // Makes sure that the InputStream is closed after the app is
- // finished using it.
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
-
- // Each Entry object represents a single post in the XML feed.
- // This section processes the entries list to combine each entry with
- // HTML markup.
- // Each entry is displayed in the UI as a link that optionally includes
- // a text summary.
- return entries.get(0).title;
- }
-
- // Given a string representation of a URL, sets up a connection and gets
- // an input stream.
- private InputStream downloadUrl(String urlString) throws IOException {
- URL url = new URL(urlString);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setReadTimeout(10000 /* milliseconds */);
- conn.setConnectTimeout(15000 /* milliseconds */);
- conn.setRequestMethod("GET");
- conn.setDoInput(true);
- // Starts the query
- conn.connect();
- InputStream stream = conn.getInputStream();
- return stream;
- }
-}
@@ -92,14 +92,14 @@ public static boolean getLolo() throws IOException {
+ " sec");
return lolo;
}
-
+
public static PendingIntent getOnTouchIntent(Context context) {
PendingIntent pendingIntent = null;
Intent intent = null;
-
+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int onClick = Integer.parseInt(prefs.getString(Constants.ONCLICK, "0"));
-
+
switch (onClick) {
case 0:
intent = new Intent("com.codeskraps.lol.DO_NOTHING");

0 comments on commit a79d367

Please sign in to comment.