Guest User

Untitled

a guest
Feb 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package com.example.cain.mvvmexample;
  2.  
  3.  
  4. import android.content.Intent;
  5. import android.databinding.BindingAdapter;
  6. import android.databinding.InverseBindingAdapter;
  7. import android.databinding.InverseBindingListener;
  8. import android.support.annotation.Nullable;
  9. import android.view.View;
  10.  
  11. public class ViewBindings {
  12.  
  13. @BindingAdapter(value = {"navRequest", "navRequestAttrChanged"}, requireAll = false)
  14. public static void setNavRequest(View view, @Nullable NavigationRequest navRequest, @Nullable InverseBindingListener inverseBindingListener) {
  15. if (navRequest != null) {
  16. Intent intent = navRequest.getIntent(view.getContext());
  17. view.getContext().startActivity(intent);
  18. if (inverseBindingListener != null) {
  19. inverseBindingListener.onChange();
  20. }
  21. }
  22. }
  23.  
  24. @InverseBindingAdapter(attribute = "navRequest")
  25. public static NavigationRequest getNavRequest(View view) {
  26. return null; // clear nav request
  27. }
  28.  
  29. }
Add Comment
Please, Sign In to add comment