Skip to content

Commit ccef1a4

Browse files
committed
Merge branch 'develop'
2 parents 556fa7e + 65dfc85 commit ccef1a4

File tree

9 files changed

+120
-125
lines changed

9 files changed

+120
-125
lines changed

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ android {
2222

2323
dependencies {
2424
compile fileTree(dir: 'libs', include: ['*.jar'])
25-
compile project(path: ':tagcloudlib')
25+
//compile project(path: ':tagcloudlib')
2626
compile 'com.android.support:appcompat-v7:23.2.1'
2727
compile 'com.android.support:design:23.2.1'
2828
compile 'com.android.support:support-vector-drawable:23.2.0'
2929
compile 'com.android.support:animated-vector-drawable:23.2.0'
3030
compile 'com.android.support:support-v4:23.2.1'
31+
compile 'com.moxun:tagcloudlib:1.2.0'
3132
}

app/src/main/java/com/moxun/tagcloud/MainActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Intent;
44
import android.graphics.Color;
55
import android.os.Bundle;
6-
import android.support.annotation.NonNull;
76
import android.support.v7.app.AppCompatActivity;
87
import android.view.View;
98

app/src/main/java/com/moxun/tagcloud/TextTagsAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.moxun.tagcloud;
22

33
import android.content.Context;
4+
import android.graphics.Color;
45
import android.support.annotation.NonNull;
56
import android.util.Log;
67
import android.view.Gravity;
@@ -44,6 +45,7 @@ public void onClick(View v) {
4445
Toast.makeText(context, "Tag " + position + " clicked", Toast.LENGTH_SHORT).show();
4546
}
4647
});
48+
tv.setTextColor(Color.WHITE);
4749
return tv;
4850
}
4951

@@ -59,6 +61,6 @@ public int getPopularity(int position) {
5961

6062
@Override
6163
public void onThemeColorChanged(View view, int themeColor) {
62-
((TextView) view).setTextColor(themeColor);
64+
view.setBackgroundColor(themeColor);
6365
}
6466
}
Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
2+
3+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
35
xmlns:tools="http://schemas.android.com/tools"
6+
android:id="@+id/container"
7+
tools:context="com.moxun.tagcloud.MainActivity"
48
android:layout_width="match_parent"
5-
android:layout_height="wrap_content">
9+
android:layout_height="wrap_content"
10+
android:gravity="center"
11+
android:orientation="vertical">
612

7-
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
8-
android:id="@+id/container"
13+
<LinearLayout
914
android:layout_width="match_parent"
10-
android:layout_height="wrap_content"
11-
android:gravity="center"
12-
android:orientation="vertical"
13-
tools:context="com.moxun.tagcloud.MainActivity">
15+
android:layout_height="20dp"
16+
android:orientation="horizontal">
1417

15-
<LinearLayout
16-
android:layout_width="match_parent"
17-
android:layout_height="20dp"
18-
android:orientation="horizontal">
18+
<View
19+
android:layout_width="0dp"
20+
android:layout_height="match_parent"
21+
android:layout_weight="1"
22+
android:background="@color/tagLight" />
1923

20-
<View
21-
android:layout_width="0dp"
22-
android:layout_height="match_parent"
23-
android:layout_weight="1"
24-
android:background="@color/tagLight" />
25-
26-
<View
27-
android:layout_width="0dp"
28-
android:layout_height="match_parent"
29-
android:layout_weight="1"
30-
android:background="@color/tagDark" />
31-
</LinearLayout>
24+
<View
25+
android:layout_width="0dp"
26+
android:layout_height="match_parent"
27+
android:layout_weight="1"
28+
android:background="@color/tagDark" />
29+
</LinearLayout>
3230

33-
<com.moxun.tagcloudlib.view.TagCloudView
34-
android:id="@+id/tag_cloud"
35-
android:layout_width="wrap_content"
36-
android:layout_height="wrap_content"
37-
android:layout_margin="10dp"
38-
app:autoScrollMode="uniform"
39-
app:darkColor="@color/tagDark"
40-
app:lightColor="@color/tagLight"
41-
app:radiusPercent="0.6"
42-
app:scrollSpeed="3" />
31+
<com.moxun.tagcloudlib.view.TagCloudView
32+
android:id="@+id/tag_cloud"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_margin="10dp"
36+
app:autoScrollMode="uniform"
37+
app:darkColor="@color/tagDark"
38+
app:lightColor="@color/tagLight"
39+
app:radiusPercent="0.6"
40+
app:scrollSpeed="3" />
4341

44-
<Button
45-
android:id="@+id/tag_text"
46-
android:layout_width="match_parent"
47-
android:layout_height="wrap_content"
48-
android:text="Simple Text Tag" />
42+
<Button
43+
android:id="@+id/tag_text"
44+
android:layout_width="match_parent"
45+
android:layout_height="wrap_content"
46+
android:text="Simple Text Tag" />
4947

50-
<Button
51-
android:id="@+id/tag_view"
52-
android:layout_width="match_parent"
53-
android:layout_height="wrap_content"
54-
android:text="Custom View Tag" />
48+
<Button
49+
android:id="@+id/tag_view"
50+
android:layout_width="match_parent"
51+
android:layout_height="wrap_content"
52+
android:text="Custom View Tag" />
5553

56-
<Button
57-
android:id="@+id/tag_vector"
58-
android:layout_width="match_parent"
59-
android:layout_height="wrap_content"
60-
android:text="VectorDrawable Tag" />
54+
<Button
55+
android:id="@+id/tag_vector"
56+
android:layout_width="match_parent"
57+
android:layout_height="wrap_content"
58+
android:text="VectorDrawable Tag" />
6159

