linkpreview

Additional

Language
N/A
Version
N/A
Created
Dec 18, 2017
Updated
Jun 4, 2018 (Retired)
Owner
David (eukaprotech)
Contributor
David (eukaprotech)
1
Activity
Badge
Generate
Download
Source code

Advertisement

Description

An android asynchronous preview of a webpage from its link.

Versions

Getting Started (V1.0.0)

Add the dependency in build.gradle (App module)

compile 'com.eukaprotech.linkpreview:linkpreview:1.0.0@aar'

Add permission in manifest file

<uses-permission android:name="android.permission.INTERNET" />

Usage (V1.0.0)

    LinkPreview linkPreview = new LinkPreview(context);
    String link = "the web page complete link";
    linkPreview.preview(link, new LinkPreviewHandler() {

        @Override
        public void onStart() {
            
        }

        @Override
        public void onGetLinkRedirectedTo(String link_redirected_to) {
            
        }

        @Override
        public void onGetTitle(String title) {
            
        }

        @Override
        public void onGetDescription(String description) {
            
        }

        @Override
        public void onGetFavicon(String faviconLink) {
            
        }

        @Override
        public void onGetImageLink(String imageLink) {
            
        }

        @Override
        public void onFail(String response, String error) {
            
        }


        @Override
        public void onComplete() {
            
        }
    });

By default, the necessary preview content of the web page is stored to cache for faster later retrieval.

To skip reading from cache:

   linkPreview.skipReadFromCache(true);

To skip storing to cache:

   linkPreview.skipStoreToCache(true);

The below sample will avoid reading the contents of the previewed webpage from cache:

    LinkPreview linkPreview = new LinkPreview(context);
    String link = "the web page complete link";
    linkPreview.skipReadFromCache(true).preview(link, new LinkPreviewHandler() {

        @Override
        public void onStart() {
            
        }

        @Override
        public void onGetLinkRedirectedTo(String link_redirected_to) {
            
        }

        @Override
        public void onGetTitle(String title) {
            
        }

        @Override
        public void onGetDescription(String description) {
            
        }

        @Override
        public void onGetFavicon(String faviconLink) {
            
        }

        @Override
        public void onGetImageLink(String imageLink) {
            
        }

        @Override
        public void onFail(String response, String error) {
            
        }


        @Override
        public void onComplete() {
            
        }
    });

The entire cache, for all previewed web pages, is cleared with time.

To force the clearing of cache, use the static method:

   LinkPreview.clearCache(context);