GithubHelp home page GithubHelp logo

3dtagcloudandroid's Issues

White tag text color is shown black

It is not possible to set white as dark or light tag text color.

When I set #ffffff as darkColor or lightColor the text color of the tag cloud is always shown black.

Also when I set a grey color tone e.g. #63696b the result is a yellow tone.

文字抖动

细看的话,文字有一些抖动,请问有什么方法可以优化吗?

当为子View设置背景色后,旋转至后方的子View无法被前方子View遮挡

如题,考虑可能是子View的Z轴排列问题,我自己fork之后做了修改,目前我的解决办法是在TagCloudViewonLayout中用child.bringToFront();控制Z轴排序。但可能性能上会有问题,希望能有更好的解决方法:)
TagCloudView

@Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        left = l;
        right = r;
        top = t;
        bottom = b;
        Collections.sort(tags, new SortByScale());
        for (int i=0;i<tags.size();i++){
            Tag tag=tags.get(i);
            View child =tag.getChildView();
            if (child!=null&&child.getVisibility() != GONE) {
                child.setScaleX(tag.getScale());
                child.setScaleY(tag.getScale());
                child.setAlpha(tag.getAlpha());
                int left, top;
                left = (int) (centerX + tag.getLoc2DX()) - child.getMeasuredWidth() / 2;
                top = (int) (centerY + tag.getLoc2DY()) - child.getMeasuredHeight() / 2;
                child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
                child.bringToFront();
            }
        }

SortByScale

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;
        }
    }

子线程更新星球需要反射

主线程更新TagCloudView出现较多jank,可以尝试使用单独的非主线程进行维护进行优化,但是目前的TagClouldView限制了更新线程只能在主线程

解决方案:https://github.com/misakuo/3dTagCloudAndroid/pull/33/commits

如下方法可以自定义一个线程,并在线程中维护TagCloudView

