updated build script

This commit is contained in:
Mariotaku Lee 2016-08-16 21:23:45 +08:00
parent 5a88250a8b
commit db347550d2
10 changed files with 76 additions and 82 deletions

View File

@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath('fr.avianey.androidsvgdrawable:gradle-plugin:3.0.0') {

View File

@ -1,6 +1,6 @@
#Fri Mar 18 11:41:44 CST 2016
#Tue Aug 16 11:14:33 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

View File

@ -71,12 +71,12 @@ public class ListViewScrollHandler extends ContentScrollHandler implements AbsLi
}
@Override
public boolean isComputingLayout() {
public boolean getComputingLayout() {
return ViewSupport.isInLayout(listView);
}
@Override
public void post(Runnable runnable) {
public void post(@NonNull Runnable runnable) {
listView.post(runnable);
}
}

View File

@ -433,7 +433,7 @@ abstract class AbsActivitiesFragment protected constructor() : AbsContentListRec
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
scrollListener!!.setReversed(preferences.getBoolean(KEY_READ_FROM_BOTTOM))
scrollListener!!.reversed = preferences.getBoolean(KEY_READ_FROM_BOTTOM)
val adapter = adapter
val layoutManager = layoutManager
adapter!!.setListener(this)

View File

@ -42,7 +42,7 @@ import org.mariotaku.twidere.util.TwidereColorUtils
* Created by mariotaku on 15/4/16.
*/
abstract class AbsContentListViewFragment<A : ListAdapter> : BaseSupportFragment(), OnRefreshListener, RefreshScrollTopInterface, ControlBarOffsetListener, ContentListSupport, AbsListView.OnScrollListener {
private var mScrollHandler: ListViewScrollHandler? = null
private var scrollHandler: ListViewScrollHandler? = null
override var adapter: A? = null
@ -128,19 +128,19 @@ abstract class AbsContentListViewFragment<A : ListAdapter> : BaseSupportFragment
}
listView.adapter = adapter
listView.clipToPadding = false
mScrollHandler = ListViewScrollHandler(this, ListViewScrollHandler.ListViewCallback(listView))
mScrollHandler!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
mScrollHandler!!.onScrollListener = this
scrollHandler = ListViewScrollHandler(this, ListViewScrollHandler.ListViewCallback(listView))
scrollHandler!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
scrollHandler!!.onScrollListener = this
}
override fun onStart() {
super.onStart()
listView.setOnScrollListener(mScrollHandler)
listView.setOnScrollListener(scrollHandler)
}
override fun onStop() {
listView.setOnScrollListener(mScrollHandler)
listView.setOnScrollListener(scrollHandler)
super.onStop()
}

View File

@ -200,8 +200,8 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
recyclerView.adapter = adapter
scrollListener = RecyclerViewScrollHandler(this, RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
scrollListener!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
recyclerView.setOnTouchListener(scrollListener!!.onTouchListener)
scrollListener!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
recyclerView.setOnTouchListener(scrollListener!!.touchListener)
}
protected open fun setupRecyclerView(context: Context, recyclerView: RecyclerView) {

View File

@ -445,7 +445,7 @@ abstract class AbsStatusesFragment protected constructor() : AbsContentListRecyc
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
scrollListener?.setReversed(preferences.getBoolean(SharedPreferenceConstants.KEY_READ_FROM_BOTTOM))
scrollListener?.reversed = preferences.getBoolean(SharedPreferenceConstants.KEY_READ_FROM_BOTTOM)
val adapter = adapter!!
adapter.statusClickListener = this
registerForContextMenu(recyclerView)

View File

@ -122,7 +122,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
private var loadTranslationTask: LoadTranslationTask? = null
private var navigationHelper: RecyclerViewNavigationHelper? = null
private var mScrollListener: RecyclerViewScrollHandler? = null
private var scrollListener: RecyclerViewScrollHandler? = null
// Data fields
private var conversationLoaderInitialized: Boolean = false
@ -280,9 +280,9 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
recyclerView.adapter = adapter
registerForContextMenu(recyclerView!!)
mScrollListener = RecyclerViewScrollHandler(this,
scrollListener = RecyclerViewScrollHandler(this,
RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
mScrollListener!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
scrollListener!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
navigationHelper = RecyclerViewNavigationHelper(recyclerView!!, layoutManager!!,
adapter!!, null)
@ -293,8 +293,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
}
override fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) {
val status = adapter!!.getStatus(statusPosition)
if (status == null) return
val status = adapter!!.getStatus(statusPosition) ?: return
IntentUtils.openMedia(activity, status, media, null,
preferences.getBoolean(SharedPreferenceConstants.KEY_NEW_DOCUMENT_API))
@ -595,13 +594,13 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
override fun onStart() {
super.onStart()
bus.register(this)
recyclerView!!.addOnScrollListener(mScrollListener)
recyclerView!!.setOnTouchListener(mScrollListener!!.onTouchListener)
recyclerView!!.addOnScrollListener(scrollListener)
recyclerView!!.setOnTouchListener(scrollListener!!.touchListener)
}
override fun onStop() {
recyclerView.setOnTouchListener(null)
recyclerView!!.removeOnScrollListener(mScrollListener)
recyclerView!!.removeOnScrollListener(scrollListener)
bus.unregister(this)
super.onStop()
}

View File

@ -30,43 +30,32 @@ import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosi
* Created by mariotaku on 15/3/15.
*/
open class ContentScrollHandler(
private val mContentListSupport: ContentScrollHandler.ContentListSupport,
private val mViewCallback: ContentScrollHandler.ViewCallback?
private val contentListSupport: ContentScrollHandler.ContentListSupport,
private val viewCallback: ContentScrollHandler.ViewCallback?
) {
private val mTouchListener: TouchListener
val touchListener: View.OnTouchListener
var touchSlop: Int = 0
var reversed: Boolean = false
protected var scrollState: Int = 0
private set
private var mScrollSum: Int = 0
private var mTouchSlop: Int = 0
private var mReversed: Boolean = false
private var scrollSum: Int = 0
private var mScrollDirection: Int = 0
private var scrollDirection: Int = 0
init {
mTouchListener = TouchListener(this)
touchListener = TouchListener(this)
}
fun setTouchSlop(touchSlop: Int) {
mTouchSlop = touchSlop
}
fun setReversed(inversed: Boolean) {
mReversed = inversed
}
val onTouchListener: View.OnTouchListener
get() = mTouchListener
private fun postNotifyScrollStateChanged() {
if (mContentListSupport is Fragment) {
if (mContentListSupport.context == null) return
if (contentListSupport is Fragment) {
if (contentListSupport.context == null) return
}
if (mViewCallback != null) {
mViewCallback.post(object : Runnable {
if (viewCallback != null) {
viewCallback.post(object : Runnable {
override fun run() {
if (mViewCallback.isComputingLayout) {
mViewCallback.post(this)
if (viewCallback.computingLayout) {
viewCallback.post(this)
} else {
notifyScrollStateChanged()
}
@ -78,28 +67,30 @@ open class ContentScrollHandler(
}
private fun notifyScrollStateChanged() {
if (mContentListSupport is Fragment) {
if (mContentListSupport.context == null) return
if (contentListSupport is Fragment) {
if (contentListSupport.context == null) return
}
val adapter = mContentListSupport.adapter
val adapter = contentListSupport.adapter
if (adapter !is ILoadMoreSupportAdapter) return
if (!mContentListSupport.refreshing && adapter.loadMoreSupportedPosition != ILoadMoreSupportAdapter.NONE
if (!contentListSupport.refreshing && adapter.loadMoreSupportedPosition != ILoadMoreSupportAdapter.NONE
&& adapter.loadMoreIndicatorPosition == ILoadMoreSupportAdapter.NONE) {
var position: Long = 0
if (mContentListSupport.reachingEnd && mScrollDirection >= 0) {
if (contentListSupport.reachingEnd && scrollDirection >= 0) {
position = position or ILoadMoreSupportAdapter.END
}
if (mContentListSupport.reachingStart && mScrollDirection <= 0) {
if (contentListSupport.reachingStart && scrollDirection <= 0) {
position = position or ILoadMoreSupportAdapter.START
}
resetScrollDirection()
mContentListSupport.onLoadMoreContents(position.toLong())
if (position != 0L) {
contentListSupport.onLoadMoreContents(position)
}
}
}
fun handleScrollStateChanged(scrollState: Int, idleState: Int) {
if (mContentListSupport is Fragment) {
if (mContentListSupport.context == null) return
if (contentListSupport is Fragment) {
if (contentListSupport.context == null) return
}
if (this.scrollState != idleState) {
postNotifyScrollStateChanged()
@ -108,17 +99,17 @@ open class ContentScrollHandler(
}
fun handleScroll(dy: Int, scrollState: Int, oldState: Int, idleState: Int) {
if (mContentListSupport is Fragment) {
if (mContentListSupport.context == null) return
if (contentListSupport is Fragment) {
if (contentListSupport.context == null) return
}
//Reset mScrollSum when scrolling in reverse direction
if (dy * mScrollSum < 0) {
mScrollSum = 0
if (dy * scrollSum < 0) {
scrollSum = 0
}
mScrollSum += dy
if (Math.abs(mScrollSum) > mTouchSlop) {
mContentListSupport.setControlVisible(mReversed xor (dy < 0))
mScrollSum = 0
scrollSum += dy
if (Math.abs(scrollSum) > touchSlop) {
contentListSupport.setControlVisible(reversed xor (dy < 0))
scrollSum = 0
}
if (scrollState == idleState && oldState != scrollState) {
postNotifyScrollStateChanged()
@ -126,28 +117,28 @@ open class ContentScrollHandler(
}
private fun setScrollDirection(direction: Int) {
mScrollDirection = direction
scrollDirection = direction
}
private fun resetScrollDirection() {
mScrollDirection = 0
scrollDirection = 0
}
internal class TouchListener(private val listener: ContentScrollHandler) : View.OnTouchListener {
private var mLastY: Float = 0.toFloat()
private var lastY: Float = 0f
override fun onTouch(v: View, event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
listener.resetScrollDirection()
mLastY = java.lang.Float.NaN
lastY = Float.NaN
}
MotionEvent.ACTION_MOVE -> {
if (!java.lang.Float.isNaN(mLastY)) {
val delta = mLastY - event.rawY
if (!java.lang.Float.isNaN(lastY)) {
val delta = lastY - event.rawY
listener.setScrollDirection(if (delta < 0) -1 else 1)
} else {
mLastY = event.rawY
lastY = event.rawY
}
}
}
@ -156,7 +147,7 @@ open class ContentScrollHandler(
}
interface ViewCallback {
val isComputingLayout: Boolean
val computingLayout: Boolean
fun post(runnable: Runnable)
}

View File

@ -18,16 +18,20 @@ class RecyclerViewScrollHandler(contentListSupport: ContentListSupport, viewCall
scrollHandler = ContentScrollHandler(contentListSupport, viewCallback)
}
fun setReversed(inversed: Boolean) {
scrollHandler.setReversed(inversed)
}
var touchSlop: Int
get() = scrollHandler.touchSlop
set(value) {
scrollHandler.touchSlop = value
}
fun setTouchSlop(touchSlop: Int) {
scrollHandler.setTouchSlop(touchSlop)
}
var reversed: Boolean
get() = scrollHandler.reversed
set(value) {
scrollHandler.reversed = value
}
val onTouchListener: View.OnTouchListener
get() = scrollHandler.onTouchListener
val touchListener: View.OnTouchListener
get() = scrollHandler.touchListener
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
scrollHandler.handleScrollStateChanged(newState, RecyclerView.SCROLL_STATE_IDLE)
@ -41,7 +45,7 @@ class RecyclerViewScrollHandler(contentListSupport: ContentListSupport, viewCall
class RecyclerViewCallback(private val recyclerView: RecyclerView) : ViewCallback {
override val isComputingLayout: Boolean
override val computingLayout: Boolean
get() = recyclerView.isComputingLayout
override fun post(runnable: Runnable) {