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