當前位置: 首頁>>代碼示例>>Java>>正文


Java Observable.OnPropertyChangedCallback方法代碼示例

本文整理匯總了Java中android.databinding.Observable.OnPropertyChangedCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java Observable.OnPropertyChangedCallback方法的具體用法?Java Observable.OnPropertyChangedCallback怎麽用?Java Observable.OnPropertyChangedCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.databinding.Observable的用法示例。


在下文中一共展示了Observable.OnPropertyChangedCallback方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AtomWatcher

import android.databinding.Observable; //導入方法依賴的package包/類
public AtomWatcher(BaseObservable... fields){
    for(BaseObservable field: fields){

        BaseObservable af = field;

        Observable.OnPropertyChangedCallback callback = new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                run();
            }
        };

        field.addOnPropertyChangedCallback(callback);

        closables.add(new ClosableAction(()->{
            af.removeOnPropertyChangedCallback(callback);
        }));
    }
}
 
開發者ID:neurospeech,項目名稱:ui-atoms-android,代碼行數:20,代碼來源:AtomWatcher.java

示例2: onCreate

import android.databinding.Observable; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    currentAudioCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            onCurrentAudioChanged(currentAudio.get());
        }
    };
    currentAlbumArtCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            getActivity().runOnUiThread(() -> {
                onCurrentAlbumArtChanged(currentAlbumArt.get());
            });
        }
    };
}
 
開發者ID:Mavamaarten,項目名稱:vk_music_android,代碼行數:20,代碼來源:BaseMusicFragment.java

示例3: setAdapter

import android.databinding.Observable; //導入方法依賴的package包/類
@BindingAdapter(value = {"clickCommand", "commandParameter"}, requireAll = false)
public static void setAdapter(View button, AtomCommand command, Object parameter){

    Observable.OnPropertyChangedCallback pc;
    AtomCommand oldCommand = (AtomCommand)button.getTag(R.id.atomCommand);
    if(oldCommand != command) {
        if(button instanceof Button) {
            if(oldCommand!=null) {
                pc = (Observable.OnPropertyChangedCallback)
                    button.getTag(R.id.atomCommandEnabled);
                if (pc != null) {
                    oldCommand.enabled.removeOnPropertyChangedCallback(pc);
                }
            }

            pc = new Observable.OnPropertyChangedCallback() {
                @Override
                public void onPropertyChanged(Observable sender, int propertyId) {
                    ((Button)button).setEnabled(command.enabled.get());
                }
            };
            command.enabled.addOnPropertyChangedCallback(pc);
        }

        button.setTag(R.id.atomCommand, command);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                command.execute(parameter);
            }
        });
    }

    command.parameter.set(parameter);
}
 
開發者ID:neurospeech,項目名稱:ui-atoms-android,代碼行數:37,代碼來源:AtomCommand.java

示例4: bindViewModel

import android.databinding.Observable; //導入方法依賴的package包/類
@Override
public void bindViewModel(AddEditTaskViewModel viewModel) {
    checkNotNull(viewModel);
    this.viewModel = viewModel;
    snackbarCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            SnackbarUtils.showSnackbar(getView(), viewModel.getSnackbarText());
        }
    };
    viewModel.snackbarText.addOnPropertyChangedCallback(snackbarCallback);
}
 
開發者ID:Zhuinden,項目名稱:simple-stack,代碼行數:13,代碼來源:AddEditTaskFragment.java

示例5: setupSnackbar

import android.databinding.Observable; //導入方法依賴的package包/類
private void setupSnackbar() {
    snackbarCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            SnackbarUtils.showSnackbar(getView(), viewModel.getSnackbarText());
        }
    };
    viewModel.snackbarText.addOnPropertyChangedCallback(snackbarCallback);
}
 
開發者ID:Zhuinden,項目名稱:simple-stack,代碼行數:10,代碼來源:TaskDetailFragment.java

示例6: bindVisible

