Make commentaries on videos
This commit is contained in:
parent
ab69d59f9a
commit
176e580f1f
|
@ -1,6 +1,5 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
import android.opengl.Visibility
|
||||
import android.os.AsyncTask
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
|
@ -11,7 +10,6 @@ import android.support.v7.widget.RecyclerView
|
|||
import android.util.Log
|
||||
import android.view.View
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_reproductor.*
|
||||
import org.libre.agosto.p2play.adapters.CommentariesAdapter
|
||||
import org.libre.agosto.p2play.ajax.Actions
|
||||
|
@ -68,6 +66,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
subscribeBtn.setOnClickListener { subscribe() }
|
||||
likeLayout.setOnClickListener { rate("like") }
|
||||
dislikeLayout.setOnClickListener { rate("dislike") }
|
||||
commentaryBtn.setOnClickListener { makeComment() }
|
||||
}
|
||||
|
||||
private fun subscribe(){
|
||||
|
@ -194,6 +193,27 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun makeComment() {
|
||||
if(commentaryText.text.toString() == ""){
|
||||
ManagerSingleton.Toast(getString(R.string.emptyCommentaryMsg))
|
||||
return
|
||||
}
|
||||
val text = commentaryText.text.toString()
|
||||
AsyncTask.execute {
|
||||
val res = this.client.makeCommentary(ManagerSingleton.token.token, this.video.id, text)
|
||||
runOnUiThread {
|
||||
if (res) {
|
||||
ManagerSingleton.Toast(getString(R.string.makedCommentaryMsg))
|
||||
commentaryText.text.clear()
|
||||
this.getComments()
|
||||
}
|
||||
else {
|
||||
ManagerSingleton.Toast(getString(R.string.errorCommentaryMsg))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if(ManagerSingleton.user.status == 1) {
|
||||
|
@ -201,6 +221,10 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
this.getSubscription()
|
||||
actionsLayout.visibility = View.VISIBLE
|
||||
subscribeBtn.visibility = View.VISIBLE
|
||||
commentaryLayout.visibility = View.VISIBLE
|
||||
if(ManagerSingleton.user.avatar != ""){
|
||||
Picasso.get().load("https://"+ManagerSingleton.url+ManagerSingleton.user.avatar).into(userImgCom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,4 +89,24 @@ class Comments: Client() {
|
|||
return commentaries
|
||||
}
|
||||
|
||||
fun makeCommentary(token: String, videoId: Int, text: String): Boolean {
|
||||
val con = this._newCon("videos/$videoId/comment-threads", "POST", token)
|
||||
val params:String= "text=$text"
|
||||
con.outputStream.write(params.toByteArray())
|
||||
|
||||
try {
|
||||
if (con.responseCode == 200) {
|
||||
return true
|
||||
}
|
||||
else{
|
||||
Log.d("Status", con.responseMessage)
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
err.printStackTrace()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
|
@ -192,9 +192,11 @@
|
|||
android:text="@string/commentariesTxt" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/commentaryLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -202,9 +204,9 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="50dp"
|
||||
android:id="@+id/userImgCom"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/default_avatar" />
|
||||
|
||||
|
@ -212,14 +214,15 @@
|
|||
android:id="@+id/commentaryText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="2"
|
||||
android:ems="10"
|
||||
android:inputType="textMultiLine" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:id="@+id/commentaryBtn"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<string name="subscribeMsg">Te has subscribido a este canal</string>
|
||||
<string name="rateMsg">Has valorado este video</string>
|
||||
<string name="unSubscribeMsg">Te has desubscribido de este canal</string>
|
||||
<string name="makedCommentaryMsg">Has comentado este video</string>
|
||||
<string name="errorCommentaryMsg">A ocurrido un error, intenta de nuevo</string>
|
||||
<string name="emptyCommentaryMsg">Porfavor has un comentario primero</string>
|
||||
<!-- End Reproductor strings -->
|
||||
<!-- Start Settings strings -->
|
||||
<string name="title_activity_settings">Configuracion</string>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<string name="navigation_drawer_open" translatable="false">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close" translatable="false">Close navigation drawer</string>
|
||||
<string name="nav_header_desc" translatable="false">Navigation header</string>
|
||||
<string name="comming">Comming soon!</string>
|
||||
<string name="comming">Coming soon!</string>
|
||||
<!-- End Global string -->
|
||||
|
||||
|
||||
|
@ -35,10 +35,10 @@
|
|||
<string name="registerActionBtn">Create new account</string>
|
||||
<!-- Toast msg -->
|
||||
<string name="loginSuccess_msg">You are logged</string>
|
||||
<string name="loginError_msg">An error has ocurred</string>
|
||||
<string name="loginError_msg">An error has occurred</string>
|
||||
<string name="loginFailed_msg">Invalid credentials</string>
|
||||
<string name="registerSuccess_msg">You are registered</string>
|
||||
<string name="registerError_msg">An error has ocurred</string>
|
||||
<string name="registerError_msg">An error has occurred</string>
|
||||
<string name="registerFailed_msg">Invalid data</string>
|
||||
<!-- Register msg -->
|
||||
<string name="registerBtn">Register now</string>
|
||||
|
@ -85,6 +85,9 @@
|
|||
<string name="subscribeMsg">You are subscribed to this channel</string>
|
||||
<string name="rateMsg">You are rated the video</string>
|
||||
<string name="unSubscribeMsg">You are unsubscribed to this channel</string>
|
||||
<string name="makedCommentaryMsg">You are commented this video</string>
|
||||
<string name="errorCommentaryMsg">An error has occurred, try again</string>
|
||||
<string name="emptyCommentaryMsg">Please make a comment first</string>
|
||||
<!-- End Reproductor strings -->
|
||||
<!-- Start Settings strings -->
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
|
Loading…
Reference in New Issue