For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun <T> T.doAsync( | |
| exceptionHandler: ((Throwable) -> Unit)? = crashLogger, | |
| task: AnkoAsyncContext<T>.() -> Unit | |
| ): Future<Unit> { | |
| val context = AnkoAsyncContext(WeakReference(this)) | |
| return BackgroundExecutor.submit { | |
| return@submit try { | |
| context.task() | |
| } catch (thr: Throwable) { | |
| val result = exceptionHandler?.invoke(thr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun getAsyncFacts(){ | |
| doAsync{ | |
| val index = Random().nextInt(10) | |
| val randomFact = getFacts()[index] | |
| uiThread{ | |
| updateText(randomFact) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun getRandomFact(){ | |
| doAsync{ | |
| //background task | |
| uiThread{ | |
| // post execute block on main thread | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| et = (EditText) vw.findViewById(R.id.tx_edittext); | |
| et.setFilters(new InputFilter[] { | |
| new DigitsKeyListener(Boolean.FALSE, Boolean.TRUE) { | |
| int beforeDecimal = 5, afterDecimal = 2; | |
| @Override | |
| public CharSequence filter(CharSequence source, int start, int end, | |
| Spanned dest, int dstart, int dend) { | |
| String temp = et.getText() + source.toString(); |