Pull to refresh working

This commit is contained in:
ivan agosto 2018-09-10 17:45:51 -05:00
parent c042e508b1
commit 09dc380ff2
5 changed files with 143 additions and 39 deletions

View File

@ -12,8 +12,8 @@
<list default="true" id="a90c1ed9-b878-4668-a70f-a124e45496b4" name="Default" comment="">
<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/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/java/org/libre/agosto/p2play/ReproductorActivity.kt" afterPath="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_reproductor.xml" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_reproductor.xml" />
<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/" />
@ -38,27 +38,58 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="content_main.xml" pinned="false" current-in-tab="false">
<file leaf-file-name="content_main.xml" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider editor-type-id="android-designer2">
<provider editor-type-id="text-editor">
<state relative-caret-position="136">
<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>
<provider selected="true" editor-type-id="android-designer2">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="activity_reproductor.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_reproductor.xml">
<provider 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>
<provider selected="true" editor-type-id="android-designer2">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="ReproductorActivity.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt">
<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" />
<state relative-caret-position="120">
<caret line="13" column="42" lean-forward="false" selection-start-line="13" selection-start-column="42" selection-end-line="13" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="MainActivity.kt" pinned="false" current-in-tab="true">
<file leaf-file-name="MainActivity.kt" pinned="false" current-in-tab="false">
<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 relative-caret-position="360">
<caret line="96" column="13" lean-forward="false" selection-start-line="96" selection-start-column="13" selection-end-line="96" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ManagerSingleton.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ManagerSingleton.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="19" column="26" lean-forward="false" selection-start-line="19" selection-start-column="26" selection-end-line="19" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
@ -69,6 +100,7 @@
<findStrings>
<find>Looper.prepare()</find>
<find>setData</find>
<find>logout</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -2212,8 +2244,10 @@
<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" />
<option value="$PROJECT_DIR$/app/src/main/res/layout/content_main.xml" />
<option value="$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt" />
<option value="$PROJECT_DIR$/app/src/main/res/layout/activity_reproductor.xml" />
</list>
</option>
</component>
@ -2238,9 +2272,10 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scratches" />
<pane id="ProjectPane" />
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="Scratches" />
<pane id="AndroidView">
<subPane>
<expand>
@ -2264,6 +2299,12 @@
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="res" type="d4f16f75:AndroidResFolderNode" />
</path>
<path>
<item name="p2play" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="res" type="d4f16f75:AndroidResFolderNode" />
<item name="layout" type="ddeffd01:AndroidResFolderTypeNode" />
</path>
<path>
<item name="p2play" type="1abcf292:AndroidViewProjectNode" />
<item name="Gradle Scripts" type="ae0cef3a:AndroidBuildScriptsGroupNode" />
@ -2272,12 +2313,11 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="$USER_HOME$/Android/Sdk" />
<property name="device.picker.selection" value="Nexus_4_API_22" />
<property name="device.picker.selection" value="84B7N15A09002408" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -2454,7 +2494,7 @@
<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="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="4" 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" />
@ -2462,7 +2502,7 @@
<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.18497577" 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.1631664" 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" />
@ -2488,6 +2528,17 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<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>
<provider editor-type-id="android-designer2">
<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="495">
@ -2624,26 +2675,51 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider editor-type-id="android-designer2">
<state />
</provider>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ManagerSingleton.kt">
<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" />
<state relative-caret-position="255">
<caret line="19" column="26" lean-forward="false" selection-start-line="19" selection-start-column="26" selection-end-line="19" selection-end-column="26" />
<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 relative-caret-position="360">
<caret line="96" column="13" lean-forward="false" selection-start-line="96" selection-start-column="13" selection-end-line="96" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="13" column="42" lean-forward="false" selection-start-line="13" selection-start-column="42" selection-end-line="13" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_reproductor.xml">
<provider 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>
<provider selected="true" editor-type-id="android-designer2">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml">
<provider editor-type-id="text-editor">
<state relative-caret-position="136">
<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>
<provider selected="true" editor-type-id="android-designer2">
<state />
</provider>
</entry>
</component>
</project>

View File

@ -31,6 +31,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private lateinit var lastItem: MenuItem
lateinit var myMenu: Menu
val _db = Database(this)
var section: String = ""
override fun onCreate(savedInstanceState: Bundle?) {
@ -60,8 +61,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
this.getLastVideos()
swipeContainer.setOnRefreshListener {
ManagerSingleton.Toast(getText(R.string.comming).toString())
swipeContainer.isRefreshing = false
this.refresh()
}
}
@ -79,13 +79,28 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// specify an viewAdapter (see also next example)
adapter = viewAdapter
}
swipeContainer.isRefreshing = false
}
fun refresh(){
swipeContainer.isRefreshing = true
when(section){
"local" -> this.getLocalVideos()
"popular" -> this.getPopularVideos()
"last" -> this.getLastVideos()
"my_videos" -> {
if(ManagerSingleton.token.token != "")
this.getMyVideos()
else
this.getLastVideos()
}
}
}
// Last videos
fun getLastVideos(){
section = "last"
setTitle(R.string.title_recent)
AsyncTask.execute {
val videos = client.getLastVideos()
@ -97,6 +112,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
//
fun getPopularVideos(){
section = "popular"
setTitle(R.string.title_popular)
AsyncTask.execute {
val videos = client.getPopularVideos()
@ -107,6 +123,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
fun getLocalVideos(){
section = "local"
setTitle(R.string.title_local)
AsyncTask.execute {
val videos = client.getLocalVideos()
@ -117,6 +134,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
fun getMyVideos(){
section = "my_videos"
setTitle(R.string.title_myVideos)
AsyncTask.execute {
val videos = client.myVideos(ManagerSingleton.token.token)

View File

@ -20,7 +20,7 @@ class ReproductorActivity : AppCompatActivity() {
try {
this.video = this.intent.extras.getSerializable("video") as VideoModel
tittleVideoTxt.text = this.video.name
viewsTxt.text = this.video.views.toString() + getString(R.string.view_text)
viewsTxt.text = this.video.views.toString() + ' ' + getString(R.string.view_text)
userTxt.text = this.video.username
descriptionVideoTxt.text = this.video.description

View File

@ -8,7 +8,10 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
@ -22,7 +25,7 @@
<WebView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="200dp">
android:layout_height="220dp">
</WebView>
@ -30,6 +33,7 @@
android:id="@+id/tittleVideoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textStyle="bold" />
@ -37,13 +41,14 @@
android:id="@+id/viewsTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="invisible">
android:visibility="gone">
<Button
android:id="@+id/button2"
@ -106,13 +111,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/subscribeBtn" />
android:text="@string/subscribeBtn"
android:visibility="invisible" />
</LinearLayout>
<TextView
android:id="@+id/descriptionTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="@string/descriptionTxt" />
<ScrollView
@ -124,6 +131,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="1000"
android:maxLines="1000"
android:paddingLeft="5dp"
android:text="TextView"
android:textStyle="italic" />
</ScrollView>
@ -135,7 +144,6 @@
android:background="?android:attr/listDivider" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>

View File

@ -12,6 +12,8 @@
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:touchscreenBlocksFocus="false"
android:visibility="visible"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.RecyclerView