kaedea / android-tagview

An Android TagView Widget. You can edit the tag's style, and set listener of selecting or deleting tag.
663 stars 134 forks source link

TagView is not initiated or not display and also get overlap #11

Open ShreyashPromact opened 8 years ago

ShreyashPromact commented 8 years ago

I have added tagview to my recyclerview's footer. I am facing issue like, when I scroll to down. initially tags that is in the footer is not going to display. But then I scroll a little bit to up direction and again come back to footer, it show me the tags. I dont know where is the issue.

I am adding tags as mention below:

for(int i = 0; i < mStory.getTags().size(); i++) {
                footerHolder.tagView.removeAllTags();
                Tag tag = new Tag(mStory.getTags().get(i).getName());
                tag.layoutBorderSize = 2f;
                tag.layoutBorderColor = ContextCompat.getColor(mContext
                        , R.color.my_theme_primary);
                tag.tagTextColor = ContextCompat.getColor(mContext
                        , R.color.my_theme_primary_text);
                tag.background = ContextCompat.getDrawable(mContext,R.drawable.bg_tag);
                footerHolder.tagView.addTag(tag);
            }

            footerHolder.tagView.setOnTagClickListener(new OnTagClickListener() {
                @Override
                public void onTagClick(Tag tag, int position) {
                    Toast.makeText(mContext, "position=" + position,
                            Toast.LENGTH_SHORT).show();
                }
            });

My code is proper in footer because other view that I have mention in footer looks fine with even initial scrolling. But Tags is not getting displayed when scroll initial.

Please share solution to that with me.

ShreyashPromact commented 8 years ago

I am in high priority to complete the work. Is there any solution to this issue?

I have try adding TagView infooter for ListView in your given example. But when I have added same in recyclerview for footer, it is not working as expected. It is appearing after i scroll second time to bottom.

Sincerely, Shreyash

ShreyashPromact commented 8 years ago

Also there is one more issue I have observer here, the tags are getting updated on each other. E.g: If I have "Car" and "Racing" as tags, it is getting updated on same place and hiding the tags that are previous then that. Means "Car" is hiding here and "Racing" is display above "Car".

Please resolved this issue and let me know, or I need to move on other library as this is worth to use as per my requirements.

Thanks.

Sincerely, Shreyash

ShreyashPromact commented 8 years ago

@kaedea Can you please guide me for the cause of this issue and resolved it. I have to deliver the app to my client. But just because of this I can't.

Sincerely, Shreyash

kaedea commented 8 years ago

Hey, SP. This bug is because the value of mWidth in the TagView.java is not set correctly in the first time you scroll to bottom. You can just set a coustom value (e.x. screen width) to mWidth in the init of TagView.

ShreyashPromact commented 8 years ago

@kaedea

OK. Thanks for reply. I am updating it and will let you know about it.

ShreyashPromact commented 8 years ago

@kaedea That is not the cause of issue. I have print the log which it is assigning value to mWidth, It is always loading right width. But the problem is somewhere else. I guess you need to handled it proper. Because you have used RelativeLayout, it is also causing overlapping issue while adding Tags directly in for loop as mention in raised question.

Please review that in depth.

Thanks. Sincerely, Shreyash

kaedea commented 8 years ago

Well, set TagView#drawTags to public and call this method after footerHolder.tagView.addTag(tag);

ShreyashPromact commented 8 years ago

@kaedea I have checked that method before and also make the changes as you have said. But not working.

I have observed that somehow, it is not getting initiated while scrolling down first time. That's why it get return. While on second time scrolling it get get initiated and displaying me the tags.

I have updated this code in drawTags()

if (!mInitialized) { Log.d("TagView", "IS NOT INITIALIZED"); return; }

So, first time I got log printed and not second time. Hope you got my point.

Looking for solution to that.

Sincerely, Shreyash

kaedea commented 8 years ago

Please try debug in the Constructor of TagView to see where the logic is wrong. Make sure the method drawTags could be called correctly.

ShreyashPromact commented 8 years ago

@kaedea If I have time to check that I will not inform you to do that. I will simply pull the request an update your code.

Please update me for the feasible solution to that.

Sincerely, Shreyash

kaedea commented 8 years ago

Well, now the problem is that the code works just porfect for me. I don't know how you use the lib so that I have no way to debug.

kaedea commented 8 years ago

Please see this pr. It may help. https://github.com/kaedea/Android-Cloud-TagView-Plus/pull/7

ShreyashPromact commented 8 years ago

@KANGOD @kaedea I don't know you guys using it in recyclerview or not. If not then please try with recyclerview. It is not working at all.

I have already try your demo with the listview and it is working fine there. But not with recyclerview. Please try that with recycler view as well.

Sincerely, Shreyash

Ram8948 commented 8 years ago

tagview inside (layout within layout) nested layout not display but work perfactly when i use tagview inside layout. any solution please?

ShreyashPromact commented 8 years ago

@kaedea

Have you got any solution to issue, i have mention?

ShreyashPromact commented 8 years ago

@kaedea

I have seen that the issue is with below method in TagView class.

/**
     * initalize instance
     *
     * @param ctx
     * @param attrs
     * @param defStyle
     */
    private void initialize(Context ctx, AttributeSet attrs, int defStyle) {
        mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mViewTreeObserber = getViewTreeObserver();
        mViewTreeObserber.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!mInitialized) {
                    mInitialized = true;
                    drawTags();
                }
            }
        });

        // get AttributeSet
        TypedArray typeArray = ctx.obtainStyledAttributes(attrs, R.styleable.TagView, defStyle, defStyle);
        this.lineMargin = (int) typeArray.getDimension(R.styleable.TagView_lineMargin, Utils.dpToPx(this.getContext(), Constants.DEFAULT_LINE_MARGIN));
        this.tagMargin = (int) typeArray.getDimension(R.styleable.TagView_tagMargin, Utils.dpToPx(this.getContext(), Constants.DEFAULT_TAG_MARGIN));
        this.textPaddingLeft = (int) typeArray.getDimension(R.styleable.TagView_textPaddingLeft, Utils.dpToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_LEFT));
        this.textPaddingRight = (int) typeArray.getDimension(R.styleable.TagView_textPaddingRight, Utils.dpToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_RIGHT));
        this.textPaddingTop = (int) typeArray.getDimension(R.styleable.TagView_textPaddingTop, Utils.dpToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_TOP));
        this.texPaddingBottom = (int) typeArray.getDimension(R.styleable.TagView_textPaddingBottom, Utils.dpToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_BOTTOM));
        typeArray.recycle();
    }

Please check that for footer view of the recycler view and update it. I don't know what changes makes it to work proper.

Sincerely, Shreyash

ShreyashPromact commented 8 years ago

@kaedea

Is there any solution to that or should I have to move on other library? I suppose that will gone resolved with in 1 week. But its taking more time.

Sincerely, Shreyash

kaedea commented 8 years ago

@ShreyashPromact sorry to leave this bug so long

I have tested it and it does exist. I have try to refractor this project. There is a substitute repo you may check it out. https://github.com/kingideayou/TagCloudView

Chinese coder is occupied with jobs all day and sorry for this bug again.