-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化加载和缓存性能,修改默认HttpLoader为OkHttpLoader来提高图片请求性能
- Loading branch information
1 parent
f589cd4
commit b0df20b
Showing
13 changed files
with
83 additions
and
26 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.lt.load_the_image.loader | ||
package com.lt.load_the_image.loader.http | ||
|
||
/** | ||
* creator: lt 2022/4/8 [email protected] | ||
|
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
27 changes: 27 additions & 0 deletions
27
load-the-image/src/main/java/com/lt/load_the_image/loader/http/OkHttpLoader.kt
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,27 @@ | ||
package com.lt.load_the_image.loader.http | ||
|
||
import com.lt.load_the_image.util.println | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
|
||
/** | ||
* creator: lt 2022/4/8 [email protected] | ||
* effect : Use OkHttp load url | ||
* warning: | ||
*/ | ||
open class OkHttpLoader( | ||
private val okHttpClient: OkHttpClient = OkHttpClient() | ||
) : HttpLoader { | ||
|
||
override fun load(url: String): ByteArray? { | ||
return try { | ||
val build = Request.Builder() | ||
.url(url) | ||
.build() | ||
okHttpClient.newCall(build).execute().body?.bytes() | ||
} catch (e: Exception) { | ||
e.println() | ||
null | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,12 +14,14 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.lt.load_the_image.loader | ||
package com.lt.load_the_image.loader.image | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import com.lt.load_the_image.LoadTheImageManager | ||
import com.lt.load_the_image.loader.DataToBeLoaded | ||
import com.lt.load_the_image.loader.LoadTheImage | ||
|
||
/** | ||
* creator: lt 2022/6/1 [email protected] | ||
|
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