Skip to content

Commit

Permalink
fixed crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Smithy-x committed Mar 9, 2024
1 parent 126e082 commit 3393748
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 99 deletions.
27 changes: 12 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {
}

}

externalNativeBuild {
ndkBuild {
path = File("src/main/jni/Android.mk")
Expand Down Expand Up @@ -91,20 +90,17 @@ dependencies {

// Accompanist

implementation("org.nanohttpd:nanohttpd:2.3.1")
implementation("commons-net:commons-net:3.6")

implementation("de.hdodenhof:circleimageview:3.1.0")
implementation("javax.inject:javax.inject:1")
implementation("net.danlew:android.joda:2.12.5")

implementation("org.nanohttpd:nanohttpd-webserver:2.3.1")
implementation("com.squareup.picasso:picasso:2.71828")

implementation("io.coil-kt:coil-compose:2.2.2")
implementation("io.noties.markwon:core:4.6.2")
implementation(libs.nanohttpd)
implementation(libs.nanohttpd.webserver)
implementation(libs.commons.net)
implementation(libs.circleimageview)
implementation(libs.picasso)
implementation(libs.coil.compose)
implementation(libs.markwon.core)
implementation(libs.kotlinx.coroutines.android)

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
implementation(libs.javax.inject)
implementation(libs.android.joda)

implementation(platform(libs.firebase.bom))
implementation(libs.firebase.crashlytics.ktx)
Expand All @@ -113,7 +109,6 @@ dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraint)
implementation(libs.androidx.constraint.compose)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.preference.ktx)
implementation(libs.androidx.swiperefreshlayout)
Expand All @@ -123,6 +118,7 @@ dependencies {
implementation(libs.accompanist.pager)
implementation(libs.accompanist.pager.indicators)
implementation(libs.accompanist.themeadapter)
implementation(libs.androidx.animation.graphics.android)

ksp(libs.glide.ksp)
implementation(libs.glide)
Expand Down Expand Up @@ -171,6 +167,7 @@ dependencies {
implementation(libs.androidx.navigation.testing)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.navigation.runtime.ktx)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.fragment.ktx)
androidTestImplementation(libs.androidx.navigation.testing)
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/io/vonley/mi/ui/interop/MainActivityXml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import android.view.LayoutInflater
import android.view.View
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.viewinterop.AndroidViewBinding
Expand Down Expand Up @@ -91,8 +97,9 @@ class MainActivityXml : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PreviewHomeFragmentView() { binding ->
this.navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
PreviewHomeFragmentView { binding ->
this@MainActivityXml.navHostFragment =
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
setSupportActionBar(binding.bottomAppBar)
NavigationUI.setupWithNavController(binding.bottomNavigation, navController)
navController.addOnDestinationChangedListener(onDestinationChanged(binding))
Expand All @@ -105,7 +112,9 @@ class MainActivityXml : AppCompatActivity() {
@Composable
@Preview(showBackground = true)
fun PreviewHomeFragmentView(binding: ((binding: ActivityMainXmlBinding) -> Unit)? = null) {
AndroidViewBinding(ActivityMainXmlBinding::inflate) {
AndroidViewBinding(factory = { inflator, parent, attachToParent ->
ActivityMainXmlBinding.inflate(inflator, parent, attachToParent)
}) {
binding?.invoke(this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
Expand Down Expand Up @@ -48,10 +52,8 @@ class HomeFragmentView : Fragment() {
fun HomeView() {
val vm = hiltViewModel<HomeViewModel>()
val logs = vm.state.collectAsState()
Column() {
ArticleList() {
LogList(logs)
}
ArticleList {
LogList(logs)
}
}

Expand All @@ -65,28 +67,33 @@ fun LogList(state: State<HomeState>) {
fontStyle = FontStyle.Normal,
fontSize = 20.sp
)
Column(modifier = Modifier.verticalScroll(state = ScrollState(0))) {
when (val curr = state.value) {
HomeState.Empty -> {
LogCardBase(
title = "Connect to http://192.168.11.18:8080",
description = "",
background = Mi.Color.QUATERNARY
)
}
is HomeState.Log -> {
curr.logs.forEach {
when (val curr = state.value) {
HomeState.Empty -> {
LogCardBase(
title = "Connect to http://192.168.11.18:8080",
description = "",
background = Mi.Color.QUATERNARY
)
}

is HomeState.Log -> {
LazyColumn {
items(curr.logs) {
LogCard(log = it)
}
}
}
}

}

@Composable
inline fun ArticleList(content: @Composable () -> Unit) {
inline fun ArticleList(crossinline content: @Composable () -> Unit) {
Column(
modifier = Modifier.verticalScroll(state = ScrollState(0))
modifier = Modifier
.verticalScroll(ScrollState(0))
.fillMaxHeight()
.fillMaxWidth()
) {
Mi.ARTICLES.forEach {
ArticleCard(article = it)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package io.vonley.mi.ui.screens.packages.presentation

import android.graphics.drawable.AnimatedVectorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -18,17 +23,22 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.fragment.app.Fragment
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import coil.compose.rememberAsyncImagePainter
import dagger.hilt.android.AndroidEntryPoint
import io.vonley.mi.Mi
Expand Down Expand Up @@ -283,7 +293,7 @@ fun ListRepoPackages(packages: Array<Package>, onPackageClick: (Package) -> Unit
}
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationGraphicsApi::class)
@Composable
fun RepoPackageItem(repoPackage: Package, onPackageClick: (Package) -> Unit) {
Card(
Expand All @@ -297,11 +307,11 @@ fun RepoPackageItem(repoPackage: Package, onPackageClick: (Package) -> Unit) {
onPackageClick(repoPackage)
}
) {

val animated = ImageVector.vectorResource(io.vonley.mi.R.drawable.icon_svg_inbox)
val painter = rememberAsyncImagePainter(
model = repoPackage.icon,
placeholder = painterResource(
id = io.vonley.mi.R.mipmap.orb
)
placeholder = rememberVectorPainter(animated)
)
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down
Loading

0 comments on commit 3393748

Please sign in to comment.