|  |  | @ -14,20 +14,20 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun topSource(vararg sources: BookSource) { |  |  |  |     fun topSource(vararg sources: BookSource) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val minOrder = appDb.bookSourceDao.minOrder - 1 |  |  |  |             val minOrder = appDb.bookSourceDao.minOrder - 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEachIndexed { index, bookSource -> |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 bookSource.customOrder = minOrder - index |  |  |  |                 sources[it].copy(customOrder = minOrder - it) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*sources) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun bottomSource(vararg sources: BookSource) { |  |  |  |     fun bottomSource(vararg sources: BookSource) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val maxOrder = appDb.bookSourceDao.maxOrder + 1 |  |  |  |             val maxOrder = appDb.bookSourceDao.maxOrder + 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEachIndexed { index, bookSource -> |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 bookSource.customOrder = maxOrder + index |  |  |  |                 sources[it].copy(customOrder = maxOrder + it) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*sources) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -51,59 +51,55 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun enableSelection(sources: List<BookSource>) { |  |  |  |     fun enableSelection(sources: List<BookSource>) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val list = arrayListOf<BookSource>() |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { |  |  |  |                 sources[it].copy(enabled = true) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 list.add(it.copy(enabled = true)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*list.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun disableSelection(sources: List<BookSource>) { |  |  |  |     fun disableSelection(sources: List<BookSource>) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val list = arrayListOf<BookSource>() |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { |  |  |  |                 sources[it].copy(enabled = false) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 list.add(it.copy(enabled = false)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*list.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun enableSelectExplore(sources: List<BookSource>) { |  |  |  |     fun enableSelectExplore(sources: List<BookSource>) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val list = arrayListOf<BookSource>() |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { |  |  |  |                 sources[it].copy(enabledExplore = true) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 list.add(it.copy(enabledExplore = true)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*list.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun disableSelectExplore(sources: List<BookSource>) { |  |  |  |     fun disableSelectExplore(sources: List<BookSource>) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             val list = arrayListOf<BookSource>() |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { |  |  |  |                 sources[it].copy(enabledExplore = false) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 list.add(it.copy(enabledExplore = false)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*list.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun selectionAddToGroups(sources: List<BookSource>, groups: String) { |  |  |  |     fun selectionAddToGroups(sources: List<BookSource>, groups: String) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { source -> |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 source.addGroup(groups) |  |  |  |                 sources[it].copy().addGroup(groups) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*sources.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun selectionRemoveFromGroups(sources: List<BookSource>, groups: String) { |  |  |  |     fun selectionRemoveFromGroups(sources: List<BookSource>, groups: String) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         execute { |  |  |  |         execute { | 
			
		
	
		
		
			
				
					
					|  |  |  |             sources.forEach { source -> |  |  |  |             val array = Array(sources.size) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 source.removeGroup(groups) |  |  |  |                 sources[it].copy().removeGroup(groups) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             appDb.bookSourceDao.update(*sources.toTypedArray()) |  |  |  |             appDb.bookSourceDao.update(*array) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |