@@ -53,6 +53,7 @@ public class SimpleThumbnailCursorAdapter extends SimpleCursorAdapter {
5353 private final Context mContext ;
5454
5555 private boolean mShowIndeterminate = false ;
56+ private int mExpectedCount = -1 ;
5657
5758 /**
5859 * All parameters are passed directly to {@link SimpleCursorAdapter}
@@ -86,7 +87,7 @@ public SimpleThumbnailCursorAdapter(Context context, int layout, Cursor c,
8687 }
8788 }
8889
89- setIndeterminateLoading (c == null );
90+ setIndeterminateLoading (c == null || isNotShowingExpectedCount ( c ) );
9091 }
9192
9293 final View v = LayoutInflater .from (context )
@@ -172,13 +173,22 @@ public View getView(int position, View convertView, ViewGroup parent) {
172173
173174 @ Override
174175 public Cursor swapCursor (Cursor c ) {
175- setIndeterminateLoading (c == null );
176+ setIndeterminateLoading (c == null || isNotShowingExpectedCount ( c ) );
176177 return super .swapCursor (c );
177178 }
178179
179180 @ Override
180181 public void changeCursor (Cursor cursor ) {
181182 super .changeCursor (cursor );
182- setIndeterminateLoading (cursor == null );
183+ setIndeterminateLoading (cursor == null || isNotShowingExpectedCount (cursor ));
184+ }
185+
186+ private boolean isNotShowingExpectedCount (Cursor c ){
187+ return c != null && (mExpectedCount > -1 && (c .getCount () != mExpectedCount ));
188+ }
189+
190+ public void setExpectedCount (int expectedCount ){
191+ mExpectedCount = expectedCount ;
192+ setIndeterminateLoading (mCursor == null || isNotShowingExpectedCount (mCursor ));
183193 }
184194}
0 commit comments