Skip to content

Commit e68acac

Browse files
committed
修改项目结构
1 parent ebaf43c commit e68acac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1810
-512
lines changed

Android-Rapid-Development-Of-Library/.idea/codeStyleSettings.xml

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Android-Rapid-Development-Of-Library/.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Android-Rapid-Development-Of-Library/android_library/android_library.iml

+8-7
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,19 @@
102102
<orderEntry type="library" exported="" name="retrofit-2.0.0" level="project" />
103103
<orderEntry type="library" exported="" name="rxandroid-1.1.0" level="project" />
104104
<orderEntry type="library" exported="" name="rxjava-1.1.1" level="project" />
105+
<orderEntry type="library" exported="" name="design-23.3.0" level="project" />
105106
<orderEntry type="library" exported="" name="converter-gson-2.0.0" level="project" />
106-
<orderEntry type="library" exported="" name="recyclerview-v7-23.2.1" level="project" />
107+
<orderEntry type="library" exported="" name="recyclerview-v7-23.3.0" level="project" />
108+
<orderEntry type="library" exported="" name="bottom-navigation-bar-1.0.0" level="project" />
107109
<orderEntry type="library" exported="" name="umeng-onlineconfig_v1.0.0" level="project" />
108110
<orderEntry type="library" exported="" name="adapter-rxjava-2.0.0" level="project" />
109111
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
110-
<orderEntry type="library" exported="" name="support-v4-23.2.1" level="project" />
112+
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
111113
<orderEntry type="library" exported="" name="okhttp-3.2.0" level="project" />
112-
<orderEntry type="library" exported="" name="bottom-navigation-bar-0.9.5" level="project" />
113114
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
114-
<orderEntry type="library" exported="" name="support-annotations-23.2.1" level="project" />
115-
<orderEntry type="library" exported="" name="animated-vector-drawable-23.2.1" level="project" />
116-
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.1" level="project" />
117-
<orderEntry type="library" exported="" name="appcompat-v7-23.2.1" level="project" />
115+
<orderEntry type="library" exported="" name="support-annotations-23.3.0" level="project" />
116+
<orderEntry type="library" exported="" name="support-vector-drawable-23.3.0" level="project" />
117+
<orderEntry type="library" exported="" name="animated-vector-drawable-23.3.0" level="project" />
118+
<orderEntry type="library" exported="" name="appcompat-v7-23.3.0" level="project" />
118119
</component>
119120
</module>

Android-Rapid-Development-Of-Library/android_library/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ dependencies {
3131
compile files('libs/butterknife-7.0.1.jar')
3232
compile 'com.nineoldandroids:library:2.4.0'
3333
compile 'com.squareup.picasso:picasso:2.5.2'
34-
compile 'com.ashokvarma.android:bottom-navigation-bar:0.9.5'
34+
compile 'com.ashokvarma.android:bottom-navigation-bar:1.0.0'
3535
compile files('libs/umeng-onlineconfig_v1.0.0.jar')
3636
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
package com.lidong.android_ibrary.tagflowlayout;
2+
3+
import android.content.Context;
4+
import android.content.res.TypedArray;
5+
import android.util.AttributeSet;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
9+
import com.lidong.android_ibrary.R;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
/**
14+
*@类名 : FlowLayout
15+
*@描述 :
16+
*@时间 : 2016/4/15 8:53
17+
*@作者: 李东
18+
19+
*@company: chni
20+
*/
21+
public class FlowLayout extends ViewGroup
22+
{
23+
private static final String TAG = "FlowLayout";
24+
private static final int LEFT = -1;
25+
private static final int CENTER = 0;
26+
private static final int RIGHT = 1;
27+
28+
protected List<List<View>> mAllViews = new ArrayList<List<View>>();
29+
protected List<Integer> mLineHeight = new ArrayList<Integer>();
30+
protected List<Integer> mLineWidth = new ArrayList<Integer>();
31+
private int mGravity;
32+
private List<View> lineViews = new ArrayList<>();
33+
34+
public FlowLayout(Context context, AttributeSet attrs, int defStyle)
35+
{
36+
super(context, attrs, defStyle);
37+
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TagFlowLayout);
38+
mGravity = ta.getInt(R.styleable.TagFlowLayout_gravity,LEFT);
39+
ta.recycle();
40+
}
41+
42+
public FlowLayout(Context context, AttributeSet attrs)
43+
{
44+
this(context, attrs, 0);
45+
}
46+
47+
public FlowLayout(Context context)
48+
{
49+
this(context, null);
50+
}
51+
52+
@Override
53+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
54+
{
55+
int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
56+
int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
57+
int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
58+
int modeHeight = MeasureSpec.getMode(heightMeasureSpec);
59+
60+
// wrap_content
61+
int width = 0;
62+
int height = 0;
63+
64+
int lineWidth = 0;
65+
int lineHeight = 0;
66+
67+
int cCount = getChildCount();
68+
69+
for (int i = 0; i < cCount; i++)
70+
{
71+
View child = getChildAt(i);
72+
if (child.getVisibility() == View.GONE)
73+
{
74+
if (i == cCount - 1)
75+
{
76+
width = Math.max(lineWidth, width);
77+
height += lineHeight;
78+
}
79+
continue;
80+
}
81+
measureChild(child, widthMeasureSpec, heightMeasureSpec);
82+
MarginLayoutParams lp = (MarginLayoutParams) child
83+
.getLayoutParams();
84+
85+
int childWidth = child.getMeasuredWidth() + lp.leftMargin
86+
+ lp.rightMargin;
87+
int childHeight = child.getMeasuredHeight() + lp.topMargin
88+
+ lp.bottomMargin;
89+
90+
if (lineWidth + childWidth > sizeWidth - getPaddingLeft() - getPaddingRight())
91+
{
92+
width = Math.max(width, lineWidth);
93+
lineWidth = childWidth;
94+
height += lineHeight;
95+
lineHeight = childHeight;
96+
} else
97+
{
98+
lineWidth += childWidth;
99+
lineHeight = Math.max(lineHeight, childHeight);
100+
}
101+
if (i == cCount - 1)
102+
{
103+
width = Math.max(lineWidth, width);
104+
height += lineHeight;
105+
}
106+
}
107+
setMeasuredDimension(
108+
//
109+
modeWidth == MeasureSpec.EXACTLY ? sizeWidth : width + getPaddingLeft() + getPaddingRight(),
110+
modeHeight == MeasureSpec.EXACTLY ? sizeHeight : height + getPaddingTop() + getPaddingBottom()//
111+
);
112+
113+
}
114+
115+
116+
@Override
117+
protected void onLayout(boolean changed, int l, int t, int r, int b)
118+
{
119+
mAllViews.clear();
120+
mLineHeight.clear();
121+
mLineWidth.clear();
122+
lineViews.clear();
123+
124+
int width = getWidth();
125+
126+
int lineWidth = 0;
127+
int lineHeight = 0;
128+
129+
int cCount = getChildCount();
130+
131+
for (int i = 0; i < cCount; i++)
132+
{
133+
View child = getChildAt(i);
134+
if (child.getVisibility() == View.GONE) continue;
135+
MarginLayoutParams lp = (MarginLayoutParams) child
136+
.getLayoutParams();
137+
138+
int childWidth = child.getMeasuredWidth();
139+
int childHeight = child.getMeasuredHeight();
140+
141+
if (childWidth + lineWidth + lp.leftMargin + lp.rightMargin > width - getPaddingLeft() - getPaddingRight())
142+
{
143+
mLineHeight.add(lineHeight);
144+
mAllViews.add(lineViews);
145+
mLineWidth.add(lineWidth);
146+
147+
lineWidth = 0;
148+
lineHeight = childHeight + lp.topMargin + lp.bottomMargin;
149+
lineViews = new ArrayList<View>();
150+
}
151+
lineWidth += childWidth + lp.leftMargin + lp.rightMargin;
152+
lineHeight = Math.max(lineHeight, childHeight + lp.topMargin
153+
+ lp.bottomMargin);
154+
lineViews.add(child);
155+
156+
}
157+
mLineHeight.add(lineHeight);
158+
mLineWidth.add(lineWidth);
159+
mAllViews.add(lineViews);
160+
161+
162+
163+
int left = getPaddingLeft();
164+
int top = getPaddingTop();
165+
166+
int lineNum = mAllViews.size();
167+
168+
for (int i = 0; i < lineNum; i++)
169+
{
170+
lineViews = mAllViews.get(i);
171+
lineHeight = mLineHeight.get(i);
172+
173+
// set gravity
174+
int currentLineWidth = this.mLineWidth.get(i);
175+
switch (this.mGravity){
176+
case LEFT:
177+
left = getPaddingLeft();
178+
break;
179+
case CENTER:
180+
left = (width - currentLineWidth)/2+getPaddingLeft();
181+
break;
182+
case RIGHT:
183+
left = width - currentLineWidth + getPaddingLeft();
184+
break;
185+
}
186+
187+
for (int j = 0; j < lineViews.size(); j++)
188+
{
189+
View child = lineViews.get(j);
190+
if (child.getVisibility() == View.GONE)
191+
{
192+
continue;
193+
}
194+
195+
MarginLayoutParams lp = (MarginLayoutParams) child
196+
.getLayoutParams();
197+
198+
int lc = left + lp.leftMargin;
199+
int tc = top + lp.topMargin;
200+
int rc = lc + child.getMeasuredWidth();
201+
int bc = tc + child.getMeasuredHeight();
202+
203+
child.layout(lc, tc, rc, bc);
204+
205+
left += child.getMeasuredWidth() + lp.leftMargin
206+
+ lp.rightMargin;
207+
}
208+
top += lineHeight;
209+
}
210+
211+
}
212+
213+
@Override
214+
public LayoutParams generateLayoutParams(AttributeSet attrs)
215+
{
216+
return new MarginLayoutParams(getContext(), attrs);
217+
}
218+
219+
@Override
220+
protected LayoutParams generateDefaultLayoutParams()
221+
{
222+
return new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
223+
}
224+
225+
@Override
226+
protected LayoutParams generateLayoutParams(LayoutParams p)
227+
{
228+
return new MarginLayoutParams(p);
229+
}
230+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.lidong.android_ibrary.tagflowlayout;
2+
3+
import android.view.View;
4+
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import java.util.HashSet;
8+
import java.util.List;
9+
import java.util.Set;
10+
/**
11+
*@类名 : TagAdapter
12+
*@描述 :
13+
*@时间 : 2016/4/15 9:16
14+
*@作者: 李东
15+
16+
*@company: chni
17+
*/
18+
public abstract class TagAdapter<T>
19+
{
20+
private List<T> mTagDatas;
21+
private OnDataChangedListener mOnDataChangedListener;
22+
private HashSet<Integer> mCheckedPosList = new HashSet<Integer>();
23+
24+
public TagAdapter(List<T> datas)
25+
{
26+
mTagDatas = datas;
27+
}
28+
29+
public TagAdapter(T[] datas)
30+
{
31+
mTagDatas = new ArrayList<T>(Arrays.asList(datas));
32+
}
33+
34+
static interface OnDataChangedListener
35+
{
36+
void onChanged();
37+
}
38+
39+
void setOnDataChangedListener(OnDataChangedListener listener)
40+
{
41+
mOnDataChangedListener = listener;
42+
}
43+
44+
public void setSelectedList(int... pos)
45+
{
46+
for (int i = 0; i < pos.length; i++)
47+
mCheckedPosList.add(pos[i]);
48+
notifyDataChanged();
49+
}
50+
51+
public void setSelectedList(Set<Integer> set)
52+
{
53+
mCheckedPosList.clear();
54+
mCheckedPosList.addAll(set);
55+
notifyDataChanged();
56+
}
57+
58+
HashSet<Integer> getPreCheckedList()
59+
{
60+
return mCheckedPosList;
61+
}
62+
63+
64+
public int getCount()
65+
{
66+
return mTagDatas == null ? 0 : mTagDatas.size();
67+
}
68+
69+
public void notifyDataChanged()
70+
{
71+
mOnDataChangedListener.onChanged();
72+
}
73+
74+
public T getItem(int position)
75+
{
76+
return mTagDatas.get(position);
77+
}
78+
79+
public abstract View getView(FlowLayout parent, int position, T t);
80+
81+
public boolean setSelected(int position ,T t)
82+
{
83+
return false;
84+
}
85+
86+
87+
}

0 commit comments

Comments
 (0)