Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New changelist

  • Loading branch information...
commit 45e460843b61e501ba20d7e14056a9919c6587fa 1 parent 830a16b
@jleo authored
View
11 res/drawable/listbg.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_window_focused="false"
+ android:drawable="@color/background_color" />
+ <item android:state_focused="true" android:state_pressed="true"
+ android:drawable="@color/verylightblue" />
+ <item android:state_focused="false" android:state_pressed="true"
+ android:drawable="@color/verylightblue" />
+ <item android:state_selected="true" android:drawable="@color/verylightblue" />
+ <item android:state_focused="true" android:drawable="@color/verylightblue" />
+</selector>
View
2  res/values/colors.xml
@@ -12,5 +12,5 @@
<color name="background_color">#f4f4f2</color>
<color name="transparent">#00f4f4f2</color>
<color name="content_background">#f4f4f2</color>
-
+ <color name="verylightblue">#ff66ccff</color>
</resources>
View
2  src/com/handmark/pulltorefresh/library/PullToRefreshListView.java
@@ -3,6 +3,7 @@
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
+import com.srz.androidtools.R;
public class PullToRefreshListView extends PullToRefreshBase<ListView> {
@@ -19,6 +20,7 @@ protected final ListView createAdapterView(Context context, AttributeSet attrs)
ListView lv = new ListView(context, attrs);
// Set it to this so it can be used in ListActivity/ListFragment
lv.setVerticalFadingEdgeEnabled(true);
+ lv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.listbg));
// lv.setPadding(10,0,10,0);
lv.setId(android.R.id.list);
return lv;
View
21 src/com/srz/androidtools/autoloadlistview/AutoLoadArrayAdapter.java
@@ -25,7 +25,14 @@
private static LayoutInflater inflater;
ListView listView;
- public AutoLoadArrayAdapter(Activity activity, ListView listView, int layoutId, int progressDrawableResourceId, List items, int nodataview, View.OnClickListener noitemListener) {
+ public int getActualItemCount(){
+ if(items == null)
+ return 0;
+
+ return items.size();
+ }
+
+ public AutoLoadArrayAdapter(Activity activity, ListView listView, int layoutId, int progressDrawableResourceId, List items, int nodataview, View.OnClickListener noitemListener, OnNothingLoaded onNothingLoadedListener) {
super(activity, layoutId, items);
this.items = items;
this.layoutId = layoutId;
@@ -44,7 +51,7 @@ public AutoLoadArrayAdapter(Activity activity, ListView listView, int layoutId,
public List load() throws NoSuchPageException {
return AutoLoadArrayAdapter.this.load();
}
- }, this, listView);
+ }, this, listView, onNothingLoadedListener);
listView.setOnScrollListener(autoLoadScrollListener);
listView.setAdapter(this);
}
@@ -65,9 +72,9 @@ public boolean isLoadingData() {
private View progressView;
private View nodataitem;
- public void addItems(List detailInfos) {
- if (detailInfos != null)
- this.items.addAll(detailInfos);
+ public void addItems(List items) {
+ if (items != null)
+ this.items.addAll(items);
}
public void forceLoad(boolean showLoading) {
@@ -130,4 +137,8 @@ public View buildViewFromItem(int position, View convertView, ViewGroup parent)
public void setNoMoreToLoad(boolean noMoreToLoad) {
this.noMoreToLoad = noMoreToLoad;
}
+
+ public boolean isNoMoreToLoad() {
+ return this.noMoreToLoad;
+ }
}
View
15 src/com/srz/androidtools/autoloadlistview/AutoLoadScrollListener.java
@@ -1,6 +1,7 @@
package com.srz.androidtools.autoloadlistview;
import android.os.Handler;
+import android.util.Log;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
@@ -21,9 +22,11 @@
private AutoLoadArrayAdapter adapter;
Handler handler = new Handler();
private ListView listView;
+ private OnNothingLoaded onNothingLoadedListener;
- public AutoLoadScrollListener(OnLoadListener listener, AutoLoadArrayAdapter adapter, ListView listView) {
+ public AutoLoadScrollListener(OnLoadListener listener, AutoLoadArrayAdapter adapter, ListView listView, OnNothingLoaded nothingLoadedListener) {
this.onLoadListener = listener;
+ this.onNothingLoadedListener = nothingLoadedListener;
this.adapter = adapter;
this.listView = listView;
// listView.setFastScrollEnabled(true);
@@ -53,14 +56,14 @@ public void onScroll(AbsListView view, int firstVisibleItem,
public void onScrollStateChanged(AbsListView view, int scrollState) {
int first = view.getFirstVisiblePosition();
int count = view.getChildCount();
+ Log.d("jleoo",scrollState+"");
if (scrollState == SCROLL_STATE_IDLE || (first + count >= adapter.getCount())) {
- if ((fireLoad || isLastItemVisible()) && !adapter.isLoadingData()) {
- triggerHeavyUIOperation();
+ if ((fireLoad || isLastItemVisible()) && !adapter.isLoadingData() && !adapter.isNoMoreToLoad()) {
load(true);
+// triggerHeavyUIOperation();
} else {
fireLoad = false;
triggerHeavyUIOperation();
-
}
}
}
@@ -102,6 +105,10 @@ public void run() {
public void run() {
adapter.addItems(toAdd);
adapter.notifyDataSetChanged();
+ if((toAdd==null || toAdd.size() == 0)&&adapter.getActualItemCount()==0){
+ if(onNothingLoadedListener != null)
+ onNothingLoadedListener.onNothingLoaded();
+ }
}
});
handler.postDelayed(new Runnable() {
View
116 src/com/srz/androidtools/autoloadlistview/NoMoreDataSupportDefaultAdapter.java
@@ -1,58 +1,58 @@
-package com.srz.androidtools.autoloadlistview;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ListView;
-import com.srz.androidtools.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by IntelliJ IDEA.
- * User: janexie
- * Date: 12-1-26
- * Time: 下午8:05
- * To change this template use File | Settings | File Templates.
- */
-public abstract class NoMoreDataSupportDefaultAdapter<T> extends PaginationLoaderAdapter {
- protected Context context;
- private boolean loaded;
-
- public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService, List<T> detailInfo, int nodataview, View.OnClickListener noitemListener) {
- super(activity, listView, layoutId, progressDrawableResourceId, detailInfo, nodataview, loaderService, noitemListener);
- this.context = activity;
- }
-
- public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService, int nodataview, View.OnClickListener noitemListener) {
- this(activity, listView, progressDrawableResourceId, layoutId, loaderService, new ArrayList(), nodataview, noitemListener);
- }
-
- public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService) {
- this(activity, listView, progressDrawableResourceId, layoutId, loaderService, new ArrayList(), -1, null);
- }
-
- @Override
- protected void setNoDataOnClickListener(View nodataitem, View.OnClickListener listener) {
- nodataitem.findViewById(R.id.addmore).setOnClickListener(listener);
- }
-
- public boolean isLoaded() {
- return loaded;
- }
-
- public void setLoaded(boolean loaded) {
- this.loaded = loaded;
- }
-
- @Override
- public void forceLoad() {
- super.forceLoad();
- loaded = true;
- }
-
-
-}
+//package com.srz.androidtools.autoloadlistview;
+//
+//import android.app.Activity;
+//import android.content.Context;
+//import android.content.Intent;
+//import android.view.View;
+//import android.widget.AdapterView;
+//import android.widget.ListView;
+//import com.srz.androidtools.R;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+///**
+// * Created by IntelliJ IDEA.
+// * User: janexie
+// * Date: 12-1-26
+// * Time: 下午8:05
+// * To change this template use File | Settings | File Templates.
+// */
+//public abstract class NoMoreDataSupportDefaultAdapter<T> extends PaginationLoaderAdapter {
+// protected Context context;
+// private boolean loaded;
+//
+// public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService, List<T> detailInfo, int nodataview, View.OnClickListener noitemListener) {
+// super(activity, listView, layoutId, progressDrawableResourceId, detailInfo, nodataview, loaderService, noitemListener);
+// this.context = activity;
+// }
+//
+// public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService, int nodataview, View.OnClickListener noitemListener) {
+// this(activity, listView, progressDrawableResourceId, layoutId, loaderService, new ArrayList(), nodataview, noitemListener);
+// }
+//
+// public NoMoreDataSupportDefaultAdapter(Activity activity, ListView listView, int progressDrawableResourceId, int layoutId, PaginationLoaderService loaderService) {
+// this(activity, listView, progressDrawableResourceId, layoutId, loaderService, new ArrayList(), -1, null);
+// }
+//
+// @Override
+// protected void setNoDataOnClickListener(View nodataitem, View.OnClickListener listener) {
+// nodataitem.findViewById(R.id.addmore).setOnClickListener(listener);
+// }
+//
+// public boolean isLoaded() {
+// return loaded;
+// }
+//
+// public void setLoaded(boolean loaded) {
+// this.loaded = loaded;
+// }
+//
+// @Override
+// public void forceLoad() {
+// super.forceLoad();
+// loaded = true;
+// }
+//
+//
+//}
View
13 src/com/srz/androidtools/autoloadlistview/OnNothingLoaded.java
@@ -0,0 +1,13 @@
+package com.srz.androidtools.autoloadlistview;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: jleo
+ * Date: 12-5-22
+ * Time: 下午5:17
+ * To change this template use File | Settings | File Templates.
+ */
+public interface OnNothingLoaded {
+ public void onNothingLoaded();
+ public void setAdapter(PaginationLoaderAdapter adapter);
+}
View
4 src/com/srz/androidtools/autoloadlistview/PaginationLoaderAdapter.java
@@ -35,8 +35,8 @@ public void setPageCount(int pageCount) {
PaginationLoaderService loader;
- public PaginationLoaderAdapter(Activity activity, ListView listView, int layoutId, int progressDrawableResourceId, List items, int nodataview, PaginationLoaderService loader, View.OnClickListener noitemListener) {
- super(activity, listView, layoutId, progressDrawableResourceId, items, nodataview, noitemListener);
+ public PaginationLoaderAdapter(Activity activity, ListView listView, int layoutId, int progressDrawableResourceId, List items, int nodataview, PaginationLoaderService loader, View.OnClickListener noitemListener, OnNothingLoaded onNothingLoadedListener) {
+ super(activity, listView, layoutId, progressDrawableResourceId, items, nodataview, noitemListener, onNothingLoadedListener);
this.loader = loader;
}
View
3  src/com/srz/androidtools/util/AlarmSender.java
@@ -35,6 +35,9 @@ public static void sendInstantMessage(String msg, Context context) {
title.setText(msg);
if (toast == null)
toast = new Toast(context);
+ else
+ toast.cancel();
+
toast.setGravity(Gravity.CENTER, 0, 200);
toast.setDuration(2000);
toast.setView(layout);
Please sign in to comment.
Something went wrong with that request. Please try again.