[markww-foursquared] 6 new revisions pushed by markww on 2010-09-30 20:02 GMT

3 views
Skip to first unread message

markww-fo...@googlecode.com

unread,
Sep 30, 2010, 4:03:48 PM9/30/10
to foursqu...@googlegroups.com
6 new revisions:

Revision: 5043658909
Author: mar...@gmail.com
Date: Thu Sep 30 11:43:33 2010
Log: Allowing UserDetailsActivity to accept a null user id, interpreted
as ...
http://code.google.com/r/markww-foursquared/source/detail?r=5043658909

Revision: e0e36103dc
Author: mar...@gmail.com
Date: Thu Sep 30 11:47:13 2010
Log: Replaced creation of new runnables with single runnable member.
Fetchi...
http://code.google.com/r/markww-foursquared/source/detail?r=e0e36103dc

Revision: ed45efa7d9
Author: mar...@gmail.com
Date: Thu Sep 30 11:51:02 2010
Log: Removed extra new runnable calls.
http://code.google.com/r/markww-foursquared/source/detail?r=ed45efa7d9

Revision: 2fd06bd8ae
Author: mar...@gmail.com
Date: Thu Sep 30 12:01:25 2010
Log: Turning off debug flags.
http://code.google.com/r/markww-foursquared/source/detail?r=2fd06bd8ae

Revision: fc71fe486c
Author: mar...@gmail.com
Date: Thu Sep 30 12:20:32 2010
Log: Removed creation of new runnables for photo updates.
http://code.google.com/r/markww-foursquared/source/detail?r=fc71fe486c

Revision: a7c38c4378
Author: mar...@gmail.com
Date: Thu Sep 30 13:00:32 2010
Log: Put a null check for todos without a tip. There are not supposed to
be...
http://code.google.com/r/markww-foursquared/source/detail?r=a7c38c4378

==============================================================================
Revision: 5043658909
Author: mar...@gmail.com
Date: Thu Sep 30 11:43:33 2010
Log: Allowing UserDetailsActivity to accept a null user id, interpreted as
logged-in user. Using a simple bitmap cache for photo strip. Changed
friendlist adapter fetching of images to reduce number of threads created.
The model of fetching images for these lists needs to be rethought in the
next version though. Made sure intent sharing with 3rd party apps is
working, will probably add to project tests.
http://code.google.com/r/markww-foursquared/source/detail?r=5043658909

Modified:
/main/AndroidManifest.xml
/main/assets/changelog-en.html
/main/src/com/joelapenna/foursquared/BrowsableActivity.java
/main/src/com/joelapenna/foursquared/NearbyVenuesActivity.java
/main/src/com/joelapenna/foursquared/UserDetailsActivity.java
/main/src/com/joelapenna/foursquared/widget/FriendListAdapter.java
/main/src/com/joelapenna/foursquared/widget/PhotoStrip.java

=======================================
--- /main/AndroidManifest.xml Tue Sep 28 12:22:07 2010
+++ /main/AndroidManifest.xml Thu Sep 30 11:43:33 2010
@@ -4,7 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joelapenna.foursquared"
android:installLocation="auto"
- android:versionName="2010-09-28" android:versionCode="2010092800">
+ android:versionName="2010-09-30" android:versionCode="2010093000"
+ android:debuggable="true">

<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
=======================================
--- /main/assets/changelog-en.html Tue Sep 28 12:22:07 2010
+++ /main/assets/changelog-en.html Thu Sep 30 11:43:33 2010
@@ -41,10 +41,11 @@
<h4><span>What's new in v2010-09-28?</span></h4>
<ul>
<li>Redesign for most activity screens.</li>
- <li>Tips and To-do screens added as top-level tabs..</li>
+ <li>Tips and To-do screens added as top-level tabs.</li>
<li>Friend information added to venue pages.</li>
<li>Can access friend requests from Me tab.</li>
<li>Can now refresh Me tab.</li>
+ <li>Switched from xml to json for API calls.</li>
</ul>

<h4><span>What's new in v2010-08-31</span></h4>
=======================================
--- /main/src/com/joelapenna/foursquared/BrowsableActivity.java Wed Sep 22
11:57:13 2010
+++ /main/src/com/joelapenna/foursquared/BrowsableActivity.java Thu Sep 30
11:43:33 2010
@@ -35,6 +35,7 @@
public static String PARAM_SHOUT_TEXT = "shout";
public static String PARAM_SEARCH_QUERY = "q";
public static String PARAM_SEARCH_IMMEDIATE= "immediate";
+ public static String PARAM_USER_ID= "uid";

