Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 2.91 KB

README.md

File metadata and controls

95 lines (70 loc) · 2.91 KB

BahaUrlPreview

Maven Central

The library help android developer easier to get url preview info.

100% Kotlin , use Kotlin-coroutines to fetch html code.

Inspire by LeonardoCardoso-SwiftLinkPreview,Android-Link-Preview!

Demo

device-2021-04-29-115050.mp4

How do I use BahaUrlPreview

Setup

//Top-level build.gradle
buildscript {
  ...
    repositories {
      mavenCentral()
      ...
    }
}

//project build.gradle
dependencies {
    ...
    implementation 'tw.com.oneup.www:Baha-UrlPreview:1.0.1'
}

Functions

val urlPreview = BahaUrlPreview(urlString, object : IUrlPreviewCallback {
                override fun onComplete(urlInfo: UrlInfoItem) {
                    //urlInfo.title -> is url preivew title
                    //urlInfo.description -> is url preview 
                    //urlInfo.image -> is url preview image
                 }

                override fun onFailed(throwable: Throwable) {
                   // in there control error
                 }
               })

urlPreview.fetchUrlPreview()


//avoid memory leak ,when activity or fragment destory need call BahaUrlPreview.cleanUp()

override fun onDestroy() {
  ...
   urlPreview.cleanUp()
}

Requirements

Android 5.+ (API 21)

Latest version

- v1.0.1 (May 6 , 2021)

Recent Breaking Change Info

- v1.0.1
  1.add support to url that ends with image type (eg., .jpg

Developed By

OneupNetwork-SolinariWu 

License

MIT License

Copyright (c) 2021 OneupNetwork

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.