Android Custom View 102 (Part 9)

A RatingBar Example

Guowei Lv

1 minute read

There is nothing new here, just another exercise. Two things to be careful with: Try to call validate() as fewer times as possible, it is expensive. If you want to handle the touch events in this manner, remember to return true from onTouchEvent(). Otherwise, only the first event will be triggered(most likely DOWN in this case) and not the succeeding ones (like the MOVES). Source Code

Emacs Orgmode Minted Setup

How to setup orgmode pdf export with minted on Arch Linux

Guowei Lv

1 minute read

Install minted package https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages Install Pygments https://pygments.org/ Configure Emacs (setq org-latex-listings 'minted org-latex-packages-alist '(("" "minted")) org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) Remove cached minted* dirs This is the step that unblocked me. Prevent src block line too long (setq org-latex-minted-options '(("breaklines" "true") ("breakanywhere" "true")))

[Guowei Lv]

1 minute read

Hello World First item Second item this is some code This is a subheading private static void main() {} LaTeX formatted equation: ( E = -J \sum_{i=1}^N s_i s_{i+1} ) \begin{equation} \label{eq:1} C = W\log_{2} (1+\mathrm{SNR}) \end{equation}

Guowei Lv

1 minute read

Let’s take a look at what we are going to build. The secret is to clip canvas before drawing the text! private fun drawText(canvas: Canvas, paint: Paint, start: Int, end: Int) { canvas.save() rect.set(start, 0, end, height) canvas.clipRect(rect) val textString = text.toString() paint.getTextBounds(textString, 0, textString.length, bounds) val x = width / 2 - bounds.width() / 2 val fontMetrics = changePaint.fontMetrics val dy = (fontMetrics.bottom - fontMetrics.top) / 2 - fontMetrics.