private static final UriMatcher sUriMatcher = new
UriMatcher(UriMatcher.NO_MATCH);
static {
@@ -105,7 +106,10 @@
case URI_PATH_USER:
if (DEBUG) Log.d(TAG, "Matched: URI_PATH_USER");
intent = new Intent(this, UserDetailsActivity.class);
- intent.putExtra(UserDetailsActivity.EXTRA_USER_ID,
uri.getQueryParameter("uid"));
+ if
(!TextUtils.isEmpty(uri.getQueryParameter(PARAM_USER_ID))) {
+ intent.putExtra(UserDetailsActivity.EXTRA_USER_ID,
+ uri.getQueryParameter(PARAM_USER_ID));
+ }
startActivity(intent);
break;
case URI_PATH_VENUE:
=======================================
--- /main/src/com/joelapenna/foursquared/NearbyVenuesActivity.java Sun Sep
26 10:33:26 2010
+++ /main/src/com/joelapenna/foursquared/NearbyVenuesActivity.java Thu Sep
30 11:43:33 2010
@@ -14,7 +14,6 @@
import com.joelapenna.foursquared.preferences.Preferences;
import com.joelapenna.foursquared.util.MenuUtils;
import com.joelapenna.foursquared.util.NotificationsUtil;
-import com.joelapenna.foursquared.util.UserUtils;
import com.joelapenna.foursquared.util.VenueUtils;
import com.joelapenna.foursquared.widget.SeparatedListAdapter;
import com.joelapenna.foursquared.widget.VenueListAdapter;
@@ -30,7 +29,6 @@
import android.location.Geocoder;
import android.location.Location;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
@@ -65,11 +63,10 @@
public static final String INTENT_EXTRA_STARTUP_GEOLOC_DELAY =
Foursquared.PACKAGE_NAME
+ ".NearbyVenuesActivity.INTENT_EXTRA_STARTUP_GEOLOC_DELAY";

- private static final int MENU_REFRESH = 0;
+ private static final int MENU_REFRESH = 0;
private static final int MENU_ADD_VENUE = 1;
- private static final int MENU_SEARCH = 2;
- private static final int MENU_MYINFO = 3;
- private static final int MENU_MAP = 4;
+ private static final int MENU_SEARCH = 2;
+ private static final int MENU_MAP = 3;

private static final int RESULT_CODE_ACTIVITY_VENUE = 1;

@@ -191,14 +188,6 @@
menu.add(Menu.NONE, MENU_ADD_VENUE, Menu.NONE,
R.string.nearby_menu_add_venue) //
.setIcon(R.drawable.ic_menu_add);

- int sdk = new Integer(Build.VERSION.SDK).intValue();
- if (sdk < 4) {
- int menuIcon = UserUtils.getDrawableForMeMenuItemByGender(
- ((Foursquared) getApplication()).getUserGender());
- menu.add(Menu.NONE, MENU_MYINFO, Menu.NONE,
R.string.myinfo_label) //
- .setIcon(menuIcon);
- }
-
// Shows a map of all nearby venues, works but not going into this
version.
//menu.add(Menu.NONE, MENU_MAP, Menu.NONE, "Map")
// .setIcon(R.drawable.ic_menu_places);
@@ -224,12 +213,6 @@
case MENU_ADD_VENUE:
startActivity(new Intent(NearbyVenuesActivity.this,
AddVenueActivity.class));
return true;
- case MENU_MYINFO:
- Intent intentUser = new Intent(NearbyVenuesActivity.this,
UserDetailsActivity.class);
- intentUser.putExtra(UserDetailsActivity.EXTRA_USER_ID,
- ((Foursquared) getApplication()).getUserId());
- startActivity(intentUser);
- return true;
case MENU_MAP:
startActivity(new Intent(NearbyVenuesActivity.this,
NearbyVenuesMapActivity.class));
return true;
=======================================
--- /main/src/com/joelapenna/foursquared/UserDetailsActivity.java Wed Sep
29 15:27:00 2010
+++ /main/src/com/joelapenna/foursquared/UserDetailsActivity.java Thu Sep
30 11:43:33 2010
@@ -113,31 +113,29 @@
} else {

mStateHolder = new StateHolder();
- if (getIntent().getExtras() != null) {
- if
(getIntent().getExtras().containsKey(EXTRA_USER_PARCEL)) {
- User user =
getIntent().getExtras().getParcelable(EXTRA_USER_PARCEL);
- mStateHolder.setUser(user);
- mStateHolder.setLoadType(LOAD_TYPE_USER_PARTIAL);
- } else if
(getIntent().getExtras().containsKey(EXTRA_USER_ID)) {
- User user = new User();
-
user.setId(getIntent().getExtras().getString(EXTRA_USER_ID));
- mStateHolder.setUser(user);
- mStateHolder.setLoadType(LOAD_TYPE_USER_ID);
- } else {
- Log.e(TAG, "UserDetailsActivity requires a userid in
its intent extras.");
- finish();
- return;
- }
-
- mStateHolder.setIsLoggedInUser(
- mStateHolder.getUser().getId().equals(
- ((Foursquared) getApplication()).getUserId()));
-
+ if (getIntent().hasExtra(EXTRA_USER_PARCEL)) {
+ Log.i(TAG, "Starting " + TAG + " with full user parcel.");
+ User user =
getIntent().getExtras().getParcelable(EXTRA_USER_PARCEL);
+ mStateHolder.setUser(user);
+ mStateHolder.setLoadType(LOAD_TYPE_USER_PARTIAL);
+ } else if (getIntent().hasExtra(EXTRA_USER_ID)) {
+ Log.i(TAG, "Starting " + TAG + " with user ID.");
+ User user = new User();
+
user.setId(getIntent().getExtras().getString(EXTRA_USER_ID));
+ mStateHolder.setUser(user);
+ mStateHolder.setLoadType(LOAD_TYPE_USER_ID);
} else {
- Log.e(TAG, "UserDetailsActivity requires a userid in its
intent extras.");
- finish();
- return;
- }
+ Log.i(TAG, "Starting " + TAG + " as logged-in user.");
+ User user = new User();
+ user.setId(null);
+ mStateHolder.setUser(user);
+ mStateHolder.setLoadType(LOAD_TYPE_USER_ID);
+ }
+
+ mStateHolder.setIsLoggedInUser(
+ mStateHolder.getUser().getId() == null ||
+ mStateHolder.getUser().getId().equals(
+ ((Foursquared) getApplication()).getUserId()));
}

mHandler = new Handler();
@@ -775,8 +773,7 @@

UiUtil.startDialer(UserDetailsActivity.this,
mStateHolder.getUser().getPhone());
break;
case
UserContactAdapter.Action.ACTION_ID_TWITTER:
-
//UiUtil.startWebIntent(UserDetailsActivity.this, "http://www.twitter.com/"
+
-
UiUtil.startWebIntent(UserDetailsActivity.this, "http://m.twitter.com/" +
+
UiUtil.startWebIntent(UserDetailsActivity.this, "http://www.twitter.com/" +
mStateHolder.getUser().getTwitter());
break;
case
UserContactAdapter.Action.ACTION_ID_FACEBOOK:
=======================================
--- /main/src/com/joelapenna/foursquared/widget/FriendListAdapter.java Wed
Mar 10 03:10:47 2010
+++ /main/src/com/joelapenna/foursquared/widget/FriendListAdapter.java Thu
Sep 30 11:43:33 2010
@@ -5,9 +5,7 @@
package com.joelapenna.foursquared.widget;

import com.joelapenna.foursquare.Foursquare;
-import com.joelapenna.foursquare.types.Group;
import com.joelapenna.foursquare.types.User;
-import com.joelapenna.foursquared.FoursquaredSettings;
import com.joelapenna.foursquared.R;
import com.joelapenna.foursquared.util.RemoteResourceManager;

@@ -16,7 +14,6 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Handler;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -24,8 +21,10 @@
import android.widget.TextView;

import java.io.IOException;
+import java.util.HashSet;
import java.util.Observable;
import java.util.Observer;
+import java.util.Set;

/**
* @date March 8, 2010
@@ -34,16 +33,13 @@
public class FriendListAdapter extends BaseGroupAdapter<User>
implements ObservableAdapter {

- private static final String TAG = "";
- private static final boolean DEBUG = FoursquaredSettings.DEBUG;
-
private LayoutInflater mInflater;
private int mLayoutToInflate;
private RemoteResourceManager mRrm;
private RemoteResourceManagerObserver mResourcesObserver;
private Handler mHandler = new Handler();
- private int mLoadedPhotoIndex;
-
+
+ private Set<String> mLaunchedPhotoFetches;

public FriendListAdapter(Context context, RemoteResourceManager rrm) {
super(context);
@@ -51,13 +47,13 @@
mLayoutToInflate = R.layout.friend_list_item;
mRrm = rrm;
mResourcesObserver = new RemoteResourceManagerObserver();
- mLoadedPhotoIndex = 0;
+ mLaunchedPhotoFetches = new HashSet<String>();

mRrm.addObserver(mResourcesObserver);
}

public void removeObserver() {
- mHandler.removeCallbacks(mRunnableLoadPhotos);
+ mHandler.removeCallbacks(mUpdatePhoto);
mRrm.deleteObserver(mResourcesObserver);
}

@@ -103,6 +99,11 @@
} else {
holder.photo.setImageResource(R.drawable.blank_girl);
}
+
+ if (!mLaunchedPhotoFetches.contains(user.getId())) {
+ mLaunchedPhotoFetches.add(user.getId());
+ mRrm.request(photoUri);
+ }
}

holder.name.setText(user.getFirstname() + " "
@@ -116,45 +117,17 @@
notifyDataSetInvalidated();
}

- @Override
- public void setGroup(Group<User> g) {
- super.setGroup(g);
- mLoadedPhotoIndex = 0;
-
- mHandler.postDelayed(mRunnableLoadPhotos, 10L);
-
-// for (int i = 0; i < g.size(); i++) {
-// Uri photoUri = Uri.parse(g.get(i).getPhoto());
-// if (!mRrm.exists(photoUri)) {
-// mRrm.request(photoUri);
-// }
-// }
- }
-
private class RemoteResourceManagerObserver implements Observer {
@Override
public void update(Observable observable, Object data) {
- if (DEBUG) Log.d(TAG, "Fetcher got: " + data);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyDataSetChanged();
- }
- });
+ mHandler.post(mUpdatePhoto);
}
}

- private Runnable mRunnableLoadPhotos = new Runnable() {
- @Override
+ private Runnable mUpdatePhoto = new Runnable() {
+ @Override
public void run() {
- if (mLoadedPhotoIndex < getCount()) {
- User user = (User)getItem(mLoadedPhotoIndex++);
- Uri photoUri = Uri.parse(user.getPhoto());
- if (!mRrm.exists(photoUri)) {
- mRrm.request(photoUri);
- }
- mHandler.postDelayed(mRunnableLoadPhotos, 200L);
- }
+ notifyDataSetChanged();
}
};

=======================================
--- /main/src/com/joelapenna/foursquared/widget/PhotoStrip.java Thu Sep 23
21:08:59 2010
+++ /main/src/com/joelapenna/foursquared/widget/PhotoStrip.java Thu Sep 30
11:43:33 2010
@@ -20,6 +20,8 @@
import android.view.View;

import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Observable;
import java.util.Observer;

@@ -41,6 +43,7 @@
private int mPhotoBorderStrokeColor;

private Group<User> mTypes;
+ private Map<String, Bitmap> mCachedBitmaps = new HashMap<String,
Bitmap>();

private RemoteResourceManager mRrm;
private RemoteResourceManagerObserver mResourcesObserver;
@@ -112,29 +115,26 @@
break;
}

- FoursquareType type = mTypes.get(index);
- Bitmap bmp = fetchBitmapForUser(type);
- if (bmp != null) {
- Rect rcSrc = new Rect(0, 0, bmp.getWidth(), bmp.getHeight());
- Rect rcDst = new Rect(
- index * (mPhotoSize + mPhotoSpacing),
- 0,
- index * (mPhotoSize + mPhotoSpacing) + mPhotoSize,
- mPhotoSize);
-
- paint.setColor(mPhotoBorderStrokeColor);
- canvas.drawRect(rcDst, paint);
- rcDst.inset(mPhotoBorderStroke, mPhotoBorderStroke);
- paint.setColor(mPhotoBorderColor);
- canvas.drawRect(rcDst, paint);
-
- rcDst.inset(mPhotoBorder, mPhotoBorder);
-
- canvas.drawBitmap(bmp, rcSrc, rcDst, paint);
-
- sum += (mPhotoSize + mPhotoSpacing);
- index++;
- }
+ Rect rcDst = new Rect(
+ index * (mPhotoSize + mPhotoSpacing),
+ 0,
+ index * (mPhotoSize + mPhotoSpacing) + mPhotoSize,
+ mPhotoSize);
+ paint.setColor(mPhotoBorderStrokeColor);
+ canvas.drawRect(rcDst, paint);
+ rcDst.inset(mPhotoBorderStroke, mPhotoBorderStroke);
+ paint.setColor(mPhotoBorderColor);
+ canvas.drawRect(rcDst, paint);
+ rcDst.inset(mPhotoBorder, mPhotoBorder);
+
+ FoursquareType type = mTypes.get(index);
+ Bitmap bmp = fetchBitmapForUser(type);
+ if (bmp != null) {
+ Rect rcSrc = new Rect(0, 0, bmp.getWidth(), bmp.getHeight());
+ canvas.drawBitmap(bmp, rcSrc, rcDst, paint);
+ }
+ sum += (mPhotoSize + mPhotoSpacing);
+ index++;
}
}

@@ -153,10 +153,15 @@
}

String photoUrl = user.getPhoto();
+ if (mCachedBitmaps.containsKey(photoUrl)) {
+ return mCachedBitmaps.get(photoUrl);
+ }
+
Uri uriPhoto = Uri.parse(photoUrl);
if (mRrm.exists(uriPhoto)) {
try {
Bitmap bitmap =
BitmapFactory.decodeStream(mRrm.getInputStream(Uri.parse(photoUrl)));
+ mCachedBitmaps.put(photoUrl, bitmap);
return bitmap;
} catch (IOException e) {
}

==============================================================================
Revision: e0e36103dc
Author: mar...@gmail.com
Date: Thu Sep 30 11:47:13 2010
Log: Replaced creation of new runnables with single runnable member.
Fetching of images needs to be re-architected though as in other adapters.
http://code.google.com/r/markww-foursquared/source/detail?r=e0e36103dc

Modified:
/main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java

=======================================
--- /main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java Mon
Sep 27 12:49:27 2010
+++ /main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java Thu
Sep 30 11:47:13 2010
@@ -68,6 +68,7 @@
}

public void removeObserver() {
+ mHandler.removeCallbacks(mUpdatePhotos);
mRrm.deleteObserver(mResourcesObserver);
}

@@ -164,15 +165,16 @@
private class RemoteResourceManagerObserver implements Observer {
@Override
public void update(Observable observable, Object data) {
- if (DEBUG) Log.d(TAG, "Fetcher got: " + data);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyDataSetChanged();
- }
- });
+ mHandler.post(mUpdatePhotos);
}
}
+
+ private Runnable mUpdatePhotos = new Runnable() {
+ @Override
+ public void run() {
+ notifyDataSetChanged();
+ }
+ };

private static class ViewHolder {
ImageView photo;

==============================================================================
Revision: ed45efa7d9
Author: mar...@gmail.com
Date: Thu Sep 30 11:51:02 2010
Log: Removed extra new runnable calls.
http://code.google.com/r/markww-foursquared/source/detail?r=ed45efa7d9

Modified:
/main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java

/main/src/com/joelapenna/foursquared/widget/FriendActionableListAdapter.java

=======================================
--- /main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java Thu
Sep 30 11:47:13 2010
+++ /main/src/com/joelapenna/foursquared/widget/CheckinListAdapter.java Thu
Sep 30 11:51:02 2010
@@ -8,7 +8,6 @@
import com.joelapenna.foursquare.types.Checkin;
import com.joelapenna.foursquare.types.Group;
import com.joelapenna.foursquare.types.User;
-import com.joelapenna.foursquared.FoursquaredSettings;
import com.joelapenna.foursquared.R;
import com.joelapenna.foursquared.util.CheckinTimestampSort;
import com.joelapenna.foursquared.util.RemoteResourceManager;
@@ -21,7 +20,6 @@
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -43,9 +41,6 @@
*/
public class CheckinListAdapter extends BaseCheckinAdapter implements
ObservableAdapter {

- private static final String TAG = "CheckinListAdapter";
- private static final boolean DEBUG = FoursquaredSettings.DEBUG;
-
private LayoutInflater mInflater;

private RemoteResourceManager mRrm;
=======================================
---
/main/src/com/joelapenna/foursquared/widget/FriendActionableListAdapter.java
Sat Sep 25 22:10:34 2010
+++
/main/src/com/joelapenna/foursquared/widget/FriendActionableListAdapter.java
Thu Sep 30 11:51:02 2010
@@ -65,6 +65,7 @@

public void removeObserver() {
mHandler.removeCallbacks(mRunnableLoadPhotos);
+ mHandler.removeCallbacks(mUpdatePhotos);
mRrm.deleteObserver(mResourcesObserver);
}

@@ -155,15 +156,17 @@
private class RemoteResourceManagerObserver implements Observer {
@Override
public void update(Observable observable, Object data) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyDataSetChanged();
- }
- });
+ mHandler.post(mUpdatePhotos);
}
}

