RichLinkPreview icon indicating copy to clipboard operation
RichLinkPreview copied to clipboard

Issue while using in recyclerview

Open Slake07 opened this issue 5 years ago • 8 comments
trafficstars

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().

Slake07 avatar Jan 20 '20 07:01 Slake07

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 avatar May 21 '20 11:05 santhoshpr

@Slake07 Thanks for the solution it seems to work now

@PonnamKarthik You can close this issue now.

santhoshpr avatar May 21 '20 11:05 santhoshpr

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 avatar Aug 03 '20 06:08 Mahato12nikhil

I solved it!!!

Mahato12nikhil avatar Nov 20 '20 08:11 Mahato12nikhil

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 avatar Dec 08 '20 11:12 notchdesign

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

notchdesign avatar Dec 08 '20 11:12 notchdesign

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

notchdesign avatar Dec 11 '20 17:12 notchdesign

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

mahbub-java avatar Aug 18 '21 21:08 mahbub-java