Fix #329
This commit is contained in:
parent
a871712216
commit
9dfadd4da6
3 changed files with 36 additions and 1 deletions
|
@ -114,8 +114,9 @@ public class MenuUtilsFragmentActivity extends PodcastFragmentActivity {
|
|||
if(ndf != null)
|
||||
{
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(activity);
|
||||
//dbConn.markAllItemsAsReadForCurrentView();
|
||||
dbConn.markAllItemsAsReadForCurrentView();
|
||||
|
||||
/*
|
||||
for(int i = 0; i < ndf.getListAdapter().getCount(); i++) {
|
||||
RssItem rssItem = (RssItem) ndf.getListAdapter().getItem(i);
|
||||
rssItem.setRead_temp(true);
|
||||
|
@ -123,11 +124,13 @@ public class MenuUtilsFragmentActivity extends PodcastFragmentActivity {
|
|||
}
|
||||
|
||||
ndf.notifyDataSetChangedOnAdapter();
|
||||
*/
|
||||
|
||||
//If tablet view is enabled update the listview as well
|
||||
if(activity instanceof NewsReaderListActivity)
|
||||
((NewsReaderListActivity) activity).updateAdapter();
|
||||
|
||||
ndf.UpdateCurrentRssView(activity, false);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
@ -372,6 +372,10 @@ public class NewsReaderDetailFragment extends ListFragment implements IOnStayUnr
|
|||
BlockingListView bView = ((BlockingListView) getListView());
|
||||
bView.setBlockLayoutChildren(true);
|
||||
|
||||
if(getListAdapter() != null) {
|
||||
((NewsListArrayAdapter) getListAdapter()).getLazyList().close(); //Close cursor to release resources
|
||||
}
|
||||
|
||||
NewsListArrayAdapter lvAdapter = new NewsListArrayAdapter(getActivity(), rssItemLazyList, NewsReaderDetailFragment.this, (PodcastFragmentActivity) getActivity());
|
||||
setListAdapter(lvAdapter);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import de.greenrobot.dao.query.LazyList;
|
||||
import de.greenrobot.dao.query.WhereCondition;
|
||||
import de.luhmer.owncloudnewsreader.Constants;
|
||||
import de.luhmer.owncloudnewsreader.database.model.CurrentRssItemView;
|
||||
import de.luhmer.owncloudnewsreader.database.model.CurrentRssItemViewDao;
|
||||
import de.luhmer.owncloudnewsreader.database.model.DaoSession;
|
||||
import de.luhmer.owncloudnewsreader.database.model.Feed;
|
||||
|
@ -265,6 +266,33 @@ public class DatabaseConnectionOrm {
|
|||
daoSession.getRssItemDao().update(rssItem);
|
||||
}
|
||||
|
||||
public void markAllItemsAsReadForCurrentView() {
|
||||
/*
|
||||
String sql = "UPDATE " + RssItemDao.TABLENAME + " SET " + RssItemDao.Properties.Read_temp.columnName + " = 1 " +
|
||||
"WHERE " + RssItemDao.Properties.Id.columnName + " IN (SELECT " + CurrentRssItemViewDao.Properties.RssItemId.columnName + " FROM " + CurrentRssItemViewDao.TABLENAME + ")";
|
||||
daoSession.getDatabase().execSQL(sql);
|
||||
*/
|
||||
|
||||
WhereCondition whereCondition = new WhereCondition.StringCondition(RssItemDao.Properties.Id.columnName + " IN " +
|
||||
"(SELECT " + CurrentRssItemViewDao.Properties.RssItemId.columnName + " FROM " + CurrentRssItemViewDao.TABLENAME + ")");
|
||||
|
||||
int iterationCount = 0;
|
||||
final int itemsPerIteration = 100;
|
||||
List<RssItem> rssItemList;
|
||||
do {
|
||||
int offset = iterationCount * itemsPerIteration;
|
||||
int limit = itemsPerIteration;
|
||||
rssItemList = daoSession.getRssItemDao().queryBuilder().where(whereCondition).limit(limit).offset(offset).listLazy();
|
||||
for (RssItem rssItem : rssItemList) {
|
||||
rssItem.setRead_temp(true);
|
||||
}
|
||||
daoSession.getRssItemDao().updateInTx(rssItemList);
|
||||
|
||||
iterationCount++;
|
||||
} while(rssItemList.size() == itemsPerIteration);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getRssItemsIdsFromList(List<RssItem> rssItemList) {
|
||||
List<String> itemIds = new ArrayList<String>();
|
||||
for(RssItem rssItem : rssItemList) {
|
||||
|
|
Loading…
Reference in a new issue