updated build script
This commit is contained in:
parent
5a88250a8b
commit
db347550d2
|
@ -8,7 +8,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
|
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.google.gms:google-services:3.0.0'
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||||
classpath('fr.avianey.androidsvgdrawable:gradle-plugin:3.0.0') {
|
classpath('fr.avianey.androidsvgdrawable:gradle-plugin:3.0.0') {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Fri Mar 18 11:41:44 CST 2016
|
#Tue Aug 16 11:14:33 CST 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|
|
@ -71,12 +71,12 @@ public class ListViewScrollHandler extends ContentScrollHandler implements AbsLi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isComputingLayout() {
|
public boolean getComputingLayout() {
|
||||||
return ViewSupport.isInLayout(listView);
|
return ViewSupport.isInLayout(listView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void post(Runnable runnable) {
|
public void post(@NonNull Runnable runnable) {
|
||||||
listView.post(runnable);
|
listView.post(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ abstract class AbsActivitiesFragment protected constructor() : AbsContentListRec
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
scrollListener!!.setReversed(preferences.getBoolean(KEY_READ_FROM_BOTTOM))
|
scrollListener!!.reversed = preferences.getBoolean(KEY_READ_FROM_BOTTOM)
|
||||||
val adapter = adapter
|
val adapter = adapter
|
||||||
val layoutManager = layoutManager
|
val layoutManager = layoutManager
|
||||||
adapter!!.setListener(this)
|
adapter!!.setListener(this)
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.mariotaku.twidere.util.TwidereColorUtils
|
||||||
* Created by mariotaku on 15/4/16.
|
* Created by mariotaku on 15/4/16.
|
||||||
*/
|
*/
|
||||||
abstract class AbsContentListViewFragment<A : ListAdapter> : BaseSupportFragment(), OnRefreshListener, RefreshScrollTopInterface, ControlBarOffsetListener, ContentListSupport, AbsListView.OnScrollListener {
|
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
|
override var adapter: A? = null
|
||||||
|
|
||||||
|
@ -128,19 +128,19 @@ abstract class AbsContentListViewFragment<A : ListAdapter> : BaseSupportFragment
|
||||||
}
|
}
|
||||||
listView.adapter = adapter
|
listView.adapter = adapter
|
||||||
listView.clipToPadding = false
|
listView.clipToPadding = false
|
||||||
mScrollHandler = ListViewScrollHandler(this, ListViewScrollHandler.ListViewCallback(listView))
|
scrollHandler = ListViewScrollHandler(this, ListViewScrollHandler.ListViewCallback(listView))
|
||||||
mScrollHandler!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
|
scrollHandler!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
||||||
mScrollHandler!!.onScrollListener = this
|
scrollHandler!!.onScrollListener = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
listView.setOnScrollListener(mScrollHandler)
|
listView.setOnScrollListener(scrollHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
listView.setOnScrollListener(mScrollHandler)
|
listView.setOnScrollListener(scrollHandler)
|
||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,8 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
|
|
||||||
scrollListener = RecyclerViewScrollHandler(this, RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
|
scrollListener = RecyclerViewScrollHandler(this, RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
|
||||||
scrollListener!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
|
scrollListener!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
||||||
recyclerView.setOnTouchListener(scrollListener!!.onTouchListener)
|
recyclerView.setOnTouchListener(scrollListener!!.touchListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun setupRecyclerView(context: Context, recyclerView: RecyclerView) {
|
protected open fun setupRecyclerView(context: Context, recyclerView: RecyclerView) {
|
||||||
|
|
|
@ -445,7 +445,7 @@ abstract class AbsStatusesFragment protected constructor() : AbsContentListRecyc
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
scrollListener?.setReversed(preferences.getBoolean(SharedPreferenceConstants.KEY_READ_FROM_BOTTOM))
|
scrollListener?.reversed = preferences.getBoolean(SharedPreferenceConstants.KEY_READ_FROM_BOTTOM)
|
||||||
val adapter = adapter!!
|
val adapter = adapter!!
|
||||||
adapter.statusClickListener = this
|
adapter.statusClickListener = this
|
||||||
registerForContextMenu(recyclerView)
|
registerForContextMenu(recyclerView)
|
||||||
|
|
|
@ -122,7 +122,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||||
private var loadTranslationTask: LoadTranslationTask? = null
|
private var loadTranslationTask: LoadTranslationTask? = null
|
||||||
|
|
||||||
private var navigationHelper: RecyclerViewNavigationHelper? = null
|
private var navigationHelper: RecyclerViewNavigationHelper? = null
|
||||||
private var mScrollListener: RecyclerViewScrollHandler? = null
|
private var scrollListener: RecyclerViewScrollHandler? = null
|
||||||
// Data fields
|
// Data fields
|
||||||
private var conversationLoaderInitialized: Boolean = false
|
private var conversationLoaderInitialized: Boolean = false
|
||||||
|
|
||||||
|
@ -280,9 +280,9 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
registerForContextMenu(recyclerView!!)
|
registerForContextMenu(recyclerView!!)
|
||||||
|
|
||||||
mScrollListener = RecyclerViewScrollHandler(this,
|
scrollListener = RecyclerViewScrollHandler(this,
|
||||||
RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
|
RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
|
||||||
mScrollListener!!.setTouchSlop(ViewConfiguration.get(context).scaledTouchSlop)
|
scrollListener!!.touchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
||||||
|
|
||||||
navigationHelper = RecyclerViewNavigationHelper(recyclerView!!, layoutManager!!,
|
navigationHelper = RecyclerViewNavigationHelper(recyclerView!!, layoutManager!!,
|
||||||
adapter!!, null)
|
adapter!!, null)
|
||||||
|
@ -293,8 +293,7 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) {
|
override fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) {
|
||||||
val status = adapter!!.getStatus(statusPosition)
|
val status = adapter!!.getStatus(statusPosition) ?: return
|
||||||
if (status == null) return
|
|
||||||
IntentUtils.openMedia(activity, status, media, null,
|
IntentUtils.openMedia(activity, status, media, null,
|
||||||
preferences.getBoolean(SharedPreferenceConstants.KEY_NEW_DOCUMENT_API))
|
preferences.getBoolean(SharedPreferenceConstants.KEY_NEW_DOCUMENT_API))
|
||||||
|
|
||||||
|
@ -595,13 +594,13 @@ class StatusFragment : BaseSupportFragment(), LoaderCallbacks<SingleResponse<Par
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
bus.register(this)
|
bus.register(this)
|
||||||
recyclerView!!.addOnScrollListener(mScrollListener)
|
recyclerView!!.addOnScrollListener(scrollListener)
|
||||||
recyclerView!!.setOnTouchListener(mScrollListener!!.onTouchListener)
|
recyclerView!!.setOnTouchListener(scrollListener!!.touchListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
recyclerView.setOnTouchListener(null)
|
recyclerView.setOnTouchListener(null)
|
||||||
recyclerView!!.removeOnScrollListener(mScrollListener)
|
recyclerView!!.removeOnScrollListener(scrollListener)
|
||||||
bus.unregister(this)
|
bus.unregister(this)
|
||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,43 +30,32 @@ import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosi
|
||||||
* Created by mariotaku on 15/3/15.
|
* Created by mariotaku on 15/3/15.
|
||||||
*/
|
*/
|
||||||
open class ContentScrollHandler(
|
open class ContentScrollHandler(
|
||||||
private val mContentListSupport: ContentScrollHandler.ContentListSupport,
|
private val contentListSupport: ContentScrollHandler.ContentListSupport,
|
||||||
private val mViewCallback: ContentScrollHandler.ViewCallback?
|
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
|
protected var scrollState: Int = 0
|
||||||
private set
|
private set
|
||||||
private var mScrollSum: Int = 0
|
private var scrollSum: Int = 0
|
||||||
private var mTouchSlop: Int = 0
|
|
||||||
private var mReversed: Boolean = false
|
|
||||||
|
|
||||||
private var mScrollDirection: Int = 0
|
private var scrollDirection: Int = 0
|
||||||
|
|
||||||
init {
|
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() {
|
private fun postNotifyScrollStateChanged() {
|
||||||
if (mContentListSupport is Fragment) {
|
if (contentListSupport is Fragment) {
|
||||||
if (mContentListSupport.context == null) return
|
if (contentListSupport.context == null) return
|
||||||
}
|
}
|
||||||
if (mViewCallback != null) {
|
if (viewCallback != null) {
|
||||||
mViewCallback.post(object : Runnable {
|
viewCallback.post(object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (mViewCallback.isComputingLayout) {
|
if (viewCallback.computingLayout) {
|
||||||
mViewCallback.post(this)
|
viewCallback.post(this)
|
||||||
} else {
|
} else {
|
||||||
notifyScrollStateChanged()
|
notifyScrollStateChanged()
|
||||||
}
|
}
|
||||||
|
@ -78,28 +67,30 @@ open class ContentScrollHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyScrollStateChanged() {
|
private fun notifyScrollStateChanged() {
|
||||||
if (mContentListSupport is Fragment) {
|
if (contentListSupport is Fragment) {
|
||||||
if (mContentListSupport.context == null) return
|
if (contentListSupport.context == null) return
|
||||||
}
|
}
|
||||||
val adapter = mContentListSupport.adapter
|
val adapter = contentListSupport.adapter
|
||||||
if (adapter !is ILoadMoreSupportAdapter) return
|
if (adapter !is ILoadMoreSupportAdapter) return
|
||||||
if (!mContentListSupport.refreshing && adapter.loadMoreSupportedPosition != ILoadMoreSupportAdapter.NONE
|
if (!contentListSupport.refreshing && adapter.loadMoreSupportedPosition != ILoadMoreSupportAdapter.NONE
|
||||||
&& adapter.loadMoreIndicatorPosition == ILoadMoreSupportAdapter.NONE) {
|
&& adapter.loadMoreIndicatorPosition == ILoadMoreSupportAdapter.NONE) {
|
||||||
var position: Long = 0
|
var position: Long = 0
|
||||||
if (mContentListSupport.reachingEnd && mScrollDirection >= 0) {
|
if (contentListSupport.reachingEnd && scrollDirection >= 0) {
|
||||||
position = position or ILoadMoreSupportAdapter.END
|
position = position or ILoadMoreSupportAdapter.END
|
||||||
}
|
}
|
||||||
if (mContentListSupport.reachingStart && mScrollDirection <= 0) {
|
if (contentListSupport.reachingStart && scrollDirection <= 0) {
|
||||||
position = position or ILoadMoreSupportAdapter.START
|
position = position or ILoadMoreSupportAdapter.START
|
||||||
}
|
}
|
||||||
resetScrollDirection()
|
resetScrollDirection()
|
||||||
mContentListSupport.onLoadMoreContents(position.toLong())
|
if (position != 0L) {
|
||||||
|
contentListSupport.onLoadMoreContents(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleScrollStateChanged(scrollState: Int, idleState: Int) {
|
fun handleScrollStateChanged(scrollState: Int, idleState: Int) {
|
||||||
if (mContentListSupport is Fragment) {
|
if (contentListSupport is Fragment) {
|
||||||
if (mContentListSupport.context == null) return
|
if (contentListSupport.context == null) return
|
||||||
}
|
}
|
||||||
if (this.scrollState != idleState) {
|
if (this.scrollState != idleState) {
|
||||||
postNotifyScrollStateChanged()
|
postNotifyScrollStateChanged()
|
||||||
|
@ -108,17 +99,17 @@ open class ContentScrollHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleScroll(dy: Int, scrollState: Int, oldState: Int, idleState: Int) {
|
fun handleScroll(dy: Int, scrollState: Int, oldState: Int, idleState: Int) {
|
||||||
if (mContentListSupport is Fragment) {
|
if (contentListSupport is Fragment) {
|
||||||
if (mContentListSupport.context == null) return
|
if (contentListSupport.context == null) return
|
||||||
}
|
}
|
||||||
//Reset mScrollSum when scrolling in reverse direction
|
//Reset mScrollSum when scrolling in reverse direction
|
||||||
if (dy * mScrollSum < 0) {
|
if (dy * scrollSum < 0) {
|
||||||
mScrollSum = 0
|
scrollSum = 0
|
||||||
}
|
}
|
||||||
mScrollSum += dy
|
scrollSum += dy
|
||||||
if (Math.abs(mScrollSum) > mTouchSlop) {
|
if (Math.abs(scrollSum) > touchSlop) {
|
||||||
mContentListSupport.setControlVisible(mReversed xor (dy < 0))
|
contentListSupport.setControlVisible(reversed xor (dy < 0))
|
||||||
mScrollSum = 0
|
scrollSum = 0
|
||||||
}
|
}
|
||||||
if (scrollState == idleState && oldState != scrollState) {
|
if (scrollState == idleState && oldState != scrollState) {
|
||||||
postNotifyScrollStateChanged()
|
postNotifyScrollStateChanged()
|
||||||
|
@ -126,28 +117,28 @@ open class ContentScrollHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setScrollDirection(direction: Int) {
|
private fun setScrollDirection(direction: Int) {
|
||||||
mScrollDirection = direction
|
scrollDirection = direction
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetScrollDirection() {
|
private fun resetScrollDirection() {
|
||||||
mScrollDirection = 0
|
scrollDirection = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TouchListener(private val listener: ContentScrollHandler) : View.OnTouchListener {
|
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 {
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
listener.resetScrollDirection()
|
listener.resetScrollDirection()
|
||||||
mLastY = java.lang.Float.NaN
|
lastY = Float.NaN
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
if (!java.lang.Float.isNaN(mLastY)) {
|
if (!java.lang.Float.isNaN(lastY)) {
|
||||||
val delta = mLastY - event.rawY
|
val delta = lastY - event.rawY
|
||||||
listener.setScrollDirection(if (delta < 0) -1 else 1)
|
listener.setScrollDirection(if (delta < 0) -1 else 1)
|
||||||
} else {
|
} else {
|
||||||
mLastY = event.rawY
|
lastY = event.rawY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +147,7 @@ open class ContentScrollHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ViewCallback {
|
interface ViewCallback {
|
||||||
val isComputingLayout: Boolean
|
val computingLayout: Boolean
|
||||||
|
|
||||||
fun post(runnable: Runnable)
|
fun post(runnable: Runnable)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,20 @@ class RecyclerViewScrollHandler(contentListSupport: ContentListSupport, viewCall
|
||||||
scrollHandler = ContentScrollHandler(contentListSupport, viewCallback)
|
scrollHandler = ContentScrollHandler(contentListSupport, viewCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setReversed(inversed: Boolean) {
|
var touchSlop: Int
|
||||||
scrollHandler.setReversed(inversed)
|
get() = scrollHandler.touchSlop
|
||||||
}
|
set(value) {
|
||||||
|
scrollHandler.touchSlop = value
|
||||||
|
}
|
||||||
|
|
||||||
fun setTouchSlop(touchSlop: Int) {
|
var reversed: Boolean
|
||||||
scrollHandler.setTouchSlop(touchSlop)
|
get() = scrollHandler.reversed
|
||||||
}
|
set(value) {
|
||||||
|
scrollHandler.reversed = value
|
||||||
|
}
|
||||||
|
|
||||||
val onTouchListener: View.OnTouchListener
|
val touchListener: View.OnTouchListener
|
||||||
get() = scrollHandler.onTouchListener
|
get() = scrollHandler.touchListener
|
||||||
|
|
||||||
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
|
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
|
||||||
scrollHandler.handleScrollStateChanged(newState, RecyclerView.SCROLL_STATE_IDLE)
|
scrollHandler.handleScrollStateChanged(newState, RecyclerView.SCROLL_STATE_IDLE)
|
||||||
|
@ -41,7 +45,7 @@ class RecyclerViewScrollHandler(contentListSupport: ContentListSupport, viewCall
|
||||||
|
|
||||||
class RecyclerViewCallback(private val recyclerView: RecyclerView) : ViewCallback {
|
class RecyclerViewCallback(private val recyclerView: RecyclerView) : ViewCallback {
|
||||||
|
|
||||||
override val isComputingLayout: Boolean
|
override val computingLayout: Boolean
|
||||||
get() = recyclerView.isComputingLayout
|
get() = recyclerView.isComputingLayout
|
||||||
|
|
||||||
override fun post(runnable: Runnable) {
|
override fun post(runnable: Runnable) {
|
||||||
|
|
Loading…
Reference in New Issue