Dashboard list touch events actually start playing streams
Refined Home Fragment to clean up double definition of it for clarity Updated Gradle release
This commit is contained in:
parent
d69aeece54
commit
2e9b76ce3b
8 changed files with 38 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.theoks.customstreams.android.ui.dashboard
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
|
@ -7,6 +8,7 @@ import android.util.Log
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
|
@ -16,13 +18,18 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.android.volley.Request
|
||||
import com.android.volley.Response
|
||||
import com.android.volley.toolbox.JsonArrayRequest
|
||||
import com.android.volley.toolbox.JsonObjectRequest
|
||||
import com.android.volley.toolbox.Volley
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.lists.SingleLineItemViewHolder
|
||||
import net.theoks.customstreams.android.R
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import com.google.android.material.lists.ThreeLineItemViewHolder
|
||||
import com.google.android.material.lists.TwoLineItemViewHolder
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import kotlinx.android.synthetic.main.fragment_home.view.*
|
||||
import net.theoks.customstreams.android.PlayerActivity
|
||||
|
||||
class DashboardFragment : Fragment() {
|
||||
|
||||
|
@ -92,6 +99,28 @@ class DashboardFragment : Fragment() {
|
|||
vh.tertiary.text = split[2]
|
||||
vh.secondary.ellipsize = TextUtils.TruncateAt.END
|
||||
}
|
||||
vh.itemView.setOnClickListener { view ->
|
||||
val realIt = view as RelativeLayout
|
||||
val textView = realIt.getChildAt(1) as MaterialTextView
|
||||
val streamKey = textView.text.toString()
|
||||
|
||||
val queue = Volley.newRequestQueue(view.context)
|
||||
val url = "https://buyvm-cf.theoks.net/custom-streams-player/get_title.php?streamkey=$streamKey"
|
||||
val streamInfoJsonRequest = JsonObjectRequest(Request.Method.GET, url, null, Response.Listener<JSONObject> {
|
||||
if(it.getBoolean("stream_is_live")) {
|
||||
val intent = Intent(view.context, PlayerActivity::class.java).apply {
|
||||
putExtra("net.theoks.customstreams.streamkey", streamKey)
|
||||
}
|
||||
view.context.startActivity(intent)
|
||||
} else {
|
||||
val builder = MaterialAlertDialogBuilder(view.context ?: throw Exception("Couldn't get context while building alert"))
|
||||
builder.setTitle(R.string.stream_not_live).setMessage("Stream $streamKey is not live.").setPositiveButton(R.string.ok, null).show()
|
||||
Log.i("OKSCustom-StreamInfo", "Stream $streamKey is not live!")
|
||||
}
|
||||
},
|
||||
Response.ErrorListener {Log.e("OKSCustom-StreamInfo", "Error when requesting stream info ${it.message}")})
|
||||
queue.add(streamInfoJsonRequest)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
|
|
@ -36,11 +36,11 @@ class HomeFragment : Fragment() {
|
|||
val root = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
|
||||
val button = root.findViewById(R.id.watchButton) as Button
|
||||
button.setOnClickListener {
|
||||
val streamKey = (it.rootView.findViewById(R.id.streamKeyEdit) as EditText).text.toString()
|
||||
button.setOnClickListener { view ->
|
||||
val streamKey = (view.rootView.findViewById(R.id.streamKeyEdit) as EditText).text.toString()
|
||||
Log.i("OKSCustomHome", "Button pressed, found stream key $streamKey")
|
||||
|
||||
val queue = Volley.newRequestQueue(it.context)
|
||||
val queue = Volley.newRequestQueue(view.context)
|
||||
val url = "https://buyvm-cf.theoks.net/custom-streams-player/get_title.php?streamkey=$streamKey"
|
||||
val streamInfoJsonRequest = JsonObjectRequest(Request.Method.GET, url, null, Response.Listener<JSONObject> {
|
||||
if(it.getBoolean("stream_is_live")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue