mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
improved refresh
fixed user list picker
This commit is contained in:
parent
151cead5ab
commit
3031a7186d
@ -7,7 +7,7 @@ android:
|
||||
- tools
|
||||
|
||||
# The BuildTools version used by your project
|
||||
- build-tools-25.0.1
|
||||
- build-tools-25.0.2
|
||||
|
||||
# The SDK version used to compile your project
|
||||
- android-25
|
||||
|
@ -42,7 +42,7 @@ subprojects {
|
||||
if (project.hasProperty('android')) {
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '25.0.1'
|
||||
buildToolsVersion '25.0.2'
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
|
@ -302,7 +302,7 @@ public class UserListSelectorActivity extends BaseActivity implements OnClickLis
|
||||
final MicroBlog twitter = MicroBlogAPIFactory.getInstance(mActivity, mAccountKey);
|
||||
if (twitter == null) return SingleResponse.Companion.getInstance();
|
||||
try {
|
||||
final ResponseList<UserList> lists = twitter.getUserLists(mScreenName, true);
|
||||
final ResponseList<UserList> lists = twitter.getUserListsByScreenName(mScreenName, true);
|
||||
final List<ParcelableUserList> data = new ArrayList<>();
|
||||
boolean isMyAccount = mScreenName.equalsIgnoreCase(getAccountScreenName(mActivity,
|
||||
mAccountKey));
|
||||
|
@ -54,25 +54,25 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
private set
|
||||
|
||||
// Callbacks and listeners
|
||||
private var drawerCallback: SimpleDrawerCallback? = null
|
||||
private lateinit var drawerCallback: SimpleDrawerCallback
|
||||
var scrollListener: RecyclerViewScrollHandler? = null
|
||||
// Data fields
|
||||
private val systemWindowsInsets = Rect()
|
||||
|
||||
override fun canScroll(dy: Float): Boolean {
|
||||
return drawerCallback!!.canScroll(dy)
|
||||
return drawerCallback.canScroll(dy)
|
||||
}
|
||||
|
||||
override fun cancelTouch() {
|
||||
drawerCallback!!.cancelTouch()
|
||||
drawerCallback.cancelTouch()
|
||||
}
|
||||
|
||||
override fun fling(velocity: Float) {
|
||||
drawerCallback!!.fling(velocity)
|
||||
drawerCallback.fling(velocity)
|
||||
}
|
||||
|
||||
override fun isScrollContent(x: Float, y: Float): Boolean {
|
||||
return drawerCallback!!.isScrollContent(x, y)
|
||||
return drawerCallback.isScrollContent(x, y)
|
||||
}
|
||||
|
||||
override fun onControlBarOffsetChanged(activity: IControlBarActivity, offset: Float) {
|
||||
@ -91,7 +91,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
}
|
||||
|
||||
override fun scrollBy(dy: Float) {
|
||||
drawerCallback!!.scrollBy(dy)
|
||||
drawerCallback.scrollBy(dy)
|
||||
}
|
||||
|
||||
override fun scrollToStart(): Boolean {
|
||||
@ -124,11 +124,11 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
}
|
||||
|
||||
override fun shouldLayoutHeaderBottom(): Boolean {
|
||||
return drawerCallback!!.shouldLayoutHeaderBottom()
|
||||
return drawerCallback.shouldLayoutHeaderBottom()
|
||||
}
|
||||
|
||||
override fun topChanged(offset: Int) {
|
||||
drawerCallback!!.topChanged(offset)
|
||||
drawerCallback.topChanged(offset)
|
||||
}
|
||||
|
||||
override var refreshing: Boolean
|
||||
@ -161,16 +161,14 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater!!.inflate(R.layout.fragment_content_recyclerview, container, false)
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_content_recyclerview, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
drawerCallback = SimpleDrawerCallback(recyclerView)
|
||||
|
||||
val view = view!!
|
||||
val context = view.context
|
||||
val backgroundColor = ThemeUtils.getThemeBackgroundColor(context)
|
||||
val colorRes = TwidereColorUtils.getContrastYIQ(backgroundColor,
|
||||
R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark)
|
||||
@ -268,19 +266,19 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
protected fun showContent() {
|
||||
errorContainer.visibility = View.GONE
|
||||
progressContainer.visibility = View.GONE
|
||||
swipeLayout.visibility = View.VISIBLE
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
protected fun showProgress() {
|
||||
errorContainer.visibility = View.GONE
|
||||
progressContainer.visibility = View.VISIBLE
|
||||
swipeLayout.visibility = View.GONE
|
||||
recyclerView.visibility = View.GONE
|
||||
}
|
||||
|
||||
protected fun showError(icon: Int, text: CharSequence) {
|
||||
errorContainer.visibility = View.VISIBLE
|
||||
progressContainer.visibility = View.GONE
|
||||
swipeLayout.visibility = View.GONE
|
||||
recyclerView.visibility = View.GONE
|
||||
errorIcon.setImageResource(icon)
|
||||
errorText.text = text
|
||||
}
|
||||
@ -288,7 +286,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
protected fun showEmpty(icon: Int, text: CharSequence) {
|
||||
errorContainer.visibility = View.VISIBLE
|
||||
progressContainer.visibility = View.GONE
|
||||
swipeLayout.visibility = View.VISIBLE
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
errorIcon.setImageResource(icon)
|
||||
errorText.text = text
|
||||
}
|
||||
|
@ -8,11 +8,8 @@ import android.support.v4.content.Loader
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import org.apache.commons.lang3.ArrayUtils
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.adapter.StaggeredGridParcelableStatusesAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
@ -62,7 +59,6 @@ class UserMediaTimelineFragment : AbsContentRecyclerViewFragment<StaggeredGridPa
|
||||
return StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
|
||||
}
|
||||
|
||||
|
||||
fun getStatuses(maxId: String?, sinceId: String?): Int {
|
||||
if (context == null) return -1
|
||||
val args = Bundle(arguments)
|
||||
@ -74,15 +70,10 @@ class UserMediaTimelineFragment : AbsContentRecyclerViewFragment<StaggeredGridPa
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateAdapter(context: Context): StaggeredGridParcelableStatusesAdapter {
|
||||
return StaggeredGridParcelableStatusesAdapter(context)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater!!.inflate(R.layout.fragment_content_recyclerview, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<List<ParcelableStatus>> {
|
||||
val context = activity
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
|
@ -26,6 +26,7 @@ import android.support.annotation.WorkerThread
|
||||
import android.util.Log
|
||||
import com.bluelinelabs.logansquare.LoganSquare
|
||||
import com.nostra13.universalimageloader.cache.disc.DiskCache
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.Paging
|
||||
@ -33,6 +34,7 @@ import org.mariotaku.microblog.library.twitter.model.Status
|
||||
import org.mariotaku.twidere.BuildConfig
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.app.TwidereApplication
|
||||
import org.mariotaku.twidere.constant.loadItemLimitKey
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ListResponse
|
||||
@ -45,11 +47,9 @@ import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.TwidereArrayUtils
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
import java.io.PipedInputStream
|
||||
import java.io.PipedOutputStream
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@ -225,17 +225,12 @@ abstract class MicroBlogAPIStatusesLoader(
|
||||
private fun saveCachedData(data: List<ParcelableStatus>?) {
|
||||
val key = serializationKey
|
||||
if (key == null || data == null) return
|
||||
val databaseItemLimit = preferences.getInt(KEY_DATABASE_ITEM_LIMIT, DEFAULT_DATABASE_ITEM_LIMIT)
|
||||
val databaseItemLimit = preferences[loadItemLimitKey]
|
||||
try {
|
||||
val statuses = data.subList(0, Math.min(databaseItemLimit, data.size))
|
||||
val pos = PipedOutputStream()
|
||||
val pis = PipedInputStream(pos)
|
||||
val future = pool.submit(Callable<Unit> {
|
||||
LoganSquare.serialize(statuses, pos)
|
||||
})
|
||||
val saved = fileCache.save(key, pis) { current, total -> !future.isDone }
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.v(LOGTAG, key + " saved: " + saved)
|
||||
fileCache.save(key, ByteArrayInputStream(byteArrayOf())) { current, total -> true }
|
||||
fileCache.get(key)?.outputStream()?.use {
|
||||
LoganSquare.serialize(statuses, it, ParcelableStatus::class.java)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// Ignore
|
||||
|
@ -16,20 +16,19 @@
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
<org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout
|
||||
android:id="@+id/swipeLayout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<include layout="@layout/layout_content_fragment_common"/>
|
||||
|
||||
<org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout
|
||||
android:id="@+id/swipeLayout"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/layout_content_fragment_common"/>
|
||||
|
||||
<org.mariotaku.twidere.view.ExtendedRecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
@ -38,6 +37,5 @@
|
||||
android:clipToPadding="false"
|
||||
android:focusable="true"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
</org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
</org.mariotaku.twidere.view.ExtendedSwipeRefreshLayout>
|
Loading…
x
Reference in New Issue
Block a user