Skip to content

Instantly share code, notes, and snippets.

View erdalkaymak's full-sized avatar

erdalkaymak

View GitHub Profile
{
"result": true,
"data": {
"id": 607,
"title": "Identifier Service",
"sequence": 3,
"design": [
"info",
"question",
"info"
class ViewPagerChapterAdapter(
private val fragmentList: ArrayList<Fragment>,
fragmentManager: FragmentManager,
lifecycle: Lifecycle
) : FragmentStateAdapter(fragmentManager, lifecycle) {
override fun getItemCount(): Int {
return fragmentList.size
}
@ExperimentalCoroutinesApi
@AndroidEntryPoint
class ViewPagerChapterFragment :
BaseFragment<FragmentViewPagerChapterBinding, ViewPagerChapterViewModel>(R.layout.fragment_view_pager_chapter),
OnRequestAction {
// var region
override val viewModel: ViewPagerChapterViewModel by viewModels()
@Inject
@HiltViewModel
class ViewPagerChapterViewModel @Inject constructor(
private val api: CourseRepository
) :
BaseViewModel() {
// live data
private val _chapter = MutableLiveData<Resource<ChapterModel>>()
val chapter: LiveData<Resource<ChapterModel>>
get() = _chapter
@ExperimentalCoroutinesApi
@AndroidEntryPoint
class ChapterQuestionFragment(private val question: Question) :
BaseFragment<FragmentChapterQuestionBinding, ChapterQuestionViewModel>(R.layout.fragment_chapter_question) {
//var region
override val viewModel: ChapterQuestionViewModel by viewModels()
private lateinit var mCallback: OnRequestAction
//end region
@HiltViewModel
class ChapterQuestionViewModel @Inject constructor(
private val api: CourseRepository
) : BaseViewModel() {
}
@HiltViewModel
class ChapterDescriptionViewModel @Inject constructor(
private val api: CourseRepository
) : BaseViewModel() {
}
/**
* @param B: DataBinding class of fragment
* @param VM: ViewModel class of fragment
* @param layoutId: Layout resource id of fragment
*
* Base class for [Fragment] instances, all common processes will be handled based on this class.
*/
abstract class BaseFragment<
B : ViewDataBinding,
VM : BaseViewModel>
/**
* Base class for [ViewModel] instances, all common processes will be handled based on this class.
*/
abstract class BaseViewModel : ViewModel() {
var showError = MutableLiveData<String?>()
override fun onCleared() {
LogUtils.d("$this")
super.onCleared()
interface OnRequestAction {
fun nextPage()
}