├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── FJMtSortButtonLib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── fj
│ │ └── mtsortbutton
│ │ └── lib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── fj
│ │ │ └── mtsortbutton
│ │ │ └── lib
│ │ │ ├── DynamicSoreView.java
│ │ │ ├── Interface
│ │ │ ├── IDynamicSore.java
│ │ │ └── ViewControl.java
│ │ │ ├── SoreButton.java
│ │ │ └── adapter
│ │ │ └── ViewPagerAdapter.java
│ └── res
│ │ ├── drawable-xhdpi
│ │ ├── radio_select.png
│ │ └── radio_unselected.png
│ │ ├── layout
│ │ ├── anfq_sore_button.xml
│ │ └── viewpager_default.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── fj
│ └── mtsortbutton
│ └── lib
│ └── ExampleUnitTest.java
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── fj
│ │ └── mtsortbutton
│ │ └── test
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── fj
│ │ │ └── mtsortbutton
│ │ │ └── test
│ │ │ ├── IndexActivity.java
│ │ │ ├── Main2Activity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── adapter
│ │ │ └── SortButtonAdapter.java
│ │ │ └── model
│ │ │ └── ButtonModel.java
│ └── res
│ │ ├── drawable-xhdpi
│ │ ├── icon_1.png
│ │ ├── icon_10.png
│ │ ├── icon_11.png
│ │ ├── icon_12.png
│ │ ├── icon_13.png
│ │ ├── icon_14.png
│ │ ├── icon_15.png
│ │ ├── icon_16.png
│ │ ├── icon_17.png
│ │ ├── icon_18.png
│ │ ├── icon_19.png
│ │ ├── icon_2.png
│ │ ├── icon_20.png
│ │ ├── icon_3.png
│ │ ├── icon_4.png
│ │ ├── icon_5.png
│ │ ├── icon_6.png
│ │ ├── icon_7.png
│ │ ├── icon_8.png
│ │ ├── icon_9.png
│ │ ├── radio1.png
│ │ └── radio2.png
│ │ ├── layout
│ │ ├── activity_index.xml
│ │ ├── activity_main.xml
│ │ ├── activity_main2.xml
│ │ ├── item_button.xml
│ │ ├── viewpager_page.xml
│ │ └── viewpager_page_text.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── fj
│ └── mtsortbutton
│ └── test
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:25.1.1'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\Android_install\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/androidTest/java/fj/mtsortbutton/lib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("fj.mtsortbutton.lib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/java/fj/mtsortbutton/lib/DynamicSoreView.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.GridView;
10 | import android.widget.ImageView;
11 | import android.widget.LinearLayout;
12 |
13 | import java.util.ArrayList;
14 | import java.util.HashMap;
15 | import java.util.List;
16 |
17 | import fj.mtsortbutton.lib.Interface.IDynamicSore;
18 | import fj.mtsortbutton.lib.Interface.ViewControl;
19 | import fj.mtsortbutton.lib.adapter.ViewPagerAdapter;
20 |
21 | /**
22 | * @author FengTong
23 | * @date 2017/6/1
24 | */
25 | public class DynamicSoreView extends LinearLayout {
26 | Context mContext;
27 | private ViewPager viewPager;
28 | private LinearLayout llIndicator;
29 |
30 | //选中点
31 | private int RadioSelect;
32 | //未选中点
33 | private int RadioUnselected;
34 | //圆点间距
35 | private int distance;
36 | //每页展示几个
37 | private int number;
38 | //展示数据的gridView
39 | private Integer gridView;
40 | //总页数
41 | private int page;
42 | //数据List
43 | private List dataList;
44 |
45 | List listSoreView = new ArrayList<>();
46 | View soreView;
47 |
48 |
49 | //接口
50 | private IDynamicSore iDynamicSore;
51 | //设置接口
52 | public IDynamicSore getiDynamicSore() {
53 | return iDynamicSore;
54 | }
55 |
56 | public void setiDynamicSore(IDynamicSore iDynamicSore) {
57 | this.iDynamicSore = iDynamicSore;
58 | }
59 |
60 | public DynamicSoreView(Context context, AttributeSet attrs) {
61 | super(context, attrs);
62 | mContext = context;
63 | LayoutInflater.from(context).inflate(R.layout.anfq_sore_button, this, true);
64 | viewPager = (ViewPager) findViewById(R.id.viewPager);
65 | llIndicator = (LinearLayout) findViewById(R.id.llIndicator);
66 |
67 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DynamicSoreView);
68 | if (typedArray != null) {
69 | //选中点
70 | RadioSelect = typedArray.getResourceId(R.styleable.DynamicSoreView_SoreRadioSelect, R.drawable.radio_select);
71 | //未选中点
72 | RadioUnselected = typedArray.getResourceId(R.styleable.DynamicSoreView_SoreRadioUnselected, R.drawable.radio_unselected);
73 | //圆点间距
74 | distance = typedArray.getInteger(R.styleable.DynamicSoreView_SoreDistance,10);
75 | //每页显示几个
76 | number = typedArray.getInteger(R.styleable.DynamicSoreView_SoreNumber,8);
77 | typedArray.recycle();
78 | }
79 |
80 | //设置空布局
81 | gridView = R.layout.viewpager_default;
82 | }
83 |
84 | //初始化ViewPager
85 | private void initViewPager(){
86 | listSoreView = new ArrayList<>();
87 | LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
88 | for (int i = 0; i < page; i++) {
89 | //循环拿到传入的View
90 | soreView = layoutInflater.inflate(gridView, null);
91 | //通过接口回掉的形式返回当前的View,实现接口后开源拿到每个View然后进行操作
92 | if (iDynamicSore!=null){
93 | List data;
94 | int total = dataList.size();
95 | if(i == page-1){
96 | //添加按钮
97 | data = new ArrayList<>();
98 | for(int j = i*number;j();
103 | int size;
104 | if(total< number){
105 | size = total;
106 | }else{
107 | size = (i+1)*number;
108 | }
109 | for(int j = i*number;j t){
198 | this.dataList = t;
199 | this.page = (int)Math.ceil((double) t.size()/number);//计算出有几页/这里用了ceil函数凑整,2.1=3
200 | initViewPager();
201 | return this;
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/java/fj/mtsortbutton/lib/Interface/IDynamicSore.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib.Interface;
2 |
3 | import android.view.View;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @author FengTong
9 | * @date 2017/6/1
10 | */
11 | public interface IDynamicSore {
12 | void setGridView(View view, int type, List data);
13 | }
14 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/java/fj/mtsortbutton/lib/Interface/ViewControl.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib.Interface;
2 |
3 | import android.view.View;
4 |
5 | public interface ViewControl {
6 | void setView(View view, int type);
7 | }
8 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/java/fj/mtsortbutton/lib/SoreButton.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.LinearLayout;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import fj.mtsortbutton.lib.Interface.ViewControl;
16 | import fj.mtsortbutton.lib.adapter.ViewPagerAdapter;
17 |
18 |
19 | public class SoreButton extends LinearLayout {
20 | Context mContext;
21 | private ViewPager viewPager;
22 | private LinearLayout llIndicator;
23 | //选中图片
24 | private int RadioSelect;
25 | //未选中图片
26 | private int RadioUnselected;
27 | //圆点间距
28 | private int distance;
29 |
30 | List listSoreView = new ArrayList<>();
31 | View soreView;
32 | private List listView;
33 |
34 | //接口
35 | private ViewControl viewControl;
36 | //设置接口
37 | public void setViewControl(ViewControl viewControl) {
38 | this.viewControl = viewControl;
39 | }
40 |
41 | public SoreButton(Context context) {
42 | super(context);
43 | }
44 |
45 | public SoreButton(Context context, AttributeSet attrs) {
46 | super(context, attrs);
47 | mContext = context;
48 | LayoutInflater.from(context).inflate(R.layout.anfq_sore_button, this, true);
49 | viewPager = (ViewPager) findViewById(R.id.viewPager);
50 | llIndicator = (LinearLayout) findViewById(R.id.llIndicator);
51 |
52 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DynamicSoreView);
53 | if (typedArray != null) {
54 | //选中点
55 | RadioSelect = typedArray.getResourceId(R.styleable.DynamicSoreView_SoreRadioSelect, R.drawable.radio_select);
56 | //未选中点
57 | RadioUnselected = typedArray.getResourceId(R.styleable.DynamicSoreView_SoreRadioUnselected, R.drawable.radio_unselected);
58 | //圆点间距
59 | distance = typedArray.getInteger(R.styleable.DynamicSoreView_SoreDistance,10);
60 | typedArray.recycle();
61 | }
62 | //设置空布局
63 | listView = new ArrayList<>();
64 | listView.add(R.layout.viewpager_default);
65 | }
66 |
67 | //初始化ViewPager
68 | private void initViewPager(){
69 | listSoreView = new ArrayList<>();
70 | LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
71 | int size = listView.size();
72 | for (int i = 0; i < size; i++) {
73 | //循环拿到传入的View
74 | soreView = layoutInflater.inflate(listView.get(i), null);
75 | //通过接口回掉的形式返回当前的View,实现接口后开源拿到每个View然后进行操作
76 | if (viewControl!=null){
77 | viewControl.setView(soreView,i);
78 | }
79 | //将获取到的View添加到List中
80 | listSoreView.add(soreView);
81 | }
82 | //设置viewPager的Adapter
83 | viewPager.setAdapter(new ViewPagerAdapter(listSoreView));
84 | //初始化LinearLayout,加入指示器
85 | initLinearLayout(viewPager, size, llIndicator);
86 | }
87 |
88 | /**
89 | * 设置指示器,设置ViewPager滑动事件监听
90 | * @param viewPager --ViewPager
91 | * @param pageSize --View的页数
92 | * @param linearLayout --LinearLayout
93 | */
94 | private void initLinearLayout(ViewPager viewPager, int pageSize, LinearLayout linearLayout) {
95 | linearLayout.removeAllViews();
96 | //定义数组放置指示器的点,pageSize是View个数
97 | final ImageView[] imageViews = new ImageView[pageSize];
98 | for (int i = 0; i < pageSize; i++) {
99 | //创建ImageView
100 | ImageView image = new ImageView(mContext);
101 | //将ImageView放入数组
102 | imageViews[i] = image;
103 | //默认选中第一个
104 | if (i == 0) {
105 | //选中的点
106 | image.setImageResource(RadioSelect);
107 | } else {
108 | //未选中的点
109 | image.setImageResource(RadioUnselected);
110 | }
111 | //设置宽高
112 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
113 | LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
114 | params.setMargins(distance, 0, distance, 0);
115 | //将点添加到LinearLayout中
116 | linearLayout.addView(image, params);
117 | }
118 |
119 | //ViewPager的滑动事件
120 | viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
121 | @Override
122 | public void onPageScrollStateChanged(int arg0) {}
123 | @Override
124 | public void onPageScrolled(int arg0, float arg1, int arg2) {}
125 | @Override
126 | public void onPageSelected(int arg0) {
127 | //arg0当前ViewPager
128 | for (int i = 0; i < imageViews.length; i++) {
129 | //设置为选中的点
130 | imageViews[arg0].setImageResource(RadioSelect);
131 | //判断当前的点i如果不等于当前页的话就设置为未选中
132 | if (arg0 != i) {
133 | imageViews[i].setImageResource(RadioUnselected);
134 | }
135 | }
136 | }
137 | });
138 | }
139 |
140 | /**
141 | * 设置圆点距离
142 | * @param distance --距离
143 | * @return
144 | */
145 | @Deprecated
146 | public SoreButton setDistance(int distance){
147 | this.distance = distance;
148 | return this;
149 | }
150 | /**
151 | * 设置指示器图片
152 | * @param radioSelect --选中图片
153 | * @param radioUnselected --未选中图片
154 | * @return
155 | */
156 | @Deprecated
157 | public SoreButton setIndicator(int radioSelect,int radioUnselected){
158 | //选中图片
159 | RadioSelect = radioSelect;
160 | //未选中图片
161 | RadioUnselected = radioUnselected;
162 | return this;
163 | }
164 | /**
165 | * 设置view
166 | * @param listView --view
167 | * @return
168 | */
169 | public SoreButton setView(List listView){
170 | this.listView = listView;
171 | return this;
172 | }
173 | /**
174 | * 设置初始化
175 | */
176 | public SoreButton init(){
177 | initViewPager();
178 | return this;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/java/fj/mtsortbutton/lib/adapter/ViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib.adapter;
2 |
3 | import android.support.v4.view.PagerAdapter;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | import java.util.List;
8 |
9 | public class ViewPagerAdapter extends PagerAdapter {
10 |
11 | private List views = null;
12 |
13 | public ViewPagerAdapter(List views) {
14 | this.views = views;
15 | }
16 |
17 | @Override
18 | public int getCount() {
19 | return views.size() > 0 ? views.size() : 0;
20 | }
21 |
22 | @Override
23 | public boolean isViewFromObject(View view, Object object) {
24 | return view == object;
25 | }
26 |
27 | @Override
28 | public Object instantiateItem(ViewGroup viewGroup, int i) {
29 | viewGroup.addView(views.get(i));
30 | return views.get(i);
31 | }
32 |
33 | @Override
34 | public void destroyItem(ViewGroup viewGroup, int i, Object object) {
35 | viewGroup.removeView(views.get(i));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/drawable-xhdpi/radio_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/FJMtSortButtonLib/src/main/res/drawable-xhdpi/radio_select.png
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/drawable-xhdpi/radio_unselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/FJMtSortButtonLib/src/main/res/drawable-xhdpi/radio_unselected.png
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/layout/anfq_sore_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/layout/viewpager_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FJMtSortButtonLib
3 |
4 |
--------------------------------------------------------------------------------
/FJMtSortButtonLib/src/test/java/fj/mtsortbutton/lib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.lib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > ## 栗子——高仿美团首页分类按钮(更灵活)
2 |
3 | ---
4 |
5 |
6 | > ### 栗子惯例,先上GIF
7 |
8 | 
9 |
10 |
11 |
12 | ## 使用姿势
13 |
14 | **引入(使用Gradle或者Maven)**
15 |
16 | 1)Gradle
17 |
18 | allprojects {
19 | repositories {
20 | ...
21 | maven { url 'https://jitpack.io' }
22 | }
23 | }
24 | dependencies {
25 | compile 'com.github.FJ917:FJMtSortButton:v1.1'
26 | }
27 | 2)Maven
28 |
29 |
30 |
31 | jitpack.io
32 | https://jitpack.io
33 |
34 |
35 |
36 |
37 | com.github.FJ917
38 | FJMtSortButton
39 | v1.1
40 |
41 |
42 | ---
43 |
44 | #### v1.1版本
45 | ## 新增自定义控件DynamicSoreView
46 | 实现通过服务器获取的数据,动态添加按钮,可以设置每页显示的个数。
47 | ## 使用方法
48 | 1)xml文件
49 | ```
50 |
59 | ```
60 | 2 )java
61 | ```
62 | private void data(){
63 | buttonList = setData();//模拟服务器获取到的按钮列表
64 | //设置界面监听
65 | dynamicSoreView.setiDynamicSore(this);
66 | //控件相关设置
67 | dynamicSoreView.setGridView(R.layout.viewpager_page).init(buttonList);
68 | }
69 |
70 |
71 | @Override
72 | public void setGridView(View view, final int type, List data) {
73 | List buttonModels= data;
74 | GridView gridView = (GridView) view.findViewById(R.id.gridView);
75 | dynamicSoreView.setNumColumns(gridView);
76 | SortButtonAdapter adapter = new SortButtonAdapter(this,buttonModels);
77 | gridView.setAdapter(adapter);
78 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
79 | @Override
80 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
81 | Toast.makeText(context,"第"+type+"页"+position,Toast.LENGTH_LONG).show();
82 | }
83 | });
84 | }
85 | ```
86 |
87 | #### 说明:修改了1.0里的使用方式,但原来的也可以用,详细参考1.0使用方法
88 | ---
89 |
90 | #### v1.0版本
91 |
92 | ## 使用方法
93 |
94 | 1)xml文件
95 | ```
96 |
97 |
102 |
103 |
111 | ```
112 |
113 | 2)java文件
114 | 1.对自定义控件做一些设置
115 |
116 | //设置界面监听
117 | soreButton.setViewControl(this);
118 | //添加界面到list
119 | list = new ArrayList<>();
120 | list.add(R.layout.viewpager_page);
121 | list.add(R.layout.viewpager_page);
122 | list.add(R.layout.viewpager_page_text);
123 |
124 | //控件相关设置
125 | //以前
126 | soreButton
127 | //设置选中和未选中指示器图标
128 | .setIndicator(R.drawable.radio1,R.drawable.radio2)
129 | //设置指示器半间距px
130 | .setDistance(10)
131 | //设置view组
132 | .setView(list)
133 | .init();
134 | //修改(废弃了设置参数的方法,但是也可以用,只是建议在xml设置)
135 | soreButton.setView(list).init();
136 | 将layout的布局add进去list中,然后调用setView方法把list传过去,
137 | 还提供了设置指示器图标的方法,以及指示器间距的方法,最后必须调用初始化方法init进行初始化
138 |
139 |
140 | 这是其中的一个layout布局,其实这里可以添加任意布局文件进去,是不是比美团更灵活呢?
141 | `布局R.layout.viewpager_page`
142 |
143 |
144 |
149 |
150 |
160 |
161 |
162 |
163 | 2.设置soreButton监听事件(具体的可以参考GIt里面的Demo)
164 |
165 | public class MainActivity extends AppCompatActivity implements ViewControl {
166 |
167 | private SoreButton soreButton;
168 | @Override
169 | protected void onCreate(Bundle savedInstanceState) {
170 | super.onCreate(savedInstanceState);
171 | setContentView(R.layout.activity_main);
172 | soreButton = (SoreButton) findViewById(R.id.soreButton);
173 |
174 | soreButton.setViewControl(this);
175 | }
176 |
177 | @Override
178 | public void setView(View view, final int type) {
179 | //这里会返回前面设置进去的View及对应的type,然后就可以进行操作了
180 | }
181 | }
182 |
183 | **划重点:上面的list中可以传入任意layout布局,然后通过接口回掉拿到View。比美团更加灵活。**
184 |
185 | **[博客地址](http://www.jianshu.com/p/e1631a8fab68)**
186 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "fj.mtsortbutton.test"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.1.1'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':FJMtSortButtonLib')
30 | }
31 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\Android_install\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/fj/mtsortbutton/test/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("fj.mtsortbutton.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/fj/mtsortbutton/test/IndexActivity.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | public class IndexActivity extends AppCompatActivity implements View.OnClickListener{
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_index);
15 | findViewById(R.id.btn1).setOnClickListener(this);
16 | findViewById(R.id.btn2).setOnClickListener(this);
17 | }
18 |
19 | @Override
20 | public void onClick(View v) {
21 | switch (v.getId()){
22 | case R.id.btn1:
23 | startActivity(new Intent(this,MainActivity.class));
24 | break;
25 | case R.id.btn2:
26 | startActivity(new Intent(this,Main2Activity.class));
27 | break;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/fj/mtsortbutton/test/Main2Activity.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test;
2 |
3 | import android.content.Context;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.Button;
9 | import android.widget.GridView;
10 | import android.widget.Toast;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import fj.mtsortbutton.lib.DynamicSoreView;
16 | import fj.mtsortbutton.lib.Interface.IDynamicSore;
17 | import fj.mtsortbutton.test.adapter.SortButtonAdapter;
18 | import fj.mtsortbutton.test.model.ButtonModel;
19 |
20 | public class Main2Activity extends AppCompatActivity implements IDynamicSore {
21 |
22 | private Context context;
23 | private DynamicSoreView dynamicSoreView;
24 | private List list;
25 |
26 | List buttonList;
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_main2);
31 | context = this;
32 | dynamicSoreView = (DynamicSoreView) findViewById(R.id.dynamicSoreView);
33 |
34 | data();
35 | Button button = (Button) findViewById(R.id.btn);
36 | button.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 | data();
40 | }
41 | });
42 | }
43 |
44 | private void data(){
45 | buttonList = setData();//模拟服务器获取到的按钮列表
46 | //设置界面监听
47 | dynamicSoreView.setiDynamicSore(this);
48 | //控件相关设置
49 | dynamicSoreView.setGridView(R.layout.viewpager_page).init(buttonList);
50 | }
51 |
52 |
53 | @Override
54 | public void setGridView(View view, final int type, List data) {
55 | List buttonModels= data;
56 | GridView gridView = (GridView) view.findViewById(R.id.gridView);
57 | dynamicSoreView.setNumColumns(gridView);
58 | SortButtonAdapter adapter = new SortButtonAdapter(this,buttonModels);
59 | gridView.setAdapter(adapter);
60 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
61 | @Override
62 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
63 | Toast.makeText(context,"第"+type+"页"+position,Toast.LENGTH_LONG).show();
64 | }
65 | });
66 | }
67 |
68 | private List setData(){
69 | List data = new ArrayList<>();
70 | ButtonModel buttonModel = new ButtonModel();
71 | buttonModel.setDrawableIcon(R.drawable.icon_1);
72 | buttonModel.setName("美食");
73 | data.add(buttonModel);
74 |
75 | buttonModel = new ButtonModel();
76 | buttonModel.setDrawableIcon(R.drawable.icon_2);
77 | buttonModel.setName("电影");
78 | data.add(buttonModel);
79 | buttonModel = new ButtonModel();
80 | buttonModel.setDrawableIcon(R.drawable.icon_3);
81 | buttonModel.setName("酒店");
82 | data.add(buttonModel);
83 | buttonModel = new ButtonModel();
84 | buttonModel.setDrawableIcon(R.drawable.icon_4);
85 | buttonModel.setName("休闲娱乐");
86 | data.add(buttonModel);
87 | buttonModel = new ButtonModel();
88 | buttonModel.setDrawableIcon(R.drawable.icon_5);
89 | buttonModel.setName("外卖");
90 | data.add(buttonModel);
91 | buttonModel = new ButtonModel();
92 | buttonModel.setDrawableIcon(R.drawable.icon_6);
93 | buttonModel.setName("机票/火车票");
94 | data.add(buttonModel);
95 | buttonModel = new ButtonModel();
96 | buttonModel.setDrawableIcon(R.drawable.icon_7);
97 | buttonModel.setName("KTV");
98 | data.add(buttonModel);
99 | buttonModel = new ButtonModel();
100 | buttonModel.setDrawableIcon(R.drawable.icon_8);
101 | buttonModel.setName("周边游");
102 | data.add(buttonModel);
103 | buttonModel = new ButtonModel();
104 | buttonModel.setDrawableIcon(R.drawable.icon_9);
105 | buttonModel.setName("丽人");
106 | data.add(buttonModel);
107 | buttonModel = new ButtonModel();
108 | buttonModel.setDrawableIcon(R.drawable.icon_10);
109 | buttonModel.setName("旅游出行");
110 | data.add(buttonModel);
111 |
112 | buttonModel = new ButtonModel();
113 | buttonModel.setDrawableIcon(R.drawable.icon_11);
114 | buttonModel.setName("品质酒店");
115 | data.add(buttonModel);
116 | buttonModel = new ButtonModel();
117 | buttonModel.setDrawableIcon(R.drawable.icon_12);
118 | buttonModel.setName("生活服务");
119 | data.add(buttonModel);
120 | buttonModel = new ButtonModel();
121 | buttonModel.setDrawableIcon(R.drawable.icon_13);
122 | buttonModel.setName("足疗按摩");
123 | data.add(buttonModel);
124 | buttonModel = new ButtonModel();
125 | buttonModel.setDrawableIcon(R.drawable.icon_14);
126 | buttonModel.setName("母婴亲子");
127 | data.add(buttonModel);
128 | buttonModel = new ButtonModel();
129 | buttonModel.setDrawableIcon(R.drawable.icon_15);
130 | buttonModel.setName("结婚");
131 | data.add(buttonModel);
132 | buttonModel = new ButtonModel();
133 | buttonModel.setDrawableIcon(R.drawable.icon_16);
134 | buttonModel.setName("景点");
135 | data.add(buttonModel);
136 | buttonModel = new ButtonModel();
137 | buttonModel.setDrawableIcon(R.drawable.icon_17);
138 | buttonModel.setName("温泉");
139 | data.add(buttonModel);
140 | buttonModel = new ButtonModel();
141 | buttonModel.setDrawableIcon(R.drawable.icon_18);
142 | buttonModel.setName("学习培训");
143 | data.add(buttonModel);
144 | buttonModel = new ButtonModel();
145 | buttonModel.setDrawableIcon(R.drawable.icon_19);
146 | buttonModel.setName("洗浴/汗蒸");
147 | data.add(buttonModel);
148 | buttonModel = new ButtonModel();
149 | buttonModel.setDrawableIcon(R.drawable.icon_20);
150 | buttonModel.setName("全部分类");
151 | data.add(buttonModel);
152 | return data;
153 | }
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/app/src/main/java/fj/mtsortbutton/test/MainActivity.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test;
2 |
3 | import android.content.Context;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.GridView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import java.util.ArrayList;
13 | import java.util.HashMap;
14 | import java.util.List;
15 |
16 | import fj.mtsortbutton.lib.Interface.ViewControl;
17 | import fj.mtsortbutton.lib.SoreButton;
18 | import fj.mtsortbutton.test.adapter.SortButtonAdapter;
19 | import fj.mtsortbutton.test.model.ButtonModel;
20 |
21 | public class MainActivity extends AppCompatActivity implements ViewControl {
22 |
23 | private Context context;
24 | private SoreButton soreButton;
25 | private List list;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_main);
31 | context = this;
32 | soreButton = (SoreButton) findViewById(R.id.soreButton);
33 |
34 | //设置界面监听
35 | soreButton.setViewControl(this);
36 | //添加界面到list
37 | list = new ArrayList<>();
38 | list.add(R.layout.viewpager_page);
39 | list.add(R.layout.viewpager_page);
40 | list.add(R.layout.viewpager_page_text);
41 |
42 | //控件相关设置
43 | // soreButton
44 | // //设置选中和未选中指示器图标
45 | // .setIndicator(R.drawable.radio1,R.drawable.radio2)
46 | // //设置指示器半间距px
47 | // .setDistance(10)
48 | // //设置view组
49 | // .setView(list)
50 | // .init();
51 | soreButton.setView(list).init();
52 | }
53 |
54 | @Override
55 | public void setView(View view, final int type) {
56 | switch (type) {
57 | case 0://第一个界面
58 | GridView gridView = (GridView) view.findViewById(R.id.gridView);
59 | SortButtonAdapter adapter = new SortButtonAdapter(this,setData());
60 | gridView.setAdapter(adapter);
61 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
62 | @Override
63 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
64 | Toast.makeText(context,"第"+type+"页"+position,Toast.LENGTH_LONG).show();
65 | }
66 | });
67 | break;
68 | case 1://第二个界面
69 | GridView gridView2 = (GridView) view.findViewById(R.id.gridView);
70 | SortButtonAdapter adapter2 = new SortButtonAdapter(this,setData2());
71 | gridView2.setAdapter(adapter2);
72 | gridView2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
73 | @Override
74 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
75 | Toast.makeText(context,"第"+type+"页"+position,Toast.LENGTH_LONG).show();
76 | }
77 | });
78 | break;
79 | case 2://第三个界面
80 | TextView tvTitle = (TextView) view.findViewById(R.id.tvTitle);
81 | tvTitle.setText("可高度定制,可设置任意layout,并且在回调中获取该layout内的所有控件");
82 | tvTitle.setOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View v) {
85 | Toast.makeText(context,"点击了该文字",Toast.LENGTH_LONG).show();
86 | }
87 | });
88 | break;
89 | }
90 | }
91 |
92 | private List setData(){
93 | List data = new ArrayList<>();
94 | ButtonModel buttonModel = new ButtonModel();
95 | buttonModel.setDrawableIcon(R.drawable.icon_1);
96 | buttonModel.setName("美食");
97 | data.add(buttonModel);
98 |
99 | buttonModel = new ButtonModel();
100 | buttonModel.setDrawableIcon(R.drawable.icon_2);
101 | buttonModel.setName("电影");
102 | data.add(buttonModel);
103 | buttonModel = new ButtonModel();
104 | buttonModel.setDrawableIcon(R.drawable.icon_3);
105 | buttonModel.setName("酒店");
106 | data.add(buttonModel);
107 | buttonModel = new ButtonModel();
108 | buttonModel.setDrawableIcon(R.drawable.icon_4);
109 | buttonModel.setName("休闲娱乐");
110 | data.add(buttonModel);
111 | buttonModel = new ButtonModel();
112 | buttonModel.setDrawableIcon(R.drawable.icon_5);
113 | buttonModel.setName("外卖");
114 | data.add(buttonModel);
115 | buttonModel = new ButtonModel();
116 | buttonModel.setDrawableIcon(R.drawable.icon_6);
117 | buttonModel.setName("机票/火车票");
118 | data.add(buttonModel);
119 | buttonModel = new ButtonModel();
120 | buttonModel.setDrawableIcon(R.drawable.icon_7);
121 | buttonModel.setName("KTV");
122 | data.add(buttonModel);
123 | buttonModel = new ButtonModel();
124 | buttonModel.setDrawableIcon(R.drawable.icon_8);
125 | buttonModel.setName("周边游");
126 | data.add(buttonModel);
127 | buttonModel = new ButtonModel();
128 | buttonModel.setDrawableIcon(R.drawable.icon_9);
129 | buttonModel.setName("丽人");
130 | data.add(buttonModel);
131 | buttonModel = new ButtonModel();
132 | buttonModel.setDrawableIcon(R.drawable.icon_10);
133 | buttonModel.setName("旅游出行");
134 | data.add(buttonModel);
135 | return data;
136 | }
137 |
138 | private List setData2(){
139 | List data = new ArrayList<>();
140 | ButtonModel buttonModel = new ButtonModel();
141 | buttonModel.setDrawableIcon(R.drawable.icon_11);
142 | buttonModel.setName("品质酒店");
143 | data.add(buttonModel);
144 | buttonModel = new ButtonModel();
145 | buttonModel.setDrawableIcon(R.drawable.icon_12);
146 | buttonModel.setName("生活服务");
147 | data.add(buttonModel);
148 | buttonModel = new ButtonModel();
149 | buttonModel.setDrawableIcon(R.drawable.icon_13);
150 | buttonModel.setName("足疗按摩");
151 | data.add(buttonModel);
152 | buttonModel = new ButtonModel();
153 | buttonModel.setDrawableIcon(R.drawable.icon_14);
154 | buttonModel.setName("母婴亲子");
155 | data.add(buttonModel);
156 | buttonModel = new ButtonModel();
157 | buttonModel.setDrawableIcon(R.drawable.icon_15);
158 | buttonModel.setName("结婚");
159 | data.add(buttonModel);
160 | buttonModel = new ButtonModel();
161 | buttonModel.setDrawableIcon(R.drawable.icon_16);
162 | buttonModel.setName("景点");
163 | data.add(buttonModel);
164 | buttonModel = new ButtonModel();
165 | buttonModel.setDrawableIcon(R.drawable.icon_17);
166 | buttonModel.setName("温泉");
167 | data.add(buttonModel);
168 | buttonModel = new ButtonModel();
169 | buttonModel.setDrawableIcon(R.drawable.icon_18);
170 | buttonModel.setName("学习培训");
171 | data.add(buttonModel);
172 | buttonModel = new ButtonModel();
173 | buttonModel.setDrawableIcon(R.drawable.icon_19);
174 | buttonModel.setName("洗浴/汗蒸");
175 | data.add(buttonModel);
176 | buttonModel = new ButtonModel();
177 | buttonModel.setDrawableIcon(R.drawable.icon_20);
178 | buttonModel.setName("全部分类");
179 | data.add(buttonModel);
180 | return data;
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/java/fj/mtsortbutton/test/adapter/SortButtonAdapter.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | import fj.mtsortbutton.test.R;
14 | import fj.mtsortbutton.test.model.ButtonModel;
15 |
16 | public class SortButtonAdapter extends BaseAdapter {
17 | private Context mContext;
18 | private LayoutInflater inflater;
19 | private List data;
20 | public SortButtonAdapter(Context context, List data) {
21 | this.mContext = context;
22 | this.inflater = LayoutInflater.from(context);
23 | this.data = data;
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return data.size();
29 | }
30 |
31 | @Override
32 | public Object getItem(int position) {
33 | return position;
34 | }
35 |
36 | @Override
37 | public long getItemId(int position) {
38 | return position;
39 | }
40 |
41 | @Override
42 | public View getView(int position, View view, ViewGroup parent) {
43 | ViewHolder holder;
44 | if (null == view) {
45 | view = inflater.inflate(R.layout.item_button, null);
46 | holder = new ViewHolder();
47 | holder.icon = (ImageView) view.findViewById(R.id.icon);
48 | holder.name = (TextView) view.findViewById(R.id.name);
49 | view.setTag(holder);
50 | } else {
51 | holder = (ViewHolder) view.getTag();
52 | }
53 | holder.name.setText(data.get(position).getName());
54 | holder.icon.setImageResource(data.get(position).getDrawableIcon());
55 | return view;
56 | }
57 | class ViewHolder {
58 | ImageView icon;
59 | TextView name;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/fj/mtsortbutton/test/model/ButtonModel.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test.model;
2 |
3 | /**
4 | * @author FengTong
5 | * @date 2017/6/1
6 | */
7 | public class ButtonModel {
8 | private int id;
9 | private int drawableIcon;
10 | private String urlIcon;
11 | private String name;
12 |
13 | public int getId() {
14 | return id;
15 | }
16 |
17 | public void setId(int id) {
18 | this.id = id;
19 | }
20 |
21 | public int getDrawableIcon() {
22 | return drawableIcon;
23 | }
24 |
25 | public void setDrawableIcon(int drawableIcon) {
26 | this.drawableIcon = drawableIcon;
27 | }
28 |
29 | public String getUrlIcon() {
30 | return urlIcon;
31 | }
32 |
33 | public void setUrlIcon(String urlIcon) {
34 | this.urlIcon = urlIcon;
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_10.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_11.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_12.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_13.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_14.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_15.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_16.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_17.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_18.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_19.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_20.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_6.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_7.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_8.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/icon_9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/radio1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/radio1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/radio2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/drawable-xhdpi/radio2.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_index.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/viewpager_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/viewpager_page_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FJMtSortButton
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/fj/mtsortbutton/test/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package fj.mtsortbutton.test;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FJ917/FJMtSortButton/64620c5386efb1c0f579ffdca78406aa8648bf02/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':FJMtSortButtonLib'
2 |
--------------------------------------------------------------------------------