62-
<Button
63-
android:id="@+id/test_fragment"
64-
android:layout_width="match_parent"
65-
android:layout_height="wrap_content"
66-
android:text="Using in Fragment" />
60+
<Button
61+
android:id="@+id/test_fragment"
62+
android:layout_width="match_parent"
63+
android:layout_height="wrap_content"
64+
android:text="Using in Fragment" />
6765

68-
</LinearLayout>
69-
</ScrollView>
66+
</LinearLayout>

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

tagcloudlib/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
33
apply plugin: 'com.jfrog.bintray'
44

5-
version = "1.1.3"
5+
version = "1.2.0"
66
android {
77
compileSdkVersion 23
88
buildToolsVersion "23.0.1"
@@ -21,6 +21,7 @@ android {
2121
}
2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
compile 'com.android.support:support-annotations:23.2.1'
2425
}
2526
def siteUrl = 'https://github.com/misakuo/3dTagCloudAndroid' // 项目的主页
2627
def gitUrl = 'https://github.com/misakuo/3dTagCloudAndroid.git' // Git仓库的url

tagcloudlib/src/main/java/com/moxun/tagcloudlib/view/Tag.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.moxun.tagcloudlib.view;
22

33
import android.graphics.Color;
4-
import android.util.Log;
54
import android.view.View;
65

76
/**
@@ -34,7 +33,7 @@ public class Tag {
3433
private float scale;
3534
private float[] argb;
3635
private static final int DEFAULT_POPULARITY = 5;
37-
private View childView;
36+
private View mView;
3837

3938

4039
public Tag() {
@@ -99,12 +98,12 @@ public void setScale(float scale) {
9998
this.scale = scale;
10099
}
101100

102-
public View getChildView() {
103-
return childView;
101+
public View getView() {
102+
return mView;
104103
}
105104

106-
public void setChildView(View view) {
107-
this.childView = view;
105+
public void setView(View view) {
106+
this.mView = view;
108107
}
109108

110109
public void setAlpha(float alpha) {
@@ -137,7 +136,7 @@ public void setLoc2DY(float loc2dy) {
137136

138137
public void setColorByArray(float[] rgb) {
139138
if (rgb != null) {
140-
System.arraycopy(rgb, 0, this.argb, this.argb.length - rgb.length , rgb.length);
139+
System.arraycopy(rgb, 0, this.argb, this.argb.length - rgb.length, rgb.length);
141140
}
142141
}
143142

@@ -146,8 +145,6 @@ public int getColor() {
146145
for (int i = 0; i < 4; i++) {
147146
result[i] = (int) (this.argb[i] * 0xff);
148147
}
149-
int color = Color.argb(result[0], result[1], result[2], result[3]);
150-
//Log.e("TAG","#" + Integer.toHexString(color));
151-
return color;
148+
return Color.argb(result[0], result[1], result[2], result[3]);
152149
}
153150
}

tagcloudlib/src/main/java/com/moxun/tagcloudlib/view/TagCloud.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* OR OTHER DEALINGS IN THE SOFTWARE.
2323
*/
2424

25-
import android.util.Log;
26-
2725
import java.util.ArrayList;
2826
import java.util.Collections;
2927
import java.util.Comparator;
@@ -32,7 +30,6 @@
3230
public class TagCloud {
3331

3432
private List<Tag> tagCloud;
35-
private List<Tag> tagCloudSort;
3633
private int radius;
3734
private static final int DEFAULT_RADIUS = 3;
3835
private static final float[] DEFAULT_COLOR_DARK = {0.886f, 0.725f, 0.188f, 1f};
@@ -69,7 +66,6 @@ public TagCloud(List<Tag> tags, int radius, float[] tagColor1, float[] tagColor2
6966
this.radius = radius;
7067
this.tagColorLight = tagColor1;
7168
this.tagColorDark = tagColor2;
72-
this.tagCloudSort = new ArrayList<>();
7369
}
7470

7571
//create method calculates the correct initial location of each tag
@@ -100,7 +96,6 @@ public void create(boolean distrEven) {
10096

10197
public void clear() {
10298
tagCloud.clear();
103-
tagCloudSort.clear();
10499
}
105100

106101
public List<Tag> getTagList() {
@@ -156,7 +151,6 @@ public void add(Tag newTag) {
156151
position(distrEven, newTag);
157152
//now add the new tag to the tagCloud
158153
tagCloud.add(newTag);
159-
tagCloudSort.add(newTag);
160154
updateAll();
161155
}
162156

@@ -231,6 +225,7 @@ private void updateAll() {
231225
tagCloud.get(j).setScale(per);
232226
tagCloud.get(j).setAlpha(per / 2);
233227
}
228+
sortTagByScale();
234229
}
235230

236231
private float[] getColorFromGradient(float percentage) {
@@ -273,18 +268,15 @@ public void setAngleY(float mAngleY) {
273268
this.mAngleY = mAngleY;
274269
}
275270

276-
public List<Tag> sortTagByScale(){
277-
Collections.sort(tagCloudSort, new SortByScale());
278-
return tagCloudSort;
271+
public void sortTagByScale() {
272+
Collections.sort(tagCloud, new TagComparator());
279273
}
280274

281-
private static class SortByScale implements Comparator {
282-
public int compare(Object o1, Object o2) {
283-
if(o1 instanceof Tag && o2 instanceof Tag){
284-
return ((Tag) o1).getScale()>((Tag) o2).getScale()?1:-1;
285-
}
286-
return 0;
275+
private static class TagComparator implements Comparator<Tag> {
276+
277+
@Override
278+
public int compare(Tag o1, Tag o2) {
279+
return o1.getScale() > o2.getScale() ? 1 : -1;
287280
}
288281
}
289-
290282
}

0 commit comments

Comments
 (0)