+ private Runnable mUpdatePhotos = new Runnable() {
+ @Override
+ public void run() {
+ notifyDataSetChanged();
+ }
+ };
+
private Runnable mRunnableLoadPhotos = new Runnable() {
@Override
public void run() {

==============================================================================
Revision: 2fd06bd8ae
Author: mar...@gmail.com
Date: Thu Sep 30 12:01:25 2010
Log: Turning off debug flags.
http://code.google.com/r/markww-foursquared/source/detail?r=2fd06bd8ae

Modified:
/main/AndroidManifest.xml
/main/src/com/joelapenna/foursquare/Foursquare.java

=======================================
--- /main/AndroidManifest.xml Thu Sep 30 11:43:33 2010
+++ /main/AndroidManifest.xml Thu Sep 30 12:01:25 2010
@@ -4,8 +4,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joelapenna.foursquared"
android:installLocation="auto"
- android:versionName="2010-09-30" android:versionCode="2010093000"
- android:debuggable="true">
+ android:versionName="2010-09-30" android:versionCode="2010093000" >

<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
=======================================
--- /main/src/com/joelapenna/foursquare/Foursquare.java Wed Sep 29 12:59:38
2010
+++ /main/src/com/joelapenna/foursquare/Foursquare.java Thu Sep 30 12:01:25
2010
@@ -34,7 +34,7 @@
*/
public class Foursquare {
private static final Logger LOG =
Logger.getLogger("com.joelapenna.foursquare");
- public static final boolean DEBUG = true;
+ public static final boolean DEBUG = false;
public static final boolean PARSER_DEBUG = false;

public static final String FOURSQUARE_API_DOMAIN
= "api.foursquare.com";

==============================================================================
Revision: fc71fe486c
Author: mar...@gmail.com
Date: Thu Sep 30 12:20:32 2010
Log: Removed creation of new runnables for photo updates.
http://code.google.com/r/markww-foursquared/source/detail?r=fc71fe486c

Modified:
/main/src/com/joelapenna/foursquared/widget/TipsListAdapter.java
/main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java

=======================================
--- /main/src/com/joelapenna/foursquared/widget/TipsListAdapter.java Fri
Sep 24 21:33:41 2010
+++ /main/src/com/joelapenna/foursquared/widget/TipsListAdapter.java Thu
Sep 30 12:20:32 2010
@@ -10,7 +10,6 @@
import com.joelapenna.foursquare.types.Tip;
import com.joelapenna.foursquare.types.User;
import com.joelapenna.foursquare.types.Venue;
-import com.joelapenna.foursquared.FoursquaredSettings;
import com.joelapenna.foursquared.R;
import com.joelapenna.foursquared.util.RemoteResourceManager;
import com.joelapenna.foursquared.util.StringFormatters;
@@ -22,7 +21,6 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Handler;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -42,9 +40,6 @@
public class TipsListAdapter extends BaseGroupAdapter<Tip>
implements ObservableAdapter {

- private static final String TAG = "";
- private static final boolean DEBUG = FoursquaredSettings.DEBUG;
-
private LayoutInflater mInflater;
private int mLayoutToInflate;
private Resources mResources;
@@ -71,6 +66,7 @@
}

public void removeObserver() {
+ mHandler.removeCallbacks(mUpdatePhotos);
mHandler.removeCallbacks(mRunnableLoadPhotos);
mRrm.deleteObserver(mResourcesObserver);
}
@@ -226,16 +222,17 @@
private class RemoteResourceManagerObserver implements Observer {
@Override
public void update(Observable observable, Object data) {
- if (DEBUG) Log.d(TAG, "Fetcher got: " + data);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyDataSetChanged();
- }
- });
+ mHandler.post(mUpdatePhotos);
}
}

