Trending videos added

This commit is contained in:
ivan agosto 2019-02-17 18:34:38 -06:00
parent d680eb77b8
commit 90f2ab6e7d
6 changed files with 46 additions and 16 deletions

View File

@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Init RecyclerView
this.initRecycler()
this.getLastVideos()
this.getTrengindVideos()
swipeContainer.setOnRefreshListener {
this.refresh()
@ -127,6 +127,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
when(section){
"local" -> this.getLocalVideos()
"popular" -> this.getPopularVideos()
"trending" -> this.getTrengindVideos()
"last" -> this.getLastVideos()
"sub" -> this.getSubscriptionVideos()
"search" -> this.searchVideos()
@ -182,6 +183,19 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
}
// Trending videos
private fun getTrengindVideos(){
swipeContainer.isRefreshing = true
section = "trending"
setTitle(R.string.title_trending)
AsyncTask.execute {
val videos = client.getTrendingVideos(this.pagination)
runOnUiThread {
this.addVideos(videos)
}
}
}
// Local videos
private fun getLocalVideos(){
swipeContainer.isRefreshing = true
@ -286,19 +300,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// item.isChecked = true
when (item.itemId) {
R.id.nav_subscriptions->{
getSubscriptionVideos()
}
R.id.nav_popular-> {
getPopularVideos()
}
R.id.nav_recent-> {
getLastVideos()
}
R.id.nav_local-> {
getLocalVideos()
}
R.id.nav_about-> {
R.id.nav_subscriptions -> getSubscriptionVideos()
R.id.nav_popular -> getPopularVideos()
R.id.nav_trending -> getTrengindVideos()
R.id.nav_recent -> getLastVideos()
R.id.nav_local -> getLocalVideos()
R.id.nav_about -> {
val intent = Intent(this, AboutActivity::class.java)
startActivity(intent)
}
@ -320,6 +327,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
if(ManagerSingleton.user.avatar!="" && side_imageView != null)
Picasso.get().load("https://"+ManagerSingleton.url+ManagerSingleton.user.avatar).into(side_imageView)
side_imageView?.setOnClickListener {
pagination = 0
getMyVideos()
drawer_layout.closeDrawer(GravityCompat.START)
}
@ -355,6 +363,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
when(section){
"local" -> this.getLocalVideos()
"popular" -> this.getPopularVideos()
"trending" -> this.getTrengindVideos()
"last" -> this.getLastVideos()
"sub" -> this.getSubscriptionVideos()
"search" -> this.searchVideos()

View File

@ -119,6 +119,10 @@ class Videos: Client() {
return this.getVideos(start,"-views")
}
fun getTrendingVideos(start:Int = 0): ArrayList<VideoModel>{
return this.getVideos(start,"-trending")
}
fun getLocalVideos(start:Int = 0): ArrayList<VideoModel>{
return this.getVideos(start,"-publishedAt", "local")
}

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="M16,6l2.29,2.29 -4.88,4.88 -4,-4L2,16.59 3.41,18l6,-6 4,4 6.3,-6.29L22,12V6z"/>
</vector>

View File

@ -16,6 +16,10 @@
android:id="@+id/nav_popular"
android:icon="@android:drawable/btn_star"
android:title="@string/nav_popular" />
<item
android:id="@+id/nav_trending"
android:icon="@drawable/ic_trending_up_black_24dp"
android:title="@string/nav_trending" />
<item
android:id="@+id/nav_recent"
android:icon="@drawable/ic_add_circle_black_24dp"

View File

@ -92,6 +92,8 @@
<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>
<string name="nav_trending">Tendencias</string>
<string name="title_trending">Tendencias</string>
<!-- End Settings strings -->
</resources>

View File

@ -48,8 +48,9 @@
<!-- End Login strings -->
<!-- Start Main strings -->
<string name="title_subscriptions">Subscriptions</string>
<string name="title_recent">Recent videos</string>
<string name="title_popular">Popular videos</string>
<string name="title_recent">Recent</string>
<string name="title_popular">Popular</string>
<string name="title_trending">Trending</string>
<string name="title_local">Local videos</string>
<string name="title_myVideos">My videos</string>
<string name="view_text">views</string>
@ -64,6 +65,7 @@
<!-- Start Menu strings -->
<string name="nav_subscriptions">Subscriptions</string>
<string name="nav_popular">Popular</string>
<string name="nav_trending">Trending</string>
<string name="nav_recent">Recent</string>
<string name="nav_local">Local</string>
<string name="nav_about">About</string>