當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。