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
| long startTime = System.currentTimeMillis(); | |
| // some code block here | |
| long elapsedTime = System.currentTimeMillis() - startTime; | |
| System.out.println("Execution took (in millis): " + elapsedTime); |
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
| val timeElapsed = measureTimeMillis { | |
| // some code block | |
| } | |
| println("$timeElapsed") |
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
| val forLoopMillisElapsed = measureTimeMillis { | |
| for (i in 0..10_000_000) { | |
| if (i % 2 == 0) { | |
| // do something | |
| } | |
| } | |
| } | |
| println("forLoopMillisElapsed: $forLoopMillisElapsed") |
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
| val forEachMillisEllapsed = measureTimeMillis { | |
| (0..10_000_000).forEach { | |
| if (it % 2 == 0) { | |
| // do something | |
| } | |
| } | |
| } | |
| println("forEachMillisEllapsed: $forEachMillisEllapsed") |
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
| i = 0; | |
| int var8 = 10000000; | |
| if(i <= var8) { | |
| while(true) { | |
| if(i % 2 == 0) { | |
| var10000 = true; | |
| } else { | |
| var10000 = false; | |
| } |
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
| Iterable $receiver$iv = (Iterable)(new IntRange(0, 10000000)); | |
| Iterator var6 = $receiver$iv.iterator(); | |
| boolean var10000; | |
| int i; | |
| while(var6.hasNext()) { | |
| i = ((IntIterator)var6).nextInt(); | |
| if(i % 2 == 0) { | |
| var10000 = true; | |
| } else { |
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
| public class ViewModelDemoActivity extends LifecycleActivity { | |
| @BindView(R.id.click_count_text) | |
| protected TextView clickCountText; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_viewmodel_demo); | |
| ButterKnife.bind(this); |
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
| public class DemoActivity extends AppCompatActivity { | |
| @BindView(R.id.click_count_text) | |
| protected TextView clickCountText; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_viewmodel_demo); | |
| ButterKnife.bind(this); |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent"> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" |
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
| import android.arch.lifecycle.ViewModel; | |
| public class ClickCounterViewModel extends ViewModel { | |
| private int count; | |
| public void setCount(int count) { | |
| this.count = count; | |
| } | |
| public int getCount() { |
OlderNewer