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

Issue while using in recyclerview #18

Open
Slake07 opened this issue Jan 20, 2020 · 8 comments
Open

Issue while using in recyclerview #18

Slake07 opened this issue Jan 20, 2020 · 8 comments

Comments

@Slake07
Copy link

Slake07 commented Jan 20, 2020

When I am using RichLinkView into recycler view, it generates layout every time I scroll my recycler view.

I solved this issue with change in RichLinkView class.
call below initView() method in every constructor of RichLinkView class.

public void initView() {
    this.view = this;
    inflate(context, R.layout.include_link_preview_post_item,this);
    linearLayout = (LinearLayout) findViewById(R.id.llMainIncRowLinPreviewPost);
    imageView = (AppCompatImageView) findViewById(R.id.ivPreviewIncRowLinPreviewPost);
    textViewTitle = (AppCompatTextView) findViewById(R.id.tvTitleIncRowLinPreviewPost);
    textViewUrl = (AppCompatTextView) findViewById(R.id.tvLinkIncRowLinPreviewPost);
  }

private void setData(){
    if(meta.getImageurl().equals("") || meta.getImageurl().isEmpty()) {
        imageView.setVisibility(GONE);
    } else {
        imageView.setVisibility(VISIBLE);
        Glide.with(context).load(meta.getImageurl()).into(imageView);
    }

    if(meta.getTitle().isEmpty() || meta.getTitle().equals("")) {
        textViewTitle.setVisibility(GONE);
    } else {
        textViewTitle.setVisibility(VISIBLE);
        textViewTitle.setText(meta.getTitle());
    }
    if(meta.getUrl().isEmpty() || meta.getUrl().equals("")) {
        textViewUrl.setVisibility(GONE);
    } else {
        textViewUrl.setVisibility(VISIBLE);
        textViewUrl.setText(meta.getUrl());
    }

    linearLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if(isDefaultClick) {
                richLinkClicked();
            } else {
                if(richLinkListener != null) {
                    richLinkListener.onClicked(view, meta);
                } else {
                    richLinkClicked();
                }
            }
        }
    });
}

Then call setData() method into setLink() method instend of initView().

@santhoshpr
Copy link

santhoshpr commented May 21, 2020

Am also facing the same issue
Am using RichLinkViewSkype and it is getting reset and blank view is set when we scroll through the recycler view for the second time !

The above solution by Slake07 seems to work thanks

@santhoshpr
Copy link

@Slake07 Thanks for the solution it seems to work now

@ponnamkarthik You can close this issue now.

@Mahato12nikhil
Copy link

Mahato12nikhil commented Aug 3, 2020

Actually here I am not using RichLinkview class as I am using Richpreview class and populating values to my own xml and getting same issues.

@Mahato12nikhil
Copy link

I solved it!!!

@notchdesign
Copy link

hey, do you guys just manually edited the code while downloading? I have implemented and the code is only readable? know any way bypassing? Or I also implement it manually?

@notchdesign
Copy link

@santhoshpr can you tell me how you edited the code? I am not familiar with manual installation.

@notchdesign
Copy link

@Mahato12nikhil can you help me build is not working for me

@mahbub-java
Copy link

When in recycleview link fetch every time when scroll. So I also use a static map to hold url with metadata and check if previous url already successfully fetch for metadata or not.

private static Map<String, MetaData> linkMap=new HashMap<>();

public void setLink(String url, final ViewListener viewListener) {
        MetaData data = linkMap.get(url);
        if(data == null) {
            main_url = url;
            RichPreview richPreview = new RichPreview(new ResponseListener() {
                @Override
                public void onData(MetaData metaData) {
                    meta = metaData;

                    if (!meta.getTitle().isEmpty() || !meta.getTitle().equals("")) {
                        viewListener.onSuccess(true);
                        linkMap.put(url, metaData);
                    }

                    setData();
                }

                @Override
                public void onError(Exception e) {
                    viewListener.onError(e);
                }
            });
            richPreview.getPreview(url);
        }else{
            main_url = url;
            meta = data;
            viewListener.onSuccess(true);
            setData();
        }
    }

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

6 participants
@Slake07 @mahbub-java @Mahato12nikhil @santhoshpr @notchdesign and others