diff --git a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt index 97a823f..1ef6fa8 100644 --- a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt @@ -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() 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 f2d7682..46d2040 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 @@ -119,6 +119,10 @@ class Videos: Client() { return this.getVideos(start,"-views") } + fun getTrendingVideos(start:Int = 0): ArrayList{ + return this.getVideos(start,"-trending") + } + fun getLocalVideos(start:Int = 0): ArrayList{ return this.getVideos(start,"-publishedAt", "local") } diff --git a/app/src/main/res/drawable/ic_trending_up_black_24dp.xml b/app/src/main/res/drawable/ic_trending_up_black_24dp.xml new file mode 100644 index 0000000..4c9da94 --- /dev/null +++ b/app/src/main/res/drawable/ic_trending_up_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 9f0a1dc..da35853 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -16,6 +16,10 @@ android:id="@+id/nav_popular" android:icon="@android:drawable/btn_star" android:title="@string/nav_popular" /> + Reinicia para aplicar los cambios Videos por pagina Mostrar mas + Tendencias + Tendencias \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85d03ca..fa61479 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,8 +48,9 @@ Subscriptions - Recent videos - Popular videos + Recent + Popular + Trending Local videos My videos views @@ -64,6 +65,7 @@ Subscriptions Popular + Trending Recent Local About