本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例6: getDiffCallback
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
/**
* @return {@link DiffUtil.Callback} concrete implementation.
*/
@NonNull
public DiffUtil.Callback getDiffCallback() {
return mDiffCallback;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}