当前位置: 首页>>代码示例>>Java>>正文


Java DiffUtil.calculateDiff方法代码示例

本文整理汇总了Java中android.support.v7.util.DiffUtil.calculateDiff方法的典型用法代码示例。如果您正苦于以下问题:Java DiffUtil.calculateDiff方法的具体用法?Java DiffUtil.calculateDiff怎么用?Java DiffUtil.calculateDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.util.DiffUtil的用法示例。


在下文中一共展示了DiffUtil.calculateDiff方法的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;
}
 
开发者ID:MEiDIK,项目名称:SlimAdapter,代码行数:25,代码来源:SlimAdapter.java

示例2: getRootSuccess

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
@Override
public void getRootSuccess(List<AppInfo> apps, List<AppInfo> appsNew) {
    DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new DiffCallBack(apps, appsNew), false);
    diffResult.dispatchUpdatesTo(mDisableAppAdapter);
    mAppList = appsNew;
    mDisableAppAdapter.setData(mAppList);
    for (int i = 0; i < mAppList.size(); i++) {
        AppInfo info = mAppList.get(i);
        if (mMainActivity.getSelection().contains(info)) {
            mMainActivity.getSelection().remove(info);
            mDisableAppAdapter.notifyItemChanged(i);
        }
    }
    mMainActivity.checkSelection();
    String str = mMainActivity.mRootStr;
    if (!TextUtils.isEmpty(str)) {
        snackBarShow(mMainActivity.mCoordinatorLayout, mMainActivity.mRootStr);
    }
    setRefreshing(false);
    if (mAppList.isEmpty()) {
        mDisableAppAdapter.showLoadFailed(R.drawable.empty, getResources().getString(R.string.no_disable_apps), "");
        snackBarShow(mMainActivity.mCoordinatorLayout, getString(R.string.no_disable_apps));
    }
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:25,代码来源:MainFragment.java

示例3: setSuggestions

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
void setSuggestions(@NonNull List<String> newStrings) {
    final SuggestionDiff suggestionDiff = new SuggestionDiff(suggestions, newStrings);
    final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(suggestionDiff, true);
    suggestions.clear();
    suggestions.addAll(newStrings);
    diffResult.dispatchUpdatesTo(this);
}
 
开发者ID:arunkumar9t2,项目名称:rxSuggestions,代码行数:8,代码来源:MainActivity.java

示例4: addDailyBeforeDate

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void addDailyBeforeDate(DailyBeforeListBean info) {
        currentTitle = info.getDate();
        DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new ZhihuDiffCallback(mList, info.getStories()), true);
        mList = info.getStories();
        isBefore = true;
        diffResult.dispatchUpdatesTo(this);
//        notifyDataSetChanged();
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:DailyAdapter.java

