项目作者: Schinizer

项目描述 :
A reactive extension to generate URL previews.
高级语言: Java
项目地址: git://github.com/Schinizer/RxUnfurl.git
创建时间: 2016-08-29T16:56:45Z
项目社区:https://github.com/Schinizer/RxUnfurl

开源协议:Apache License 2.0

下载


RxUnfurl

Download
Build Status

A reactive extension to generate URL previews.

This library parses available open graph data from the provided url and returns them as a simple model class. Otherwise, the library searches for other fallbacks and returns them instead.

Image dimensions are read from its uri by fetching the required bytes and then sorted according to their resolution.

Gradle dependency

To use the library, add the following dependency to your build.gradle

  1. dependencies {
  2. compile 'com.schinizer:rxunfurl:0.3.0'
  3. }

RxJava 2 notice

RxUnfurl.generatePreview() is now a Single instead of an Observable

RxJava 1 is dropped entirely and no longer supported.

Usage

To generate previews, simply subscribe to RxUnfurl.generatePreview(yourURL).

If you are on android, you will need RxAndroid to subscribe to network calls on another thread.

  1. OkHttpClient okhttpClient = new OkHttpClient();
  2. RxUnfurl inst = new RxUnfurl.Builder()
  3. .client(okhttpClient) // You can supply your okhttp client here
  4. .scheduler(Schedulers.io())
  5. .build();
  6. inst.generatePreview("http://9gag.com")
  7. .observeOn(AndroidSchedulers.mainThread())
  8. .subscribeWith(new DisposableSingleObserver<PreviewData>() {
  9. @Override
  10. public void onSuccess(PreviewData previewData) { // Observable has been changed to Single
  11. }
  12. @Override
  13. public void onError(Throwable e) {
  14. }
  15. });

Sample App

You may find a sample android implementation in /app.

License

  1. Copyright 2016 Schinizer
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.