Option for show full description
This commit is contained in:
parent
2abdcb8375
commit
90aac608be
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -191,7 +191,7 @@
|
|||
android:layout_weight="1"
|
||||
android:text="@string/subscribeBtn"
|
||||
android:textSize="10sp"
|
||||
android:visibility="visible" />
|
||||
android:visibility="invisible" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
@ -201,12 +201,15 @@
|
|||
android:maxLength="1000"
|
||||
android:maxLines="100"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="@string/descriptionTxt" />
|
||||
android:text="@string/descriptionTxt"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descriptionVideoTxt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:autoLink="web"
|
||||
android:linksClickable="true"
|
||||
android:maxLength="10000"
|
||||
|
@ -214,6 +217,15 @@
|
|||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/showMoreBtn"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/showMore"
|
||||
android:visibility="visible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -222,14 +234,16 @@
|
|||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp" />
|
||||
android:layout_height="10dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/commentariesTxt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="@string/commentariesTxt" />
|
||||
android:text="@string/commentariesTxt"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
|
@ -279,7 +293,6 @@
|
|||
android:id="@+id/listCommentaries"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
<string name="pref_hostname_title">Instancia Peertube</string>
|
||||
<string name="pref_message_exit">Reinicia para aplicar los cambios</string>
|
||||
<string name="pref_videos_count_title">Videos por pagina</string>
|
||||
<string name="showMore">Mostrar mas</string>
|
||||
<!-- End Settings strings -->
|
||||
|
||||
</resources>
|
|
@ -85,6 +85,7 @@
|
|||
<string name="reportBtn">Report</string>
|
||||
<string name="unSubscribeBtn">Unsubscribe</string>
|
||||
<string name="commentaryText">Comment</string>
|
||||
<string name="showMore">Show more</string>
|
||||
<!-- Messages -->
|
||||
<string name="subscribeMsg">You are subscribed to this channel</string>
|
||||
<string name="rateMsg">You are rated the video</string>
|
||||
|
|
Loading…
Reference in New Issue