|  |  | @ -32,7 +32,6 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : | 
			
		
	
		
		
			
				
					
					|  |  |  |     ItemTouchCallback.Callback { |  |  |  |     ItemTouchCallback.Callback { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private val selected = linkedSetOf<BookSource>() |  |  |  |     private val selected = linkedSetOf<BookSource>() | 
			
		
	
		
		
			
				
					
					|  |  |  |     private val selectedPosition = linkedSetOf<Int>() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     val selection: List<BookSource> |  |  |  |     val selection: List<BookSource> | 
			
		
	
		
		
			
				
					
					|  |  |  |         get() { |  |  |  |         get() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -143,10 +142,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (view.isPressed) { |  |  |  |                     if (view.isPressed) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         if (checked) { |  |  |  |                         if (checked) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                             selected.add(it) |  |  |  |                             selected.add(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                             selectedPosition.add(holder.layoutPosition) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } else { |  |  |  |                         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                             selected.remove(it) |  |  |  |                             selected.remove(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                             selectedPosition.remove(holder.layoutPosition) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |                         callBack.upCountView() |  |  |  |                         callBack.upCountView() | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -219,22 +216,19 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun selectAll() { |  |  |  |     fun selectAll() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         getItems().forEachIndexed { index, it -> |  |  |  |         getItems().forEach { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             selected.add(it) |  |  |  |             selected.add(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |             selectedPosition.add(index) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         notifyItemRangeChanged(0, itemCount, bundleOf(Pair("selected", null))) |  |  |  |         notifyItemRangeChanged(0, itemCount, bundleOf(Pair("selected", null))) | 
			
		
	
		
		
			
				
					
					|  |  |  |         callBack.upCountView() |  |  |  |         callBack.upCountView() | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun revertSelection() { |  |  |  |     fun revertSelection() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         getItems().forEachIndexed { index, it -> |  |  |  |         getItems().forEach { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             if (selected.contains(it)) { |  |  |  |             if (selected.contains(it)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selected.remove(it) |  |  |  |                 selected.remove(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selectedPosition.remove(index) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else { |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selected.add(it) |  |  |  |                 selected.add(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selectedPosition.add(index) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         notifyItemRangeChanged(0, itemCount, bundleOf(Pair("selected", null))) |  |  |  |         notifyItemRangeChanged(0, itemCount, bundleOf(Pair("selected", null))) | 
			
		
	
	
		
		
			
				
					|  |  | @ -242,13 +236,18 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     fun checkSelectedInterval() { |  |  |  |     fun checkSelectedInterval() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         val selectedPosition = linkedSetOf<Int>() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         getItems().forEachIndexed { index, it -> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (selected.contains(it)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 selectedPosition.add(index) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         val minPosition = Collections.min(selectedPosition) |  |  |  |         val minPosition = Collections.min(selectedPosition) | 
			
		
	
		
		
			
				
					
					|  |  |  |         val maxPosition = Collections.max(selectedPosition) |  |  |  |         val maxPosition = Collections.max(selectedPosition) | 
			
		
	
		
		
			
				
					
					|  |  |  |         val itemCount = maxPosition - minPosition + 1 |  |  |  |         val itemCount = maxPosition - minPosition + 1 | 
			
		
	
		
		
			
				
					
					|  |  |  |         for (i in minPosition..maxPosition) { |  |  |  |         for (i in minPosition..maxPosition) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             getItem(i)?.let { |  |  |  |             getItem(i)?.let { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selected.add(it) |  |  |  |                 selected.add(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 selectedPosition.add(i) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         notifyItemRangeChanged(minPosition, itemCount, bundleOf(Pair("selected", null))) |  |  |  |         notifyItemRangeChanged(minPosition, itemCount, bundleOf(Pair("selected", null))) | 
			
		
	
	
		
		
			
				
					|  |  | @ -296,10 +295,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : | 
			
		
	
		
		
			
				
					
					|  |  |  |                 getItem(position)?.let { |  |  |  |                 getItem(position)?.let { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (isSelected) { |  |  |  |                     if (isSelected) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         selected.add(it) |  |  |  |                         selected.add(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                         selectedPosition.add(position) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } else { |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         selected.remove(it) |  |  |  |                         selected.remove(it) | 
			
		
	
		
		
			
				
					
					|  |  |  |                         selectedPosition.remove(position) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |                     notifyItemChanged(position, bundleOf(Pair("selected", null))) |  |  |  |                     notifyItemChanged(position, bundleOf(Pair("selected", null))) | 
			
		
	
		
		
			
				
					
					|  |  |  |                     callBack.upCountView() |  |  |  |                     callBack.upCountView() | 
			
		
	
	
		
		
			
				
					|  |  | 
 |