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


Java DiffUtil.DiffResult方法代码示例

本文整理汇总了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;
}
 
开发者ID:MEiDIK,项目名称:SlimAdapter,代码行数:25,代码来源:SlimAdapter.java

示例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);
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:18,代码来源:ContactPresenter.java

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

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

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

示例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();
        }
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:14,代码来源:TasksFragment.java

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

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

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

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

示例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);

}
 
开发者ID:evrencoskun,项目名称:TableView,代码行数:10,代码来源:CellRecyclerViewAdapter.java

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

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

示例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;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:6,代码来源:DownloadInfoUpdate.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:6,代码来源:ClaimItemAdapter.java


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