Loading app/src/main/java/io/eelo/appinstaller/categories/CategoriesFragment.kt +11 −12 Original line number Original line Diff line number Diff line Loading @@ -33,27 +33,22 @@ class CategoriesFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_categories, container, false) val view = inflater.inflate(R.layout.fragment_categories, container, false) categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java) applicationsCategoriesList = view.findViewById(R.id.applications_categories_list) applicationsCategoriesList = view.findViewById(R.id.applications_categories_list) gamesCategoriesList = view.findViewById(R.id.games_categories_list) gamesCategoriesList = view.findViewById(R.id.games_categories_list) categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java) categoriesContainer = view.findViewById(R.id.categories_container) categoriesContainer = view.findViewById(R.id.categories_container) categoriesContainer.visibility = View.GONE progressBar = view.findViewById(R.id.progress_bar) progressBar = view.findViewById(R.id.progress_bar) progressBar.visibility = View.VISIBLE val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) errorContainer.visibility = View.GONE val errorDescription = view.findViewById<TextView>(R.id.error_description) val errorDescription = view.findViewById<TextView>(R.id.error_description) view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE categoriesViewModel.loadCategories(context!!) } // Initialise UI elements initialiseDimensions() initialiseDimensions() handleDeviceOrientation() handleDeviceOrientation() if (categoriesViewModel.getApplicationsCategories().value!!.isEmpty() || categoriesContainer.visibility = View.GONE categoriesViewModel.getGamesCategories().value!!.isEmpty()) { progressBar.visibility = View.VISIBLE errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE categoriesViewModel.loadCategories(context!!) categoriesViewModel.loadCategories(context!!) } } Loading @@ -78,6 +73,10 @@ class CategoriesFragment : Fragment() { } } }) }) if (categoriesViewModel.getApplicationsCategories().value!!.isEmpty() || categoriesViewModel.getGamesCategories().value!!.isEmpty()) { categoriesViewModel.loadCategories(context!!) } return view return view } } Loading app/src/main/java/io/eelo/appinstaller/home/HomeFragment.kt +8 −9 Original line number Original line Diff line number Diff line Loading @@ -37,30 +37,25 @@ class HomeFragment : Fragment() { val view = inflater.inflate(R.layout.fragment_home, container, false) val view = inflater.inflate(R.layout.fragment_home, container, false) homeViewModel = ViewModelProviders.of(activity!!).get(HomeViewModel::class.java) homeViewModel = ViewModelProviders.of(activity!!).get(HomeViewModel::class.java) homeViewModel.initialise(installManager!!) imageCarousel = view.findViewById(R.id.image_carousel) imageCarousel = view.findViewById(R.id.image_carousel) categoryList = view.findViewById(R.id.category_list) categoryList = view.findViewById(R.id.category_list) progressBar = view.findViewById(R.id.progress_bar) progressBar = view.findViewById(R.id.progress_bar) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) // Initialise UI elements // Initialise UI elements imageCarousel.visibility = View.GONE homeViewModel.initialise(installManager!!) setCustomScroller() setCustomScroller() imageCarousel.visibility = View.GONE categoryList.visibility = View.GONE categoryList.visibility = View.GONE categoryList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) categoryList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) errorContainer.visibility = View.GONE errorContainer.visibility = View.GONE val errorDescription = view.findViewById<TextView>(R.id.error_description) view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE homeViewModel.loadCategories(context!!) homeViewModel.loadCategories(context!!) } } if (homeViewModel.getBannerApplications().value!!.isEmpty() || homeViewModel.getCategories().value!!.isEmpty()) { homeViewModel.loadCategories(context!!) } // Bind image carousel adapter to banner images in view model // Bind image carousel adapter to banner images in view model homeViewModel.getBannerApplications().observe(this, Observer { homeViewModel.getBannerApplications().observe(this, Observer { if (homeViewModel.getBannerApplications().value!!.isNotEmpty()) { if (homeViewModel.getBannerApplications().value!!.isNotEmpty()) { Loading Loading @@ -92,6 +87,10 @@ class HomeFragment : Fragment() { } } }) }) if (homeViewModel.getBannerApplications().value!!.isEmpty() || homeViewModel.getCategories().value!!.isEmpty()) { homeViewModel.loadCategories(context!!) } return view return view } } Loading app/src/main/java/io/eelo/appinstaller/updates/UpdatesFragment.kt +23 −0 Original line number Original line Diff line number Diff line Loading @@ -9,11 +9,14 @@ import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.LayoutInflater import android.view.View import android.view.View import android.view.ViewGroup import android.view.ViewGroup import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.ProgressBar import android.widget.TextView import io.eelo.appinstaller.R import io.eelo.appinstaller.R import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.common.ApplicationListAdapter import io.eelo.appinstaller.common.ApplicationListAdapter import io.eelo.appinstaller.updates.viewModel.UpdatesViewModel import io.eelo.appinstaller.updates.viewModel.UpdatesViewModel import io.eelo.appinstaller.utils.Common class UpdatesFragment : Fragment() { class UpdatesFragment : Fragment() { private lateinit var updatesViewModel: UpdatesViewModel private lateinit var updatesViewModel: UpdatesViewModel Loading @@ -33,10 +36,18 @@ class UpdatesFragment : Fragment() { updatesViewModel = ViewModelProviders.of(activity!!).get(UpdatesViewModel::class.java) updatesViewModel = ViewModelProviders.of(activity!!).get(UpdatesViewModel::class.java) val recyclerView = view.findViewById<RecyclerView>(R.id.app_list) val recyclerView = view.findViewById<RecyclerView>(R.id.app_list) val progressBar = view.findViewById<ProgressBar>(R.id.progress_bar) val progressBar = view.findViewById<ProgressBar>(R.id.progress_bar) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) // Initialise UI elements updatesViewModel.initialise(installManager!!) updatesViewModel.initialise(installManager!!) initializeRecyclerView(recyclerView) initializeRecyclerView(recyclerView) progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE updatesViewModel.loadApplicationList(context!!) } // Bind recycler view adapter to search results list in view model // Bind recycler view adapter to search results list in view model updatesViewModel.getApplications().observe(this, Observer { updatesViewModel.getApplications().observe(this, Observer { Loading @@ -46,7 +57,19 @@ class UpdatesFragment : Fragment() { } } }) }) // Bind to the screen error updatesViewModel.getScreenError().observe(this, Observer { if (it != null) { errorDescription.text = activity!!.getString(Common.getScreenErrorDescriptionId(it)) errorContainer.visibility = View.VISIBLE progressBar.visibility = View.GONE } else { errorContainer.visibility = View.GONE } }) updatesViewModel.loadApplicationList(context!!) updatesViewModel.loadApplicationList(context!!) return view return view } } Loading app/src/main/java/io/eelo/appinstaller/updates/model/UpdatesModel.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -4,10 +4,12 @@ import android.arch.lifecycle.MutableLiveData import android.content.Context import android.content.Context import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.utils.Common import io.eelo.appinstaller.utils.ScreenError class UpdatesModel : UpdatesModelInterface { class UpdatesModel : UpdatesModelInterface { val applicationList = MutableLiveData<ArrayList<Application>>() val applicationList = MutableLiveData<ArrayList<Application>>() var screenError = MutableLiveData<ScreenError>() init { init { if (applicationList.value == null) { if (applicationList.value == null) { Loading @@ -18,7 +20,11 @@ class UpdatesModel : UpdatesModelInterface { var installManager: InstallManager? = null var installManager: InstallManager? = null override fun loadApplicationList(context: Context) { override fun loadApplicationList(context: Context) { if (Common.isNetworkAvailable(context)) { UnUpdatedAppsFinder(context.packageManager, this, installManager!!).execute(context) UnUpdatedAppsFinder(context.packageManager, this, installManager!!).execute(context) } else { screenError.value = ScreenError.NO_INTERNET } } } override fun onAppsFound(applications: ArrayList<Application>) { override fun onAppsFound(applications: ArrayList<Application>) { Loading app/src/main/java/io/eelo/appinstaller/updates/viewModel/UpdatesViewModel.kt +6 −0 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ import android.content.Context import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.updates.model.UpdatesModel import io.eelo.appinstaller.updates.model.UpdatesModel import io.eelo.appinstaller.utils.ScreenError class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { Loading @@ -19,7 +20,12 @@ class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { return updatesModel.applicationList return updatesModel.applicationList } } override fun getScreenError(): MutableLiveData<ScreenError> { return updatesModel.screenError } override fun loadApplicationList(context: Context) { override fun loadApplicationList(context: Context) { updatesModel.screenError.value = null updatesModel.loadApplicationList(context) updatesModel.loadApplicationList(context) } } } } Loading
app/src/main/java/io/eelo/appinstaller/categories/CategoriesFragment.kt +11 −12 Original line number Original line Diff line number Diff line Loading @@ -33,27 +33,22 @@ class CategoriesFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_categories, container, false) val view = inflater.inflate(R.layout.fragment_categories, container, false) categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java) applicationsCategoriesList = view.findViewById(R.id.applications_categories_list) applicationsCategoriesList = view.findViewById(R.id.applications_categories_list) gamesCategoriesList = view.findViewById(R.id.games_categories_list) gamesCategoriesList = view.findViewById(R.id.games_categories_list) categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java) categoriesContainer = view.findViewById(R.id.categories_container) categoriesContainer = view.findViewById(R.id.categories_container) categoriesContainer.visibility = View.GONE progressBar = view.findViewById(R.id.progress_bar) progressBar = view.findViewById(R.id.progress_bar) progressBar.visibility = View.VISIBLE val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) errorContainer.visibility = View.GONE val errorDescription = view.findViewById<TextView>(R.id.error_description) val errorDescription = view.findViewById<TextView>(R.id.error_description) view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE categoriesViewModel.loadCategories(context!!) } // Initialise UI elements initialiseDimensions() initialiseDimensions() handleDeviceOrientation() handleDeviceOrientation() if (categoriesViewModel.getApplicationsCategories().value!!.isEmpty() || categoriesContainer.visibility = View.GONE categoriesViewModel.getGamesCategories().value!!.isEmpty()) { progressBar.visibility = View.VISIBLE errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE categoriesViewModel.loadCategories(context!!) categoriesViewModel.loadCategories(context!!) } } Loading @@ -78,6 +73,10 @@ class CategoriesFragment : Fragment() { } } }) }) if (categoriesViewModel.getApplicationsCategories().value!!.isEmpty() || categoriesViewModel.getGamesCategories().value!!.isEmpty()) { categoriesViewModel.loadCategories(context!!) } return view return view } } Loading
app/src/main/java/io/eelo/appinstaller/home/HomeFragment.kt +8 −9 Original line number Original line Diff line number Diff line Loading @@ -37,30 +37,25 @@ class HomeFragment : Fragment() { val view = inflater.inflate(R.layout.fragment_home, container, false) val view = inflater.inflate(R.layout.fragment_home, container, false) homeViewModel = ViewModelProviders.of(activity!!).get(HomeViewModel::class.java) homeViewModel = ViewModelProviders.of(activity!!).get(HomeViewModel::class.java) homeViewModel.initialise(installManager!!) imageCarousel = view.findViewById(R.id.image_carousel) imageCarousel = view.findViewById(R.id.image_carousel) categoryList = view.findViewById(R.id.category_list) categoryList = view.findViewById(R.id.category_list) progressBar = view.findViewById(R.id.progress_bar) progressBar = view.findViewById(R.id.progress_bar) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) // Initialise UI elements // Initialise UI elements imageCarousel.visibility = View.GONE homeViewModel.initialise(installManager!!) setCustomScroller() setCustomScroller() imageCarousel.visibility = View.GONE categoryList.visibility = View.GONE categoryList.visibility = View.GONE categoryList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) categoryList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) errorContainer.visibility = View.GONE errorContainer.visibility = View.GONE val errorDescription = view.findViewById<TextView>(R.id.error_description) view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE homeViewModel.loadCategories(context!!) homeViewModel.loadCategories(context!!) } } if (homeViewModel.getBannerApplications().value!!.isEmpty() || homeViewModel.getCategories().value!!.isEmpty()) { homeViewModel.loadCategories(context!!) } // Bind image carousel adapter to banner images in view model // Bind image carousel adapter to banner images in view model homeViewModel.getBannerApplications().observe(this, Observer { homeViewModel.getBannerApplications().observe(this, Observer { if (homeViewModel.getBannerApplications().value!!.isNotEmpty()) { if (homeViewModel.getBannerApplications().value!!.isNotEmpty()) { Loading Loading @@ -92,6 +87,10 @@ class HomeFragment : Fragment() { } } }) }) if (homeViewModel.getBannerApplications().value!!.isEmpty() || homeViewModel.getCategories().value!!.isEmpty()) { homeViewModel.loadCategories(context!!) } return view return view } } Loading
app/src/main/java/io/eelo/appinstaller/updates/UpdatesFragment.kt +23 −0 Original line number Original line Diff line number Diff line Loading @@ -9,11 +9,14 @@ import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.LayoutInflater import android.view.View import android.view.View import android.view.ViewGroup import android.view.ViewGroup import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.ProgressBar import android.widget.TextView import io.eelo.appinstaller.R import io.eelo.appinstaller.R import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.common.ApplicationListAdapter import io.eelo.appinstaller.common.ApplicationListAdapter import io.eelo.appinstaller.updates.viewModel.UpdatesViewModel import io.eelo.appinstaller.updates.viewModel.UpdatesViewModel import io.eelo.appinstaller.utils.Common class UpdatesFragment : Fragment() { class UpdatesFragment : Fragment() { private lateinit var updatesViewModel: UpdatesViewModel private lateinit var updatesViewModel: UpdatesViewModel Loading @@ -33,10 +36,18 @@ class UpdatesFragment : Fragment() { updatesViewModel = ViewModelProviders.of(activity!!).get(UpdatesViewModel::class.java) updatesViewModel = ViewModelProviders.of(activity!!).get(UpdatesViewModel::class.java) val recyclerView = view.findViewById<RecyclerView>(R.id.app_list) val recyclerView = view.findViewById<RecyclerView>(R.id.app_list) val progressBar = view.findViewById<ProgressBar>(R.id.progress_bar) val progressBar = view.findViewById<ProgressBar>(R.id.progress_bar) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) // Initialise UI elements updatesViewModel.initialise(installManager!!) updatesViewModel.initialise(installManager!!) initializeRecyclerView(recyclerView) initializeRecyclerView(recyclerView) progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { progressBar.visibility = View.VISIBLE updatesViewModel.loadApplicationList(context!!) } // Bind recycler view adapter to search results list in view model // Bind recycler view adapter to search results list in view model updatesViewModel.getApplications().observe(this, Observer { updatesViewModel.getApplications().observe(this, Observer { Loading @@ -46,7 +57,19 @@ class UpdatesFragment : Fragment() { } } }) }) // Bind to the screen error updatesViewModel.getScreenError().observe(this, Observer { if (it != null) { errorDescription.text = activity!!.getString(Common.getScreenErrorDescriptionId(it)) errorContainer.visibility = View.VISIBLE progressBar.visibility = View.GONE } else { errorContainer.visibility = View.GONE } }) updatesViewModel.loadApplicationList(context!!) updatesViewModel.loadApplicationList(context!!) return view return view } } Loading
app/src/main/java/io/eelo/appinstaller/updates/model/UpdatesModel.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -4,10 +4,12 @@ import android.arch.lifecycle.MutableLiveData import android.content.Context import android.content.Context import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.utils.Common import io.eelo.appinstaller.utils.ScreenError class UpdatesModel : UpdatesModelInterface { class UpdatesModel : UpdatesModelInterface { val applicationList = MutableLiveData<ArrayList<Application>>() val applicationList = MutableLiveData<ArrayList<Application>>() var screenError = MutableLiveData<ScreenError>() init { init { if (applicationList.value == null) { if (applicationList.value == null) { Loading @@ -18,7 +20,11 @@ class UpdatesModel : UpdatesModelInterface { var installManager: InstallManager? = null var installManager: InstallManager? = null override fun loadApplicationList(context: Context) { override fun loadApplicationList(context: Context) { if (Common.isNetworkAvailable(context)) { UnUpdatedAppsFinder(context.packageManager, this, installManager!!).execute(context) UnUpdatedAppsFinder(context.packageManager, this, installManager!!).execute(context) } else { screenError.value = ScreenError.NO_INTERNET } } } override fun onAppsFound(applications: ArrayList<Application>) { override fun onAppsFound(applications: ArrayList<Application>) { Loading
app/src/main/java/io/eelo/appinstaller/updates/viewModel/UpdatesViewModel.kt +6 −0 Original line number Original line Diff line number Diff line Loading @@ -6,6 +6,7 @@ import android.content.Context import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.Application import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.application.model.InstallManager import io.eelo.appinstaller.updates.model.UpdatesModel import io.eelo.appinstaller.updates.model.UpdatesModel import io.eelo.appinstaller.utils.ScreenError class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { Loading @@ -19,7 +20,12 @@ class UpdatesViewModel : ViewModel(), UpdatesViewModelInterface { return updatesModel.applicationList return updatesModel.applicationList } } override fun getScreenError(): MutableLiveData<ScreenError> { return updatesModel.screenError } override fun loadApplicationList(context: Context) { override fun loadApplicationList(context: Context) { updatesModel.screenError.value = null updatesModel.loadApplicationList(context) updatesModel.loadApplicationList(context) } } } }