diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 45b5654..88ea3aa 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,8 +1,5 @@ - - diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 169fd0d..5cd135a 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,8 +1,10 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index 8a8f75b..b6ea2b1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,5 @@ - - - - - diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt index 64ef17a..e14ba5d 100644 --- a/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt +++ b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt @@ -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 { + 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 { diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt index 853ae3e..def4293 100644 --- a/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt +++ b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt @@ -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 { if(it.getBoolean("stream_is_live")) { diff --git a/build.gradle b/build.gradle index 58efbe3..bb118a0 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:3.6.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9d70bab..1915668 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Feb 08 20:51:27 PST 2020 +#Thu Feb 27 15:52:05 PST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip