Fix deep nested bullet lists for Nougat
This commit is contained in:
		
							parent
							
								
									c6349738ad
								
							
						
					
					
						commit
						66bfad16ca
					
				| @ -6,7 +6,7 @@ org.gradle.configureondemand=true | ||||
| android.enableBuildCache=true | ||||
| android.buildCacheDir=build/pre-dex-cache | ||||
| 
 | ||||
| VERSION_NAME=2.0.1 | ||||
| VERSION_NAME=2.0.2-SNAPSHOT | ||||
| 
 | ||||
| GROUP=ru.noties | ||||
| POM_DESCRIPTION=Markwon | ||||
|  | ||||
| @ -58,14 +58,28 @@ public class BulletListItemSpan implements LeadingMarginSpan { | ||||
| 
 | ||||
|             final int marginLeft = (width - side) / 2; | ||||
| 
 | ||||
|             // @since 2.0.2 | ||||
|             // There is a bug in Android Nougat, when this span receives an `x` that | ||||
|             // doesn't correspond to what it should be (text is placed correctly though). | ||||
|             // Let's make this a general rule -> manually calculate difference between expected/actual | ||||
|             // and add this difference to resulting left/right values. If everything goes well | ||||
|             // we do not encounter a bug -> this `diff` value will be 0 | ||||
|             final int diff; | ||||
|             if (dir < 0) { | ||||
|                 // rtl | ||||
|                 diff = x - (layout.getWidth() - (width * level)); | ||||
|             } else { | ||||
|                 diff = (width * level) - x; | ||||
|             } | ||||
| 
 | ||||
|             // in order to support RTL | ||||
|             final int l; | ||||
|             final int r; | ||||
|             { | ||||
|                 final int left = x + (dir * marginLeft); | ||||
|                 final int right = left + (dir * side); | ||||
|                 l = Math.min(left, right); | ||||
|                 r = Math.max(left, right); | ||||
|                 l = Math.min(left, right) + (dir * diff); | ||||
|                 r = Math.max(left, right) + (dir * diff); | ||||
|             } | ||||
| 
 | ||||
|             final int t = baseline + (int) ((paint.descent() + paint.ascent()) / 2.F + .5F) - (side / 2); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov