mirror of https://github.com/kurisufriend/Clover
parent
10155cf644
commit
48b71d83d5
@ -0,0 +1,45 @@ |
||||
package org.floens.chan.ui.view; |
||||
|
||||
import android.graphics.drawable.ColorDrawable; |
||||
import android.graphics.drawable.StateListDrawable; |
||||
import android.support.v7.widget.RecyclerView; |
||||
|
||||
import static org.floens.chan.ui.theme.ThemeHelper.theme; |
||||
import static org.floens.chan.utils.AndroidUtils.dp; |
||||
|
||||
/** |
||||
* Helper for attaching a FastScroller with the correct theme colors and default values that |
||||
* make it look like a normal scrollbar. |
||||
*/ |
||||
public class FastScrollerHelper { |
||||
public static FastScroller create(RecyclerView recyclerView) { |
||||
StateListDrawable thumb = getThumb(); |
||||
StateListDrawable track = getTrack(); |
||||
|
||||
final int defaultThickness = dp(4); |
||||
final int targetWidth = dp(8); |
||||
final int minimumRange = dp(50); |
||||
final int margin = dp(0); |
||||
final int thumbMinLength = dp(23); |
||||
|
||||
return new FastScroller(recyclerView, |
||||
thumb, track, thumb, track, |
||||
defaultThickness, minimumRange, margin, thumbMinLength, targetWidth); |
||||
} |
||||
|
||||
private static StateListDrawable getThumb() { |
||||
StateListDrawable list = new StateListDrawable(); |
||||
list.addState(new int[]{android.R.attr.state_pressed}, |
||||
new ColorDrawable(theme().accentColor.color)); |
||||
list.addState(new int[]{}, new ColorDrawable(theme().textSecondary)); |
||||
return list; |
||||
} |
||||
|
||||
private static StateListDrawable getTrack() { |
||||
StateListDrawable list = new StateListDrawable(); |
||||
list.addState(new int[]{android.R.attr.state_pressed}, |
||||
new ColorDrawable(theme().textHint)); |
||||
list.addState(new int[]{}, new ColorDrawable(0)); |
||||
return list; |
||||
} |
||||
} |
@ -1,29 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Clover - 4chan browser https://github.com/Floens/Clover/ |
||||
Copyright (C) 2014 Floens |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<item android:state_pressed="true"> |
||||
<shape android:shape="rectangle"> |
||||
<solid android:color="#ff009688" /> |
||||
</shape> |
||||
</item> |
||||
<item> |
||||
<shape android:shape="rectangle"> |
||||
<solid android:color="#5a000000" /> |
||||
</shape> |
||||
</item> |
||||
</selector> |
@ -1,29 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Clover - 4chan browser https://github.com/Floens/Clover/ |
||||
Copyright (C) 2014 Floens |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<item android:state_pressed="true"> |
||||
<shape android:shape="rectangle"> |
||||
<solid android:color="#12000000" /> |
||||
</shape> |
||||
</item> |
||||
<item> |
||||
<shape android:shape="rectangle"> |
||||
<solid android:color="#00000000" /> |
||||
</shape> |
||||
</item> |
||||
</selector> |
Loading…
Reference in new issue