+ private Runnable mUpdatePhotos = new Runnable() {
+ @Override
+ public void run() {
+ notifyDataSetChanged();
+ }
+ };
+
private Runnable mRunnableLoadPhotos = new Runnable() {
@Override
public void run() {
=======================================
--- /main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java Tue
Sep 28 10:28:32 2010
+++ /main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java Thu
Sep 30 12:20:32 2010
@@ -8,7 +8,6 @@
import com.joelapenna.foursquare.types.Tip;
import com.joelapenna.foursquare.types.Todo;
import com.joelapenna.foursquare.types.Venue;
-import com.joelapenna.foursquared.FoursquaredSettings;
import com.joelapenna.foursquared.R;
import com.joelapenna.foursquared.util.RemoteResourceManager;
import com.joelapenna.foursquared.util.StringFormatters;
@@ -22,7 +21,6 @@
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -42,9 +40,6 @@
public class TodosListAdapter extends BaseGroupAdapter<Todo>
implements ObservableAdapter {

- private static final String TAG = "";
- private static final boolean DEBUG = FoursquaredSettings.DEBUG;
-
private LayoutInflater mInflater;
private int mLayoutToInflate;
private Resources mResources;
@@ -73,6 +68,7 @@
}

public void removeObserver() {
+ mHandler.removeCallbacks(mUpdatePhotos);
mHandler.removeCallbacks(mRunnableLoadPhotos);
mRrm.deleteObserver(mResourcesObserver);
}
@@ -200,16 +196,17 @@
private class RemoteResourceManagerObserver implements Observer {
@Override
public void update(Observable observable, Object data) {
- if (DEBUG) Log.d(TAG, "Fetcher got: " + data);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- notifyDataSetChanged();
- }
- });
+ mHandler.post(mUpdatePhotos);
}
}

