Skip to content

Commit

Permalink
메모리 사용 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
jisungbin committed Jul 27, 2021
1 parent 863bd56 commit c31f793
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 280 deletions.
11 changes: 9 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
// id("kotlinx-serialization")
id("dagger.hilt.android.plugin")
id("name.remal.check-dependency-updates") version Versions.Util.CheckDependencyUpdates
}
Expand Down Expand Up @@ -53,14 +52,14 @@ android {
sourceSets {
getByName("main").run {
java.srcDirs("src/main/kotlin")
resources.excludes.add("META-INF/library_release.kotlin_module")
}
}

buildTypes {
release {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
}
}

Expand All @@ -75,6 +74,11 @@ android {
}

dependencies {
implementation("com.github.skydoves:landscapist-coil:1.2.8") {
exclude(group = "androidx.appcompat", module = "appcompat")
exclude(group = "androidx.appcompat", module = "appcompat-resources")
}

Dependencies.debug.forEach(::debugImplementation)
Dependencies.essential.forEach(::implementation)
Dependencies.network.forEach(::implementation)
Expand All @@ -84,4 +88,7 @@ dependencies {
Dependencies.hilt.forEach(::implementation)
Dependencies.room.forEach(::implementation)
Dependencies.compiler.forEach(::kapt)

// https://whyprogrammer.tistory.com/590
kapt("org.xerial:sqlite-jdbc:3.34.0")
}
38 changes: 0 additions & 38 deletions app/src/main/kotlin/team/bravepeople/devevent/GlideModule.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ import androidx.compose.ui.unit.sp
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import me.sungbin.fancybottombar.FancyBottomBar
import me.sungbin.fancybottombar.FancyColors
import me.sungbin.fancybottombar.FancyItem
import team.bravepeople.devevent.R
import team.bravepeople.devevent.activity.main.event.EventFilter
import team.bravepeople.devevent.activity.main.event.EventViewModel
Expand All @@ -72,22 +74,15 @@ import team.bravepeople.devevent.theme.SystemUiController
import team.bravepeople.devevent.theme.colors
import team.bravepeople.devevent.ui.chip.ChipViewModel
import team.bravepeople.devevent.ui.chip.FlowTag
import team.bravepeople.devevent.ui.fancybottombar.FancyBottomBar
import team.bravepeople.devevent.ui.fancybottombar.FancyColors
import team.bravepeople.devevent.ui.fancybottombar.FancyItem
import team.bravepeople.devevent.util.AlarmUtil
import team.bravepeople.devevent.util.Data
import team.bravepeople.devevent.util.config.PathConfig
import team.bravepeople.devevent.util.extension.toast

private enum class Tab {
Main, Favorite, Info
}
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : ComponentActivity() {


private var backButtonPressedTime = 0L
private var tab by mutableStateOf(Tab.Main)
private val chipVm: ChipViewModel by viewModels()
Expand Down Expand Up @@ -129,7 +124,10 @@ class MainActivity : ComponentActivity() {

setContent {
MaterialTheme {
Scaffold(topBar = { TopBar() }, content = { Main() })
Scaffold(
topBar = { TopBar() },
content = { Main() }
)
}
}
}
Expand Down Expand Up @@ -180,9 +178,11 @@ class MainActivity : ComponentActivity() {
AnimatedVisibility(visible = searching, exit = fadeOut()) {
TextField(
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {
focusManager.clearFocus()
}),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
}
),
modifier = Modifier
.fillMaxSize()
.focusRequester(FocusRequester()),
Expand Down Expand Up @@ -260,13 +260,14 @@ class MainActivity : ComponentActivity() {
ConstraintLayout(modifier = Modifier.fillMaxSize()) {
val (events, bottomBar) = createRefs()

Column(modifier = Modifier
.constrainAs(events) {
top.linkTo(parent.top)
bottom.linkTo(bottomBar.top)
height = Dimension.fillToConstraints
}
.fillMaxWidth()
Column(
modifier = Modifier
.constrainAs(events) {
top.linkTo(parent.top)
bottom.linkTo(bottomBar.top)
height = Dimension.fillToConstraints
}
.fillMaxWidth()
) {
Crossfade(tab) { target ->
when (target) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/kotlin/team/bravepeople/devevent/activity/main/Tab.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* DevEventAndroid © 2021 용감한 친구들. all rights reserved.
* DevEventAndroid license is under the MIT.
*
* [Tab.kt] created by Ji Sungbin on 21. 6. 22. 오후 3:41.
*
* Please see: https://github.com/brave-people/Dev-Event-Android/blob/master/LICENSE.
*/

package team.bravepeople.devevent.activity.main

enum class Tab {
Main, Favorite, Info
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import com.skydoves.landscapist.coil.CoilImage
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import team.bravepeople.devevent.BuildConfig
import team.bravepeople.devevent.R
import team.bravepeople.devevent.activity.main.event.database.EventDatabase
import team.bravepeople.devevent.theme.ColorOrange
import team.bravepeople.devevent.theme.colors
import team.bravepeople.devevent.ui.glideimage.GlideImage
import team.bravepeople.devevent.ui.licenser.License
import team.bravepeople.devevent.ui.licenser.Licenser
import team.bravepeople.devevent.ui.licenser.Project
Expand All @@ -81,7 +81,6 @@ import team.bravepeople.devevent.util.extension.noRippleClickable
import team.bravepeople.devevent.util.extension.noRippleLongClickable
import team.bravepeople.devevent.util.extension.toast


@Composable
fun ApplicationInfoDialog(isOpen: MutableState<Boolean>) {
if (isOpen.value) {
Expand Down Expand Up @@ -186,12 +185,6 @@ private fun OpenSourceDialog(isOpen: MutableState<Boolean>) {
"https://android.googlesource.com/platform/frameworks/support/",
License.Apache2
),
Project(
"lottie",
"https://github.com/airbnb/lottie/blob/master/android-compose.md",
License.MIT
),
Project("glide", "https://github.com/bumptech/glide", License.BSD),
Project(
"Browser",
"https://developer.android.com/jetpack/androidx/releases/browser",
Expand Down Expand Up @@ -224,15 +217,20 @@ private fun OpenSourceDialog(isOpen: MutableState<Boolean>) {
"https://github.com/square/leakcanary",
License.Apache2
),
Project(
"바른나눔고딕",
"https://help.naver.com/support/contents/contents.help?serviceNo=1074&categoryNo=3497",
License.CUSTOM("SIL")
),
Project(
"ConstraintLayout",
"https://developer.android.com/jetpack/compose/layouts/constraintlayout",
License.Apache2
),
Project(
"FancyBottomBar",
"https://github.com/jisungbin/FancyBottomBar",
License.MIT
),
Project(
"Landscapist",
"https://github.com/skydoves/Landscapist",
License.Apache2
)
)
)
Expand Down Expand Up @@ -306,12 +304,12 @@ fun Info(database: EventDatabase, activity: Activity) {
.height(100.dp),
verticalAlignment = Alignment.CenterVertically
) {
GlideImage(
CoilImage(
modifier = Modifier
.size(100.dp)
.noRippleClickable { Web.open(activity, Web.Link.Organization) }
.clip(RoundedCornerShape(10.dp)),
src = logoUrl
imageModel = logoUrl
)
Column(
modifier = Modifier.fillMaxSize(),
Expand Down Expand Up @@ -491,9 +489,11 @@ fun Info(database: EventDatabase, activity: Activity) {
TextField(
value = eventsKeyword,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {
focusManager.clearFocus()
}),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
}
),
onValueChange = {
eventsKeyword = it
Data.save(context, PathConfig.EventKeywordAlarm, it.text)
Expand Down Expand Up @@ -526,4 +526,4 @@ fun Info(database: EventDatabase, activity: Activity) {
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import android.content.Context
import android.content.Intent
import androidx.annotation.StringRes
import dagger.hilt.android.AndroidEntryPoint
import java.util.Calendar
import javax.inject.Inject
import kotlin.random.Random
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
Expand All @@ -25,10 +22,14 @@ import team.bravepeople.devevent.R
import team.bravepeople.devevent.activity.main.event.database.EventDatabase
import team.bravepeople.devevent.activity.main.event.repo.EventRepo
import team.bravepeople.devevent.activity.main.event.repo.EventRepoResult
import team.bravepeople.devevent.util.AlarmUtil
import team.bravepeople.devevent.util.Data
import team.bravepeople.devevent.util.NotificationUtil
import team.bravepeople.devevent.util.config.PathConfig
import team.bravepeople.devevent.util.extension.filterNewEventByName
import java.util.Calendar
import javax.inject.Inject
import kotlin.random.Random

@AndroidEntryPoint
class EventReloadReceiver : BroadcastReceiver() {
Expand All @@ -41,10 +42,12 @@ class EventReloadReceiver : BroadcastReceiver() {

override fun onReceive(context: Context?, intent: Intent?) {
if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) != 13) return
AlarmUtil.startReloadService(context = context!!)

CoroutineScope(Dispatchers.IO).launch {
val preEvents = database.dao().getEvents()
val receiveNewEventNotification =
Data.read(context!!, PathConfig.NewEventNotification, "false").toBoolean()
Data.read(context, PathConfig.NewEventNotification, "false").toBoolean()
val eventsKeywordAlarms =
Data.read(context, PathConfig.EventKeywordAlarm, "")!!.split(",").map { it.trim() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ fun ErrorDialog(
}
)
}
}
}
Loading

0 comments on commit c31f793

Please sign in to comment.