Videos perpage default 30 + SwipeRefresh (not working)

This commit is contained in:
ivan agosto 2018-09-07 23:17:30 -05:00
parent 13f5cb7108
commit c042e508b1
5 changed files with 162 additions and 79 deletions

View File

@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
</component>
<component name="ChangeListManager">
<list default="true" id="a90c1ed9-b878-4668-a70f-a124e45496b4" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/caches/build_file_checksums.ser" afterPath="$PROJECT_DIR$/.idea/caches/build_file_checksums.ser" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_login.xml" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_login.xml" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_register.xml" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_register.xml" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/loginActivity.xml" afterPath="$PROJECT_DIR$/app/src/main/res/values/loginActivity.xml" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/content_main.xml" afterPath="$PROJECT_DIR$/app/src/main/res/layout/content_main.xml" />
</list>
<ignored path="$PROJECT_DIR$/build/classes/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -37,32 +38,27 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="RegisterActivity.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt">
<file leaf-file-name="content_main.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider editor-type-id="android-designer2">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="41" column="48" lean-forward="false" selection-start-line="41" selection-start-column="48" selection-end-line="41" selection-end-column="48" />
<state relative-caret-position="150">
<caret line="11" column="39" lean-forward="false" selection-start-line="11" selection-start-column="25" selection-end-line="11" selection-end-column="39" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Auth.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt">
<file leaf-file-name="MainActivity.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="62">
<caret line="51" column="46" lean-forward="false" selection-start-line="51" selection-start-column="46" selection-end-line="51" selection-end-column="46" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="LoginActivity.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="167">
<caret line="43" column="0" lean-forward="false" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
<folding />
<state relative-caret-position="270">
<caret line="63" column="47" lean-forward="false" selection-start-line="63" selection-start-column="47" selection-end-line="63" selection-end-column="47" />
<folding>
<element signature="e#2374#2399#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -72,6 +68,7 @@
<component name="FindInProjectRecents">
<findStrings>
<find>Looper.prepare()</find>
<find>setData</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -2212,6 +2209,11 @@
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt" />
<option value="$PROJECT_DIR$/build.gradle" />
<option value="$PROJECT_DIR$/app/src/main/res/layout/content_main.xml" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt" />
</list>
</option>
</component>
@ -2237,8 +2239,8 @@
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane" />
<pane id="AndroidView">
<subPane>
<expand>
@ -2260,20 +2262,22 @@
<path>
<item name="p2play" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="java" type="edd41e36:AndroidSourceTypeNode" />
<item name="p2play" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="ajax" type="462c0819:PsiDirectoryNode" />
<item name="res" type="d4f16f75:AndroidResFolderNode" />
</path>
<path>
<item name="p2play" type="1abcf292:AndroidViewProjectNode" />
<item name="Gradle Scripts" type="ae0cef3a:AndroidBuildScriptsGroupNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="ProjectPane" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="$USER_HOME$/Android/Sdk" />
<property name="device.picker.selection" value="84B7N15A09002408" />
<property name="device.picker.selection" value="Nexus_4_API_22" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -2441,6 +2445,7 @@
</component>
<component name="ToolWindowManager">
<frame x="-4" y="31" width="1288" height="773" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Android Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@ -2449,14 +2454,15 @@
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3276923" sideWeight="0.503231" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32956383" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3276923" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Logcat" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3276923" sideWeight="0.49676898" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Logcat" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21538462" sideWeight="0.49676898" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24394184" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18497577" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Build" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.30461538" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Gradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@ -2482,6 +2488,30 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="495">
<caret line="41" column="48" lean-forward="false" selection-start-line="41" selection-start-column="48" selection-end-line="41" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="765">
<caret line="51" column="46" lean-forward="false" selection-start-line="51" selection-start-column="46" selection-end-line="51" selection-end-column="46" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="43" column="0" lean-forward="false" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615">
@ -2530,30 +2560,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/build.gradle">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="10" column="24" lean-forward="false" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/build.gradle">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="41" column="48" lean-forward="false" selection-start-line="41" selection-start-column="48" selection-end-line="41" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="167">
@ -2572,11 +2578,72 @@
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Auth.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="62">
<caret line="51" column="46" lean-forward="false" selection-start-line="51" selection-start-column="46" selection-end-line="51" selection-end-column="46" />
<state relative-caret-position="135">
<caret line="15" column="99" lean-forward="false" selection-start-line="15" selection-start-column="90" selection-end-line="15" selection-end-column="99" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="383">
<caret line="41" column="48" lean-forward="false" selection-start-line="41" selection-start-column="48" selection-end-line="41" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Videos.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="76">
<caret line="90" column="47" lean-forward="false" selection-start-line="90" selection-start-column="42" selection-end-line="90" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ajax/Client.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-300">
<caret line="20" column="24" lean-forward="false" selection-start-line="20" selection-start-column="24" selection-end-line="20" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/build.gradle">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="77" lean-forward="false" selection-start-line="10" selection-start-column="77" selection-end-line="10" selection-end-column="77" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/build.gradle">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="269">
<caret line="34" column="57" lean-forward="false" selection-start-line="34" selection-start-column="57" selection-end-line="34" selection-end-column="57" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider editor-type-id="android-designer2">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="11" column="39" lean-forward="false" selection-start-line="11" selection-start-column="25" selection-end-line="11" selection-end-column="39" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="63" column="47" lean-forward="false" selection-start-line="63" selection-start-column="47" selection-end-line="63" selection-end-column="47" />
<folding>
<element signature="e#2374#2399#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@ -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<String>("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<VideoModel>){
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 {

View File

@ -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", "*/*")

View File

@ -87,8 +87,8 @@ class Videos: Client() {
return videos
}
private fun getVideos(page:Int = 0, sort:String = "-publishedAt", filter:String = ""):ArrayList<VideoModel>{
val params = "start=$page&sort=$sort&filter=$filter"
private fun getVideos(start:Int, count:Int, sort:String = "-publishedAt", filter:String = ""):ArrayList<VideoModel>{
val params = "start=$start&count=$count&sort=$sort&filter=$filter"
var con=this._newCon("videos?$params","GET")
var videos = arrayListOf<VideoModel>()
try {
@ -105,16 +105,16 @@ class Videos: Client() {
return videos
}
fun getLastVideos(): ArrayList<VideoModel>{
return this.getVideos()
fun getLastVideos(start:Int = 0, count:Int = 30): ArrayList<VideoModel>{
return this.getVideos(start, count)
}
fun getPopularVideos(): ArrayList<VideoModel>{
return this.getVideos(0,"-views")
fun getPopularVideos(start:Int = 0, count:Int = 30): ArrayList<VideoModel>{
return this.getVideos(start, count,"-views")
}
fun getLocalVideos(): ArrayList<VideoModel>{
return this.getVideos(0,"-publishedAt", "local")
fun getLocalVideos(start:Int = 0, count:Int = 30): ArrayList<VideoModel>{
return this.getVideos(start, count,"-publishedAt", "local")
}
fun myVideos(token: String): ArrayList<VideoModel>{

View File

@ -8,6 +8,12 @@
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
@ -15,4 +21,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout>