fixed refreshing state

This commit is contained in:
Mariotaku Lee 2016-08-22 16:11:42 +08:00
parent d7a34d82a1
commit 169e95a8b2
4 changed files with 20 additions and 9 deletions

View File

@ -203,8 +203,11 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
}
override var refreshing: Boolean = false
override var refreshing: Boolean
get() = false
set(value) {
super.refreshing = value
}
override fun onCreateAdapter(context: Context): SimpleCursorAdapter {
return FilterListAdapter(context)

View File

@ -49,11 +49,14 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
var prevCursor: Long = 0
private set
override var refreshing: Boolean = false
override var refreshing: Boolean
get() {
if (context == null || isDetached) return false
return loaderManager.hasRunningLoaders()
}
set(value) {
super.refreshing = value
}
override fun onCreateAdapter(context: Context): ParcelableUserListsAdapter {
return ParcelableUserListsAdapter(context)

View File

@ -97,8 +97,11 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
loaderManager.restartLoader(0, null, this)
}
override var refreshing: Boolean = false
override var refreshing: Boolean
get() = loaderManager.hasRunningLoaders()
set(value) {
super.refreshing = value
}
@Subscribe
fun onSavedSearchDestroyed(event: SavedSearchDestroyedEvent) {

View File

@ -42,11 +42,11 @@ import org.mariotaku.twidere.util.Utils.getDefaultAccountKey
class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), LoaderCallbacks<Cursor>, AdapterView.OnItemClickListener {
private var mAccountId: UserKey? = null
private var accountId: UserKey? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
mAccountId = getDefaultAccountKey(activity)
accountId = getDefaultAccountKey(activity)
listView.onItemClickListener = this
loaderManager.initLoader(0, null, this)
showProgress()
@ -83,7 +83,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
}
if (trend == null) return
openTweetSearch(activity, mAccountId, trend)
openTweetSearch(activity, accountId, trend)
}
override fun onLoaderReset(loader: Loader<Cursor>) {
@ -97,12 +97,14 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
override fun onRefresh() {
if (refreshing) return
val twitter = twitterWrapper ?: return
twitter.getLocalTrendsAsync(mAccountId, preferences.getInt(KEY_LOCAL_TRENDS_WOEID, 1))
twitterWrapper.getLocalTrendsAsync(accountId, preferences.getInt(KEY_LOCAL_TRENDS_WOEID, 1))
}
override var refreshing: Boolean = false
override var refreshing: Boolean
get() = false
set(value) {
super.refreshing = value
}
override fun onStart() {
super.onStart()