+ private Runnable mUpdatePhotos = new Runnable() {
+ @Override
+ public void run() {
+ notifyDataSetChanged();
+ }
+ };
+
private Runnable mRunnableLoadPhotos = new Runnable() {
@Override
public void run() {

==============================================================================
Revision: a7c38c4378
Author: mar...@gmail.com
Date: Thu Sep 30 13:00:32 2010
Log: Put a null check for todos without a tip. There are not supposed to be
todos without a top attached returned by the api, but looks like some old
tips from a year ago are malformed and still coming through the api.
http://code.google.com/r/markww-foursquared/source/detail?r=a7c38c4378

Modified:
/main/src/com/joelapenna/foursquared/TodosActivity.java
/main/src/com/joelapenna/foursquared/VenueTodosActivity.java
/main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java

=======================================
--- /main/src/com/joelapenna/foursquared/TodosActivity.java Wed Sep 29
12:59:38 2010
+++ /main/src/com/joelapenna/foursquared/TodosActivity.java Thu Sep 30
13:00:32 2010
@@ -216,9 +216,11 @@
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
Todo todo = (Todo) parent.getAdapter().getItem(position);
- Intent intent = new Intent(TodosActivity.this,
TipActivity.class);
- intent.putExtra(TipActivity.EXTRA_TIP_PARCEL,
todo.getTip());
- startActivityForResult(intent, ACTIVITY_TIP);
+ if (todo.getTip() != null) {
+ Intent intent = new Intent(TodosActivity.this,
TipActivity.class);
+ intent.putExtra(TipActivity.EXTRA_TIP_PARCEL,
todo.getTip());
+ startActivityForResult(intent, ACTIVITY_TIP);
+ }
}
});

