Reordered menu, added history videos

This commit is contained in:
Ivan Agosto 2019-10-18 11:14:44 -05:00
parent 9638468191
commit 4946a55215
8 changed files with 92 additions and 11 deletions

View File

@ -222,6 +222,19 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
}
// Videos history of user
private fun getHistory(){
swipeContainer.isRefreshing = true
section = "my_videos"
setTitle(R.string.nav_history)
AsyncTask.execute {
val videos = client.videoHistory(ManagerSingleton.token.token, this.pagination)
runOnUiThread {
this.addVideos(videos)
}
}
}
override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
@ -309,6 +322,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val intent = Intent(this, AboutActivity::class.java)
startActivity(intent)
}
R.id.nav_history -> getHistory()
R.id.nav_myVideos -> getMyVideos()
}
drawer_layout.closeDrawer(GravityCompat.START)
@ -322,18 +337,22 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private fun setSideData(){
if(ManagerSingleton.user.status == 1){
nav_view.menu.findItem(R.id.ml).isVisible = true
side_usernameTxt?.text = ManagerSingleton.user.username
side_emailTxt?.text = ManagerSingleton.user.email
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)
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)
// }
if(::myMenu.isInitialized){
myMenu.findItem(R.id.action_login).isVisible = false
myMenu.findItem(R.id.action_logout).isVisible = true
}
}
}
@ -343,7 +362,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
myMenu.findItem(R.id.action_login).isVisible = true
myMenu.findItem(R.id.action_logout).isVisible = false
}
nav_view.menu.findItem(R.id.ml).isVisible = false
side_usernameTxt?.text = getString(R.string.nav_header_title)
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
side_imageView?.setImageResource(R.drawable.default_avatar)

View File

@ -108,6 +108,26 @@ class Videos: Client() {
return videos
}
fun videoHistory(token: String, start: Int = 0): ArrayList<VideoModel>{
val count = ManagerSingleton.videos_count
val params = "start=$start&count=$count"
val con = this._newCon("users/me/history/videos?$params","GET", token)
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
val response = InputStreamReader(con.inputStream)
val data = JsonReader(response)
videos = parseVideos(data)
data.close()
}
} catch(err:Exception){
err.printStackTrace()
}
con.disconnect()
return videos
}
fun search(text: String, start: Int = 0): ArrayList<VideoModel>{
val count = ManagerSingleton.videos_count
val nsfw = ManagerSingleton.nfsw

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="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
</vector>

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="M21,6h-7.59l3.29,-3.29L16,2l-4,4 -4,-4 -0.71,0.71L10.59,6L3,6c-1.1,0 -2,0.89 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.11 -0.9,-2 -2,-2zM21,20L3,20L3,8h18v12zM9,10v8l7,-4z"/>
</vector>

View File

@ -4,14 +4,30 @@
tools:showIn="navigation_view">
<item
android:id="@+id/ai"
android:id="@+id/ml"
android:icon="@android:color/darker_gray"
android:title="Videos">
android:title="@string/nav_menu_myLibrary"
android:visible="false">
<menu>
<item
android:id="@+id/nav_subscriptions"
android:id="@+id/nav_myVideos"
android:icon="@drawable/ic_video_library_black_24dp"
android:title="@string/title_myVideos" />
<item
android:id="@+id/nav_subscriptions"
android:icon="@drawable/ic_live_tv_black_24dp"
android:title="@string/nav_subscriptions" />
<item
android:id="@+id/nav_history"
android:icon="@drawable/ic_history_black_24dp"
android:title="@string/nav_history" />
</menu>
</item>
<item
android:id="@+id/ai"
android:icon="@android:color/darker_gray"
android:title="@string/nav_menu_videos">
<menu>
<item
android:id="@+id/nav_popular"
android:icon="@android:drawable/btn_star"
@ -34,7 +50,7 @@
<item
android:id="@+id/aiao"
android:icon="@android:color/white"
android:title="More">
android:title="@string/nav_menu_more">
<menu>
<item
android:id="@+id/nav_about"

View File

@ -56,6 +56,10 @@
<string name="nav_local">Local</string>
<string name="nav_about">Sobre</string>
<string name="nav_subscriptions">Suscripciones</string>
<string name="nav_history">Historial</string>
<string name="nav_menu_myLibrary">Mi libreria</string>
<string name="nav_menu_videos">Videos</string>
<string name="nav_menu_more">Mas</string>
<!-- End Menu strings -->
<!-- Start MiniMenu strings -->
<string name="action_settings">Configuracion</string>

View File

@ -69,6 +69,10 @@
<string name="nav_recent">Recent</string>
<string name="nav_local">Local</string>
<string name="nav_about">About</string>
<string name="nav_history">History</string>
<string name="nav_menu_myLibrary">My Library</string>
<string name="nav_menu_videos">Videos</string>
<string name="nav_menu_more">More</string>
<!-- End Menu strings -->
<!-- Start MiniMenu strings -->
<string name="action_settings">Settings</string>

BIN
docs/p2playv2.xcf Normal file

Binary file not shown.