示例5: animateDiff

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
@Deprecated //TODO: Call animateTo instead.
private synchronized void animateDiff(@Nullable List<T> newItems, Payload payloadChange) {
	if (useDiffUtil) {
		Log.v(TAG, "Animate changes with DiffUtils! oldSize=" + getItemCount() + " newSize=" + newItems.size());
		if (diffUtilCallback == null) {
			diffUtilCallback = new DiffUtilCallback();
		}
		diffUtilCallback.setItems(mItems, newItems);
		diffResult = DiffUtil.calculateDiff(diffUtilCallback, notifyMoveOfFilteredItems);
	} else {
		animateTo(newItems, payloadChange);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:FlexibleAdapter.java

示例6: onDataLoaded

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
@Override
public void onDataLoaded(List<Session> sessions) {
    SessionContract.View view = getView();
    if (view == null) {
        return;
    }
    // 差异对比
    List<Session> old = view.getRecyclerAdapter().getItems();
    DiffUiDataCallback<Session> callback = new DiffUiDataCallback<>(old, sessions);
    DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback);
    // 刷新界面
    refreshData(result, sessions);
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:14,代码来源:SessionPresenter.java

示例7: swapItems

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void swapItems(List<Watcher> watchers) {
    final WatcherListDiffCallback callback = new WatcherListDiffCallback(this.watchers, watchers);
    final DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback);

    this.watchers.clear();
    this.watchers.addAll(watchers);
    result.dispatchUpdatesTo(this);
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:9,代码来源:WatchersAdapter.java

示例8: updateEmployeeListItems

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void updateEmployeeListItems(List<BaseMessage> recentPhotoList) {
    //final MessageListDiffCall diffCallback = new MessageListDiffCall(this.mBaseMessageList, recentPhotoList);
    //final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffCallback);
    DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MessageListDiffCall(this.mBaseMessageList, recentPhotoList));
    diffResult.dispatchUpdatesTo(this);
    /*
    this.mBaseMessageList.removeAll(mBaseMessageList);
    this.mBaseMessageList.addAll(recentPhotoList);
    diffResult.dispatchUpdatesTo(RecentPhotoAdapter.this);*/
}
 
开发者ID:DarveshArt,项目名称:Mueton,代码行数:11,代码来源:MessageListAdapter.java

示例9: refresh

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
private void refresh() {
  mNewDatas.clear();
  mNewDatas.addAll(mDatas);
  //改变第三个位置的对象
  Item item = new Item(3, "zhang");
  mNewDatas.remove(3);
  mNewDatas.add(3, item);
  DiffUtil.DiffResult diffResult =
      DiffUtil.calculateDiff(new DiffCallback(mDatas, mNewDatas), true);
  //将新数据给Adapter
  mAdapter.setDatas(mNewDatas);
  diffResult.dispatchUpdatesTo(mAdapter);
  mDatas.clear();
  mDatas.addAll(mNewDatas);
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:16,代码来源:DiffUtilUI.java

示例10: refreshItems

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void refreshItems(List<Recipe> recipeList) {

        List<Recipe> newRecipeList = new ArrayList<>();
        newRecipeList.addAll(recipeList);

        DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new RecipeDiffUtilCallback(this.recipeList, newRecipeList));
        this.recipeList.clear();
        this.recipeList.addAll(recipeList);
        diffResult.dispatchUpdatesTo(this);
    }
 
开发者ID:vicky7230,项目名称:Paprika,代码行数:11,代码来源:SearchAdapter.java

示例11: 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);
}
 
开发者ID:AnkitSinhal,项目名称:DiffUtilExample,代码行数:9,代码来源:EmployeeRecyclerViewAdapter.java

示例12: swapItems

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
public void swapItems(List<User> users) {
    String newActive = getContext().getSharedPreferences("settings", Context.MODE_PRIVATE).getString("userID", "");
    final AccountListDiffCallback callback = new AccountListDiffCallback(this.users, users, oldActive, newActive);
    final DiffUtil.DiffResult result = DiffUtil.calculateDiff(callback);

    this.users.clear();
    this.users.addAll(users);
    result.dispatchUpdatesTo(this);

    oldActive = newActive;
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:12,代码来源:AccountsAdapter.java

示例13: 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);
}
 
开发者ID:WGPlaner,项目名称:wg_planer,代码行数:10,代码来源:ShoppingListCategoryAdapter.java

示例14: 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);
}
 
开发者ID:WGPlaner,项目名称:wg_planer,代码行数:10,代码来源:GroupMemberAdapter.java

示例15: sort

import android.support.v7.util.DiffUtil; //导入方法依赖的package包/类
void sort() {
    List<OpsInfo> mOld = new ArrayList<>(mOpsInfo);
    Collections.sort(mOpsInfo, getSortMethod());
    DiffUtil.DiffResult result = DiffUtil.calculateDiff(new DiffCallback(mOld, mOpsInfo));
    result.dispatchUpdatesTo(this);
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:7,代码来源:OpsItemAdapter.java


注:本文中的android.support.v7.util.DiffUtil.calculateDiff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。