=======================================
--- /main/src/com/joelapenna/foursquared/VenueTodosActivity.java Wed Sep 22
13:42:23 2010
+++ /main/src/com/joelapenna/foursquared/VenueTodosActivity.java Thu Sep 30
13:00:32 2010
@@ -115,12 +115,14 @@

venue.setCrossstreet(mStateHolder.getVenue().getCrossstreet());

Todo todo = (Todo) parent.getAdapter().getItem(position);
- todo.getTip().setVenue(venue);
-
- Intent intent = new Intent(VenueTodosActivity.this,
TipActivity.class);
- intent.putExtra(TipActivity.EXTRA_TIP_PARCEL,
todo.getTip());
- intent.putExtra(TipActivity.EXTRA_VENUE_CLICKABLE, false);
- startActivityForResult(intent, ACTIVITY_TIP);
+ if (todo.getTip() != null) {
+ todo.getTip().setVenue(venue);
+
+ Intent intent = new Intent(VenueTodosActivity.this,
TipActivity.class);
+ intent.putExtra(TipActivity.EXTRA_TIP_PARCEL,
todo.getTip());
+ intent.putExtra(TipActivity.EXTRA_VENUE_CLICKABLE,
false);
+ startActivityForResult(intent, ACTIVITY_TIP);
+ }
}
});
}
=======================================
--- /main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java Thu
Sep 30 12:20:32 2010
+++ /main/src/com/joelapenna/foursquared/widget/TodosListAdapter.java Thu
Sep 30 13:00:32 2010
@@ -109,64 +109,71 @@

