Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
352cc3a
A very rough first pass at integrating ListManager to post list
oguzkocer Oct 17, 2018
e0bcee4
Update FluxC hash, add lots of todos to post list and minor fixes
oguzkocer Oct 17, 2018
766fe4d
Featured images are properly handled in post list
oguzkocer Oct 17, 2018
45f8c74
Fix local changes not reflecting in post list
oguzkocer Oct 17, 2018
d94b356
Correctly handle upload events in post list
oguzkocer Oct 17, 2018
e4ac3aa
Add loading layout for post list
oguzkocer Oct 17, 2018
c1fb27f
Refresh the post list after an upload
oguzkocer Oct 17, 2018
14c8eaf
Adds a workaround to local drafts briefly disappearing when it's push…
oguzkocer Oct 18, 2018
3edc2dc
Skeleton view for loading posts in post list
oguzkocer Oct 18, 2018
b014196
Remove unused property and enum and replace if with when in PostListA…
oguzkocer Oct 18, 2018
36fc606
Empty view in post list should be correctly updated now
oguzkocer Oct 19, 2018
48f6e89
Fix an issue with comparing local items in post list
oguzkocer Oct 19, 2018
ae83827
Basic hide post support added for post list
oguzkocer Oct 19, 2018
1fe0f13
Update FluxC hash and implement necessary changes in post list
oguzkocer Oct 22, 2018
29a71b7
Update FluxC hash and resolve several todos in PostListFragment
oguzkocer Oct 23, 2018
60e5209
Save trashed and uploaded post ids in the instance state
oguzkocer Oct 23, 2018
be31015
Merge branch 'feature/list-store-integration-for-post-list-master' in…
oguzkocer Oct 23, 2018
5714744
Merge branch 'feature/list-store-integration-for-post-list-master' in…
oguzkocer Oct 23, 2018
9adc90d
Add a style for post list skeleton buttons
oguzkocer Oct 23, 2018
d399213
Major cleanup/reorder of PostListFragment and PostListAdapter
oguzkocer Oct 24, 2018
2d1814f
Second take at improving PostListFragment
oguzkocer Oct 24, 2018
f333500
Fix an issue for when a uploaded local draft doesn't show up in post …
oguzkocer Oct 24, 2018
8719cdf
Throw illegal exception if a view type is not handled in PostListAdapter
oguzkocer Oct 24, 2018
ee5e054
Improve empty view handling for list manager changes
oguzkocer Oct 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dependencies {
implementation 'com.squareup.okio:okio:1.13.0'
implementation 'org.apache.commons:commons-text:1.1'
implementation 'com.airbnb.android:lottie:2.0.0-rc2'
implementation 'com.facebook.shimmer:shimmer:0.3.0'

implementation ('com.yalantis:ucrop:2.2.0') {
exclude group: 'com.squareup.okhttp3'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.wordpress.android.ui

import android.support.v7.util.DiffUtil
import org.wordpress.android.fluxc.model.list.ListManager

/**
* A helper class which can be used to compare two [ListManager]s.
*
* @param oldListManager The current [ListManager] to be used in comparison
* @param newListManager The new [ListManager] that'll replace the old one
* @param areItemsTheSame A compare function to be used to determine if two items refer to the same object. This is
* not the function to compare the contents of the items. In most cases, this should compare the ids of two items.
* @param areContentsTheSame A compare function to be used to determine if two items has the same contents. This
* function will be triggered for items who return true for [areItemsTheSame] and actual content comparison should be
* made depending on the view they are used in.
*/
class ListManagerDiffCallback<T>(
private val oldListManager: ListManager<T>?,
private val newListManager: ListManager<T>,
private val areItemsTheSame: (T, T) -> Boolean,
private val areContentsTheSame: (T, T) -> Boolean
) : DiffUtil.Callback() {
override fun getOldListSize(): Int {
return oldListManager?.size ?: 0
}

override fun getNewListSize(): Int {
return newListManager.size
}

override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
if (oldListManager == null) {
return false
}
return compareItems(oldItemPosition, newItemPosition, areItemsTheSame)
}

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return compareItems(oldItemPosition, newItemPosition, areContentsTheSame)
}

/**
* A helper function to compare two items in the given positions given a compare function.
*/
private fun compareItems(oldItemPosition: Int, newItemPosition: Int, compare: (T, T) -> Boolean): Boolean {
// We shouldn't fetch items or load more pages prematurely when we are just trying to compare them
val oldItem = oldListManager?.getItem(
position = oldItemPosition,
shouldFetchIfNull = false,
shouldLoadMoreIfNecessary = false
)
val newItem = newListManager.getItem(
position = newItemPosition,
shouldFetchIfNull = false,
shouldLoadMoreIfNecessary = false
)
// If two items are null, they are the same for our intends and purposes
if (oldItem == null && newItem == null) {
return true
}
// If one of the items is null, but the other one is not, they can't be the same item
if (oldItem == null || newItem == null) {
return false
}
return compare(oldItem, newItem)
}
}
Loading