本文整理汇总了Java中android.support.v7.util.DiffUtil.DiffResult方法的典型用法代码示例。如果您正苦于以下问题:Java DiffUtil.DiffResult方法的具体用法?Java DiffUtil.DiffResult怎么用?Java DiffUtil.DiffResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.util.DiffUtil
的用法示例。
在下文中一共展示了DiffUtil.DiffResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateData
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public SlimAdapter updateData(List<?> data) {
if (moreLoader != null) {
moreLoader.reset();
}
if (diffCallback == null || getItemCount() == 0 || data == null || data.size() == 0) {
this.data = data;
if (Looper.myLooper() == Looper.getMainLooper()) {
notifyDataSetChanged();
} else {
uiHandler.removeMessages(WHAT_NOTIFY_DATA_SET_CHANGED);
uiHandler.sendEmptyMessage(WHAT_NOTIFY_DATA_SET_CHANGED);
}
} else {
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new SlimDiffUtil(this.data, data, diffCallback));
this.data = data;
if (Looper.myLooper() == Looper.getMainLooper()) {
diffResult.dispatchUpdatesTo(this);
} else {
uiHandler.removeMessages(WHAT_NOTIFY_DATA_SET_CHANGED);
uiHandler.sendEmptyMessage(WHAT_NOTIFY_DATA_SET_CHANGED);
}
}
return this;
}
示例2: 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);
}
示例3: addDailyDate
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void addDailyDate(DailyListBean info) {
currentTitle = "今日热闻";
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new ZhihuDiffCallback(mList, info.getStories()), true);
mList = info.getStories();
mTopList = info.getTop_stories();
isBefore = false;
diffResult.dispatchUpdatesTo(this);
// notifyDataSetChanged();
}
示例4: run
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
/** {@inheritDoc} */
@WorkerThread
@Override
public void run() {
final DiffUtil.DiffResult diffResult
= DiffUtil.calculateDiff(new GmlrvaDiffCallback(this.mOldDataSet, this.mNewDataSet));
if (mContext != null) {
((Activity) mContext).runOnUiThread(new UpdateUiDiffUtilResult(this.mNewDataSet, diffResult, mAdapter));
}
}
示例5: addItems
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void addItems(List<Recipe> recipeList) {
List<Recipe> newRecipeList = new ArrayList<>();
newRecipeList.addAll(this.recipeList);
newRecipeList.addAll(recipeList);
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new RecipeDiffUtilCallback(this.recipeList, newRecipeList));
this.recipeList.addAll(recipeList);
diffResult.dispatchUpdatesTo(this);
}
示例6: showTasks
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void showTasks(Pair<DiffUtil.DiffResult, List<Task>> pairOfDiffResultAndTasks, TasksFilterType filterType) {
if(tasksAdapter != null) {
DiffUtil.DiffResult diffResult = pairOfDiffResultAndTasks.getValue0();
List<Task> tasks = pairOfDiffResultAndTasks.getValue1();
tasksAdapter.setData(tasks);
diffResult.dispatchUpdatesTo(tasksAdapter);
if(tasks.isEmpty()) {
filterType.showEmptyViews(this);
} else {
hideEmptyViews();
}
}
}
示例7: run
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
@Override
public void run() {
List<T> newData = mHandleBase.getNewData();
T newHeader = mHandleBase.getNewHeader();
T newFooter = mHandleBase.getNewFooter();
int refreshType = mHandleBase.getRefreshType();
int type = mHandleBase.getType();
DiffUtil.DiffResult result = handleRefresh(newData, newHeader, newFooter, type, refreshType);
Message message = mHandler.obtainMessage(HANDLE_DATA_UPDATE);
message.obj = result;
message.sendToTarget();
}
示例8: onNewData
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void onNewData(ArrayList<User> users) {
UserCallback callback = new UserCallback(users, this.users);
DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback, true);
this.users.clear();
this.users.addAll(users);
result.dispatchUpdatesTo(this);
}
示例9: updateEmployeeListItems
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void updateEmployeeListItems(List<Employee> employees) {
final EmployeeDiffCallback diffCallback = new EmployeeDiffCallback(this.mEmployees, employees);
final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffCallback);
this.mEmployees.clear();
this.mEmployees.addAll(employees);
diffResult.dispatchUpdatesTo(this);
}
示例10: onNewData
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void onNewData(ArrayList<CategoryHolder> items) {
final CategoryDiffCallback callback = new CategoryDiffCallback(items, this.items);
final DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback, true);
this.items.clear();
this.items.addAll(items);
result.dispatchUpdatesTo(this);
}
示例11: dispatchUpdatesTo
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void dispatchUpdatesTo(DiffUtil.DiffResult p_jResults) {
for (int i = 0; i < m_jAdapterList.size(); i++) {
RecyclerView.Adapter cellRowAdapter = m_jAdapterList.get(i);
p_jResults.dispatchUpdatesTo(cellRowAdapter);
}
p_jResults.dispatchUpdatesTo(this);
}
示例12: setData
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
/**
* Sets the data set to the adapter and automatically dispatches an update
* via DiffUtil.DiffResult
* @param data new data set
*/
public void setData(List<T> data) {
final DiffUtil.DiffResult diffResult = calculateDiff(this.data, data, valueHashCache);
this.data = data;
this.valueHashCache = createValueHashList();
notifyDiffSubject.onNext(diffResult);
dataChangeSubject.onNext(data);
}
示例13: addItems
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void addItems(List<LikedRecipe> likedRecipeList) {
List<LikedRecipe> newLikedRecipeList = new ArrayList<>();
newLikedRecipeList.addAll(this.likedRecipeList);
newLikedRecipeList.addAll(likedRecipeList);
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new LikedRecipeDiffUtilCallback(this.likedRecipeList, newLikedRecipeList));
this.likedRecipeList.addAll(likedRecipeList);
diffResult.dispatchUpdatesTo(this);
}
示例14: DownloadInfoUpdate
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public DownloadInfoUpdate(List<DownloadInfo> downloadInfos, DiffUtil.DiffResult diffResult) {
this.downloadInfos = downloadInfos;
this.diffResult = diffResult;
type=TYPE_PROGRESS;
}
示例15: onForeground
import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
@Override
public void onForeground(final Pair<List<DisplayItem>, DiffUtil.DiffResult> value) {
ClaimItemAdapter.this.items = value.first;
value.second.dispatchUpdatesTo(ClaimItemAdapter.this);
}