forked from LeonardoCardoso/Android-Link-Preview
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from LoxiaLiSA/master
add DocumentGetter
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
library/src/main/java/com/leocardz/link/preview/library/BaseDocumentGetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.leocardz.link.preview.library; | ||
|
||
public abstract class BaseDocumentGetter implements DocumentGetter { | ||
|
||
protected String url; | ||
|
||
public BaseDocumentGetter(String url) { | ||
this.url = url; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
library/src/main/java/com/leocardz/link/preview/library/DocumentGetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.leocardz.link.preview.library; | ||
|
||
import org.jsoup.nodes.Document; | ||
|
||
import java.io.IOException; | ||
|
||
public interface DocumentGetter { | ||
|
||
Document getDocument() throws IOException; | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
library/src/main/java/com/leocardz/link/preview/library/JsoupDocumentGetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.leocardz.link.preview.library; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
|
||
import java.io.IOException; | ||
|
||
public class JsoupDocumentGetter extends BaseDocumentGetter { | ||
|
||
public JsoupDocumentGetter(String url) { | ||
super(url); | ||
} | ||
|
||
@Override | ||
public Document getDocument() throws IOException { | ||
return Jsoup.connect(url).userAgent("Mozilla").get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters