android-tagview icon indicating copy to clipboard operation
android-tagview copied to clipboard

TagView is not initiated or not display and also get overlap

Open ShreyashPromact opened this issue 8 years ago • 18 comments

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 avatar Apr 05 '16 07:04 ShreyashPromact

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 avatar Apr 06 '16 06:04 ShreyashPromact

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 avatar Apr 06 '16 07:04 ShreyashPromact

@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

ShreyashPromact avatar Apr 07 '16 05:04 ShreyashPromact

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.

kaedea avatar Apr 08 '16 01:04 kaedea

@kaedea

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

ShreyashPromact avatar Apr 08 '16 04:04 ShreyashPromact

@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

ShreyashPromact avatar Apr 08 '16 04:04 ShreyashPromact

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

kaedea avatar Apr 08 '16 05:04 kaedea

@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

ShreyashPromact avatar Apr 08 '16 06:04 ShreyashPromact

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

kaedea avatar Apr 08 '16 06:04 kaedea

@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

ShreyashPromact avatar Apr 08 '16 06:04 ShreyashPromact

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 avatar Apr 08 '16 06:04 kaedea

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

kaedea avatar Apr 08 '16 07:04 kaedea

@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

ShreyashPromact avatar Apr 08 '16 07:04 ShreyashPromact

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

Ram8948 avatar Apr 09 '16 05:04 Ram8948

@kaedea

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

ShreyashPromact avatar Apr 12 '16 07:04 ShreyashPromact

@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 avatar Apr 12 '16 12:04 ShreyashPromact

@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

ShreyashPromact avatar Apr 21 '16 03:04 ShreyashPromact

@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.

kaedea avatar May 11 '16 09:05 kaedea