Update samples
This commit is contained in:
		
							parent
							
								
									815f733892
								
							
						
					
					
						commit
						b5a30a55b3
					
				| @ -4,7 +4,8 @@ buildscript { | ||||
|         jcenter() | ||||
|     } | ||||
|     dependencies { | ||||
|         classpath 'com.android.tools.build:gradle:3.5.3' | ||||
|         // on `3.5.3` tests are not run from CLI | ||||
|         classpath 'com.android.tools.build:gradle:3.5.2' | ||||
|         classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0' | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -475,9 +475,7 @@ public class BasicPluginsActivity extends ActivityWithMenuOptions { | ||||
|                 .usePlugin(new AbstractMarkwonPlugin() { | ||||
|                     @Override | ||||
|                     public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { | ||||
|                         builder.linkResolver(new AnchorLinkResolver((view, top) -> { | ||||
|                             scrollView.smoothScrollTo(0, top); | ||||
|                         })); | ||||
|                         builder.linkResolver(new AnchorLinkResolver((view, top) -> scrollView.smoothScrollTo(0, top))); | ||||
|                     } | ||||
| 
 | ||||
|                     @Override | ||||
|  | ||||
| @ -11,6 +11,8 @@ import androidx.annotation.NonNull; | ||||
| import androidx.annotation.Nullable; | ||||
| import androidx.annotation.Px; | ||||
| 
 | ||||
| import org.commonmark.node.Paragraph; | ||||
| 
 | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.Random; | ||||
| @ -26,6 +28,7 @@ import io.noties.markwon.html.HtmlTag; | ||||
| import io.noties.markwon.html.MarkwonHtmlRenderer; | ||||
| import io.noties.markwon.html.TagHandler; | ||||
| import io.noties.markwon.html.tag.SimpleTagHandler; | ||||
| import io.noties.markwon.image.ImagesPlugin; | ||||
| import io.noties.markwon.sample.ActivityWithMenuOptions; | ||||
| import io.noties.markwon.sample.MenuOptions; | ||||
| import io.noties.markwon.sample.R; | ||||
| @ -38,7 +41,8 @@ public class HtmlActivity extends ActivityWithMenuOptions { | ||||
|         return MenuOptions.create() | ||||
|                 .add("align", this::align) | ||||
|                 .add("randomCharSize", this::randomCharSize) | ||||
|                 .add("enhance", this::enhance); | ||||
|                 .add("enhance", this::enhance) | ||||
|                 .add("image", this::image); | ||||
|     } | ||||
| 
 | ||||
|     private TextView textView; | ||||
| @ -239,4 +243,29 @@ public class HtmlActivity extends ActivityWithMenuOptions { | ||||
| 
 | ||||
|         markwon.setMarkdown(textView, md); | ||||
|     } | ||||
| 
 | ||||
|     private void image() { | ||||
|         // treat unclosed/void `img` tag as HTML inline | ||||
|         final String md = "" + | ||||
|                 "## Try CommonMark\n" + | ||||
|                 "\n" + | ||||
|                 "Markwon IMG:\n" + | ||||
|                 "\n" + | ||||
|                 "\n" + | ||||
|                 "\n" + | ||||
|                 "New lines...\n" + | ||||
|                 "\n" + | ||||
|                 "HTML IMG:\n" + | ||||
|                 "\n" + | ||||
|                 "<img src=\"https://upload.wikimedia.org/wikipedia/it/thumb/c/c5/GTA_2.JPG/220px-GTA_2.JPG\"></img>\n" + | ||||
|                 "\n" + | ||||
|                 "New lines\n\n"; | ||||
| 
 | ||||
|         final Markwon markwon = Markwon.builder(this) | ||||
|                 .usePlugin(ImagesPlugin.create()) | ||||
|                 .usePlugin(HtmlPlugin.create()) | ||||
|                 .build(); | ||||
| 
 | ||||
|         markwon.setMarkdown(textView, md); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -5,6 +5,7 @@ import android.graphics.Color; | ||||
| import android.graphics.drawable.ColorDrawable; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Bundle; | ||||
| import android.view.View; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import androidx.annotation.NonNull; | ||||
| @ -51,6 +52,7 @@ public class LatexActivity extends ActivityWithMenuOptions { | ||||
|     } | ||||
| 
 | ||||
|     private TextView textView; | ||||
|     private View parent; | ||||
| 
 | ||||
|     @NonNull | ||||
|     @Override | ||||
| @ -65,7 +67,8 @@ public class LatexActivity extends ActivityWithMenuOptions { | ||||
|                 .add("legacy", this::legacy) | ||||
|                 .add("textColor", this::textColor) | ||||
|                 .add("defaultTextColor", this::defaultTextColor) | ||||
|                 .add("inlineAndBlock", this::inlineAndBlock); | ||||
|                 .add("inlineAndBlock", this::inlineAndBlock) | ||||
|                 .add("dark", this::dark); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @ -74,6 +77,9 @@ public class LatexActivity extends ActivityWithMenuOptions { | ||||
| 
 | ||||
|         // reset text color | ||||
|         textView.setTextColor(0xFF000000); | ||||
| 
 | ||||
|         // reset background | ||||
|         parent.setBackgroundColor(0xFFffffff); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @ -82,6 +88,7 @@ public class LatexActivity extends ActivityWithMenuOptions { | ||||
|         setContentView(R.layout.activity_text_view); | ||||
| 
 | ||||
|         textView = findViewById(R.id.text_view); | ||||
|         parent = findViewById(R.id.scroll_view); | ||||
| 
 | ||||
| //        array(); | ||||
|         longDivision(); | ||||
| @ -203,6 +210,17 @@ public class LatexActivity extends ActivityWithMenuOptions { | ||||
|         renderWithBlocksAndInlines(md); | ||||
|     } | ||||
| 
 | ||||
|     private void dark() { | ||||
|         parent.setBackgroundColor(0xFF000000); | ||||
|         textView.setTextColor(0xFFffffff); | ||||
| 
 | ||||
|         String latex = "W=W_1+W_2=F_1X_1-F_2X_2"; | ||||
|         final String md = "" + | ||||
|                 "# LaTeX inside a blockquote\n" + | ||||
|                 "> $$" + latex + "$$\n"; | ||||
|         renderWithBlocksAndInlines(md); | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     private static String wrapLatexInSampleMarkdown(@NonNull String latex) { | ||||
|         return "" + | ||||
|  | ||||
| @ -2,13 +2,15 @@ | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/scroll_view" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|     android:layout_height="match_parent" | ||||
|     android:clipChildren="false" | ||||
|     android:clipToPadding="false" | ||||
|     android:padding="8dip"> | ||||
| 
 | ||||
|     <TextView | ||||
|         android:id="@+id/text_view" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:padding="8dip" | ||||
|         android:textAppearance="?android:attr/textAppearanceMedium" | ||||
|         android:textColor="#000" | ||||
|         android:textSize="16sp" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov