├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── src
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── wy
│ │ │ └── flowlayoutusedemo
│ │ │ └── ExampleInstrumentedTest.java
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── wy
│ │ │ │ └── flowlayoutusedemo
│ │ │ │ ├── Button1Activity.java
│ │ │ │ ├── Button2Activity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── util
│ │ │ │ ├── SharedPreferencesUtil.java
│ │ │ │ └── ToastUtil.java
│ │ └── res
│ │ │ ├── color
│ │ │ └── select_flowlayout_textview_color.xml
│ │ │ ├── drawable
│ │ │ ├── logo.png
│ │ │ ├── select_flowlayout_textview_bg.xml
│ │ │ ├── shape_circle_corner_blue.xml
│ │ │ ├── shape_circle_corner_blue3.xml
│ │ │ ├── shape_circle_corner_blue5.xml
│ │ │ ├── shape_circle_corner_blue_checked.xml
│ │ │ └── shape_circle_corner_white.xml
│ │ │ ├── layout
│ │ │ ├── activity_button1.xml
│ │ │ ├── activity_button2.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── flowlayout_textview.xml
│ │ │ ├── flowlayout_textview_no_selected.xml
│ │ │ └── flowlayout_textview_selected.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── titlebar_back.png
│ │ │ ├── titlebar_bg.png
│ │ │ └── titlebar_search.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── titlebar_back.png
│ │ │ ├── titlebar_bg.png
│ │ │ └── titlebar_search.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── titlebar_back.png
│ │ │ ├── titlebar_bg.png
│ │ │ └── titlebar_search.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── wy
│ │ └── flowlayoutusedemo
│ │ └── ExampleUnitTest.java
├── 产品标签.gif
└── 本地历史记录.gif
├── 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 |
17 |
18 |
--------------------------------------------------------------------------------
/.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 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FlowLayouUseDemo
2 |
Android 本地历史记录、及产品标签(支持单选、多选)实现(使用鸿洋大神的FlowLayout开源库),主要功能:FlowLayout的使用、从SP中读取历史记录、将历史记录写入到SP中、历史记录最大数量限制、历史记录不可重复、最新查询的在最前边、清楚历史记录;FlowLayout预先设置选中、设置最大选中数、设置标签点击和选中监听、获取选中的标签、通过selecter完成标签选择的切换等。
项目博客地址:https://blog.csdn.net/qq941263013/article/details/81223574
个人博客地址:https://blog.csdn.net/qq941263013
本地历史记录的GIF效果图:

产品标签(单选、多选)GIF效果图:

本地历史记录功能的简单说明(详细描述见博客、源码):
1.页面布局:主要是在布局文件中使用TagFlowLayout实现流失布局,并通过自定义属性(zhy:max_select="0")规定标签的最大可选数。
2.定义从SP中读取历史记录方法:从SP中获取存储的字符串,并通过wy标识将字符串分割为字符串数组,然后添加到List中,最后将list返回。
3.定义将历史记录写入到SP中方法:先判空,不为空则获取已有的历史记录,再将新的历史记录添加list中,最后把list转换成字符串(添加wy标识)存入到SP中。需要注意的是:1.历史记录最大数量限制,2.历史记录不可重复,3.最新查询的在最前边。
4.初始化历史记录:先通过本地历史记录判断页面的显示与隐藏,在为FlowLayout填充数据、设置点击事件监听。
5.点击搜索按钮:首先获取输入框中的内容,然后添加到本地历史记录中,最后再调用initHistory()刷新页面数据。具体的搜索逻辑就不写了,不是重点。
6.清除历史记录:将本地历史记录置为空字符串,再调用initHistory()刷新页面数据即可,大功告成。
3 |
4 |
--------------------------------------------------------------------------------
/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 "com.wy.flowlayoutusedemo"
8 | minSdkVersion 16
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(dir: 'libs', include: ['*.jar'])
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.3.1'
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.hyman:flowlayout-lib:1.1.2'
30 | compile 'com.jakewharton:butterknife:8.8.1'
31 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
32 | }
33 |
--------------------------------------------------------------------------------
/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 C:\Users\ZQZY-102\AppData\Local\Android\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/com/wy/flowlayoutusedemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo;
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("com.wy.flowlayoutusedemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wy/flowlayoutusedemo/Button1Activity.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo;
2 |
3 | import android.content.Context;
4 | import android.graphics.Paint;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.text.TextUtils;
9 | import android.view.View;
10 | import android.widget.EditText;
11 | import android.widget.ImageView;
12 | import android.widget.LinearLayout;
13 | import android.widget.RelativeLayout;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 |
17 | import com.wy.flowlayoutusedemo.util.SharedPreferencesUtil;
18 | import com.wy.flowlayoutusedemo.util.ToastUtil;
19 | import com.zhy.view.flowlayout.FlowLayout;
20 | import com.zhy.view.flowlayout.TagAdapter;
21 | import com.zhy.view.flowlayout.TagFlowLayout;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import butterknife.BindView;
27 | import butterknife.ButterKnife;
28 | import butterknife.OnClick;
29 |
30 | /**
31 | * Created by WY on 2018/7/25.
32 | * 本地历史记录
33 | */
34 | public class Button1Activity extends AppCompatActivity {
35 |
36 | @BindView(R.id.tv_titlebar_center)
37 | TextView tvTitlebarCenter;
38 | @BindView(R.id.iv_titlebar_left)
39 | ImageView ivTitlebarLeft;
40 | @BindView(R.id.rl)
41 | RelativeLayout rl;
42 | @BindView(R.id.iv_search)
43 | ImageView ivSearch;
44 | @BindView(R.id.et_search)
45 | EditText etSearch;
46 | @BindView(R.id.rl_search)
47 | RelativeLayout rlSearch;
48 | @BindView(R.id.flowlayout_history)
49 | TagFlowLayout flowlayoutHistory;
50 | @BindView(R.id.tv_clear)
51 | TextView tvClear;
52 | @BindView(R.id.ll_history)
53 | LinearLayout llHistory;
54 | private Context context;
55 |
56 | @Override
57 | protected void onCreate(@Nullable Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | setContentView(R.layout.activity_button1);
60 | ButterKnife.bind(this);
61 | context = this;
62 |
63 | //测试数据
64 | String testData = "活着wy1234567890wyISBNwy中华人民共和国wy唉wysfsfsfswy1wy搜索wy尴尬啦wy活着啊";
65 | SharedPreferencesUtil.putString(context, "search_history", testData);
66 |
67 | initUI();
68 | initHistory();
69 | }
70 |
71 | /**
72 | * 初始化UI
73 | */
74 | private void initUI() {
75 | //下划线
76 | tvClear.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
77 | }
78 |
79 | @OnClick({R.id.iv_titlebar_left, R.id.iv_search, R.id.tv_clear})
80 | public void onViewClicked(View view) {
81 | switch (view.getId()) {
82 | case R.id.iv_titlebar_left://返回
83 | finish();
84 | break;
85 | case R.id.iv_search://搜索
86 | initSearch();
87 | break;
88 | case R.id.tv_clear://清除历史记录
89 | SharedPreferencesUtil.putString(context, "search_history", "");
90 | initHistory();
91 | break;
92 | }
93 | }
94 |
95 | /**
96 | * 初始化历史记录
97 | */
98 | private void initHistory() {
99 | final List readHistory = readHistory();
100 | if (readHistory != null && readHistory.size() > 0) {
101 | llHistory.setVisibility(View.VISIBLE);
102 | } else {
103 | llHistory.setVisibility(View.GONE);
104 | }
105 |
106 | //为FlowLayout填充数据
107 | flowlayoutHistory.setAdapter(new TagAdapter(readHistory) {
108 | @Override
109 | public View getView(FlowLayout parent, int position, Object o) {
110 |
111 | TextView view = (TextView) View.inflate(context, R.layout.flowlayout_textview, null);
112 | view.setText(readHistory.get(position));
113 | return view;
114 | }
115 | });
116 |
117 | //为FlowLayout的标签设置监听事件
118 | flowlayoutHistory.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
119 | @Override
120 | public boolean onTagClick(View view, int position, FlowLayout parent) {
121 | ToastUtil.makeText(context, readHistory.get(position));
122 | etSearch.setText(readHistory.get(position));
123 | etSearch.setSelection(readHistory.get(position).length());
124 | return true;
125 | }
126 | });
127 | }
128 |
129 | /**
130 | * 从SP中读取历史记录
131 | */
132 | private List readHistory() {
133 | List readHistoryList = new ArrayList<>();
134 | String search_history = SharedPreferencesUtil.getString(context, "search_history", null);
135 |
136 | //将String转为List
137 | if (!TextUtils.isEmpty(search_history)) {
138 | String[] strs = search_history.split("wy");
139 | for (int i = 0; i < strs.length; i++) {
140 | readHistoryList.add(i, strs[i]);
141 | }
142 | }
143 |
144 | return readHistoryList;
145 | }
146 |
147 | /**
148 | * 将历史记录写入到SP中
149 | */
150 | private void writeHistory(String write) {
151 | if (TextUtils.isEmpty(write)) {
152 | return;
153 | }
154 |
155 | String writeHistory = "";
156 | //获取历史记录
157 | List readHistoryList = readHistory();
158 |
159 | //如果不重复,则添加为第一个历史记录;
160 | //如果重复,则删除已有,再添加为第一个历史记录;
161 | for (int i = 0; i < readHistoryList.size(); i++) {
162 | boolean hasWrite = readHistoryList.get(i).equals(write);
163 | if (hasWrite) {
164 | readHistoryList.remove(i);
165 | break;
166 | }
167 | }
168 | readHistoryList.add(0, write);
169 |
170 | //历史记录最多为10个
171 | if (readHistoryList.size() > 10) {
172 | readHistoryList = readHistoryList.subList(0, 10);
173 | }
174 |
175 | //将ArrayList转为String
176 | for (int i = 0; i < readHistoryList.size(); i++) {
177 | writeHistory += readHistoryList.get(i) + "wy";
178 | }
179 | SharedPreferencesUtil.putString(context, "search_history", writeHistory);
180 | }
181 |
182 | /**
183 | * 初始化搜索
184 | */
185 | private void initSearch() {
186 | String inputSearch = etSearch.getText().toString().trim();
187 | if (TextUtils.isEmpty(inputSearch)) {
188 | ToastUtil.makeText(context, "请输入要查询的条码");
189 | return;
190 | }
191 | writeHistory(inputSearch);
192 | initHistory();
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wy/flowlayoutusedemo/Button2Activity.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.wy.flowlayoutusedemo.util.ToastUtil;
11 | import com.zhy.view.flowlayout.FlowLayout;
12 | import com.zhy.view.flowlayout.TagAdapter;
13 | import com.zhy.view.flowlayout.TagFlowLayout;
14 |
15 | import java.util.Iterator;
16 | import java.util.Set;
17 |
18 | import butterknife.BindView;
19 | import butterknife.ButterKnife;
20 |
21 | /**
22 | * Created by WY on 2018/7/26.
23 | * 标签(单选、多选)
24 | * ##特色
25 | * 以setAdapter形式注入数据
26 | * 直接设置selector为background即可完成标签选则的切换,类似CheckBox
27 | * 支持控制选择的Tag数量,比如:单选、多选
28 | * 支持setOnTagClickListener,当点击某个Tag回调
29 | * 支持setOnSelectListener,当选择某个Tag后回调
30 | * 支持adapter.notifyDataChanged
31 | * Activity重建(或者旋转)后,选择的状态自动保存
32 | */
33 | public class Button2Activity extends AppCompatActivity {
34 |
35 | @BindView(R.id.flowlayout)
36 | TagFlowLayout flowlayout;
37 | @BindView(R.id.tv_selected)
38 | TextView tvSelected;
39 | @BindView(R.id.flowlayout_selected)
40 | TagFlowLayout flowlayoutSelected;
41 | private Context context;
42 | private String[] mVals = new String[]
43 | {"Hello", "Android", "Weclome Hi ", "Button", "TextView", "Hello",
44 | "Android", "Weclome", "Button ImageView", "TextView", "Helloworld",
45 | "Android", "Weclome Hello", "Button Text", "TextView"};
46 | private int maxSelected = 5;
47 | private Set selectedList;
48 | private String[] mValsSelected;
49 |
50 | @Override
51 | protected void onCreate(@Nullable Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 | setContentView(R.layout.activity_button2);
54 | ButterKnife.bind(this);
55 | context = this;
56 |
57 | initFlowLayout();
58 | initFlowLayoutSelected();
59 | }
60 |
61 | /**
62 | * 初始化所有标签的FlowLayout
63 | */
64 | private void initFlowLayout() {
65 | TagAdapter tagAdapter = new TagAdapter(mVals) {
66 | @Override
67 | public View getView(FlowLayout parent, int position, Object o) {
68 |
69 | TextView view = (TextView) View.inflate(context, R.layout.flowlayout_textview_selected, null);
70 | view.setText(mVals[position]);
71 | return view;
72 | }
73 | };
74 | //预先设置选中
75 | tagAdapter.setSelectedList(0, 1);
76 | flowlayout.setAdapter(tagAdapter);
77 |
78 | //设置最大选中数
79 | flowlayout.setMaxSelectCount(maxSelected);
80 |
81 | //为FlowLayout的标签设置监听事件
82 | flowlayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
83 | @Override
84 | public boolean onTagClick(View view, int position, FlowLayout parent) {
85 | if (selectedList.size() >= maxSelected) {
86 | ToastUtil.makeText(context, "已达最大选中数" + maxSelected);
87 | } else {
88 | ToastUtil.makeText(context, mVals[position]);
89 | }
90 | return true;
91 | }
92 | });
93 |
94 | //为FlowLayout的标签设置选中监听事件
95 | flowlayout.setOnSelectListener(new TagFlowLayout.OnSelectListener() {
96 | @Override
97 | public void onSelected(Set selectPosSet) {
98 | initFlowLayoutSelected();
99 | }
100 | });
101 | }
102 |
103 | /**
104 | * 初始化选中标签的FlowLayout
105 | */
106 | private void initFlowLayoutSelected() {
107 | int i = 0;
108 | //获得所有选中的position集合,例如[1,2,3,4]
109 | selectedList = flowlayout.getSelectedList();
110 | mValsSelected = new String[selectedList.size()];
111 | Iterator iterator = selectedList.iterator();
112 | while (iterator.hasNext()) {
113 | mValsSelected[i] = mVals[iterator.next()];
114 | i++;
115 | }
116 |
117 | tvSelected.setText("最大选中数为:" + maxSelected + "(已选中" + selectedList.size() + ")" + "(position:" + selectedList.toString() + ")");
118 | flowlayoutSelected.setAdapter(new TagAdapter(mValsSelected) {
119 | @Override
120 | public View getView(FlowLayout parent, int position, Object o) {
121 |
122 | TextView view = (TextView) View.inflate(context, R.layout.flowlayout_textview_no_selected, null);
123 | view.setText(mValsSelected[position]);
124 | return view;
125 | }
126 | });
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wy/flowlayoutusedemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import butterknife.BindView;
10 | import butterknife.ButterKnife;
11 | import butterknife.OnClick;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | @BindView(R.id.btn1)
16 | Button btn1;
17 | @BindView(R.id.btn2)
18 | Button btn2;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 | ButterKnife.bind(this);
25 | }
26 |
27 | @OnClick({R.id.btn1, R.id.btn2})
28 | public void onViewClicked(View view) {
29 | switch (view.getId()) {
30 | case R.id.btn1://本地历史记录
31 | startActivity(new Intent(getApplicationContext(),Button1Activity.class));
32 | break;
33 | case R.id.btn2://标签(单选、多选)
34 | startActivity(new Intent(getApplicationContext(),Button2Activity.class));
35 | break;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wy/flowlayoutusedemo/util/SharedPreferencesUtil.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * SharedPreferences:共享偏好,用来做数据存储,通过xml,存放标记性数据和设置信息
8 | */
9 | public class SharedPreferencesUtil {
10 | private static SharedPreferences sharedPreferences;
11 |
12 | /**写入Boolean变量至sharedPreferences中
13 | * @param context 上下文环境
14 | * @param key 存储节点名称
15 | * @param value 存储节点的值
16 | */
17 | public static void putBoolean(Context context,String key,Boolean value){
18 | //(存储节点文件名称,读写方式)
19 | if (sharedPreferences == null){
20 | sharedPreferences = context.getSharedPreferences("config",Context.MODE_PRIVATE);
21 | }
22 | sharedPreferences.edit().putBoolean(key,value).commit();
23 | }
24 |
25 | /**读取boolean标识从sharedPreferences中
26 | * @param context 上下文环境
27 | * @param key 存储节点名称
28 | * @param value 没有此节点的默认值
29 | * @return 默认值或者此节点读取到的结果
30 | */
31 | public static boolean getBoolean(Context context, String key, Boolean value){
32 | //(存储节点文件名称,读写方式)
33 | if (sharedPreferences == null){
34 | sharedPreferences = context.getSharedPreferences("config",Context.MODE_PRIVATE);
35 | }
36 | return sharedPreferences.getBoolean(key,value);
37 | }
38 |
39 | /**写入String变量至sharedPreferences中
40 | * @param context 上下文环境
41 | * @param key 存储节点名称
42 | * @param value 存储节点的值String
43 | */
44 | public static void putString(Context context,String key,String value){
45 | //存储节点文件的名称,读写方式
46 | if(sharedPreferences == null){
47 | sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
48 | }
49 | sharedPreferences.edit().putString(key, value).commit();
50 | }
51 |
52 |
53 | /**读取String标识从sharedPreferences中
54 | * @param context 上下文环境
55 | * @param key 存储节点名称
56 | * @param defValue 没有此节点的默认值
57 | * @return 返回默认值或者此节点读取到的结果
58 | */
59 | public static String getString(Context context,String key,String defValue){
60 | //存储节点文件的名称,读写方式
61 | if(sharedPreferences == null){
62 | sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
63 | }
64 | return sharedPreferences.getString(key, defValue);
65 | }
66 |
67 | /**写入int变量至sharedPreferences中
68 | * @param context 上下文环境
69 | * @param key 存储节点名称
70 | * @param value 存储节点的值String
71 | */
72 | public static void putInt(Context context,String key,int value){
73 | //存储节点文件的名称,读写方式
74 | if(sharedPreferences == null){
75 | sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
76 | }
77 | sharedPreferences.edit().putInt(key, value).commit();
78 | }
79 |
80 |
81 | /**读取int标识从sharedPreferences中
82 | * @param context 上下文环境
83 | * @param key 存储节点名称
84 | * @param defValue 没有此节点的默认值
85 | * @return 返回默认值或者此节点读取到的结果
86 | */
87 | public static int getInt(Context context,String key,int defValue){
88 | //存储节点文件的名称,读写方式
89 | if(sharedPreferences == null){
90 | sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
91 | }
92 | return sharedPreferences.getInt(key, defValue);
93 | }
94 |
95 | /**
96 | * 从sharedPreferences中移除指定节点
97 | * @param context 上下文环境
98 | * @param key 需要移除节点的名称
99 | */
100 | public static void remove(Context context,String key){
101 | //存储节点文件的名称,读写方式
102 | if(sharedPreferences == null){
103 | sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
104 | }
105 | sharedPreferences.edit().remove(key).commit();
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wy/flowlayoutusedemo/util/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo.util;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.widget.Toast;
6 |
7 | /**
8 | * 下一个Toast覆盖上一个Toast
9 | */
10 | public class ToastUtil {
11 | private static Toast mToast;
12 | private static Handler mHandler = new Handler();
13 | private static Runnable r = new Runnable() {
14 | public void run() {
15 | mToast.cancel();
16 | }
17 | };
18 |
19 | public static void makeText(Context mContext, String text) {
20 |
21 | mHandler.removeCallbacks(r);
22 | if (mToast != null)
23 | mToast.setText(text);
24 | else
25 | mToast = Toast.makeText(mContext, text, Toast.LENGTH_LONG);
26 | mHandler.postDelayed(r, 2000);
27 |
28 | mToast.show();
29 | }
30 |
31 | // public static void makeText(Context mContext, int resId, int duration) {
32 | // makeText(mContext, mContext.getResources().getString(resId), duration);
33 | // }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/color/select_flowlayout_textview_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_flowlayout_textview_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_corner_blue.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_corner_blue3.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_corner_blue5.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_corner_blue_checked.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_corner_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_button1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
32 |
33 |
41 |
42 |
43 |
52 |
53 |
63 |
64 |
77 |
78 |
79 |
86 |
87 |
95 |
96 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_button2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
21 |
22 |
28 |
29 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/flowlayout_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/flowlayout_textview_no_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/flowlayout_textview_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/titlebar_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-hdpi/titlebar_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/titlebar_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-hdpi/titlebar_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/titlebar_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-hdpi/titlebar_search.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/titlebar_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xhdpi/titlebar_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/titlebar_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xhdpi/titlebar_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/titlebar_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xhdpi/titlebar_search.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/titlebar_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xxhdpi/titlebar_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/titlebar_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xxhdpi/titlebar_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/titlebar_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/src/main/res/mipmap-xxhdpi/titlebar_search.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/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 | #2196f3
8 | #ffffff
9 | #cccccc
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 16sp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FlowLayoutUseDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/wy/flowlayoutusedemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.wy.flowlayoutusedemo;
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 | }
--------------------------------------------------------------------------------
/app/产品标签.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/产品标签.gif
--------------------------------------------------------------------------------
/app/本地历史记录.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/app/本地历史记录.gif
--------------------------------------------------------------------------------
/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/wangyang0313/FlowLayouUseDemo/83f63b01c3a94052b38e5be2be60d0cc0509269e/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'
2 |
--------------------------------------------------------------------------------