fix: submit segment dialog closes when there are no segments yet

This commit is contained in:
Bnyro 2024-04-14 13:00:59 +02:00
parent 81bdd71558
commit a47eac5352
2 changed files with 100 additions and 84 deletions

View File

@ -5,9 +5,9 @@ import android.os.Bundle
import android.text.format.DateUtils
import android.util.Log
import android.widget.Toast
import androidx.core.view.isGone
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.BuildConfig
import com.github.libretube.R
import com.github.libretube.api.JsonHelper
import com.github.libretube.api.RetrofitInstance
@ -148,7 +148,7 @@ class SubmitSegmentDialog : DialogFragment() {
val binding = _binding ?: return@withContext
if (segments.isEmpty()) {
dismiss()
binding.voteSegmentContainer.isGone = true
Toast.makeText(context, R.string.no_segments_found, Toast.LENGTH_SHORT).show()
return@withContext
}

View File

@ -7,6 +7,12 @@
android:paddingHorizontal="15dp"
android:paddingTop="15dp">
<LinearLayout
android:id="@+id/create_segment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -63,10 +69,18 @@
android:drawableStart="@drawable/ic_copy"
android:text="@string/sb_create_segment" />
<TextView
</LinearLayout>
<LinearLayout
android:id="@+id/vote_segment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/vote_for_segment"
android:textSize="24sp" />
@ -114,4 +128,6 @@
android:drawableStart="@drawable/ic_copy"
android:text="@string/vote_for_segment" />
</LinearLayout>
</LinearLayout>