//: MyThread.java    
@Override
    public void run() {
        Looper.prepare();
        mHandler = new Handler(Looper.myLooper());

        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT, Utils.dx2dp(400),
                TYPE_APPLICATION, 0, PixelFormat.TRANSPARENT);
        layoutParams.gravity = Gravity.TOP;
        layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        mWindowManager.addView(mFrameLayout = new FrameLayout(mContext),
                layoutParams
        );
        mFrameLayout.setVisibility(View.GONE);
        onViewCreated(mFrameLayout);

        Looper.loop();
    }

    private void onViewCreated(FrameLayout frameLayout) {
        frameLayout.setVisibility(View.VISIBLE);
        if (frameLayout.getChildCount() == 0){
            LayoutInflater.from(mContext.getApplicationContext())
                    .inflate(R.layout.layout_planet, frameLayout);
        }
        frameLayout.setVisibility(View.VISIBLE);
        initCloudView(frameLayout);
    }

    private void initCloudView(FrameLayout frameLayout) {
        if (frameLayout.getParent() == null ) return;
        TagCloudView tagCloudView = frameLayout.findViewById(R.id.tag_cloud);
        try {
            Field handler = tagCloudView.getClass().getDeclaredField("handler");
            handler.setAccessible(true);
            handler.set(tagCloudView, new Handler(Looper.myLooper()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        TagCloudAdapter adapter = new TagCloudAdapter();
        tagCloudView.setAdapter(adapter);
    }

标签事件问题

手按下拖动,拖动效果流畅。当拖动一下段距离后,放开手指,view感觉明显卡顿。

中间放个头像

请问一下,我如如何在这个球形中间放一个头像,且旋转的时候不会触碰头像范围

在Fragment中使用会报NullPointerException

按照demo的代码在Fragment中使用会报NullPointerException:java.lang.NullPointerException: Attempt to invoke virtual method 'int com.moxun.tagcloudlib.view.TagsAdapter.getCount()' on a null object reference

关于MODE_DECELERATE模式

最近使用了MODE_DECELERATE 模式
TagCloudView.java中的line384行似乎有个小bug

    @Override
    public void run() {
        if (!isOnTouch && mode != MODE_DISABLE) {
            if (mode == MODE_DECELERATE) {
                if (mAngleX > 0.04f) {
                    mAngleX -= 0.02f;
                }
                if (mAngleY > 0.04f) {
                    mAngleY -= 0.02f;
                }
                if (mAngleX < -0.04f) {
                    mAngleX += 0.02f;
                }
                if (mAngleY < 0.04f) {
                    mAngleY += 0.02f;
                }
            }
            processTouch();
        }

        handler.postDelayed(this, 50);
    }

mAngleY < 0.04f这里似乎应为mAngleY < -0.04f
否则会出现手势结束后y轴最后回归相反方向运动的状态
另外,0.04的界定值似乎略微小,会停住不动,希望可以提供属性扩展或略微调高,thx~

快速切换报空指针异常

将SIMPLE TEXT TAG和CUSTOM VIEW TAG多次切换后程序奔溃,日志显示空指针异常
FATAL EXCEPTION: main Process: com.moxun.tagcloud, PID: 20838 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundColor(int)' on a null object reference at com.moxun.tagcloud.ViewTagsAdapter.onThemeColorChanged(ViewTagsAdapter.java:38) at com.moxun.tagcloudlib.view.TagCloudView.onLayout(TagCloudView.java:282) at android.view.View.layout(View.java:15697) at android.view.ViewGroup.layout(ViewGroup.java:5050) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15697) at android.view.ViewGroup.layout(ViewGroup.java:5050)
原因是ViewTagsAdapter中onThemeColorChanged方法未做判空过滤。

请教一个问题

大神你好,你这个容器真的很棒,但我从它的规律上看他是从两头螺旋向上的,如果想要它变成经纬分明的(只有经度,或者纬度),每个view的方向面向球心,有什么好的思路吗?

另外,如果第一步能实现,可否支持这样一个方法addView(int x,int y,int z);x代表指南针角度(0-360),y代表俯仰角度,z代表左右角度。

实际上我一直在研究这件事😑

android studio添加远程依赖失败

image

作者大大您好,我这边显示无法添加依赖,您可以分享下jar包吗? 报错信息:Failed to resolve: com.moxun:tagcloudlib:1.2.0

点击事件问题

使用setOnTagClickListener()点击事件是正常的, 但直接在子布局的view上添加点击事件,会出现,点击无效的情况, 具体表现是,偶尔点击无效,拖动布局转一转,就又可以点击了

crash

Use test activity from test apk. Click buttons "simple text tag", "custom view tag", "vectordrawable tag". Somtime crash all adapters.

Log:

10-12 09:06:32.902   673  1227 I ActivityManager: Process com.moxun.tagcloud (pid 20872) has died

10-12 09:06:36.785   673  1226 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10100000 pkg=com.moxun.tagcloud cmp=com.moxun.tagcloud/.MainActivity bnds=[52,599][667,1214]} from uid 10100 on display 0

10-12 09:06:36.845   673   794 I ActivityManager: Start proc com.moxun.tagcloud for activity com.moxun.tagcloud/.MainActivity: pid=20916 uid=10230 gids={50230, 9997} abi=x86

10-12 09:07:12.832 20916 20916 E AndroidRuntime: Process: com.moxun.tagcloud, PID: 20916

10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloud.TextTagsAdapter.onThemeColorChanged(TextTagsAdapter.java:62)

10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.onLayout(TagCloudView.java:270)

10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.updateChild(TagCloudView.java:256)

10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.processTouch(TagCloudView.java:351)

10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.run(TagCloudView.java:376)

10-12 09:07:12.835   673   688 W ActivityManager:   Force finishing activity com.moxun.tagcloud/.MainActivity

10-12 09:07:13.365   673   697 W ActivityManager: Activity pause timeout for ActivityRecord{26d98e4b u0 com.moxun.tagcloud/.MainActivity t35188 f}

10-12 09:07:14.775   673   722 W InputDispatcher: channel '1fb4c40 com.moxun.tagcloud/com.moxun.tagcloud.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.