mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
@@ -140,9 +140,14 @@ class ListHabitsRootView @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateEmptyView() {
|
private fun updateEmptyView() {
|
||||||
llEmpty.visibility = when (listAdapter.itemCount) {
|
if (listAdapter.itemCount == 0) {
|
||||||
0 -> VISIBLE
|
if (listAdapter.hasNoHabit()) {
|
||||||
else -> GONE
|
llEmpty.showEmpty()
|
||||||
|
} else {
|
||||||
|
llEmpty.showDone()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
llEmpty.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,32 +34,54 @@ import org.isoron.uhabits.utils.sres
|
|||||||
import org.isoron.uhabits.utils.str
|
import org.isoron.uhabits.utils.str
|
||||||
|
|
||||||
class EmptyListView(context: Context) : LinearLayout(context) {
|
class EmptyListView(context: Context) : LinearLayout(context) {
|
||||||
|
var textTextView: TextView
|
||||||
|
var iconTextView: TextView
|
||||||
|
|
||||||
init {
|
init {
|
||||||
orientation = VERTICAL
|
orientation = VERTICAL
|
||||||
gravity = CENTER
|
gravity = CENTER
|
||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
|
|
||||||
addView(
|
iconTextView = TextView(context).apply {
|
||||||
TextView(context).apply {
|
|
||||||
text = str(R.string.fa_star_half_o)
|
text = str(R.string.fa_star_half_o)
|
||||||
typeface = getFontAwesome()
|
typeface = getFontAwesome()
|
||||||
textSize = sp(40.0f)
|
textSize = sp(40.0f)
|
||||||
gravity = CENTER
|
gravity = CENTER
|
||||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||||
},
|
}
|
||||||
|
|
||||||
|
addView(
|
||||||
|
iconTextView,
|
||||||
MATCH_PARENT,
|
MATCH_PARENT,
|
||||||
WRAP_CONTENT
|
WRAP_CONTENT
|
||||||
)
|
)
|
||||||
|
|
||||||
addView(
|
textTextView = TextView(context).apply {
|
||||||
TextView(context).apply {
|
|
||||||
text = str(R.string.no_habits_found)
|
text = str(R.string.no_habits_found)
|
||||||
gravity = CENTER
|
gravity = CENTER
|
||||||
setPadding(0, dp(20.0f).toInt(), 0, 0)
|
setPadding(0, dp(20.0f).toInt(), 0, 0)
|
||||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||||
},
|
}
|
||||||
|
addView(
|
||||||
|
textTextView,
|
||||||
MATCH_PARENT,
|
MATCH_PARENT,
|
||||||
WRAP_CONTENT
|
WRAP_CONTENT
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showDone() {
|
||||||
|
visibility = VISIBLE
|
||||||
|
iconTextView.text = str(R.string.fa_umbrella_beach)
|
||||||
|
textTextView.text = str(R.string.no_habits_left_to_do)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showEmpty() {
|
||||||
|
visibility = VISIBLE
|
||||||
|
iconTextView.text = str(R.string.fa_star_half_o)
|
||||||
|
textTextView.text = str(R.string.no_habits_found)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hide() {
|
||||||
|
visibility = GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ class HabitCardListAdapter @Inject constructor(
|
|||||||
cache.cancelTasks()
|
cache.cancelTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasNoHabit(): Boolean {
|
||||||
|
return cache.hasNoHabit()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all items as not selected.
|
* Sets all items as not selected.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
<string translatable="false" name="fa_calendar"></string>
|
<string translatable="false" name="fa_calendar"></string>
|
||||||
<string translatable="false" name="fa_exclamation_circle"></string>
|
<string translatable="false" name="fa_exclamation_circle"></string>
|
||||||
<string translatable="false" name="fa_question"></string>
|
<string translatable="false" name="fa_question"></string>
|
||||||
|
<string translatable="false" name="fa_umbrella_beach"></string>
|
||||||
|
|
||||||
<!--<string translatable="false" name="fa_glass"></string>-->
|
<!--<string translatable="false" name="fa_glass"></string>-->
|
||||||
<!--<string translatable="false" name="fa_music"></string>-->
|
<!--<string translatable="false" name="fa_music"></string>-->
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="streaks">Streaks</string>
|
<string name="streaks">Streaks</string>
|
||||||
<string name="no_habits_found">You have no active habits</string>
|
<string name="no_habits_found">You have no active habits</string>
|
||||||
|
<string name="no_habits_left_to_do">You\'re all done for today!</string>
|
||||||
<string name="long_press_to_toggle">Press-and-hold to check or uncheck</string>
|
<string name="long_press_to_toggle">Press-and-hold to check or uncheck</string>
|
||||||
<string name="reminder_off">Off</string>
|
<string name="reminder_off">Off</string>
|
||||||
<string name="create_habit">Create habit</string>
|
<string name="create_habit">Create habit</string>
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ class HabitCardListCache @Inject constructor(
|
|||||||
return data.checkmarks[habitId]!!
|
return data.checkmarks[habitId]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun hasNoHabit(): Boolean {
|
||||||
|
return allHabits.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the habits that occupies a certain position on the list.
|
* Returns the habits that occupies a certain position on the list.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user