Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SubscriptionExpandableListAdapter.java « ListView « owncloudnewsreader « luhmer « de « java « main « src « News-Android-App - github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 760173822edfe13607b682fa922179dd1bdee397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
/**
* Android ownCloud News
*
* @author David Luhmer
* @copyright 2013 David Luhmer david-dev@live.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/

package de.luhmer.owncloudnewsreader.ListView;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.io.File;
import java.util.ArrayList;

import butterknife.ButterKnife;
import butterknife.InjectView;
import de.luhmer.owncloudnewsreader.R;
import de.luhmer.owncloudnewsreader.SettingsActivity;
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
import de.luhmer.owncloudnewsreader.helper.FontHelper;
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
import de.luhmer.owncloudnewsreader.model.AbstractItem;
import de.luhmer.owncloudnewsreader.model.ConcreteFeedItem;
import de.luhmer.owncloudnewsreader.model.FolderSubscribtionItem;

import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_STARRED_ITEMS;
import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS;
import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ITEMS_WITHOUT_FOLDER;

public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
    //private static final String TAG = "SubscriptionExpandableListAdapter";

	private Context mContext;
    private DatabaseConnection dbConn;
    FontHelper fHelper;

    ListView listView;

    ExpListTextClicked eListTextClickHandler;

    private ArrayList<AbstractItem> mCategoriesArrayList;
    private SparseArray<SparseArray<ConcreteFeedItem>> mItemsArrayList;
	private boolean showOnlyUnread = false;

    public static enum SPECIAL_FOLDERS  {
        ALL_UNREAD_ITEMS(-10), ALL_STARRED_ITEMS(-11), ALL_ITEMS(-12), ITEMS_WITHOUT_FOLDER(-22);

        private int id;
        SPECIAL_FOLDERS(int id) {
            this.id = id;
        }

        public int getValue() {
            return id;
        }

        public String getValueString() {
            return String.valueOf(id);
        }

        @Override
        public String toString() {
            return getValueString();
        }
    }

    int mTextColorLightTheme;

    LayoutInflater inflater;
    private final String favIconPath;
    boolean mIsTwoPane;
    private static boolean isTwoPane(Context context) {
        return context.getResources().getBoolean(R.bool.two_pane);
        //return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
    }

    public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn, ListView listView)
    {
        mIsTwoPane = isTwoPane(mContext);

        //Picasso.with(mContext).setDebugging(true);

        this.favIconPath = ImageHandler.getPathFavIcons(mContext);
        this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    	this.mContext = mContext;
    	this.dbConn = dbConn;

        mTextColorLightTheme = mContext.getResources().getColor(R.color.slider_listview_text_color_light_theme);

    	//int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    	//Use 1/8 of the available memory for this memory cache
    	//int cachSize = maxMemory / 8;
    	//favIconCache = new BitmapDrawableLruCache(cachSize);

        fHelper = new FontHelper(mContext);

        unreadCountFeeds = new SparseArray<String>();
        unreadCountFolders = new SparseArray<String>();

        mCategoriesArrayList = new ArrayList<AbstractItem>();
        mItemsArrayList = new SparseArray<SparseArray<ConcreteFeedItem>>();

        this.listView = listView;
    }

    private void AddEverythingInCursorFolderToSubscriptions(Cursor itemsCursor)
    {
    	while (itemsCursor.moveToNext()) {
    		String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL));
            //String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL_ID));
    		long id = itemsCursor.getLong(0);
    		mCategoriesArrayList.add(new FolderSubscribtionItem(header, null, id, null));
    	}
        itemsCursor.close();
    }

    private void AddEverythingInCursorFeedsToSubscriptions(Cursor itemsCursor)
    {
    	while (itemsCursor.moveToNext()) {
    		String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
            //String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
    		long id = itemsCursor.getLong(0);
            String subscriptionId = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
            String favIconUrl = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
            mCategoriesArrayList.add(new ConcreteFeedItem(header, ITEMS_WITHOUT_FOLDER.getValueString(), subscriptionId, favIconUrl, id));
    	}
        itemsCursor.close();
    }

	@SuppressWarnings("deprecation")
	@Override
	public Object getChild(int groupPosition, int childPosition) {

		int parent_id = (int)getGroupId(groupPosition);
        return mItemsArrayList.get(parent_id).get(childPosition);
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		return ((ConcreteFeedItem)(getChild(groupPosition, childPosition))).id_database;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		final ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
        final ChildHolder viewHolder;

        if (convertView != null) {
            viewHolder = (ChildHolder) convertView.getTag();
        } else {
            LinearLayout view = new LinearLayout(mContext);
            convertView = inflater.inflate(R.layout.subscription_list_sub_item, view, true);
            viewHolder = new ChildHolder(convertView, mContext);
            convertView.setTag(viewHolder);

            if(!ThemeChooser.isDarkTheme(mContext)) {
                viewHolder.tV_HeaderText.setTextColor(mTextColorLightTheme);
                viewHolder.tV_UnreadCount.setTextColor(mTextColorLightTheme);
            }
        }


        if(item != null)
        {
	        String headerText = (item.header != null) ? item.header : "";
	        viewHolder.tV_HeaderText.setText(headerText);



            String unreadCount = unreadCountFeeds.get((int) item.id_database);
            if(unreadCount != null)
                viewHolder.tV_UnreadCount.setText(unreadCount);
            else
                viewHolder.tV_UnreadCount.setText("");
            /*
            else {
                viewHolder.tV_UnreadCount.setText("0");
                //mItemsArrayList.get(groupPosition).remove(childPosition-1);
                //this.notifyDataSetChanged();
            }*/
            /*
            else {
                boolean excludeStarredItems = (item.idFolder.equals(ALL_STARRED_ITEMS)) ? false : true;
                SetUnreadCountForFeed(viewHolder.tV_UnreadCount, String.valueOf(item.id_database), excludeStarredItems);
            }*/

            loadFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon);
        }
        else
        {
	        viewHolder.tV_HeaderText.setText(mContext.getString(R.string.login_dialog_text_something_went_wrong));
	        viewHolder.tV_UnreadCount.setText("");
	        viewHolder.imgView_FavIcon.setImageDrawable(null);
        }

        return convertView;
	}

	static class ChildHolder {
        @InjectView(R.id.summary) TextView tV_HeaderText;
        @InjectView(R.id.tv_unreadCount) TextView tV_UnreadCount;
        @InjectView(R.id.iVFavicon) ImageView imgView_FavIcon;

        public ChildHolder(View view, Context mContext) {
            ButterKnife.inject(this, view);

            FontHelper fHelper = new FontHelper(mContext);
            fHelper.setFontForAllChildren(view, fHelper.getFont());
        }
	  }

	@Override
	public int getChildrenCount(int groupPosition) {
        int parent_id = (int)getGroupId(groupPosition);
        return (mItemsArrayList.get(parent_id) != null) ? mItemsArrayList.get(parent_id).size() : 0;
	}

	@Override
	public Object getGroup(int groupPosition) {
		return mCategoriesArrayList.get(groupPosition);
	}

	@Override
	public int getGroupCount() {
		return mCategoriesArrayList.size();
	}

	@Override
	public long getGroupId(int groupPosition) {
		return ((AbstractItem)getGroup(groupPosition)).id_database;
	}

    private enum GroupViewType { FOLDER, FEED }

    @Override
    public int getGroupType(int groupPosition) {
        AbstractItem ai = mCategoriesArrayList.get(groupPosition);

        if(ai instanceof FolderSubscribtionItem)
            return GroupViewType.FOLDER.ordinal();
        else
            return GroupViewType.FEED.ordinal();
    }

    @Override
    public int getGroupTypeCount() {
        return GroupViewType.values().length;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {

		GroupHolder viewHolder;
        final AbstractItem group = (AbstractItem) getGroup(groupPosition);

        if (convertView == null) {
            LinearLayout view = new LinearLayout(mContext);
            convertView = inflater.inflate(R.layout.subscription_list_item, view, true);
            viewHolder = new GroupHolder(convertView, mContext);
            view.setTag(viewHolder);

            if(!ThemeChooser.isDarkTheme(mContext)) {
                viewHolder.txt_UnreadCount.setTextColor(mTextColorLightTheme);
                viewHolder.txt_Summary.setTextColor(mTextColorLightTheme);
            }
        } else {
        	viewHolder = (GroupHolder) convertView.getTag();
        }


        viewHolder.txt_Summary.setText(group.header);
        viewHolder.txt_Summary.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				String val = String.valueOf(group.id_database);
				boolean skipFireEvent = false;

                if(group instanceof ConcreteFeedItem) {
                    fireListTextClicked(val, mContext, false, ITEMS_WITHOUT_FOLDER.getValueString());
                    skipFireEvent = true;
				}

				if(!skipFireEvent)
					fireListTextClicked(val, mContext, true, ((FolderSubscribtionItem) group).idFolder);
			}
		});


        viewHolder.txt_UnreadCount.setText("");
        boolean skipGetUnread = false;
        if(group.idFolder != null && group.idFolder.equals(ITEMS_WITHOUT_FOLDER.getValueString())) {

            String unreadCount = unreadCountFeeds.get((int) group.id_database);
            if(unreadCount != null)
                viewHolder.txt_UnreadCount.setText(unreadCount);
            /*
            else {
                //SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
                //Log.d(TAG, "Fetching unread count manually... " + group.headerFolder);
            }
             */



            skipGetUnread = true;
        }

        if(!skipGetUnread) {
            String unreadCount = unreadCountFolders.get((int) group.id_database);
            if(unreadCount != null)
                viewHolder.txt_UnreadCount.setText(unreadCount);
            /*
            else {
                //viewHolder.txt_UnreadCount.setText("-1");
                SetUnreadCountForFolder(viewHolder.txt_UnreadCount, String.valueOf(group.id_database));
                //Log.d(TAG, "Fetching unread count manually... " + group.headerFolder);
            }
            */
        }



        //viewHolder.txt_UnreadCount.setText(group.unreadCount);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        	viewHolder.imgView.setRotation(0);


        if(group.idFolder != null)
        {
	        if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER.getValueString()))
	        {
                ConcreteFeedItem concreteFeedItem = ((ConcreteFeedItem) group);
                loadFavIconForFeed(concreteFeedItem.favIcon, viewHolder.imgView);
	        }
        } else {
        	if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS.getValueString())) {
        		viewHolder.imgView.setVisibility(View.VISIBLE);
        		//viewHolder.imgView.setImageResource(R.drawable.btn_rating_star_off_normal_holo_light);
                viewHolder.imgView.setImageDrawable(getBtn_rating_star_off_normal_holo_light(mContext));
        	} else if (getChildrenCount( groupPosition ) == 0 ) {
	        	viewHolder.imgView.setVisibility(View.INVISIBLE);
	        } else {
	        	viewHolder.imgView.setVisibility(View.VISIBLE);
	        	//viewHolder.imgView.setImageResource(R.drawable.ic_find_next_holo);
                viewHolder.imgView.setImageDrawable(getic_find_next_holo(mContext));

	        	if(isExpanded) {
	        		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
	        			viewHolder.imgView.setRotation(-90);
	        		else
                        viewHolder.imgView.setImageDrawable(getic_find_previous_holo(mContext));
	        			//viewHolder.imgView.setImageResource(R.drawable.ic_find_previous_holo);
	        	}
	        }
        }

        return convertView;
	}

    private void loadFavIconForFeed(String favIconUrl, ImageView imgView) {

        File cacheFile = ImageHandler.getFullPathOfCacheFileSafe(favIconUrl, favIconPath);
        if(cacheFile != null && cacheFile.exists()) {
            Picasso.with(mContext)
                    .load(cacheFile)
                    .placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext))
                    .into(imgView, null);
        } else {
            Picasso.with(mContext)
                    .load(favIconUrl)
                    .placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext))
                    .into(imgView, null);
        }
    }



    Drawable ic_find_next_holo;
    Drawable ic_find_previous_holo;
    Drawable btn_rating_star_off_normal_holo_light;

    private Drawable getBtn_rating_star_off_normal_holo_light(Context context) {
        if(btn_rating_star_off_normal_holo_light == null)
            btn_rating_star_off_normal_holo_light = context.getResources().getDrawable(R.drawable.btn_rating_star_off_normal_holo_light);
        return btn_rating_star_off_normal_holo_light;
    }

    private Drawable getic_find_next_holo(Context context) {
        if(ic_find_next_holo == null) {
            if(ThemeChooser.isDarkTheme(mContext))
                ic_find_next_holo = context.getResources().getDrawable(R.drawable.ic_find_next_holo_dark);
            else
                ic_find_next_holo = context.getResources().getDrawable(R.drawable.ic_find_next_holo_light);
        }
        return ic_find_next_holo;
    }

    private Drawable getic_find_previous_holo(Context context) {
        if(ic_find_previous_holo == null) {
            if(ThemeChooser.isDarkTheme(mContext))
                ic_find_previous_holo = context.getResources().getDrawable(R.drawable.ic_find_previous_holo_dark);
            else
                ic_find_previous_holo = context.getResources().getDrawable(R.drawable.ic_find_previous_holo_light);
        }
        return ic_find_previous_holo;
    }



    /*
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
	{
		IGetTextForTextViewAsyncTask iGetter = new UnreadFeedCount(mContext, idDatabase, execludeStarredItems);
        FillTextForTextViewHelper.FillTextForTextView(textView, iGetter, !mIsTwoPane);
	}

	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void SetUnreadCountForFolder(TextView textView, String idDatabase)
	{
		IGetTextForTextViewAsyncTask iGetter = new UnreadFolderCount(mContext, idDatabase);
        FillTextForTextViewHelper.FillTextForTextView(textView, iGetter, !mIsTwoPane);
	}
    */




	static class GroupHolder
	{
        @InjectView(R.id.summary) TextView txt_Summary;
        @InjectView(R.id.tV_feedsCount) TextView txt_UnreadCount;
        @InjectView(R.id.img_View_expandable_indicator) ImageView imgView;

        public GroupHolder(View view, Context mContext) {
            ButterKnife.inject(this, view);

            txt_Summary.setClickable(true);

            FontHelper fHelper = new FontHelper(mContext);
            fHelper.setFontForAllChildren(view, fHelper.getFont());
        }
	}


	@Override
	public boolean hasStableIds() {
		return false;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		return true;
	}


    public void ReloadAdapter()
    {
        SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
        showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);

        mCategoriesArrayList = new ArrayList<AbstractItem>();
        mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null, ALL_UNREAD_ITEMS.getValue(), null));
        mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null, ALL_STARRED_ITEMS.getValue(), null));

        //mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), -11, null, null));

        AddEverythingInCursorFolderToSubscriptions(dbConn.getAllTopSubscriptions(showOnlyUnread));
        AddEverythingInCursorFeedsToSubscriptions(dbConn.getAllTopSubscriptionsWithoutFolder(showOnlyUnread));

        //AddEverythingInCursorToSubscriptions(dbConn.getAllTopSubscriptionsWithUnreadFeeds());
        mItemsArrayList = new SparseArray<SparseArray<ConcreteFeedItem>>();


        for(int groupPosition = 0; groupPosition < mCategoriesArrayList.size(); groupPosition++) {
            int parent_id = (int)getGroupId(groupPosition);
            String parentId = String.valueOf(parent_id);
            mItemsArrayList.append(parent_id, new SparseArray<ConcreteFeedItem>());
            Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(parentId, showOnlyUnread);
            itemsCursor.requery();
            int childPosTemp = 0;
            if (itemsCursor.moveToFirst())
                do {
                    long id_database = itemsCursor.getLong(0);
                    String name = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
                    String subscription_id = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
                    String urlFavicon = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
                    ConcreteFeedItem newItem = new ConcreteFeedItem(name, parentId, subscription_id, urlFavicon, id_database);
                    mItemsArrayList.get(parent_id).put(childPosTemp, newItem);
                    childPosTemp++;
                } while (itemsCursor.moveToNext());
            itemsCursor.close();
        }
    }



    SparseArray<String> unreadCountFolders;
    SparseArray<String> unreadCountFeeds;
    SparseArray<String> urlsToFavIcons;

    @Deprecated
    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }

    public void NotifyDataSetChangedAsync() {
        new NotifyDataSetChangedAsyncTask().execute((Void) null);
    }


    private class NotifyDataSetChangedAsyncTask extends AsyncTask<Void, Void, Void> {
        // Block children layout for now
        BlockingExpandableListView bView;
        SparseArray<String> unreadCountFoldersTemp;
        SparseArray<String> unreadCountFeedsTemp;
        SparseArray<String> urlsToFavIconsTemp;


        @Override
        protected void onPreExecute() {
            bView = (BlockingExpandableListView) listView;
            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(Void... voids) {
            unreadCountFoldersTemp = dbConn.getUnreadItemCountForFolder(mContext);
            unreadCountFeedsTemp = dbConn.getUnreadItemCountForFeed();
            urlsToFavIconsTemp = dbConn.getUrlsToFavIcons();
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            unreadCountFolders = unreadCountFoldersTemp;
            unreadCountFeeds = unreadCountFeedsTemp;
            urlsToFavIcons = urlsToFavIconsTemp;

            int firstVisPos = bView.getFirstVisiblePosition();
            View firstVisView = bView.getChildAt(0);
            int top = firstVisView != null ? firstVisView.getTop() : 0;

            // Number of items added before the first visible item
            int itemsAddedBeforeFirstVisible = 0;

            bView.setBlockLayoutChildren(true);
            notifyDataSetChanged();
            bView.setBlockLayoutChildren(false);

            // Call setSelectionFromTop to change the ListView position
            if(bView.getCount() >= firstVisPos + itemsAddedBeforeFirstVisible)
                bView.setSelectionFromTop(firstVisPos + itemsAddedBeforeFirstVisible, top);

            super.onPostExecute(aVoid);
        }
    }


    public void setHandlerListener(ExpListTextClicked listener)
	{
		eListTextClickHandler = listener;
	}
	protected void fireListTextClicked(String idSubscription, Context context, boolean isFolder, String optional_folder_id)
	{
		if(eListTextClickHandler != null)
			eListTextClickHandler.onTextClicked(idSubscription, context, isFolder, optional_folder_id);
	}
}