-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangpeng
committed
Jan 28, 2020
1 parent
b5449a7
commit f16341c
Showing
18 changed files
with
95 additions
and
515 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
106 changes: 53 additions & 53 deletions
106
app/src/main/java/ch/ielse/demo/p02/FrescoSimpleLoader.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 |
---|---|---|
@@ -1,53 +1,53 @@ | ||
package ch.ielse.demo.p02; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.net.Uri; | ||
import android.support.annotation.Nullable; | ||
|
||
import com.facebook.common.executors.CallerThreadExecutor; | ||
import com.facebook.common.references.CloseableReference; | ||
import com.facebook.datasource.DataSource; | ||
import com.facebook.drawee.backends.pipeline.Fresco; | ||
import com.facebook.imagepipeline.core.ImagePipeline; | ||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber; | ||
import com.facebook.imagepipeline.image.CloseableImage; | ||
import com.facebook.imagepipeline.request.ImageRequest; | ||
import com.facebook.imagepipeline.request.ImageRequestBuilder; | ||
import com.github.ielse.imagewatcher.ImageWatcher; | ||
|
||
class FrescoSimpleLoader implements ImageWatcher.Loader { | ||
@Override | ||
public void load(final Context context, Uri uri, final ImageWatcher.LoadCallback lc) { | ||
lc.onLoadStarted(null); | ||
|
||
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(true).build(); | ||
ImagePipeline imagePipeline = Fresco.getImagePipeline(); | ||
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this); | ||
dataSource.subscribe(new BaseBitmapDataSubscriber() { | ||
@Override | ||
public void onNewResultImpl(@Nullable final Bitmap bitmap) { | ||
//bitmap即为下载所得图片 | ||
|
||
((Activity) context).runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
lc.onResourceReady(new BitmapDrawable(bitmap)); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onFailureImpl(DataSource dataSource) { | ||
((Activity) context).runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
lc.onLoadFailed(null); | ||
} | ||
}); | ||
} | ||
}, CallerThreadExecutor.getInstance()); | ||
} | ||
} | ||
//package ch.ielse.demo.p02; | ||
// | ||
//import android.app.Activity; | ||
//import android.content.Context; | ||
//import android.graphics.Bitmap; | ||
//import android.graphics.drawable.BitmapDrawable; | ||
//import android.net.Uri; | ||
//import android.support.annotation.Nullable; | ||
// | ||
//import com.facebook.common.executors.CallerThreadExecutor; | ||
//import com.facebook.common.references.CloseableReference; | ||
//import com.facebook.datasource.DataSource; | ||
//import com.facebook.drawee.backends.pipeline.Fresco; | ||
//import com.facebook.imagepipeline.core.ImagePipeline; | ||
//import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber; | ||
//import com.facebook.imagepipeline.image.CloseableImage; | ||
//import com.facebook.imagepipeline.request.ImageRequest; | ||
//import com.facebook.imagepipeline.request.ImageRequestBuilder; | ||
//import com.github.ielse.imagewatcher.ImageWatcher; | ||
// | ||
//class FrescoSimpleLoader implements ImageWatcher.Loader { | ||
// @Override | ||
// public void load(final Context context, Uri uri, final ImageWatcher.LoadCallback lc) { | ||
// lc.onLoadStarted(null); | ||
// | ||
// ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(true).build(); | ||
// ImagePipeline imagePipeline = Fresco.getImagePipeline(); | ||
// DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this); | ||
// dataSource.subscribe(new BaseBitmapDataSubscriber() { | ||
// @Override | ||
// public void onNewResultImpl(@Nullable final Bitmap bitmap) { | ||
// //bitmap即为下载所得图片 | ||
// | ||
// ((Activity) context).runOnUiThread(new Runnable() { | ||
// @Override | ||
// public void run() { | ||
// lc.onResourceReady(new BitmapDrawable(bitmap)); | ||
// } | ||
// }); | ||
// } | ||
// | ||
// @Override | ||
// public void onFailureImpl(DataSource dataSource) { | ||
// ((Activity) context).runOnUiThread(new Runnable() { | ||
// @Override | ||
// public void run() { | ||
// lc.onLoadFailed(null); | ||
// } | ||
// }); | ||
// } | ||
// }, CallerThreadExecutor.getInstance()); | ||
// } | ||
//} |
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,31 +1,26 @@ | ||
package github.iielse.imageviewer.demo | ||
|
||
import android.util.Log | ||
|
||
data class Picture( | ||
val url: String, | ||
val width: Int, | ||
val height: Int | ||
) | ||
|
||
data class Feed( | ||
val id: Int, | ||
val title: String, | ||
val cover: Picture | ||
) | ||
|
||
fun fetch(pageNo: Int) { | ||
|
||
if (pageNo == 0) { | ||
} | ||
} | ||
|
||
fun test() { | ||
import android.os.Handler | ||
import android.os.Looper | ||
import com.google.gson.Gson | ||
import com.google.gson.reflect.TypeToken | ||
|
||
fun fetch(pageNo: Int, callback: (List<Feed>) -> Unit) { | ||
mainHandler.postDelayed({ | ||
callback(gson.fromJson(when (pageNo) { | ||
0 -> page1 | ||
1 -> page2 | ||
2 -> page3 | ||
else -> "[]" | ||
}, object : TypeToken<List<Feed>>() {}.type)) | ||
}, 200) | ||
} | ||
|
||
data class Picture(val url: String, val width: Int, val height: Int) | ||
data class Feed(val imageUrl: String, val title: String, val id: Int) | ||
|
||
data class Temp( | ||
val roomImageUrl: String, | ||
val roomNo: Int, | ||
val roomOwnerNickName: String | ||
) | ||
private val gson = Gson() | ||
private val mainHandler = Handler(Looper.getMainLooper()) | ||
private const val page1 = "[{\"id\":511257,\"imageUrl\":\"http://static.unicolive.com/20190715/me_0-1563200961.618469\",\"title\":\"(◕ H ◕)\"},{\"id\":114128,\"imageUrl\":\"http://static.unicolive.com/20190921/me_0-1569009105.980272\",\"title\":\"sini kuy\"},{\"id\":1807011,\"imageUrl\":\"http://static.unicolive.com/20190909/me_0-1568015233.561832\",\"title\":\"Cà khịa mọi người ui \uD83E\uDD70\uD83D\uDE18\"},{\"id\":1737997,\"imageUrl\":\"http://static.unicolive.com/20190901/register_0-1567351873.8413858\",\"title\":\"hello mn✌\uD83C\uDFFC\"},{\"id\":118204,\"imageUrl\":\"http://static.unicolive.com/18201-1568118760945\",\"title\":\"[JD]N\"},{\"id\":118975,\"imageUrl\":\"http://static.unicolive.com/18972-1563897100975.jpg\",\"title\":\"\uD83D\uDE18\"},{\"id\":1175247,\"imageUrl\":\"http://static.unicolive.com/716256-1565635947518.jpg\",\"title\":\"مساء الخيير \uD83D\uDC9C\"},{\"id\":119866,\"imageUrl\":\"http://static.unicolive.com/19863-1563799135564.jpg\",\"title\":\"bntu supportny \uD83D\uDE4F\"},{\"id\":1468481,\"imageUrl\":\"http://static.unicolive.com/1008883-1565012543776.jpg\",\"title\":\"اسماء\"},{\"id\":1665038,\"imageUrl\":\"http://static.unicolive.com/20190907/me_0-1567852815.8663669\",\"title\":\"use ơi\"},{\"id\":116199,\"imageUrl\":\"http://static.unicolive.com/16197-1568829846572\",\"title\":\"يارب\"},{\"id\":584871,\"imageUrl\":\"http://static.unicolive.com/483490-1567823381482\",\"title\":\"music\"},{\"id\":130315,\"imageUrl\":\"http://static.unicolive.com/30305-1558239762430.jpg\",\"title\":\"ياااااارب التارجت بقااا\uD83D\uDE2D\uD83D\uDE2D\uD83D\uDE2D\"},{\"id\":119380,\"imageUrl\":\"http://static.unicolive.com/19377-1564675511867.jpg\",\"title\":\"[McD] Gracella\"},{\"id\":122366,\"imageUrl\":\"http://static.unicolive.com/22363-1562250897238.jpg\",\"title\":\"hai\"},{\"id\":581573,\"imageUrl\":\"http://static.unicolive.com/20190924/me_0-1569294296.057159\",\"title\":\"MIMI [MCD]\"},{\"id\":1702281,\"imageUrl\":\"http://static.unicolive.com/20190828/me_0-1566970123.035431\",\"title\":\"Hôm nay Sồ lại live \"},{\"id\":1738379,\"imageUrl\":\"http://static.unicolive.com/20190901/register_0-1567354441.867106\",\"title\":\"a ăn cơm chưa vậy\uD83D\uDE02\uD83D\uDE02\uD83D\uDE02\"},{\"id\":570429,\"imageUrl\":\"http://static.unicolive.com/469085-1561535283130.jpg\",\"title\":\"Suport Event Musik\uD83D\uDE18\"},{\"id\":574704,\"imageUrl\":\"http://static.unicolive.com/473352-1566034586120.jpg\",\"title\":\"hellow\"},{\"id\":1424670,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F91.png\",\"title\":\"siang\"},{\"id\":668571,\"imageUrl\":\"http://static.unicolive.com/566930-1568146220282\",\"title\":\"@Britzone English Club\"},{\"id\":295751,\"imageUrl\":\"http://static.unicolive.com/195240-1568321854765\",\"title\":\"1jam\"},{\"id\":119824,\"imageUrl\":\"http://static.unicolive.com/19821-1567760875040\",\"title\":\"[MCD] sunflower\"},{\"id\":119237,\"imageUrl\":\"http://static.unicolive.com/20190508/19234-1557318000834.jpg\",\"title\":\"Temanin \"},{\"id\":576333,\"imageUrl\":\"http://static.unicolive.com/474969-1568501179732\",\"title\":\"sejam lagi\"},{\"id\":122894,\"imageUrl\":\"http://static.unicolive.com/22891-1569138425374\",\"title\":\"\uD83C\uDF37LIAHAN2\uD83C\uDF37\"},{\"id\":136884,\"imageUrl\":\"http://static.unicolive.com/36869-1565149139932.jpg\",\"title\":\"support me pliss\"},{\"id\":1782829,\"imageUrl\":\"http://unic-check-img.uae-dubai.ufileos.com/20190913/me_0-1568327674.688939\",\"title\":\"challenge Old Age MakeUp\uD83E\uDD36\uD83C\uDFFB\"},{\"id\":1293848,\"imageUrl\":\"http://static.unicolive.com/834819-1565349279690.jpg\",\"title\":\"coins for camilla\"}]" | ||
private const val page2 = "[{\"id\":1690803,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F6.png\",\"title\":\"days 17 \\\"EVENT MUSIC\\\"\"},{\"id\":1722783,\"imageUrl\":\"http://static.unicolive.com/1262817-1567796173937\",\"title\":\"\uD83D\uDC78ملكة\uD83D\uDC95 نفسي\uD83D\uDC96\"},{\"id\":1672153,\"imageUrl\":\"http://static.unicolive.com/20190908/me_0-1567936408.52511\",\"title\":\"haii ❤️\uD83D\uDDA4\uD83E\uDD70\"},{\"id\":1725267,\"imageUrl\":\"http://static.unicolive.com/1265298-1567225340746\",\"title\":\"vô lắc lư cho hết buồn\uD83D\uDE02\uD83D\uDE02\uD83D\uDE02\"},{\"id\":1704052,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F23.png\",\"title\":\"vào lại Mn oi\"},{\"id\":153904,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569328021.615963\",\"title\":\"bru smpe rmh \uD83D\uDE2B\"},{\"id\":1689347,\"imageUrl\":\"http://static.unicolive.com/20190826/me_0-1566809710.261486\",\"title\":\"MUN BFLY\"},{\"id\":1753307,\"imageUrl\":\"http://static.unicolive.com/20190904/me_0-1567565539.288422\",\"title\":\"\uD83E\uDD8ADoraemon \"},{\"id\":1691074,\"imageUrl\":\"http://static.unicolive.com/20190918/me_0-1568740270.2149181\",\"title\":\"talk+music\"},{\"id\":1702310,\"imageUrl\":\"http://static.unicolive.com/20190906/me_0-1567716808.865864\",\"title\":\"idol ms nà\uD83D\uDE02\"},{\"id\":157394,\"imageUrl\":\"http://static.unicolive.com/57328-1567190462582\",\"title\":\"\uD83D\uDC4B hi\"},{\"id\":1468043,\"imageUrl\":\"http://static.unicolive.com/20190919/me_0-1568908815.083327\",\"title\":\"sakit\"},{\"id\":1664490,\"imageUrl\":\"http://static.unicolive.com/1204610-1566467119606\",\"title\":\"[KOB]Celly\"},{\"id\":1696903,\"imageUrl\":\"http://static.unicolive.com/1236985-1568808175225\",\"title\":\"ممكن تقرو الفاتحه لأختي\"},{\"id\":1698449,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569326625.33106\",\"title\":\"\uD83C\uDF03\"},{\"id\":1709336,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F4.png\",\"title\":\"amada⭐\"},{\"id\":1389350,\"imageUrl\":\"http://static.unicolive.com/930288-1567919611905\",\"title\":\"-1200\"},{\"id\":1665671,\"imageUrl\":\"http://static.unicolive.com/1205791-1566484042784\",\"title\":\"{PF} INDAH\uD83D\uDC9E\"},{\"id\":1734760,\"imageUrl\":\"http://static.unicolive.com/1274772-1567324288858\",\"title\":\"hiiii\"},{\"id\":1737007,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569330047.949619\",\"title\":\"Hi. help me 500 for target\"},{\"id\":1775528,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569330268.155995\",\"title\":\"hello mọi người \uD83D\uDE0D\"},{\"id\":1813222,\"imageUrl\":\"http://static.unicolive.com/1353127-1567874140154\",\"title\":\"مراحب welcom\"},{\"id\":1737307,\"imageUrl\":\"http://static.unicolive.com/20190901/register_0-1567346568.598847\",\"title\":\"ai nhớ tui hôn\"},{\"id\":1724197,\"imageUrl\":\"http://static.unicolive.com/1264228-1568502817136\",\"title\":\"\uD83D\uDC84الاء \uD83D\uDC85\uD83D\uDC8B\uD83D\uDC84\"},{\"id\":1709451,\"imageUrl\":\"http://static.unicolive.com/20190830/me_0-1567131124.294796\",\"title\":\"Help me 500 coin\uD83D\uDE0D♥️\"},{\"id\":1662903,\"imageUrl\":\"http://static.unicolive.com/1203023-1566436070011\",\"title\":\"hello help me 50 coin\"},{\"id\":1661605,\"imageUrl\":\"http://static.unicolive.com/20190830/me_0-1567197797.224405\",\"title\":\"miryaam\"},{\"id\":1784777,\"imageUrl\":\"http://static.unicolive.com/20190905/me_0-1567679370.5308042\",\"title\":\"\uD83D\uDC8E\uD83D\uDC8E\uD83D\uDC8E\"},{\"id\":1796445,\"imageUrl\":\"http://static.unicolive.com/1336383-1567753010776\",\"title\":\"hú hú\uD83E\uDD23\"},{\"id\":1839029,\"imageUrl\":\"http://static.unicolive.com/1378895-1568118496861\",\"title\":\"[KM] Erlina\"}]" | ||
private const val page3 = "[{\"id\":1784777,\"imageUrl\":\"http://static.unicolive.com/20190905/me_0-1567679370.5308042\",\"title\":\"\uD83D\uDC8E\uD83D\uDC8E\uD83D\uDC8E\"},{\"id\":123781,\"imageUrl\":\"http://static.unicolive.com/23778-1564657460457.jpg\",\"title\":\"bantu aku dong :(\"},{\"id\":1838120,\"imageUrl\":\"http://static.unicolive.com/1377986-1568032789984\",\"title\":\"هلااا❤❤❤\"},{\"id\":172795,\"imageUrl\":\"http://static.unicolive.com/72677-1569110415875\",\"title\":\"قطرة ندى\"},{\"id\":1743673,\"imageUrl\":\"http://static.unicolive.com/20190916/me_0-1568639597.955298\",\"title\":\"ồ lalla \uD83D\uDE02♥️\"},{\"id\":1717901,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569330220.717983\",\"title\":\"hello cả nhà\"},{\"id\":1688793,\"imageUrl\":\"http://static.unicolive.com/1228889-1568796550156\",\"title\":\"lg skit :)\"},{\"id\":116098,\"imageUrl\":\"http://static.unicolive.com/16096-1567422766564\",\"title\":\"Loleta\"},{\"id\":1696698,\"imageUrl\":\"http://static.unicolive.com/1236780-1566901941948\",\"title\":\"Manar Lt\"},{\"id\":130288,\"imageUrl\":\"http://static.unicolive.com/30278-1568323191148\",\"title\":\"امير ابن سوريا \"},{\"id\":1772542,\"imageUrl\":\"https://platform-lookaside.fbsbx.com/platform/profilepic/?asid\\u003d219024612416250\\u0026height\\u003d50\\u0026width\\u003d50\\u0026ext\\u003d1570183259\\u0026hash\\u003dAeTqUAQ65y_Oz7ue\",\"title\":\"casting nè\uD83D\uDE02\uD83D\uDE02\"},{\"id\":1727706,\"imageUrl\":\"http://static.unicolive.com/1267737-1567253955501\",\"title\":\"bé xin 100kc hoy❤\"},{\"id\":1718724,\"imageUrl\":\"http://static.unicolive.com/20190830/register_0-1567166596.770875\",\"title\":\"samara\"},{\"id\":1837314,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F33.png\",\"title\":\"jangan masuk lagi wik2\uD83D\uDC83\uD83C\uDFFB\uD83D\uDCA8\"},{\"id\":1696458,\"imageUrl\":\"http://static.unicolive.com/1236540-1566899662690\",\"title\":\"night out\"},{\"id\":1686782,\"imageUrl\":\"http://static.unicolive.com/1226878-1569234763254\",\"title\":\"Holaaa\uD83D\uDC83\uD83C\uDFFC\"},{\"id\":1714688,\"imageUrl\":\"http://static.unicolive.com/20190924/me_0-1569326115.046289\",\"title\":\"casting \"},{\"id\":1711337,\"imageUrl\":\"http://static.unicolive.com/20190924/start_live_0-1569329151.635291\",\"title\":\"castinggg \uD83D\uDC8B\uD83D\uDC8B\uD83D\uDC8B\"},{\"id\":1748231,\"imageUrl\":\"http://static.unicolive.com/1288232-1567601663099\",\"title\":\"Casting\"},{\"id\":1191935,\"imageUrl\":\"http://static.unicolive.com/732941-1569306477054\",\"title\":\"ممنوع دخول البوابين \"},{\"id\":1835409,\"imageUrl\":\"http://static.unicolive.com/1375275-1568168533581\",\"title\":\"Hello ❤❤❤❤\"},{\"id\":1965460,\"imageUrl\":\"http://cdn.unicolive.com/woman_default.png\",\"title\":\"Ani\"},{\"id\":1715164,\"imageUrl\":\"http://static.unicolive.com/1255220-1567133868997\",\"title\":\"Explore Rumah tua\"},{\"id\":1988417,\"imageUrl\":\"http://static.unicolive.com/1528033-1569169249230\",\"title\":\"vo noi chuyen di\"},{\"id\":1966754,\"imageUrl\":\"http://static.unicolive.com/20190920/me_0-1568948302.7193751\",\"title\":\"cassting \uD83D\uDC8B\uD83D\uDC8B\"},{\"id\":1988397,\"imageUrl\":\"http://cdn.unicolive.com/cover%2F43.png\",\"title\":\"trò chuyện mọi người ơi\"},{\"id\":2000380,\"imageUrl\":\"http://static.unicolive.com/20190924/me_0-1569327363.548912\",\"title\":\"CASTINGGGG\"},{\"id\":2000401,\"imageUrl\":\"http://static.unicolive.com/1540013-1569328786217\",\"title\":\"⚘\uD83D\uDC9DLOVE GURU \uD83D\uDC9D⚘\"},{\"id\":1999928,\"imageUrl\":\"http://static.unicolive.com/1539542-1569322457639\",\"title\":\"Lucky\"},{\"id\":1577335,\"imageUrl\":\"http://static.unicolive.com/1117586-1569330353926\",\"title\":\"حمودي\"}]" |
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
Oops, something went wrong.