All Projects → mrmike → Diffutil Sample

mrmike / Diffutil Sample

Licence: apache-2.0
Android sample app in Kotlin showing usage of DiffUtil class.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Diffutil Sample

Babypiganimation
基本动画、位移动画、缩放动画、旋转动画、组动画、关键帧动画、贝塞尔曲线、进度条动画、复杂动画、OC动画、aniamtion、basicanimation等。
Stars: ✭ 192 (-4.95%)
Mutual labels:  demo
Demo Html Css
超好看的前端模板(学习用)
Stars: ✭ 199 (-1.49%)
Mutual labels:  demo
Koa Vue Notes Web
🤓 This is a simple SPA built using Koa as the backend, Vue as the first frontend, and React as the second frontend. Features MySQL integration, user authentication, CRUD note actions, and Vuex store modules.
Stars: ✭ 200 (-0.99%)
Mutual labels:  demo
Jsstudy
Study JavaScript
Stars: ✭ 192 (-4.95%)
Mutual labels:  demo
Fermionjs
Visual Prototyping Tool for React Applications
Stars: ✭ 197 (-2.48%)
Mutual labels:  demo
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (-1.98%)
Mutual labels:  demo
Vue Switches
An on/off switch component for Vue.js with theme support.
Stars: ✭ 188 (-6.93%)
Mutual labels:  demo
Dekryptize
A ncurses animation to make decryption look like, well, decryption.
Stars: ✭ 201 (-0.5%)
Mutual labels:  demo
Awesome Spring Boot
springboot 各种资料整理(demo、教程、网站、starter文档等),持续更新,欢迎pr。
Stars: ✭ 198 (-1.98%)
Mutual labels:  demo
Preact Redux Example
🔁 Preact + Redux Example Project
Stars: ✭ 199 (-1.49%)
Mutual labels:  demo
Pytorch Cpp
PyTorch C++ inference with LibTorch
Stars: ✭ 194 (-3.96%)
Mutual labels:  demo
Imodels
Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).
Stars: ✭ 194 (-3.96%)
Mutual labels:  demo
Demo Project
存放学习过程中的demo项目,别光fork,顺便点下⭐哦
Stars: ✭ 198 (-1.98%)
Mutual labels:  demo
Geopackage Js
GeoPackage JavaScript Library
Stars: ✭ 191 (-5.45%)
Mutual labels:  demo
React Leaflet Demo
Demo of a Leaflet map created with React
Stars: ✭ 200 (-0.99%)
Mutual labels:  demo
Esp8266 Demos
ESP8266示例工程集合
Stars: ✭ 190 (-5.94%)
Mutual labels:  demo
Mocapnet
We present MocapNET2, a real-time method that estimates the 3D human pose directly in the popular Bio Vision Hierarchy (BVH) format, given estimations of the 2D body joints originating from monocular color images. Our contributions include: (a) A novel and compact 2D pose NSRM representation. (b) A human body orientation classifier and an ensemble of orientation-tuned neural networks that regress the 3D human pose by also allowing for the decomposition of the body to an upper and lower kinematic hierarchy. This permits the recovery of the human pose even in the case of significant occlusions. (c) An efficient Inverse Kinematics solver that refines the neural-network-based solution providing 3D human pose estimations that are consistent with the limb sizes of a target person (if known). All the above yield a 33% accuracy improvement on the Human 3.6 Million (H3.6M) dataset compared to the baseline method (MocapNET) while maintaining real-time performance (70 fps in CPU-only execution).
Stars: ✭ 194 (-3.96%)
Mutual labels:  demo
Rn Wunderlist
Wunderlist Clone written in React Native
Stars: ✭ 201 (-0.5%)
Mutual labels:  demo
Seniverse Api Demos
心知天气 API 产品使用调用示例
Stars: ✭ 201 (-0.5%)
Mutual labels:  demo
Web Push Book
Web Push Book
Stars: ✭ 199 (-1.49%)
Mutual labels:  demo

DiffUtil Android Sample - Kotlin

Example of usage DiffUtil utility class added originally in Support Library 24.2.0.

Demo

Demo

Implementation

calculateDiff method from DiffUtill class requires DiffUtil.Callback object as parameter.

DiffUtil callback - ActorDiffCallback.kt

Implements 4 methods:

  • getOldListSize - returns size of the old list
  • getNewListSize - returns size of the new list
  • areItemsTheSame - returns true if two items are the same, e.g. have the same ids
  • areContentsTheSame - returns true if displayed content was not changed. In our case we only display actor's name so we're detecing name's change.

Applying diff result - ActorAdapter.swap()

DiffResult can be applied to adapter by calling diffResult.dispatchUpdatesTo(adapter).

    fun swap(actors: List<Actor>) {
            val diffCallback = ActorDiffCallback(this.actors, actors)
            val diffResult = DiffUtil.calculateDiff(diffCallback)

            this.actors.clear()
            this.actors.addAll(actors)
            diffResult.dispatchUpdatesTo(this)
    }

Resources

License

Copyright 2016 Michał Moczulski

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].