mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
@@ -140,9 +140,14 @@ class ListHabitsRootView @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateEmptyView() {
|
||||
llEmpty.visibility = when (listAdapter.itemCount) {
|
||||
0 -> VISIBLE
|
||||
else -> GONE
|
||||
if (listAdapter.itemCount == 0) {
|
||||
if (listAdapter.hasNoHabit()) {
|
||||
llEmpty.showEmpty()
|
||||
} else {
|
||||
llEmpty.showDone()
|
||||
}
|
||||
} else {
|
||||
llEmpty.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,32 +34,54 @@ import org.isoron.uhabits.utils.sres
|
||||
import org.isoron.uhabits.utils.str
|
||||
|
||||
class EmptyListView(context: Context) : LinearLayout(context) {
|
||||
var textTextView: TextView
|
||||
var iconTextView: TextView
|
||||
|
||||
init {
|
||||
orientation = VERTICAL
|
||||
gravity = CENTER
|
||||
visibility = View.GONE
|
||||
|
||||
iconTextView = TextView(context).apply {
|
||||
text = str(R.string.fa_star_half_o)
|
||||
typeface = getFontAwesome()
|
||||
textSize = sp(40.0f)
|
||||
gravity = CENTER
|
||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||
}
|
||||
|
||||
addView(
|
||||
TextView(context).apply {
|
||||
text = str(R.string.fa_star_half_o)
|
||||
typeface = getFontAwesome()
|
||||
textSize = sp(40.0f)
|
||||
gravity = CENTER
|
||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||
},
|
||||
iconTextView,
|
||||
MATCH_PARENT,
|
||||
WRAP_CONTENT
|
||||
)
|
||||
|
||||
textTextView = TextView(context).apply {
|
||||
text = str(R.string.no_habits_found)
|
||||
gravity = CENTER
|
||||
setPadding(0, dp(20.0f).toInt(), 0, 0)
|
||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||
}
|
||||
addView(
|
||||
TextView(context).apply {
|
||||
text = str(R.string.no_habits_found)
|
||||
gravity = CENTER
|
||||
setPadding(0, dp(20.0f).toInt(), 0, 0)
|
||||
setTextColor(sres.getColor(R.attr.mediumContrastTextColor))
|
||||
},
|
||||
textTextView,
|
||||
MATCH_PARENT,
|
||||
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()
|
||||
}
|
||||
|
||||
fun hasNoHabit(): Boolean {
|
||||
return cache.hasNoHabit()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all items as not selected.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<string translatable="false" name="fa_calendar"></string>
|
||||
<string translatable="false" name="fa_exclamation_circle"></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_music"></string>-->
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<string name="save">Save</string>
|
||||
<string name="streaks">Streaks</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="reminder_off">Off</string>
|
||||
<string name="create_habit">Create habit</string>
|
||||
|
||||
Reference in New Issue
Block a user