Android 0, clear casting
One of the things Google announces in IO 2017 is what is called "throw away" :). An Android developer does not have to cast manually for findViewById (). For example, the old way to get a textual representation using findViewById () would look something like this.
TextView txtDesc = (TextView) findViewById(R.id.textViewDesc); txtDesc.setText(getString(R.string.info_angkot_description));
While the new path will be like this
TextView txtDesc = findViewById(R.id.textViewDesc); txtDesc.setText(getString(R.string.info_angkot_description));
This is a simple change. But for an experienced programmer, clean code like this can make you very happy, and it helps you tune in to programming :)
To do this, all you had to do was set the compiled SDK version of your project to version 26 in your build.gradle application.
You can still use an earlier version of the SDK, so these are not intrusive changes.
Now the real problem is how you clear that old code that uses cast all this time. Especially when you have hundreds of activity files. You can do it manually, or perhaps hire an intern to do it . But, fortunately for all these interns, the android studio is ready to help us with this.
When you put your carriage (or click on the redundant cast), the android studio will offer 2 options for processing the extra conversion.
You will first be asked to remove this redundant cast, or you can choose to clear the code. This will remove all unnecessary conversions for this file. This is better, but we want more. We do not want to open each file and clear it one by one.
A feature of IntelliJ's idea is that this function is called intentional action. All you have to do is press Ctrl + Shift + A and then type clean. And select "Clear Code", and select the entire project volume. With these few simple steps, your code will be much cleaner.
One of the important points is that you do this with some version control system of code. This way, you can compare the changes made by the intent action and discard any files you want.
Copied from the original post:
https://medium.com/@abangkis/android-0-clean-up-casting-c30acec56cef