Skip to content

Commit

Permalink
Added a button that calls notifyDataSetChanged() on the list adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel committed Jul 12, 2012
1 parent 365489d commit 1ded7f0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 8 deletions.
24 changes: 18 additions & 6 deletions demo/res/layout/single_table_base_list_activity.xml
@@ -1,8 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/android:list"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:smoothScrollbar="true" />
<!-- added by dwa012 -->
<Button
android:id="@+id/refresh_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="refresh" />

<ListView
android:id="@android:id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:smoothScrollbar="true" />

</LinearLayout>
3 changes: 2 additions & 1 deletion demo/src/com/novoda/imageloader/demo/DemoApplication.java
Expand Up @@ -57,7 +57,8 @@ private void verboseImageManagerSettings() {
settingsBuilder.withAsyncTasks(false);

//You can set a specific directory for caching files on the sdcard
settingsBuilder.withCacheDir(new File("/something"));
// settingsBuilder.withCacheDir(new File("/something"));


//Setting this to false means that file cache will use the url without the query part
//for the generation of the hashname
Expand Down
15 changes: 15 additions & 0 deletions demo/src/com/novoda/imageloader/demo/activity/BigImages.java
Expand Up @@ -3,6 +3,8 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter.ViewBinder;

Expand Down Expand Up @@ -43,6 +45,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory = new ImageTagFactory(this, R.drawable.bg_img_loading);
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
setAdapter();

//added by dwa012
Button button = (Button) this.findViewById(R.id.refresh_button);
button.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
refreshData();


}

});
}

/**
Expand Down
15 changes: 15 additions & 0 deletions demo/src/com/novoda/imageloader/demo/activity/ImageLongList.java
Expand Up @@ -3,6 +3,8 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter.ViewBinder;

Expand Down Expand Up @@ -47,6 +49,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
imageTagFactory.setSaveThumbnail(true);
setAdapter();

//added by dwa012
Button button = (Button) this.findViewById(R.id.refresh_button);
button.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
refreshData();


}

});
}

/**
Expand Down
Expand Up @@ -3,7 +3,10 @@
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter.ViewBinder;

import com.novoda.imageloader.core.ImageManager;
Expand Down Expand Up @@ -50,6 +53,19 @@ public void onCreate(Bundle savedInstanceState) {
imageTagFactory.setErrorImageId(R.drawable.bg_img_notfound);
imageTagFactory.setSaveThumbnail(true);
setAdapter();

//added by dwa012
Button button = (Button) this.findViewById(R.id.refresh_button);
button.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
refreshData();


}

});
}

/**
Expand Down
Expand Up @@ -13,6 +13,9 @@ public abstract class SingleTableBaseListActivity extends ListActivity {

private static final String[] FROM = new String[] { "url" };
private static final int[] TO = new int[] { R.id.list_item_image };

//added by dwa012
private SimpleCursorAdapter adapter;

protected int getImageItem() {
return R.layout.image_item;
Expand All @@ -30,14 +33,23 @@ private Cursor getCursor() {
protected abstract String getTableName();

protected void setAdapter() {
SimpleCursorAdapter adapter = initAdapter();

//changed by dwa012
// SimpleCursorAdapter adapter = initAdapter();
adapter = initAdapter();
ListView lv = getListView();
ViewBinder binder = getViewBinder();
if (binder != null) {
adapter.setViewBinder(binder);
}
lv.setAdapter(adapter);
}

//added by dwa012
protected void refreshData(){
adapter.notifyDataSetChanged();
}


protected abstract ViewBinder getViewBinder();

Expand Down

0 comments on commit 1ded7f0

Please sign in to comment.