Skip to content

Commit

Permalink
Fix Crash for low end devices.
Browse files Browse the repository at this point in the history
Used Coil instead of Glide to load Image.
  • Loading branch information
yogeshpaliyal committed Dec 2, 2021
1 parent 87b79e5 commit 0c24210
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
implementation "androidx.activity:activity-compose:$compose_activity_version"

implementation "com.github.skydoves:landscapist-glide:$landscapist_version"
implementation "com.mxalbert.zoomable:zoomable:$zoomable_version"

implementation("io.coil-kt:coil-compose:1.4.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,55 @@ package io.getstream.androiddeveloperroadmap
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.rememberImagePainter
import com.mxalbert.zoomable.Zoomable
import com.skydoves.landscapist.glide.GlideImage
import io.getstream.androiddeveloperroadmap.ui.theme.AndroidDeveloperRoadmapTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
AndroidDeveloperRoadmapTheme {
Surface(
color = MaterialTheme.colors.background
) {
Roadmap()
setContent {
AndroidDeveloperRoadmapTheme {
Surface(
color = MaterialTheme.colors.background
) {
Roadmap()
}
}
}
}
}
}
}

@Composable
private fun Roadmap() {
Zoomable(
modifier = Modifier.height(3200.dp)
) {
GlideImage(
imageModel = "https://user-images.githubusercontent.com/24237865/144350753-5a52e6e5-3517-476c-8e5c-adad919abe8e.png",
modifier = Modifier.fillMaxSize(),
previewPlaceholder = R.drawable.roadmap_preview,
contentScale = ContentScale.Fit
)
}
Zoomable(
modifier = Modifier.fillMaxSize(),
) {
Image(
painter = rememberImagePainter("https://user-images.githubusercontent.com/24237865/144350753-5a52e6e5-3517-476c-8e5c-adad919abe8e.png",
builder = {
placeholder(R.drawable.roadmap_preview)
}),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Fit,
contentDescription = null
)
}
}

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
AndroidDeveloperRoadmapTheme {
Roadmap()
}
AndroidDeveloperRoadmapTheme {
Roadmap()
}
}
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pluginManagement {
mavenCentral()
}
plugins {
id 'com.android.application' version '7.1.0-alpha13'
id 'com.android.library' version '7.1.0-alpha13'
id 'com.android.application' version '7.1.0-beta03'
id 'com.android.library' version '7.1.0-beta03'
id 'org.jetbrains.kotlin.android' version '1.5.31'
}
}
Expand Down

0 comments on commit 0c24210

Please sign in to comment.