fix crash in TouchDelegateHelper when not all views are available (#3016)
* fix crash in TouchDelegateHelper when not all views are available * filter views before passing to TouchDelegateHelper * remove unused import * fix indentation
This commit is contained in:
		
					parent
					
						
							
								e20fda322e
							
						
					
				
			
			
				commit
				
					
						88125ef7da
					
				
			
		
					 2 changed files with 18 additions and 6 deletions
				
			
		|  | @ -64,7 +64,6 @@ import com.keylesspalace.tusky.viewdata.PollViewDataKt; | |||
| import com.keylesspalace.tusky.viewdata.StatusViewData; | ||||
| 
 | ||||
| import java.text.NumberFormat; | ||||
| import java.util.Arrays; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
|  | @ -173,7 +172,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { | |||
| 
 | ||||
|         mediaPreviewUnloaded = new ColorDrawable(ThemeUtils.getColor(itemView.getContext(), R.attr.colorBackgroundAccent)); | ||||
| 
 | ||||
|         TouchDelegateHelper.expandTouchSizeToFillRow((ViewGroup) itemView, Arrays.asList(replyButton, reblogButton, favouriteButton, bookmarkButton, moreButton)); | ||||
|         TouchDelegateHelper.expandTouchSizeToFillRow((ViewGroup) itemView, CollectionsKt.listOfNotNull(replyButton, reblogButton, favouriteButton, bookmarkButton, moreButton)); | ||||
|     } | ||||
| 
 | ||||
|     protected void setDisplayName(String name, List<Emoji> customEmojis, StatusDisplayOptions statusDisplayOptions) { | ||||
|  |  | |||
|  | @ -1,3 +1,18 @@ | |||
| /* Copyright 2022 Tusky contributors | ||||
| 
 | ||||
|  * This file is a part of Tusky. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it under the terms of the | ||||
|  * GNU General Public License as published by the Free Software Foundation; either version 3 of the | ||||
|  * License, or (at your option) any later version. | ||||
|  * | ||||
|  * Tusky 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 General | ||||
|  * Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with Tusky; if not, | ||||
|  * see <http://www.gnu.org/licenses>. */ | ||||
| 
 | ||||
| @file:JvmName("TouchDelegateHelper") | ||||
| 
 | ||||
| package com.keylesspalace.tusky.util | ||||
|  | @ -39,13 +54,11 @@ private class CompositeTouchDelegate(view: View, private val delegates: List<Tou | |||
|     TouchDelegate(Rect(), view) { | ||||
| 
 | ||||
|     override fun onTouchEvent(event: MotionEvent): Boolean { | ||||
|         var res = false | ||||
|         val x = event.x | ||||
|         val y = event.y | ||||
|         for (delegate in delegates) { | ||||
|         return delegates.fold(false) { res, delegate -> | ||||
|             event.setLocation(x, y) | ||||
|             res = delegate.onTouchEvent(event) || res | ||||
|             delegate.onTouchEvent(event) || res | ||||
|         } | ||||
|         return res | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue