Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization with adding list of items #9

Open
mtychyna opened this issue Apr 26, 2016 · 2 comments
Open

Optimization with adding list of items #9

mtychyna opened this issue Apr 26, 2016 · 2 comments

Comments

@mtychyna
Copy link

mtychyna commented Apr 26, 2016

In class TagView in method addTags(List<Tag> tags)you do addTag(item);
But what are doing here?

    public void addTag(Tag tag) {
        mTags.add(tag);
        drawTags();
    }

After adding of each tag to addTag you draw tags...
Inside drawTags()
first
removeAllViews();
and then
for (Tag item : mTags)
Are you jokking? Why if you are going to remove and redraw all, you do it after adding of each element to inner list?
Sorry guys but it have to be optimized!

@masquadel
Copy link

masquadel commented Jan 7, 2017

Why if you are going to remove and redraw all, you do it after adding of each element to inner list?

I agree with you here. I don't understand it either. It's just so slow to load tags.

But I can see that was 9 months ago and no response. Why even bother...

@ChristopheCVBWDG
Copy link
Contributor

:/ I decided to Inherit from TagView to override this method...

    @Override
    public void addTags(List<Tag> tags)
    {
        //        super.addTags(tags);
        try
        {
            Field tagsField = TagView.class.getDeclaredField("mTags");
            tagsField.setAccessible(true);
            
            ArrayList<Tag> mTags = new ArrayList<>();

            Method drawTagsMethod = TagView.class.getDeclaredMethod("drawTags");
            drawTagsMethod.setAccessible(true);

            if (tags != null)
            {
                for (Tag tag : tags)
                {
                    mTags.add(tag);
                }

                tagsField.set(this, mTags);
                drawTagsMethod.invoke(this);
            }
        }
        catch (NoSuchFieldException e)
        {
            e.printStackTrace();
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
        catch (NoSuchMethodException e)
        {
            e.printStackTrace();
        }
        catch (InvocationTargetException e)
        {
            e.printStackTrace();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants