handle swipe to refresh inline
This commit is contained in:
parent
80a1d286e6
commit
828b4f4256
|
@ -10,7 +10,6 @@ import android.os.Bundle
|
|||
import android.provider.MediaStore
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v4.widget.SwipeRefreshLayout
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
|
@ -27,7 +26,7 @@ import kotlinx.android.synthetic.main.activity_main.*
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, GetDirectoriesAsynctask.GetDirectoriesListener, View.OnTouchListener, DirectoryAdapter.DirOperationsListener {
|
||||
class MainActivity : SimpleActivity(), GetDirectoriesAsynctask.GetDirectoriesListener, View.OnTouchListener, DirectoryAdapter.DirOperationsListener {
|
||||
companion object {
|
||||
private val STORAGE_PERMISSION = 1
|
||||
private val PICK_MEDIA = 2
|
||||
|
@ -62,7 +61,7 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get
|
|||
mIsGetAnyContentIntent || mIsSetWallpaperIntent
|
||||
|
||||
mToBeDeleted = ArrayList<String>()
|
||||
directories_holder.setOnRefreshListener(this)
|
||||
directories_holder.setOnRefreshListener({ getDirectories() })
|
||||
mDirs = ArrayList<Directory>()
|
||||
}
|
||||
|
||||
|
@ -287,12 +286,8 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get
|
|||
}
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
getDirectories()
|
||||
directories_holder.isRefreshing = false
|
||||
}
|
||||
|
||||
override fun gotDirectories(dirs: ArrayList<Directory>) {
|
||||
directories_holder.isRefreshing = false
|
||||
mIsGettingDirs = false
|
||||
if (dirs.toString() == mDirs.toString()) {
|
||||
return
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v4.widget.SwipeRefreshLayout
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -32,7 +31,7 @@ import java.io.IOException
|
|||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class MediaActivity : SimpleActivity(), View.OnTouchListener, SwipeRefreshLayout.OnRefreshListener, MediaAdapter.MediaOperationsListener {
|
||||
class MediaActivity : SimpleActivity(), View.OnTouchListener, MediaAdapter.MediaOperationsListener {
|
||||
companion object {
|
||||
private val TAG = MediaActivity::class.java.simpleName
|
||||
|
||||
|
@ -57,7 +56,7 @@ class MediaActivity : SimpleActivity(), View.OnTouchListener, SwipeRefreshLayout
|
|||
mIsGetAnyIntent = getBooleanExtra(Constants.GET_ANY_INTENT, false)
|
||||
}
|
||||
|
||||
media_holder.setOnRefreshListener(this)
|
||||
media_holder.setOnRefreshListener({ refreshDir() })
|
||||
mPath = intent.getStringExtra(Constants.DIRECTORY)
|
||||
mToBeDeleted = ArrayList<String>()
|
||||
mMedia = ArrayList<Medium>()
|
||||
|
@ -363,10 +362,6 @@ class MediaActivity : SimpleActivity(), View.OnTouchListener, SwipeRefreshLayout
|
|||
refreshDir()
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
refreshDir()
|
||||
}
|
||||
|
||||
private fun refreshDir() {
|
||||
val dir = File(mPath)
|
||||
if (dir.isDirectory) {
|
||||
|
|
Loading…
Reference in New Issue