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 Presenter { | |
| private Context context; | |
| public Presenter(Context context) { | |
| this.context = context; | |
| } | |
| public void onClickMethod(View view) { | |
| Toast.makeText(this.context, "Clicked Method reference button", Toast.LENGTH_SHORT).show(); | |
| } |
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
| ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); | |
| //Set presenter binding | |
| binding.setPresenter(new Presenter(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"?> | |
| <layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <data> | |
| <variable | |
| name="user" | |
| type="com.ladwa.aditya.databinding_blitzkrieg.User"/> | |
| <variable |
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
| <data> | |
| <import type="android.view.View"/> | |
| </data> |
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
| <TextView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="@{user.firstName}" | |
| android:visibility="@{user.clicked ? View.INVISIBLE : View.VISIBLE}"/> |
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
| User user = new User("Aditya", "Ladwa", 22, true); |
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 User extends BaseObservable { | |
| private boolean clicked; | |
| @Bindable public boolean isClicked() { | |
| return clicked; | |
| } | |
| public void setClicked(boolean clicked) { | |
| this.clicked = !clicked; |
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 void onClickReference(User user) { | |
| Toast.makeText(this.context, "Clicked Listener method " + user.getFirstName() + user.getLastName(), Toast.LENGTH_SHORT).show(); | |
| user.setClicked(user.isClicked()); | |
| } |
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
| apply from: 'deps.gradle' | |
| // ... | |
| dependencies { | |
| compile supportLibs | |
| compile rxJavaLibs | |
| compile retrofitLibs | |
| compile okHttpLibs |
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
| class NetworkInterceptor(context: Context) : Interceptor { | |
| private val mApplicationContext: Context = context.applicationContext | |
| private val isConnected: Boolean | |
| get() { | |
| val cm = mApplicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| val activeNetwork = cm.activeNetworkInfo | |
| return activeNetwork != null && activeNetwork.isConnectedOrConnecting | |
| } |