Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
misakuo committed Jun 28, 2016
2 parents 556fa7e + 65dfc85 commit ccef1a4
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 125 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Expand Up @@ -22,10 +22,11 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':tagcloudlib')
//compile project(path: ':tagcloudlib')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-vector-drawable:23.2.0'
compile 'com.android.support:animated-vector-drawable:23.2.0'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.moxun:tagcloudlib:1.2.0'
}
1 change: 0 additions & 1 deletion app/src/main/java/com/moxun/tagcloud/MainActivity.java
Expand Up @@ -3,7 +3,6 @@
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/moxun/tagcloud/TextTagsAdapter.java
@@ -1,6 +1,7 @@
package com.moxun.tagcloud;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.Gravity;
Expand Down Expand Up @@ -44,6 +45,7 @@ public void onClick(View v) {
Toast.makeText(context, "Tag " + position + " clicked", Toast.LENGTH_SHORT).show();
}
});
tv.setTextColor(Color.WHITE);
return tv;
}

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

@Override
public void onThemeColorChanged(View view, int themeColor) {
((TextView) view).setTextColor(themeColor);
view.setBackgroundColor(themeColor);
}
}
109 changes: 53 additions & 56 deletions app/src/main/res/layout/activity_main.xml
@@ -1,69 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
tools:context="com.moxun.tagcloud.MainActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
tools:context="com.moxun.tagcloud.MainActivity">
android:layout_height="20dp"
android:orientation="horizontal">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/tagLight" />

<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/tagLight" />

<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/tagDark" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/tagDark" />
</LinearLayout>

<com.moxun.tagcloudlib.view.TagCloudView
android:id="@+id/tag_cloud"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:autoScrollMode="uniform"
app:darkColor="@color/tagDark"
app:lightColor="@color/tagLight"
app:radiusPercent="0.6"
app:scrollSpeed="3" />
<com.moxun.tagcloudlib.view.TagCloudView
android:id="@+id/tag_cloud"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:autoScrollMode="uniform"
app:darkColor="@color/tagDark"
app:lightColor="@color/tagLight"
app:radiusPercent="0.6"
app:scrollSpeed="3" />

<Button
android:id="@+id/tag_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Tag" />
<Button
android:id="@+id/tag_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Tag" />

<Button
android:id="@+id/tag_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Custom View Tag" />
<Button
android:id="@+id/tag_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Custom View Tag" />

<Button
android:id="@+id/tag_vector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="VectorDrawable Tag" />
<Button
android:id="@+id/tag_vector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="VectorDrawable Tag" />

<Button
android:id="@+id/test_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Using in Fragment" />
<Button
android:id="@+id/test_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Using in Fragment" />

</LinearLayout>
</ScrollView>
</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down
3 changes: 2 additions & 1 deletion tagcloudlib/build.gradle
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.1.3"
version = "1.2.0"
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
Expand All @@ -21,6 +21,7 @@ android {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:23.2.1'
}
def siteUrl = 'https://github.com/misakuo/3dTagCloudAndroid' // 项目的主页
def gitUrl = 'https://github.com/misakuo/3dTagCloudAndroid.git' // Git仓库的url
Expand Down
17 changes: 7 additions & 10 deletions tagcloudlib/src/main/java/com/moxun/tagcloudlib/view/Tag.java
@@ -1,7 +1,6 @@
package com.moxun.tagcloudlib.view;

import android.graphics.Color;
import android.util.Log;
import android.view.View;

/**
Expand Down Expand Up @@ -34,7 +33,7 @@ public class Tag {
private float scale;
private float[] argb;
private static final int DEFAULT_POPULARITY = 5;
private View childView;
private View mView;


public Tag() {
Expand Down Expand Up @@ -99,12 +98,12 @@ public void setScale(float scale) {
this.scale = scale;
}

public View getChildView() {
return childView;
public View getView() {
return mView;
}

public void setChildView(View view) {
this.childView = view;
public void setView(View view) {
this.mView = view;
}

public void setAlpha(float alpha) {
Expand Down Expand Up @@ -137,7 +136,7 @@ public void setLoc2DY(float loc2dy) {

public void setColorByArray(float[] rgb) {
if (rgb != null) {
System.arraycopy(rgb, 0, this.argb, this.argb.length - rgb.length , rgb.length);
System.arraycopy(rgb, 0, this.argb, this.argb.length - rgb.length, rgb.length);
}
}

Expand All @@ -146,8 +145,6 @@ public int getColor() {
for (int i = 0; i < 4; i++) {
result[i] = (int) (this.argb[i] * 0xff);
}
int color = Color.argb(result[0], result[1], result[2], result[3]);
//Log.e("TAG","#" + Integer.toHexString(color));
return color;
return Color.argb(result[0], result[1], result[2], result[3]);
}
}
24 changes: 8 additions & 16 deletions tagcloudlib/src/main/java/com/moxun/tagcloudlib/view/TagCloud.java
Expand Up @@ -22,8 +22,6 @@
* OR OTHER DEALINGS IN THE SOFTWARE.
*/

import android.util.Log;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -32,7 +30,6 @@
public class TagCloud {

private List<Tag> tagCloud;
private List<Tag> tagCloudSort;
private int radius;
private static final int DEFAULT_RADIUS = 3;
private static final float[] DEFAULT_COLOR_DARK = {0.886f, 0.725f, 0.188f, 1f};
Expand Down Expand Up @@ -69,7 +66,6 @@ public TagCloud(List<Tag> tags, int radius, float[] tagColor1, float[] tagColor2
this.radius = radius;
this.tagColorLight = tagColor1;
this.tagColorDark = tagColor2;
this.tagCloudSort = new ArrayList<>();
}

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

public void clear() {
tagCloud.clear();
tagCloudSort.clear();
}

public List<Tag> getTagList() {
Expand Down Expand Up @@ -156,7 +151,6 @@ public void add(Tag newTag) {
position(distrEven, newTag);
//now add the new tag to the tagCloud
tagCloud.add(newTag);
tagCloudSort.add(newTag);
updateAll();
}

Expand Down Expand Up @@ -231,6 +225,7 @@ private void updateAll() {
tagCloud.get(j).setScale(per);
tagCloud.get(j).setAlpha(per / 2);
}
sortTagByScale();
}

private float[] getColorFromGradient(float percentage) {
Expand Down Expand Up @@ -273,18 +268,15 @@ public void setAngleY(float mAngleY) {
this.mAngleY = mAngleY;
}

public List<Tag> sortTagByScale(){
Collections.sort(tagCloudSort, new SortByScale());
return tagCloudSort;
public void sortTagByScale() {
Collections.sort(tagCloud, new TagComparator());
}

private static class SortByScale implements Comparator {
public int compare(Object o1, Object o2) {
if(o1 instanceof Tag && o2 instanceof Tag){
return ((Tag) o1).getScale()>((Tag) o2).getScale()?1:-1;
}
return 0;
private static class TagComparator implements Comparator<Tag> {

@Override
public int compare(Tag o1, Tag o2) {
return o1.getScale() > o2.getScale() ? 1 : -1;
}
}

}

0 comments on commit ccef1a4

Please sign in to comment.