import android.databinding.Observable; //導入方法依賴的package包/類
public void bindVisible(final ObservableField<Boolean> visibleChangeField) {
    if (visibleChangeField.get() != null) setVisible(visibleChangeField.get());

    visibleChangeCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            setVisible(visibleChangeField.get());
        }
    };
    visibleChangeField.addOnPropertyChangedCallback(visibleChangeCallback);
    this.visibleChangeField = visibleChangeField;
}
 
開發者ID:chuross,項目名稱:recyclerview-adapters,代碼行數:13,代碼來源:BindingViewItem.java

示例7: testOnPropertyChangedCallbacksAddedToViewModel

import android.databinding.Observable; //導入方法依賴的package包/類
@Test
public void testOnPropertyChangedCallbacksAddedToViewModel() {
    final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class);
    final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class);
    activityController.create();
    activity.setViewModel(activity.createViewModel());

    activity.addOnPropertyChangedCallback(firstCallback);
    activity.addOnPropertyChangedCallback(secondCallback);

    verify(activity.getViewModel()).addOnPropertyChangedCallback(firstCallback);
    verify(activity.getViewModel()).addOnPropertyChangedCallback(secondCallback);
}
 
開發者ID:A-Zaiats,項目名稱:android-mvvm,代碼行數:14,代碼來源:MvvmActivityTest.java

示例8: testRemoveOnPropertyChangedCallbacksOnActivityDestroy

import android.databinding.Observable; //導入方法依賴的package包/類
@Test
public void testRemoveOnPropertyChangedCallbacksOnActivityDestroy() {
    final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class);
    final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class);
    activityController.create();
    activity.setViewModel(activity.createViewModel());
    activity.addOnPropertyChangedCallback(firstCallback);
    activity.addOnPropertyChangedCallback(secondCallback);

    activity.onDestroy();
    verify(activity.getViewModel()).removeOnPropertyChangedCallback(firstCallback);
    verify(activity.getViewModel()).removeOnPropertyChangedCallback(secondCallback);
}
 
開發者ID:A-Zaiats,項目名稱:android-mvvm,代碼行數:14,代碼來源:MvvmActivityTest.java

示例9: testOnPropertyChangedCallbacksAddedToViewModel

import android.databinding.Observable; //導入方法依賴的package包/類
@Test
public void testOnPropertyChangedCallbacksAddedToViewModel() {
    final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class);
    final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class);
    fragment.setViewModel(fragment.createViewModel());

    fragment.addOnPropertyChangedCallback(firstCallback);
    fragment.addOnPropertyChangedCallback(secondCallback);

    verify(fragment.getViewModel()).addOnPropertyChangedCallback(firstCallback);
    verify(fragment.getViewModel()).addOnPropertyChangedCallback(secondCallback);
}
 
開發者ID:A-Zaiats,項目名稱:android-mvvm,代碼行數:13,代碼來源:MvvmFragmentTest.java

示例10: testRemoveOnPropertyChangedCallbacksOnActivityDestroy

import android.databinding.Observable; //導入方法依賴的package包/類
@Test
public void testRemoveOnPropertyChangedCallbacksOnActivityDestroy() {
    final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class);
    final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class);
    fragment.setViewModel(fragment.createViewModel());
    fragment.addOnPropertyChangedCallback(firstCallback);
    fragment.addOnPropertyChangedCallback(secondCallback);

    SupportFragmentTestUtil.startFragment(fragment);
    fragment.onDestroy();
    verify(fragment.getViewModel()).removeOnPropertyChangedCallback(firstCallback);
    verify(fragment.getViewModel()).removeOnPropertyChangedCallback(secondCallback);
}
 
開發者ID:A-Zaiats,項目名稱:android-mvvm,代碼行數:14,代碼來源:MvvmFragmentTest.java

示例11: addCallback

import android.databinding.Observable; //導入方法依賴的package包/類
public static void addCallback(BaseActivity activity, Observable observable, Observable.OnPropertyChangedCallback callback) {
    ArrayMap<Observable, Observable.OnPropertyChangedCallback> localMap = mGlobalMap.get(activity);
    if (localMap == null) {
        localMap = new ArrayMap<>();
        mGlobalMap.put(activity, localMap);
    }
    observable.addOnPropertyChangedCallback(callback);
    localMap.put(observable, callback);
}
 
