diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8bdd263..b771ce8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,19 +1,20 @@
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
@@ -37,32 +38,27 @@
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -72,6 +68,7 @@
Looper.prepare()
+ setData
@@ -2212,6 +2209,11 @@
+
+
+
+
+
@@ -2237,8 +2239,8 @@
-
+
@@ -2260,20 +2262,22 @@
-
-
-
+
+
+
+
+
-
+
-
+
+
@@ -2449,14 +2454,15 @@
+
-
+
-
+
@@ -2482,6 +2488,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2530,30 +2560,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -2572,11 +2578,72 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 126da0b..70b809d 100644
--- a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt
+++ b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt
@@ -17,6 +17,7 @@ import android.widget.ImageView
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
+import kotlinx.android.synthetic.main.content_main.*
import kotlinx.android.synthetic.main.nav_header_main.*
import org.libre.agosto.p2play.adapters.VideosAdapter
import org.libre.agosto.p2play.ajax.Videos
@@ -47,19 +48,24 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
drawer_layout.addDrawerListener(toggle)
toggle.syncState()
+ // Context for ManagerSingleton
ManagerSingleton.context = this
nav_view.setNavigationItemSelectedListener(this)
viewManager = LinearLayoutManager(this)
- // val data = arrayOf("test","test2","test3","test4")
- // viewAdapter = VideosAdapter(data)
-
+ // Set data for RecyclerView
this.setData(arrayListOf())
this.getLastVideos()
+
+ swipeContainer.setOnRefreshListener {
+ ManagerSingleton.Toast(getText(R.string.comming).toString())
+ swipeContainer.isRefreshing = false
+ }
}
+ // Generic function for set data to RecyclerView
fun setData(data:ArrayList){
viewAdapter = VideosAdapter(data)
@@ -78,6 +84,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
+ // Last videos
fun getLastVideos(){
setTitle(R.string.title_recent)
AsyncTask.execute {
@@ -88,6 +95,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
}
+ //
fun getPopularVideos(){
setTitle(R.string.title_popular)
AsyncTask.execute {
diff --git a/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt b/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt
index 9c1f4ac..3df2c71 100644
--- a/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt
+++ b/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt
@@ -16,7 +16,7 @@ open class Client {
var url = URL("https://"+ManagerSingleton.url+"/api/v1/"+uri)
var con = url.openConnection() as HttpURLConnection
- con.setRequestProperty("User-Agent", "P2play/0.0.1")
+ con.setRequestProperty("User-Agent", "P2play/0.1")
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
con.setRequestProperty("Accept", "*/*")
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 4f1865d..7f87afa 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
@@ -87,8 +87,8 @@ class Videos: Client() {
return videos
}
- private fun getVideos(page:Int = 0, sort:String = "-publishedAt", filter:String = ""):ArrayList{
- val params = "start=$page&sort=$sort&filter=$filter"
+ private fun getVideos(start:Int, count:Int, sort:String = "-publishedAt", filter:String = ""):ArrayList{
+ val params = "start=$start&count=$count&sort=$sort&filter=$filter"
var con=this._newCon("videos?$params","GET")
var videos = arrayListOf()
try {
@@ -105,16 +105,16 @@ class Videos: Client() {
return videos
}
- fun getLastVideos(): ArrayList{
- return this.getVideos()
+ fun getLastVideos(start:Int = 0, count:Int = 30): ArrayList{
+ return this.getVideos(start, count)
}
- fun getPopularVideos(): ArrayList{
- return this.getVideos(0,"-views")
+ fun getPopularVideos(start:Int = 0, count:Int = 30): ArrayList{
+ return this.getVideos(start, count,"-views")
}
- fun getLocalVideos(): ArrayList{
- return this.getVideos(0,"-publishedAt", "local")
+ fun getLocalVideos(start:Int = 0, count:Int = 30): ArrayList{
+ return this.getVideos(start, count,"-publishedAt", "local")
}
fun myVideos(token: String): ArrayList{
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index fe4584d..c182e1d 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -8,11 +8,19 @@
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">
-
+ android:layout_height="match_parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+
+
\ No newline at end of file