This file contains 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
class ZoomableTextureView : TextureRenderView { | |
private var minScale = 1f | |
private var maxScale = 5f | |
private var saveScale = 1f | |
fun setMinScale(scale: Float) { | |
minScale = | |
if (scale < 1.0f || scale > maxScale) throw RuntimeException("minScale can't be lower than 1 or larger than maxScale($maxScale)") else scale | |
} |
This file contains 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
taskObservable.subscribe(new Observer<Task>() { | |
@Override | |
public void onSubscribe(Disposable d) { | |
} | |
@Override | |
public void onNext(Task task) { // run on main thread | |
Log.d(TAG, "onNext: : " + task.getDescription()); | |
} |
This file contains 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
Observable<Task> taskObservable = Observable // create a new Observable object | |
.fromIterable(DataSource.createTasksList()) // apply 'fromIterable' operator | |
.subscribeOn(Schedulers.io()) // designate worker thread (background) | |
.observeOn(AndroidSchedulers.mainThread()); // designate observer thread (main thread) |
This file contains 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
/** | |
* 6/24/2020 | |
* A java class accessing {@code var} and its variants defined in a kotlin {@code public final} class. | |
* | |
* @author srdpatel | |
* @since 1.0 | |
*/ | |
public class CallingVarInClass { | |
public static void main(String[] args) { |
This file contains 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
/** | |
* 6/23/2020 | |
* Examining access to a `public final` class for `var` from outside the class. | |
* | |
* @author srdpatel | |
* @since 1.0 | |
*/ | |
fun main() { | |
/** |
This file contains 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
/** | |
* 6/22/2020 | |
* Assigns a compile time value to the top-level variable: [varTopLevelCompileTime] | |
* <p> | |
* `var` is used to assign the runtime or compile time value to the variable that can be reassigned. | |
* <p> | |
* Behind the scene of top-level `var`: | |
* <p> | |
* The compiler will generate a `public final` class with `Kt` suffix | |
* for the top-level members. |
This file contains 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
/** | |
* 6/22/2020 | |
* Unlike kotlin, we have to write {@code public} keyword in Java. | |
* In kotlin, classes are {@code public} by default. We don't have to write. | |
* Unlike kotlin, we have to write {@code final} keyword in Java to save the class from inheritance. | |
* In kotlin, classes are {@code final} by default. They can't be inherited unless we mark it as {@code open}. | |
* | |
* @author srdpatel | |
* @see <a href="https://kotlinlang.org/docs/reference/classes.html">Classes and Inheritance</a> |
This file contains 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
/** | |
* 6/22/2020 | |
* <p> | |
* A java `public final` like class examining `var` variants. | |
* In kotlin, all classes are by default like java `public final`. | |
* They can't be inherited unless we mark it as `open`. | |
* <p> | |
* Being a `public` class, all the `public` members of this class are accessible from anywhere. | |
* <p> | |
* Introduction of `var`: |
This file contains 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
class FinalValInClassJava { | |
/** | |
* 6/19/2020 | |
* This is kotlin bytecode equivalent of the variable defined inside of a kotlin class as below: | |
* ``` | |
* {@code @JvmField val jvmFieldFinalExample = someFunction()} | |
* ``` | |
* We can see that the kotlin bytecode has made it public due to {@code JvmField} annotation. |
This file contains 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
/** | |
* 6/18/2020 | |
* Accessing java {@code public static final} like kotlin top-level members. | |
* We can access top-level members even those without having {@code @JvmField} annotation. | |
* | |
* @author srdpatel | |
* @since 1.0 | |
*/ | |
private void accessVal() { |
NewerOlder