Skip to content

Commit

Permalink
fix : scaleImage
Browse files Browse the repository at this point in the history
  • Loading branch information
mkw8263 committed Jul 2, 2020
1 parent 2c35533 commit e7597fb
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 21 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ object Modules {
}

object Releases {
val versionCode = 13
val versionName = "1.4"
val versionCode = 14
val versionName = "1.5"
}

object Versions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class FirebaseRepositoryImpl @Inject constructor(
private val db: DatabaseReference,
private val auth: FirebaseAuth
) : FirebaseRepository {

override fun signOut() {
auth.signOut()
}

override fun saveUser(email: String, name: String, position: String, isManager: Boolean) {
db.child(QUERY_USERS)
.child(auth.currentUser?.uid.orEmpty())
Expand All @@ -30,7 +35,7 @@ class FirebaseRepositoryImpl @Inject constructor(
db.child(QUERY_USERS)
.child(uuid)
.child(QUERY_MANAGER)
.addListenerForSingleValueEvent(object : ValueEventListener {
.addValueEventListener(object : ValueEventListener {
override fun onCancelled(error: DatabaseError) {
error(DDDException.NotFindDataBaseData(MessageManager.ERROR_NOT_FOUND_FIREBASE_DATABASE_DATA))
}
Expand Down Expand Up @@ -64,7 +69,7 @@ class FirebaseRepositoryImpl @Inject constructor(

override fun getCurriculum(getItems: (List<DomainEntity.Curriculum>) -> Unit) {
db.child("curriculum")
.addListenerForSingleValueEvent(object : ValueEventListener {
.addValueEventListener(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {}

override fun onDataChange(data: DataSnapshot) {
Expand All @@ -84,8 +89,8 @@ class FirebaseRepositoryImpl @Inject constructor(

override fun getBannerData(getItems: (DomainEntity.Banner) -> Unit) {
db.child("banner")
.addListenerForSingleValueEvent(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {}
.addValueEventListener(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) = Unit

override fun onDataChange(data: DataSnapshot) {
val title = (data.child("title").value as String)
Expand Down
1 change: 1 addition & 0 deletions domain/src/main/java/com/ddd/domain/FirebaseRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ddd.common.DDDException
import com.ddd.domain.entity.DomainEntity

interface FirebaseRepository {
fun signOut()
fun saveUser(email: String, name: String, position: String, isManager: Boolean)
fun isManager(uuid: String, result: (Boolean) -> Unit, error: (DDDException) -> Unit)
fun saveAttendance(
Expand Down
1 change: 0 additions & 1 deletion domain/src/main/java/com/ddd/domain/LoginUseCase.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ddd.domain

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.google.firebase.auth.FirebaseAuth
import kotlinx.coroutines.Dispatchers
Expand Down
8 changes: 8 additions & 0 deletions domain/src/main/java/com/ddd/domain/LogoutUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ddd.domain

import javax.inject.Inject

class LogoutUseCase @Inject constructor(private val repository: FirebaseRepository) {

operator fun invoke() = repository.signOut()
}
2 changes: 2 additions & 0 deletions presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ dependencies {
implementation Libraries.lottie
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'

implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
}
3 changes: 2 additions & 1 deletion presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
package="com.ddd.presentation">

<application>
<activity android:name=".ui.manager.ManagerActivity"/>
<activity android:name=".ui.main.ImageDetailActivity"></activity>
<activity android:name=".ui.manager.ManagerActivity" />
<activity android:name=".ui.tutorial.TutorialActivity" />
<activity android:name=".ui.splash.SplashActivity" />
<activity android:name=".ui.signup.SignUpActivity" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ddd.presentation.ui.main

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.davemorrissey.labs.subscaleview.ImageSource
import com.ddd.presentation.R
import com.google.firebase.storage.FirebaseStorage
import kotlinx.android.synthetic.main.activity_image_detail.*
import kotlinx.android.synthetic.main.activity_main.*

class ImageDetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_image_detail)

val url = FirebaseStorage.getInstance().getReference("banner/banner.png")
try {
Glide.with(this).asBitmap().load(url).into(object : CustomTarget<Bitmap>() {
override fun onLoadCleared(placeholder: Drawable?) = Unit

override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
img.setImage(ImageSource.bitmap(resource))
}
})
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
ob(viewModel.liveResult, ::result)

val url = FirebaseStorage.getInstance().getReference("banner/banner.png")
try{
try {
Glide.with(this).load(url).into(img_card)
}catch (e:Exception){
} catch (e: Exception) {
e.printStackTrace()
}
}

fun result(result: MainViewModel.Result) {
when (result) {
is MainViewModel.Result.MoveDetailImage -> {
Intent(this, ImageDetailActivity::class.java).let(::startActivity)
}
is MainViewModel.Result.Banner -> {
tv_title.text = result.title
tv_subtitle.text = result.subTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class MainViewModel @Inject constructor(
data class InitQRCode(val qrcode: Bitmap) : Result()
data class Curriculum(val items: List<DomainEntity.Curriculum>) : Result()
data class LoginActivity<T>(val nextActivity: Class<T>) : Result()
object MoveDetailImage: Result()
}

private val _liveResult = MutableLiveData<Result>()
Expand All @@ -49,8 +50,7 @@ class MainViewModel @Inject constructor(
}
}

fun tempLogout() {
auth.signOut()
fun onClickDetailImage(){
_liveResult.value = Result.MoveDetailImage
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import com.ddd.common.createViewModel
import com.ddd.common.ob
import com.ddd.common.view.TimePickerFragment
import com.ddd.presentation.BaseActivity
import com.ddd.presentation.R
import com.ddd.presentation.databinding.ActivityManagerBinding
import com.ddd.presentation.ui.signup.SignUpActivity
import com.ddd.presentation.ui.tutorial.TutorialActivity
import com.google.zxing.integration.android.IntentIntegrator
import kotlinx.android.synthetic.main.activity_manager.*
import javax.inject.Inject
Expand All @@ -16,6 +19,7 @@ class ManagerActivity : BaseActivity<ManagerViewModel, ActivityManagerBinding>()

override val layoutResource: Int
get() = R.layout.activity_manager

@Inject
lateinit var factory: ViewModelProvider.Factory
override val viewModel: ManagerViewModel by lazy {
Expand All @@ -25,14 +29,14 @@ class ManagerActivity : BaseActivity<ManagerViewModel, ActivityManagerBinding>()
override fun setupViewDataBinding() {
viewDataBinding.run {
managerViewModel = viewModel
lifecycleOwner=this@ManagerActivity
lifecycleOwner = this@ManagerActivity
}

}

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

ob(viewModel.liveNavigation, result)
btn_start_qr_code.setOnClickListener {
IntentIntegrator(this)
.apply { setOrientationLocked(false) }
Expand All @@ -44,9 +48,23 @@ class ManagerActivity : BaseActivity<ManagerViewModel, ActivityManagerBinding>()
.show(supportFragmentManager, TimePickerFragment::getTag.name)
}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
(IntentIntegrator.parseActivityResult(requestCode, resultCode, data))?.let { result ->
if (!result.contents.isNullOrEmpty()) viewModel.addAttendance(result.contents)
} ?: super.onActivityResult(requestCode, resultCode, data)
}

private val result: (ManagerViewModel.Navigation) -> Unit = {
when (it) {
is ManagerViewModel.Navigation.MoveCheckAttendance -> {

}

is ManagerViewModel.Navigation.MoveLoginActivity -> {
Intent(this, TutorialActivity::class.java).let(::startActivity)
finish()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.ddd.domain.AddAttendanceUseCase
import com.ddd.domain.LogoutUseCase
import com.ddd.domain.TimeProviderRepository
import javax.inject.Inject

class ManagerViewModel @Inject constructor(
private val addAttendanceUseCase: AddAttendanceUseCase,
private val logoutUseCase: LogoutUseCase,
private val timeProviderRepository: TimeProviderRepository
) : ViewModel() {

sealed class Navigation(){
object MoveCheckAttendance : Navigation()
object MoveLoginActivity : Navigation()
}

private val _liveDate = MutableLiveData<String>()
val liveDate: LiveData<String> = _liveDate

private val _liveNavigation = MutableLiveData<Navigation>()
val liveNavigation: LiveData<Navigation> = _liveNavigation

fun addAttendance(uuid: String) {
addAttendanceUseCase.execute(AddAttendanceUseCase.Params(
uuid,
Expand All @@ -33,4 +43,12 @@ class ManagerViewModel @Inject constructor(
_liveDate.value = timeProviderRepository.onTimeSet(hour, min)
}

fun logout(){
logoutUseCase.invoke()
_liveNavigation.value = Navigation.MoveLoginActivity
}

fun moveCheckAttendance(){
_liveNavigation.value = Navigation.MoveCheckAttendance
}
}
13 changes: 13 additions & 0 deletions presentation/src/main/res/layout/activity_image_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.ImageDetailActivity">

<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions presentation/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginEnd="64dp"
android:onClick="@{()->mainViewModel.onClickDetailImage()}"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/tv_subtitle"
Expand Down
45 changes: 39 additions & 6 deletions presentation/src/main/res/layout/activity_manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,75 @@
android:background="@color/main_background_color"
tools:context=".ui.manager.ManagerActivity">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_check_attendance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="@android:color/darker_gray"
android:gravity="center"
android:onClick="@{()->managerViewModel.moveCheckAttendance()}"
android:padding="15dp"
android:text="출석확인하기"
android:textSize="17dp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText,SpUsage" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@android:color/darker_gray"
android:gravity="center"
android:onClick="@{()->managerViewModel.logout()}"
android:padding="15dp"
android:text="로그아웃"
android:textSize="17dp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/btn_check_attendance"
tools:ignore="HardcodedText,SpUsage" />

<TextView
android:id="@+id/tv_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:gravity="center_horizontal"
android:text="오늘의 출석 시작 시간은 몇시인가요?"
android:textColor="@color/sign_up_selected_color"
android:textSize="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/tv_attend_start_time"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_logout"
app:layout_constraintVertical_chainStyle="packed"
tools:ignore="HardcodedText,SpUsage" />

<TextView
android:id="@+id/tv_attend_start_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/sign_up_input_background"
android:drawableEnd="@drawable/ic_bottom_arrow"
android:paddingStart="16dp"
android:paddingTop="15dp"
android:paddingEnd="16dp"
android:paddingBottom="15dp"
android:layout_marginStart="16dp"
android:text="@{managerViewModel.liveDate}"
android:textColor="@color/sign_up_selected_color"
android:textSize="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="@+id/tv_description"
app:layout_constraintBottom_toTopOf="@+id/btn_start_qr_code"
app:layout_constraintEnd_toEndOf="@+id/tv_description"
app:layout_constraintStart_toStartOf="@+id/tv_description"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_description"
app:layout_constraintVertical_bias="0"
tools:ignore="SpUsage" />

<Button
Expand Down

0 comments on commit e7597fb

Please sign in to comment.