Most liked videos

This commit is contained in:
Ivan Agosto 2019-12-13 09:53:10 -06:00
parent 390b1a7add
commit a66acfbcea
8 changed files with 41 additions and 1 deletions

View File

@ -235,10 +235,27 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
}
// Most liked
private fun getMostLiked(){
swipeContainer.isRefreshing = true
section = "liked"
setTitle(R.string.nav_likes)
AsyncTask.execute {
val videos = client.getMostLikedVideos(this.pagination)
runOnUiThread {
this.addVideos(videos)
}
}
}
override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
} else {
}
else if(!section.equals("trending")) {
this.getTrengindVideos()
}
else {
super.onBackPressed()
}
}
@ -324,6 +341,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
R.id.nav_history -> getHistory()
R.id.nav_myVideos -> getMyVideos()
R.id.nav_likes -> getMostLiked()
}
drawer_layout.closeDrawer(GravityCompat.START)
@ -392,6 +410,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
else
this.getLastVideos()
}
"liked" -> this.getMostLiked()
}
}

View File

@ -34,6 +34,7 @@ import org.libre.agosto.p2play.models.VideoModel
@Suppress("NAME_SHADOWING")
class ReproductorActivity : AppCompatActivity() {
lateinit var video: VideoModel
private val _actions: Actions = Actions()

View File

@ -21,6 +21,7 @@ import java.io.InputStream
import java.io.Serializable
import java.net.URL
@Suppress("DEPRECATION")
class CommentariesAdapter(private val myDataset: ArrayList<CommentaryModel>) :
RecyclerView.Adapter<CommentariesAdapter.ViewHolder>() {

View File

@ -194,4 +194,8 @@ class Videos: Client() {
con.disconnect()
return videos
}
fun getMostLikedVideos(start:Int = 0): ArrayList<VideoModel>{
return this.getVideos(start,"-likes")
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-1.91l-0.01,-0.01L23,10z"/>
</vector>

View File

@ -36,6 +36,10 @@
android:id="@+id/nav_trending"
android:icon="@drawable/ic_trending_up_black_24dp"
android:title="@string/nav_trending" />
<item
android:id="@+id/nav_likes"
android:icon="@drawable/ic_thumb_up_black_24dp"
android:title="@string/nav_likes" />
<item
android:id="@+id/nav_recent"
android:icon="@drawable/ic_add_circle_black_24dp"

View File

@ -102,6 +102,7 @@
<string name="hostIndicator">Host:</string>
<string name="reportDialog">Razon para reportar:</string>
<string name="reportDialogMsg">Has reportado el video</string>
<string name="nav_likes">Mas gustados</string>
<!-- End Settings strings -->
</resources>

View File

@ -73,6 +73,7 @@
<string name="nav_menu_myLibrary">My Library</string>
<string name="nav_menu_videos">Videos</string>
<string name="nav_menu_more">More</string>
<string name="nav_likes">Most liked</string>
<!-- End Menu strings -->
<!-- Start MiniMenu strings -->
<string name="action_settings">Settings</string>