Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed May 8, 2024
1 parent 6e22e7c commit f0d2139
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class MwQueryPage {

var diffSize = 0

val localDateTime by lazy { DateUtil.iso8601LocalDateTimeParse(timeStamp) }
val localDateTime by lazy {
if (timeStamp.isNotBlank()) DateUtil.iso8601LocalDateTimeParse(timeStamp) else null
}

fun getContentFromSlot(slot: String): String {
return slots?.get(slot)?.content.orEmpty()
Expand Down
25 changes: 11 additions & 14 deletions app/src/main/java/org/wikipedia/views/EditHistoryStatsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.wikipedia.util.DateUtil
import org.wikipedia.util.DimenUtil
import org.wikipedia.util.FeedbackUtil
import org.wikipedia.util.StringUtil
import java.time.LocalDateTime
import java.time.LocalDate

class EditHistoryStatsView constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) {

Expand All @@ -31,19 +31,16 @@ class EditHistoryStatsView constructor(context: Context, attrs: AttributeSet? =
fun setup(pageTitle: PageTitle, editHistoryStats: EditHistoryListViewModel.EditHistoryStats?) {
binding.articleTitleView.text = StringUtil.fromHtml(context.getString(R.string.page_edit_history_activity_title,
"<a href=\"#\">${pageTitle.displayText}</a>"))
editHistoryStats?.let { stats ->
val timestamp = stats.revision.timeStamp
if (timestamp.isNotBlank()) {
val createdYear = DateUtil.getYearOnlyDateString(DateUtil.iso8601DateParse(timestamp))
val localDateTime = LocalDateTime.now()
val today = DateUtil.getShortDateString(localDateTime.toLocalDate())
val lastYear = DateUtil.getShortDateString(localDateTime.minusYears(1).toLocalDate())
binding.editCountsView.text = context.resources.getQuantityString(R.plurals.page_edit_history_article_edits_since_year,
stats.allEdits.count, stats.allEdits.count, createdYear)
binding.statsGraphView.setData(stats.metrics.map { it.edits.toFloat() })
binding.statsGraphView.contentDescription = context.getString(R.string.page_edit_history_metrics_content_description, lastYear, today)
FeedbackUtil.setButtonTooltip(binding.statsGraphView)
}
editHistoryStats?.revision?.localDateTime?.let { dateTime ->
val createdYear = DateUtil.getYearOnlyDateString(dateTime.toLocalDate())
val localDate = LocalDate.now()
val today = DateUtil.getShortDateString(localDate)
val lastYear = DateUtil.getShortDateString(localDate.minusYears(1))
binding.editCountsView.text = context.resources.getQuantityString(R.plurals.page_edit_history_article_edits_since_year,
editHistoryStats.allEdits.count, editHistoryStats.allEdits.count, createdYear)
binding.statsGraphView.setData(editHistoryStats.metrics.map { it.edits.toFloat() })
binding.statsGraphView.contentDescription = context.getString(R.string.page_edit_history_metrics_content_description, lastYear, today)
FeedbackUtil.setButtonTooltip(binding.statsGraphView)
}
binding.articleTitleView.movementMethod = LinkMovementMethodExt { _ ->
context.startActivity(PageActivity.newIntentForNewTab(context, HistoryEntry(pageTitle, HistoryEntry.SOURCE_EDIT_HISTORY), pageTitle))
Expand Down

0 comments on commit f0d2139

Please sign in to comment.