開發者ID:daquexian,項目名稱:chaoli-forum-for-android-2,代碼行數:10,代碼來源:DataBindingUtils.java

示例12: removeCallbacks

import android.databinding.Observable; //導入方法依賴的package包/類
public static void removeCallbacks(BaseActivity activity) {
    ArrayMap<Observable, Observable.OnPropertyChangedCallback> localMap = mGlobalMap.get(activity);
    if (localMap != null) {
        for (Observable observable : localMap.keySet()) {
            observable.removeOnPropertyChangedCallback(localMap.get(observable));
        }
    }
}
 
開發者ID:daquexian,項目名稱:chaoli-forum-for-android-2,代碼行數:9,代碼來源:DataBindingUtils.java

示例13: setOnClick

import android.databinding.Observable; //導入方法依賴的package包/類
@BindingAdapter("rxCommandOnClick")
public static void setOnClick(final View view, final RxCommand<NoParameter> command) {
    // Set initial state.
    view.setEnabled(command.canExecute());

    // Observe click events.
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (command.canExecute()) {
                command.execute(NoParameter.INSTANCE);
            }
        }
    });

    // Observe enabled changed events.
    final Observable.OnPropertyChangedCallback callback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            view.setEnabled(command.canExecute());
        }
    };
    command.getEnabled().addOnPropertyChangedCallback(callback);

    command.setCancellable(new Cancellable() {
        @Override
        public void cancel() throws Exception {
            command.getEnabled().removeOnPropertyChangedCallback(callback);
        }
    });
}
 
開發者ID:k-kagurazaka,項目名稱:rx-property-android,代碼行數:32,代碼來源:RxCommandBinders.java

示例14: shouldNotifyPropertyChangeWhenSetRepository

import android.databinding.Observable; //導入方法依賴的package包/類
@Test
public void shouldNotifyPropertyChangeWhenSetRepository() {
    Repository repository = new Repository();
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    Observable.OnPropertyChangedCallback mockCallback =
            mock(Observable.OnPropertyChangedCallback.class);
    itemRepoViewModel.addOnPropertyChangedCallback(mockCallback);

    itemRepoViewModel.setRepository(repository);
    verify(mockCallback).onPropertyChanged(any(Observable.class), anyInt());
}
 
開發者ID:ivacf,項目名稱:archi,代碼行數:12,代碼來源:ItemRepoViewModelTest.java

示例15: init

import android.databinding.Observable; //導入方法依賴的package包/類
public void init(Context context) {
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    mDensity = metrics.density;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mLongPressTimeout = vc.getLongPressTimeout();

    mScroller = new OverScroller(context);

    mTouchRadius = TOUCH_RADIUS_DP * mDensity;
    mEditCtrlStrokeWidth = EDIT_CTRL_STROKE_DP * mDensity;
    mEditColor = getResources().getColor(R.color.colorAccent, context.getTheme());

    mOnListChangedCallback = new ObservableList
            .OnListChangedCallback<ObservableList<Layer>>() {
        @Override
        public void onChanged(ObservableList<Layer> layers) {
            invalidate();
        }

        @Override
        public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {
            invalidate();
        }

        @Override
        public void onItemRangeInserted(ObservableList<Layer> layers, int start, int count) {
            invalidate();
            addPropertyChangedCallbacks(layers, start, start + count);
        }

        @Override
        public void onItemRangeMoved(ObservableList<Layer> layers, int i, int i1, int i2) {
            invalidate();
        }

        @Override
        public void onItemRangeRemoved(ObservableList<Layer> layers, int i, int i1) {
            invalidate();
        }
    };

    mOnPropertyChangedCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            invalidate();
        }
    };
}
 
開發者ID:google,項目名稱:spline,代碼行數:51,代碼來源:DocumentView.java


注:本文中的android.databinding.Observable.OnPropertyChangedCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。