diff --git a/src/cn/trinea/android/demo/DownloadManagerDemo.java b/src/cn/trinea/android/demo/DownloadManagerDemo.java index 79ffa6d..ea32f69 100644 --- a/src/cn/trinea/android/demo/DownloadManagerDemo.java +++ b/src/cn/trinea/android/demo/DownloadManagerDemo.java @@ -47,7 +47,6 @@ public class DownloadManagerDemo extends BaseActivity { private DownloadManagerPro downloadManagerPro; private long downloadId = 0; - private Context context; private MyHandler handler; private DownloadChangeObserver downloadObserver; @@ -57,7 +56,6 @@ public class DownloadManagerDemo extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.download_manager_demo); - context = getApplicationContext(); handler = new MyHandler(); downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE); downloadManagerPro = new DownloadManagerPro(downloadManager); @@ -71,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) { */ Uri data = intent.getData(); if (data != null) { - Toast.makeText(getApplicationContext(), data.toString(), Toast.LENGTH_LONG).show(); + Toast.makeText(context, data.toString(), Toast.LENGTH_LONG).show(); } } diff --git a/src/cn/trinea/android/demo/HttpCacheDemo.java b/src/cn/trinea/android/demo/HttpCacheDemo.java index bab13c1..26f7696 100644 --- a/src/cn/trinea/android/demo/HttpCacheDemo.java +++ b/src/cn/trinea/android/demo/HttpCacheDemo.java @@ -2,7 +2,6 @@ import java.util.Date; -import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; @@ -35,7 +34,6 @@ public class HttpCacheDemo extends BaseActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.http_cache_demo); - Context context = getApplicationContext(); // get the singleton instance of HttpCache httpCache = CacheManager.getHttpCache(context); // or create a new HttpCache, like this: diff --git a/src/cn/trinea/android/demo/ImageCacheDemo.java b/src/cn/trinea/android/demo/ImageCacheDemo.java index 23d402a..019b5a8 100644 --- a/src/cn/trinea/android/demo/ImageCacheDemo.java +++ b/src/cn/trinea/android/demo/ImageCacheDemo.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; -import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Environment; @@ -46,7 +45,6 @@ public class ImageCacheDemo extends BaseActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.image_cache_demo); - Context context = getApplicationContext(); parentLayout = (RelativeLayout)findViewById(R.id.image_cache_parent_layout); initImageUrlList(); IMAGE_CACHE.initData(this, TAG_CACHE); diff --git a/src/cn/trinea/android/demo/ImagePagerFragment.java b/src/cn/trinea/android/demo/ImagePagerFragment.java index 4e09aec..4f797c0 100644 --- a/src/cn/trinea/android/demo/ImagePagerFragment.java +++ b/src/cn/trinea/android/demo/ImagePagerFragment.java @@ -45,7 +45,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa imageIdList.add(R.drawable.banner2); imageIdList.add(R.drawable.banner3); imageIdList.add(R.drawable.banner4); - viewPager.setAdapter(new ImagePagerAdapter(getActivity().getApplicationContext(), imageIdList)); + viewPager.setAdapter(new ImagePagerAdapter(context, imageIdList)); indicator.setViewPager(viewPager); viewPager.setInterval(2000); diff --git a/src/cn/trinea/android/demo/ImageSDCardCacheDemo.java b/src/cn/trinea/android/demo/ImageSDCardCacheDemo.java index dba54b7..ce00d28 100644 --- a/src/cn/trinea/android/demo/ImageSDCardCacheDemo.java +++ b/src/cn/trinea/android/demo/ImageSDCardCacheDemo.java @@ -45,7 +45,6 @@ public class ImageSDCardCacheDemo extends BaseActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.image_sdcard_cache_demo); - Context context = getApplicationContext(); initImageUrlList(); IMAGE_SD_CACHE.initData(context, TAG_CACHE); IMAGE_SD_CACHE.setContext(context); diff --git a/src/cn/trinea/android/demo/ServiceDemo.java b/src/cn/trinea/android/demo/ServiceDemo.java index f18f4fc..89afb2f 100644 --- a/src/cn/trinea/android/demo/ServiceDemo.java +++ b/src/cn/trinea/android/demo/ServiceDemo.java @@ -45,8 +45,7 @@ public class ServiceDemo extends BaseActivity { */ @Override public void onServiceDisconnected(ComponentName name) { - Toast.makeText(getApplicationContext(), "Service disconnect", - Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "Service disconnect", Toast.LENGTH_SHORT).show(); } /** @@ -55,8 +54,7 @@ public void onServiceDisconnected(ComponentName name) { @Override public void onServiceConnected(ComponentName name, IBinder service) { myService = ((MyBinder)service).getService(); - Toast.makeText(getApplicationContext(), "Service Connect", Toast.LENGTH_SHORT) - .show(); + Toast.makeText(context, "Service Connect", Toast.LENGTH_SHORT).show(); } }; diff --git a/src/cn/trinea/android/demo/SlideOnePageGalleryDemo.java b/src/cn/trinea/android/demo/SlideOnePageGalleryDemo.java index 693308d..beb9cde 100644 --- a/src/cn/trinea/android/demo/SlideOnePageGalleryDemo.java +++ b/src/cn/trinea/android/demo/SlideOnePageGalleryDemo.java @@ -40,7 +40,7 @@ public void onNothingSelected(AdapterView parent) { } }); - ImageListAdapter adapter = new ImageListAdapter(getApplicationContext()); + ImageListAdapter adapter = new ImageListAdapter(context); List idList = new ArrayList(); idList.add(R.drawable.image1); idList.add(R.drawable.image2);