Todo todo = (Todo)getItem(position);
Tip tip = todo.getTip();
-
- if (mDisplayVenueTitles && tip.getVenue() != null) {
- holder.title.setText("@ " + tip.getVenue().getName());
- holder.title.setVisibility(View.VISIBLE);
- } else {
- holder.title.setVisibility(View.GONE);
-
- holder.body.setPadding(
- holder.body.getPaddingLeft(), holder.title.getPaddingTop(),
- holder.body.getPaddingRight(),
holder.body.getPaddingBottom());
- }
-
- if (tip.getVenue() != null && tip.getVenue().getCategory() !=
null) {
- Uri photoUri =
Uri.parse(tip.getVenue().getCategory().getIconUrl());
- try {
- Bitmap bitmap =
BitmapFactory.decodeStream(mRrm.getInputStream(photoUri));
- holder.photo.setImageBitmap(bitmap);
- } catch (IOException e) {
+ if (tip != null) {
+ if (mDisplayVenueTitles && tip.getVenue() != null) {
+ holder.title.setText("@ " + tip.getVenue().getName());
+ holder.title.setVisibility(View.VISIBLE);
+ } else {
+ holder.title.setVisibility(View.GONE);
+
+ holder.body.setPadding(
+ holder.body.getPaddingLeft(),
holder.title.getPaddingTop(),
+ holder.body.getPaddingRight(),
holder.body.getPaddingBottom());
+ }
+
+ if (tip.getVenue() != null && tip.getVenue().getCategory() !=
null) {
+ Uri photoUri =
Uri.parse(tip.getVenue().getCategory().getIconUrl());
+ try {
+ Bitmap bitmap =
BitmapFactory.decodeStream(mRrm.getInputStream(photoUri));
+ holder.photo.setImageBitmap(bitmap);
+ } catch (IOException e) {
+
holder.photo.setImageResource(R.drawable.category_none);
+ }
+ } else {
holder.photo.setImageResource(R.drawable.category_none);
}
- } else {
- holder.photo.setImageResource(R.drawable.category_none);
- }
-
- if (!TextUtils.isEmpty(tip.getText())) {
- holder.body.setText(tip.getText());
- holder.body.setVisibility(View.VISIBLE);
- } else {
- if (mSdk > 3) {
- holder.body.setVisibility(View.GONE);
+
+ if (!TextUtils.isEmpty(tip.getText())) {
+ holder.body.setText(tip.getText());
+ holder.body.setVisibility(View.VISIBLE);
} else {
- holder.body.setText("");
- holder.body.setVisibility(View.INVISIBLE);
- }
- }
-
-
- holder.dateAndAuthor.setText(mResources.getString(
- R.string.todo_added_date,
- mCachedTimestamps.get(todo.getId())));
- if (tip.getUser() != null) {
- holder.dateAndAuthor.setText(
+ if (mSdk > 3) {
+ holder.body.setVisibility(View.GONE);
+ } else {
+ holder.body.setText("");
+ holder.body.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ if (tip.getUser() != null) {
+ holder.dateAndAuthor.setText(
holder.dateAndAuthor.getText() +
- mResources.getString(
+ mResources.getString(
R.string.tip_age_via,

StringFormatters.getUserFullName(tip.getUser())));
- }
-
- if (TipUtils.isDone(tip)) {
- holder.corner.setVisibility(View.VISIBLE);
-
holder.corner.setImageResource(R.drawable.tip_list_item_corner_done);
- } else if (TipUtils.isTodo(tip)) {
+ }
+
+ if (TipUtils.isDone(tip)) {
+ holder.corner.setVisibility(View.VISIBLE);
+
holder.corner.setImageResource(R.drawable.tip_list_item_corner_done);
+ } else if (TipUtils.isTodo(tip)) {
+ holder.corner.setVisibility(View.VISIBLE);
+
holder.corner.setImageResource(R.drawable.tip_list_item_corner_todo);
+ } else {
+ holder.corner.setVisibility(View.GONE);
+ }
+ } else {
+ holder.title.setText("");
+ holder.body.setText("");
holder.corner.setVisibility(View.VISIBLE);

holder.corner.setImageResource(R.drawable.tip_list_item_corner_todo);
- } else {
- holder.corner.setVisibility(View.GONE);
- }
-
+ holder.photo.setImageResource(R.drawable.category_none);
+ }
+
+ holder.dateAndAuthor.setText(mResources.getString(
+ R.string.todo_added_date,
+ mCachedTimestamps.get(todo.getId())));
+
return convertView;
}

Reply all
Reply to author
Forward
0 new messages