当前位置: 首页>>代码示例>>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;未经允许,请勿转载。