mirror of
				https://github.com/viq/NewsBlur.git
				synced 2025-11-01 09:09:16 +00:00 
			
		
		
		
	Upper limit on mark-read batch size auto-flushes.
This commit is contained in:
		
							parent
							
								
									b12a83465e
								
							
						
					
					
						commit
						84be7ea490
					
				
					 2 changed files with 21 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -188,14 +188,11 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
 | 
			
		|||
	public abstract void triggerRefresh();
 | 
			
		||||
	public abstract void triggerRefresh(int page);
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void onPause() {
 | 
			
		||||
        synchronized(this.storiesToMarkAsRead) {
 | 
			
		||||
            FeedUtils.markStoriesAsRead(this.storiesToMarkAsRead, this);
 | 
			
		||||
            this.storiesToMarkAsRead.clear();
 | 
			
		||||
        }
 | 
			
		||||
		super.onPause();
 | 
			
		||||
	}
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onPause() {
 | 
			
		||||
        flushStoriesMarkedRead();
 | 
			
		||||
        super.onPause();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** 
 | 
			
		||||
     * Log a story as having been read. The local DB and remote server will be updated
 | 
			
		||||
| 
						 | 
				
			
			@ -207,6 +204,19 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
 | 
			
		|||
        synchronized (this.storiesToMarkAsRead) {
 | 
			
		||||
            this.storiesToMarkAsRead.add(story);
 | 
			
		||||
        }
 | 
			
		||||
        // flush immediately if the batch reaches a sufficient size
 | 
			
		||||
        if (this.storiesToMarkAsRead.size() >= AppConstants.MAX_MARK_READ_BATCH) {
 | 
			
		||||
            flushStoriesMarkedRead();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void flushStoriesMarkedRead() {
 | 
			
		||||
        synchronized(this.storiesToMarkAsRead) {
 | 
			
		||||
            if (this.storiesToMarkAsRead.size() > 0) {
 | 
			
		||||
                FeedUtils.markStoriesAsRead(this.storiesToMarkAsRead, this);
 | 
			
		||||
                this.storiesToMarkAsRead.clear();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,4 +19,7 @@ public class AppConstants {
 | 
			
		|||
    public static final String ROOT_FOLDER = "0000_TOP_LEVEL_";
 | 
			
		||||
 | 
			
		||||
    public static final String LAST_APP_VERSION = "LAST_APP_VERSION";
 | 
			
		||||
 | 
			
		||||
    // the max number of mark-as-read ops to batch up before flushing to the server
 | 
			
		||||
    public static final int MAX_MARK_READ_BATCH = 5;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue