packages/apps/Gallery2
修订版 | 77fd27466cabd2506acd76b29e3381fba5101a65 (tree) |
---|---|
时间 | 2011-08-19 12:24:29 |
作者 | Ray Chen <raychen@goog...> |
Commiter | Android (Google) Code Review |
Merge "Fix 5179825 Toast is created in a unprepared looper."
@@ -21,6 +21,8 @@ import com.android.gallery3d.util.ReverseGeocoder; | ||
21 | 21 | import com.android.gallery3d.util.GalleryUtils; |
22 | 22 | |
23 | 23 | import android.content.Context; |
24 | +import android.os.Handler; | |
25 | +import android.os.Looper; | |
24 | 26 | import android.widget.Toast; |
25 | 27 | |
26 | 28 | import java.util.ArrayList; |
@@ -38,6 +40,7 @@ class LocationClustering extends Clustering { | ||
38 | 40 | private ArrayList<ArrayList<SmallItem>> mClusters; |
39 | 41 | private ArrayList<String> mNames; |
40 | 42 | private String mNoLocationString; |
43 | + private Handler mHandler; | |
41 | 44 | |
42 | 45 | private static class Point { |
43 | 46 | public Point(double lat, double lng) { |
@@ -56,6 +59,7 @@ class LocationClustering extends Clustering { | ||
56 | 59 | public LocationClustering(Context context) { |
57 | 60 | mContext = context; |
58 | 61 | mNoLocationString = mContext.getResources().getString(R.string.no_location); |
62 | + mHandler = new Handler(Looper.getMainLooper()); | |
59 | 63 | } |
60 | 64 | |
61 | 65 | @Override |
@@ -131,8 +135,12 @@ class LocationClustering extends Clustering { | ||
131 | 135 | } |
132 | 136 | |
133 | 137 | if (hasUnresolvedAddress) { |
134 | - Toast.makeText(mContext, R.string.no_connectivity, | |
135 | - Toast.LENGTH_LONG).show(); | |
138 | + mHandler.post(new Runnable() { | |
139 | + public void run() { | |
140 | + Toast.makeText(mContext, R.string.no_connectivity, | |
141 | + Toast.LENGTH_LONG).show(); | |
142 | + } | |
143 | + }); | |
136 | 144 | } |
137 | 145 | } |
138 | 146 |