diff --git a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt index ede7f5e..8e3e149 100644 --- a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt @@ -22,6 +22,7 @@ import kotlinx.android.synthetic.main.activity_reproductor.* import org.libre.agosto.p2play.adapters.CommentariesAdapter import org.libre.agosto.p2play.ajax.Actions import org.libre.agosto.p2play.ajax.Comments +import org.libre.agosto.p2play.ajax.Videos import org.libre.agosto.p2play.models.CommentaryModel import org.libre.agosto.p2play.models.VideoModel @@ -30,9 +31,10 @@ import org.libre.agosto.p2play.models.VideoModel class ReproductorActivity : AppCompatActivity() { - lateinit var video:VideoModel + lateinit var video: VideoModel private val _actions: Actions = Actions() private val client: Comments = Comments() + private val videos: Videos = Videos() // Commentaries adapter values private lateinit var recyclerView: RecyclerView @@ -59,6 +61,10 @@ class ReproductorActivity : AppCompatActivity() { viewsTxt.text = "${this.video.views} ${getString(R.string.view_text)}" userTxt.text = this.video.username descriptionVideoTxt.text = this.video.description + val haveDescription = this.video.description.contains("...", ignoreCase = false) + if (haveDescription) { + showMoreBtn.visibility = View.VISIBLE + } hostTxt.text = this.video.userHost // Check if user had profile image @@ -82,6 +88,7 @@ class ReproductorActivity : AppCompatActivity() { likeLayout.setOnClickListener { rate("like") } dislikeLayout.setOnClickListener { rate("dislike") } commentaryBtn.setOnClickListener { makeComment() } + showMoreBtn.setOnClickListener { getDescription() } } private fun subscribe(){ @@ -243,6 +250,16 @@ class ReproductorActivity : AppCompatActivity() { } } + fun getDescription(){ + AsyncTask.execute { + val fullDescription = this.videos.fullDescription(this.video.id) + runOnUiThread { + descriptionVideoTxt.text = fullDescription + showMoreBtn.visibility = View.GONE + } + } + } + internal inner class WebClient: WebChromeClient() { private var mCustomView: View? = null private var mCustomViewCallback: WebChromeClient.CustomViewCallback? = null diff --git a/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt b/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt index 795b8f6..7723eb1 100644 --- a/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt +++ b/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt @@ -175,4 +175,31 @@ class Videos: Client() { } return videos } + + fun fullDescription(videoId: Int): String{ + var con=this._newCon("videos/$videoId/description","GET") + var description = "" + try { + if (con.responseCode == 200) { + var response = InputStreamReader(con.inputStream) + var data = JsonReader(response) + + data.beginObject() + while (data.hasNext()){ + val name = data.nextName() + when(name){ + "description" -> description = data.nextString() + else -> data.skipValue() + } + } + data.endObject() + data.close() + + } + } catch(err:Exception){ + err.printStackTrace() + description = "Error!" + } + return description + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_reproductor.xml b/app/src/main/res/layout/activity_reproductor.xml index 9c9f7e9..b35d434 100644 --- a/app/src/main/res/layout/activity_reproductor.xml +++ b/app/src/main/res/layout/activity_reproductor.xml @@ -191,7 +191,7 @@ android:layout_weight="1" android:text="@string/subscribeBtn" android:textSize="10sp" - android:visibility="visible" /> + android:visibility="invisible" /> + android:text="@string/descriptionTxt" + android:textStyle="bold" /> +