generated from GO-SOPT-ANDROID/android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week2 #4
Merged
Merged
Week2 #4
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
84733bb
feat : bottom navigation #3
SeonHwan-Kim 7c9e9de
add : bottom navigation #3
SeonHwan-Kim 853f1fa
add : home fragment #3
SeonHwan-Kim ae2707c
add : Gallery fragment #3
SeonHwan-Kim 764d95d
add : search fragment #3
SeonHwan-Kim ce4c336
add : recyclerview:1.3.0 #3
SeonHwan-Kim 730bff7
refactor : 파일 이동 #3
SeonHwan-Kim a9883b6
add : Dog data class 생성 #3
SeonHwan-Kim 41e7b51
add : 강아지 이미지 추가 #3
SeonHwan-Kim d5049c0
add : title 추가 #3
SeonHwan-Kim 48e7b68
feat : dog adapter 추가 #3
SeonHwan-Kim 3336601
style : padding, layoutManager 추가 #3
SeonHwan-Kim b86fe26
feat : title, dog Adapter 연결 #3
SeonHwan-Kim 817862d
add : 강아지 string 추가 #3
SeonHwan-Kim be68fa8
fix : 이미지 용량 줄이기 #3
SeonHwan-Kim 4e6d0ae
fix : 이미지 용량 큰 값 삭제 #3
SeonHwan-Kim e73ca02
feat : scrollToTop 구현 #3
SeonHwan-Kim 1a09339
feat : viewModel 사용 #3
SeonHwan-Kim 79d4e4e
refactoring : 파일 분리 #3
SeonHwan-Kim 4bc1873
add : add mypage #2
SeonHwan-Kim d1df01c
feat : mypage 하단바 추가 #2
SeonHwan-Kim d1be925
feat : 로그아웃, 회원탈퇴 구현 #2
SeonHwan-Kim 7bb9b2b
feat : finishFragment 추가 #2
SeonHwan-Kim b8e1887
fix : startActivity 삭제 #2
SeonHwan-Kim c945074
add : sharedPreferences 분리 #2
SeonHwan-Kim fb4aa20
feat : SoptApplication 사용 #2
SeonHwan-Kim 209a963
fix : DiffUtil과 ListAdapter 사용 #3
SeonHwan-Kim b49fb08
fix : applicationcontext this로 변경 #3
SeonHwan-Kim 5027dac
fix : android ktx 사용 #3
SeonHwan-Kim 314dc1d
fix : companion object 위치 수정 #3
SeonHwan-Kim a796a44
feat : mypage 이름, 특기 표시 #3
SeonHwan-Kim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.android.go.sopt | ||
|
||
import android.app.Application | ||
import org.android.go.sopt.util.UserSharedPreferences | ||
|
||
class SoptApplication : Application() { | ||
override fun onCreate() { | ||
prefs = UserSharedPreferences(this) | ||
super.onCreate() | ||
} | ||
|
||
companion object { | ||
lateinit var prefs: UserSharedPreferences | ||
} | ||
} |
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,9 @@ | ||
package org.android.go.sopt.data | ||
|
||
import androidx.annotation.DrawableRes | ||
|
||
data class Dog( | ||
val name: String, | ||
@DrawableRes val image: Int, | ||
val size: String | ||
) |
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/android/go/sopt/presentation/main/gallery/GalleryFragment.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,32 @@ | ||
package org.android.go.sopt.presentation.main.gallery | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import org.android.go.sopt.databinding.FragmentGalleryBinding | ||
|
||
class GalleryFragment : Fragment() { | ||
private var _binding: FragmentGalleryBinding? = null | ||
private val binding: FragmentGalleryBinding | ||
get() = requireNotNull(_binding) { "앗!_binding이 null이다!" } | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = FragmentGalleryBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
_binding = null | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/android/go/sopt/presentation/main/home/DogAdapter.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,42 @@ | ||
package org.android.go.sopt.presentation.main.home | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.android.go.sopt.data.Dog | ||
import org.android.go.sopt.databinding.ItemDogBinding | ||
|
||
class DogAdapter(context: Context) : ListAdapter<Dog, DogAdapter.DogViewHolder>(DogDiffCallback()) { | ||
private val inflater by lazy { LayoutInflater.from(context) } | ||
|
||
class DogViewHolder(private val binding: ItemDogBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(dog: Dog) { | ||
binding.ivDogImage.setImageDrawable(binding.root.context.getDrawable(dog.image)) | ||
binding.tvDogName.text = dog.name | ||
binding.tvDogSize.text = dog.size | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DogViewHolder { | ||
val binding = ItemDogBinding.inflate(inflater, parent, false) | ||
return DogViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: DogViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
} | ||
|
||
class DogDiffCallback : DiffUtil.ItemCallback<Dog>() { | ||
override fun areItemsTheSame(oldItem: Dog, newItem: Dog): Boolean { | ||
return oldItem.name == newItem.name | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: Dog, newItem: Dog): Boolean { | ||
return oldItem == newItem | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/org/android/go/sopt/presentation/main/home/HomeFragment.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,44 @@ | ||
package org.android.go.sopt.presentation.main.home | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.viewModels | ||
import androidx.recyclerview.widget.ConcatAdapter | ||
import org.android.go.sopt.databinding.FragmentHomeBinding | ||
|
||
class HomeFragment : Fragment() { | ||
private var _binding: FragmentHomeBinding? = null | ||
private val binding: FragmentHomeBinding | ||
get() = requireNotNull(_binding) { "앗!_binding이 null이다!" } | ||
|
||
private val viewModel by viewModels<HomeViewModel>() | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = FragmentHomeBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
val titleAdapter = TitleAdapter(requireContext()) | ||
val dogAdapter = DogAdapter(requireContext()) | ||
dogAdapter.submitList(viewModel.mockDogList) | ||
binding.rvHomeDog.adapter = ConcatAdapter(titleAdapter, dogAdapter) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
_binding = null | ||
} | ||
|
||
fun scrollToTop() { | ||
binding.rvHomeDog.smoothScrollToPosition(0) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sharedPreferences 를 왜 사용하며, 앱 구동 및 종료시 메모리에서 어떻게 동작하는지,
왜 companion object (java static) 으로 구성하는지 를 공부해보면 좋겠네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 한번 공부해보도록 하겠습니다!!!