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


Java DiffUtil.Callback方法代碼示例

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


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

示例1: onDataLoaded

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
@Override
public void onDataLoaded(List<User> users) {
    // 無論怎麽操作,數據變更,最終都會通知到這裏來
    final ContactContract.View view = getView();
    if (view == null)
        return;

    RecyclerAdapter<User> adapter = view.getRecyclerAdapter();
    List<User> old = adapter.getItems();

    // 進行數據對比
    DiffUtil.Callback callback = new DiffUiDataCallback<>(old, users);
    DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback);

    // 調用基類方法進行界麵刷新
    refreshData(result, users);
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:18,代碼來源:ContactPresenter.java

示例2: newDiffRequestWith

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * Starts building the {@link DiffRequest}.
 *
 * @param callback The {@link DiffUtil.Callback} for the diff request.
 * @return The {@link DiffRequestBuilder}.
 */
@SuppressWarnings("WeakerAccess")
@NonNull
public DiffRequestBuilder<D> newDiffRequestWith(@NonNull final DiffUtil.Callback callback) {
    checkNotNull(callback, "callback must not be null!");
    return DiffRequestBuilder.create(this, callback);
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:13,代碼來源:DiffRequestManager.java

示例3: DiffRequest

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * Constructs a new instance of {@link DiffRequest}.
 *
 * @param detectMoves  A boolean flag which determines whether moved items should be detected.
 * @param tag          A unique identifier of the request.
 * @param newData      The data to update the adapter with when the calculations are finished. Can be null if you don't want to update the adapter automatically.
 * @param diffCallback A concrete implementation of {@link DiffUtil.Callback}.
 * @throws NullPointerException     If the tag or callback is null.
 * @throws IllegalArgumentException If the tag is empty.
 */
@SuppressWarnings("WeakerAccess")
public DiffRequest(final boolean detectMoves, @NonNull final String tag, @Nullable final List<D> newData, @NonNull final DiffUtil.Callback diffCallback) {
    checkNotNull(tag, "tag string must not be null!");
    checkArgument(!tag.isEmpty(), "tag string must not be empty!");
    checkNotNull(diffCallback, "diffCallback must not be null!");

    this.mDetectMoves = detectMoves;
    this.mTag = tag;
    this.mNewData = newData;
    this.mDiffCallback = diffCallback;
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:22,代碼來源:DiffRequest.java

示例4: DiffRequestBuilder

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * Constructs a new {@link DiffRequestBuilder} instance.
 *
 * @param diffRequestManager The {@link DiffRequestManager} the built request will be automatically executed by.
 * @param callback           The concrete implementation of {@link DiffUtil.Callback}.
 * @throws NullPointerException If the diffRequestManager or callback is null.
 */
public DiffRequestBuilder(@NonNull final Manager<D> diffRequestManager,
                          @NonNull final DiffUtil.Callback callback) {
    checkNotNull(diffRequestManager, "diffRequestManager must not be null!");
    checkNotNull(callback, "callback must not be null!");

    this.mDiffRequestManager = diffRequestManager;
    this.mCallback = callback;
    this.mTag = diffRequestManager.getTag();
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:17,代碼來源:DiffRequestBuilder.java

示例5: getDiffCallBack

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
@Override
protected DiffUtil.Callback getDiffCallBack(List<OpenCloseItem> oldData, List<OpenCloseItem> newData) {
    return new OpenCloseDiffCallBack(oldData, newData);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:OpenCloseAdapterHelper.java

示例6: getDiffCallback

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * @return {@link DiffUtil.Callback} concrete implementation.
 */
@NonNull
public DiffUtil.Callback getDiffCallback() {
    return mDiffCallback;
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:8,代碼來源:DiffRequest.java

示例7: getDiffCallBack

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
@Override
protected DiffUtil.Callback getDiffCallBack(List<MultiTypeIdEntity> oldData, List<MultiTypeIdEntity> newData) {
    return new StringDiffCallBack(oldData, newData);
}
 
開發者ID:crazysunj,項目名稱:CrazyDaily,代碼行數:5,代碼來源:HomeAdapterHelper.java

示例8: getDiffCallBack

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
@Override
protected DiffUtil.Callback getDiffCallBack(List<MutiTypeTitleEntity> oldData, List<MutiTypeTitleEntity> newData) {
    return new TitleDiffCallBack(oldData, newData);
}
 
開發者ID:crazysunj,項目名稱:MultiTypeRecyclerViewAdapter,代碼行數:5,代碼來源:MyAdapterHelper.java

示例9: getDiffCallBack

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * 返回比較的callback對象,提供新老數據
 * 默認比較id和type,id設為long是為了比較效率,你可以使用字符串的hashCode,注意衝突,甚至你可以自定義Callback
 *
 * @param oldData 老數據
 * @param newData 新數據
 * @return 返回Callback
 */
protected DiffUtil.Callback getDiffCallBack(List<T> oldData, List<T> newData) {
    return new DiffCallBack<T>(oldData, newData);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RecyclerViewAdapterHelper.java

示例10: create

import android.support.v7.util.DiffUtil; //導入方法依賴的package包/類
/**
 * Forwards the call to {@link DiffRequestBuilder#DiffRequestBuilder(Manager, DiffUtil.Callback)} ensuring type safety.
 *
 * @param diffRequestManager {@link DiffRequestManager}.
 * @param callback           {@link DiffUtil.Callback}.
 * @param <T>                The type of the data model.
 * @return {@link DiffRequestBuilder}.
 */
@NonNull
public static <T> DiffRequestBuilder<T> create(@NonNull final Manager<T> diffRequestManager,
                                               @NonNull final DiffUtil.Callback callback) {
    return new DiffRequestBuilder<>(diffRequestManager, callback);
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:14,代碼來源:DiffRequestBuilder.java


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