Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Throw illegal exception if a view type is not handled in PostListAdapter
  • Loading branch information
oguzkocer committed Oct 24, 2018
commit 8719cdf4fd7a263d114ee14e44f6402ffb8fec85
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ class PostListAdapter(
val view = layoutInflater.inflate(R.layout.post_cardview_skeleton, parent, false)
LoadingViewHolder(view)
}
else -> {
VIEW_TYPE_POST -> {
val view = layoutInflater.inflate(R.layout.post_cardview, parent, false)
PostViewHolder(view)
}
else -> {
// Fail fast if a new view type is added so the we can handle it
throw IllegalStateException("The view type '$viewType' needs to be handled")
}
}
}

Expand All @@ -170,67 +174,67 @@ class PostListAdapter(

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
// nothing to do if this is the static endlist indicator
val viewType = getItemViewType(position)
if (viewType == VIEW_TYPE_ENDLIST_INDICATOR) {
if (holder is EndListViewHolder) {
return
}
if (viewType == VIEW_TYPE_LOADING) {
if (holder is LoadingViewHolder) {
return
}
if (holder !is PostViewHolder) {
// Fail fast if a new view type is added so the we can handle it
throw IllegalStateException("Only remaining ViewHolder type should be PostViewHolder")
}

listManager?.getItem(position)?.let { post ->
val context = holder.itemView.context

if (holder is PostViewHolder) {
if (StringUtils.isNotEmpty(post.title)) {
// Unescape HTML
val cleanPostTitle = StringEscapeUtils.unescapeHtml4(post.title)
holder.title.text = cleanPostTitle
} else {
holder.title.text = context.resources.getText(R.string.untitled_in_parentheses)
}
if (StringUtils.isNotEmpty(post.title)) {
// Unescape HTML
val cleanPostTitle = StringEscapeUtils.unescapeHtml4(post.title)
holder.title.text = cleanPostTitle
} else {
holder.title.text = context.resources.getText(R.string.untitled_in_parentheses)
}

var cleanPostExcerpt = PostUtils.getPostListExcerptFromPost(post)

if (StringUtils.isNotEmpty(cleanPostExcerpt)) {
holder.excerpt.visibility = View.VISIBLE
// Unescape HTML
cleanPostExcerpt = StringEscapeUtils.unescapeHtml4(cleanPostExcerpt)
// Collapse short-codes: [gallery ids="1206,1205,1191"] -> [gallery]
cleanPostExcerpt = PostUtils.collapseShortcodes(cleanPostExcerpt)
holder.excerpt.text = cleanPostExcerpt
} else {
holder.excerpt.visibility = View.GONE
}
var cleanPostExcerpt = PostUtils.getPostListExcerptFromPost(post)

showFeaturedImage(post, holder.featuredImage)
if (StringUtils.isNotEmpty(cleanPostExcerpt)) {
holder.excerpt.visibility = View.VISIBLE
// Unescape HTML
cleanPostExcerpt = StringEscapeUtils.unescapeHtml4(cleanPostExcerpt)
// Collapse short-codes: [gallery ids="1206,1205,1191"] -> [gallery]
cleanPostExcerpt = PostUtils.collapseShortcodes(cleanPostExcerpt)
holder.excerpt.text = cleanPostExcerpt
} else {
holder.excerpt.visibility = View.GONE
}

// local drafts say "delete" instead of "trash"
if (post.isLocalDraft) {
holder.date.visibility = View.GONE
holder.trashButton.buttonType = PostListButton.BUTTON_DELETE
} else {
holder.date.text = PostUtils.getFormattedDate(post)
holder.date.visibility = View.VISIBLE
holder.trashButton.buttonType = PostListButton.BUTTON_TRASH
}
showFeaturedImage(post, holder.featuredImage)

if (UploadService.isPostUploading(post)) {
holder.disabledOverlay.visibility = View.VISIBLE
holder.progressBar.isIndeterminate = true
} else if (!AppPrefs.isAztecEditorEnabled() && UploadService.isPostUploadingOrQueued(post)) {
// Editing posts with uploading media is only supported in Aztec
holder.disabledOverlay.visibility = View.VISIBLE
} else {
holder.progressBar.isIndeterminate = false
holder.disabledOverlay.visibility = View.GONE
}
// local drafts say "delete" instead of "trash"
if (post.isLocalDraft) {
holder.date.visibility = View.GONE
holder.trashButton.buttonType = PostListButton.BUTTON_DELETE
} else {
holder.date.text = PostUtils.getFormattedDate(post)
holder.date.visibility = View.VISIBLE
holder.trashButton.buttonType = PostListButton.BUTTON_TRASH
}

updateStatusTextAndImage(holder.status, holder.statusImage, post)
updatePostUploadProgressBar(holder.progressBar, post)
configurePostButtons(holder, post)
if (UploadService.isPostUploading(post)) {
holder.disabledOverlay.visibility = View.VISIBLE
holder.progressBar.isIndeterminate = true
} else if (!AppPrefs.isAztecEditorEnabled() && UploadService.isPostUploadingOrQueued(post)) {
// Editing posts with uploading media is only supported in Aztec
holder.disabledOverlay.visibility = View.VISIBLE
} else {
holder.progressBar.isIndeterminate = false
holder.disabledOverlay.visibility = View.GONE
}

updateStatusTextAndImage(holder.status, holder.statusImage, post)
updatePostUploadProgressBar(holder.progressBar, post)
configurePostButtons(holder, post)
holder.itemView.setOnClickListener {
onPostSelectedListener?.onPostSelected(post)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ subprojects {
}

ext {
fluxCVersion = 'ec255e6ce7e74a6e75a590c192757a1479871676'
fluxCVersion = '7a9d7311f0b25e9e08e2e5e9dd77d00f6f607542'
}