Android 50

[MVVM] LiveData와 ViewModel Observer로 연결

Repository의 Data가 변경 되었을 때 UI에 알리기 위해서는 ViewModel이 관찰을 하고 있어야 한다. UI(V)는 보통 onCreate()에서 VM을 생성하고, VM은 Repository를 생성한 뒤 M과 Dao를 통해 연결 되는데, 이 Dao를 LiveData로 구성하면 ViewModel이 지켜 볼 수(obsever) 있게 된다. 연결(MVVM) onCreate/onCreateView 실행이 되면서 viewModel 생성 작업과 이후 연결 작업이 실행 된다. Fragment.kt private val plantDetailViewModel: PlantDetailViewModel by viewModels { InjectorUtils.providePlantDetailViewModelFacto..

[Sunflower 디비보기] Activity, Fragment, Navigation 시작

Activity 최초 액티비티에서 activity_garden 을 layout으로 설정하게 되면 GardenActivity.kt class GardenActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(this, R.layout.activity_garden) } } NagGraph R.layout.activity_garden 에서는 이후 연결되는 view들을 아래와 같이 관리할 navigaion을 지정한다. app:navGraph="@navigation/nav_garden" R.layout.activity_garde..

[Sunflower 디비보기] ViewModel 주입(초기화) 과정

요약 viewModel 주입(Injection) Repository 와 ViewModel 을 생성 해서 Factory 에 넣은 다음 by 로 위임된 viewModels 에 주면 viewModel 을 주입해준다.(ktx 로 ViewModelProvider.get()와 같은 역활을 한다.) 결국 viewModel (LiveData) > repository > dao > db 요렇게 연결 되어서 view 와 연결되어 작업이 될 것 이다. M-V-VM private val viewModel: GardenPlantingListViewModel by viewModels { InjectorUtils.provideGardenPlantingListViewModelFactory(requireContext()) } Fact..

[Speaking Alarm Clock] Memo and Sentence

New feature!!(Patent pending function) Menu> Notes and Sentence Management Create a group of sayings, todos, study, ideas, etc. and write sentences and notes. You can also automatically show on-time notifications and alarms, or have a voice briefing automatically. Hourly sentences managed by on-time notifications can also be brought at a time. You can share sentences directly to SNS. If you pres..

Actionbar Navigation icon 변경

Drawable drawable = ContextCompat.getDrawable(getApplicationContext(),R.drawable.ic_arrow_back_white_24dp); Overflow 아이콘 변경 toolbar.setOverflowIcon(drawable); 햄버거 모양 아이콘 변경 actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable drawable = ContextCompat.getDrawable(mContext,R.drawable.ic_arrow_back_white_24dp); actionBar.setHomeAsUpIndicator(drawable); 액티비티..

Talking Alarm Clock -How to use the On-Time Tab

Just click the area. 1. Blue dot rectangle- will show the Default text dialog for editing. 2. Red dot rectangle- will show the Active hours dialog for editing. 3. Yellow dot rectangle- will show the Hourly text dialog for editing. 4. Green dot rectangle- will show the On Time Set dialog for editing. 5. Purple dot rectangle- will show the Interval dialog for editing. Then you can edit time / text..

안드로이드 리사이클러 뷰 구분선 및 색상 RecyclerView divider color

아주 간단하다.아래 처럼 넣어 주면, 색깔까지 완벽하게! DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mContext,LinearLayoutManager.VERTICAL); dividerItemDecoration.setDrawable(mContext.getResources().getDrawable(R.drawable.recyclerview_divider)); mRecyclerView.addItemDecoration(dividerItemDecoration);아래는 recyclerview_divider.xml

안드로이드 동적 컬러리스트 적용 ColorStateList setTextColor

color/a.xml ColorStateList colorStateList = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { colorStateList = context.getResources().getColorStateList(R.color.a, context.getTheme()); } else { colorStateList = context.getResources().getColorStateList(R.color.a); } textView.setTextColor(colorStateList) 요렇게 하면, 간단하게 컬러 리스트를 동적으로(programmatically) 적용 할 수 있다.