From: Eugene Crosser Date: Tue, 31 Jan 2012 14:06:09 +0000 (+0400) Subject: add Location class and parent X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=75e82caefb015eabcd87a20f002a8e89f820e33e;p=WhereAmI.git add Location class and parent --- diff --git a/src/org/average/whereami/Location.java b/src/org/average/whereami/Location.java new file mode 100644 index 0000000..fcbc59f --- /dev/null +++ b/src/org/average/whereami/Location.java @@ -0,0 +1,20 @@ +package org.average.whereami; + +import com.google.api.client.extensions.android2.AndroidHttp; +import com.google.api.client.googleapis.GoogleHeaders; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpResponse; +import com.google.api.client.http.HttpResponseException; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.util.DateTime; + +import android.util.Log; + +public final class Location extends Oracle { + @Override + public final String getResult() { + return "Response from Location.getResult"; + } + + //public PhoneLog() {} +} diff --git a/src/org/average/whereami/Oracle.java b/src/org/average/whereami/Oracle.java new file mode 100644 index 0000000..4043451 --- /dev/null +++ b/src/org/average/whereami/Oracle.java @@ -0,0 +1,5 @@ +package org.average.whereami; + +abstract public class Oracle { + abstract String getResult(); +} diff --git a/src/org/average/whereami/PhoneLog.java b/src/org/average/whereami/PhoneLog.java index bda3596..66517a4 100644 --- a/src/org/average/whereami/PhoneLog.java +++ b/src/org/average/whereami/PhoneLog.java @@ -17,8 +17,11 @@ import com.google.api.client.util.DateTime; import android.util.Log; -public final class PhoneLog { - public static final String getResult() { +public final class PhoneLog extends Oracle { + @Override + public final String getResult() { return "Response from PhoneLog.getResult"; } + + //public PhoneLog() {} } diff --git a/src/org/average/whereami/WhereAmI.java b/src/org/average/whereami/WhereAmI.java index 6f2550f..2539e0e 100644 --- a/src/org/average/whereami/WhereAmI.java +++ b/src/org/average/whereami/WhereAmI.java @@ -1,7 +1,9 @@ package org.average.whereami; import org.average.whereami.WhereAmIprefs; +import org.average.whereami.Oracle; import org.average.whereami.PhoneLog; +import org.average.whereami.Location; import android.app.Activity; import android.net.wifi.WifiManager; @@ -38,7 +40,7 @@ public class WhereAmI extends Activity private class UpdateTarget { private TextView tv; - private Integer updater; // will be the function/object + private Oracle updater; private BgUpdate task; private class BgUpdate extends AsyncTask { @@ -46,7 +48,7 @@ public class WhereAmI extends Activity protected String doInBackground(Void... params) { Log.w("WhereAmI", "BgUpdate " + updater + " starting"); SystemClock.sleep(5000); // real job do be done here - String result = PhoneLog.getResult(); + String result = updater.getResult(); Log.w("WhereAmI", "BgUpdate about to return"); return result; } @@ -73,7 +75,7 @@ public class WhereAmI extends Activity } } - public UpdateTarget(TextView tv, Integer updater) { + public UpdateTarget(TextView tv, Oracle updater) { this.tv = tv; this.updater = updater; } @@ -207,8 +209,10 @@ public class WhereAmI extends Activity tvd = (TextView)findViewById(R.id.date); tvs = (TextView)findViewById(R.id.timestamp); ut = new UpdateTarget[] { - new UpdateTarget((TextView)findViewById(R.id.location), 1), - new UpdateTarget((TextView)findViewById(R.id.phonecall), 2) + new UpdateTarget((TextView)findViewById(R.id.location), + new PhoneLog()), + new UpdateTarget((TextView)findViewById(R.id.phonecall), + new Location()) }; Log.w("WhereAmI", "created UI, about to start update task"); mHandler.post(updateClock);