nnhomescreen Framework Module

Handles downloading the specifications for the homescreen and applying them to the layout, including the contained banners and buttons. ModularHomeScreenFragment The container for all of the homescreen content. Uses custom RecyclerView.Adapter (ModularHomeScreenAdapter) to display elements, which have their own custom Views based on purpose (banner, image, Instagram etc – see views folder). NNBannerFragment Fragment that […]

nnviews Framework Module

Various common UI elements. NNStartupActivity Abstract class to be implemented in app startup Activity. Defines tasks to be run before showing the first screen e.g. downloading settings, version check. imaging folder Various classes for handling images: NNCircleImageView – Generate circular ImageView. Extends NNImageView NNImageCarousel – Create image carousel from a list of image urls NNImageView […]

nnsettings Framework Module

Framework to acquire and implement settings from CMS. NNSettings/SettingsManager/SettingsORM etc. Acquires settings from the settings database, which is stored locally after being periodically downloaded from CMS. Used very frequently. EnvironmentsActivity/EnvironmentManager/Environments Sets the environment – QA, production etc. UnpackAssets Acquires a JSON list of assets and saves them in the device storage, if run mode is […]

NN4M Framework Modules

These are the frameworks that NN4M uses to establish core functionality and consistency across their apps. nnbase This is the root framework and is a dependency of several of the others. It is essential for every app. nnnetwork Dependencies: nnbase Framework for making network requests: AbstractRequest – non-specific request type, forms basis for other request […]

nnbase Framework Module

This is the root framework and is a dependency of several of the others. It is essential for every app. NNApplication This file, or a subclass of it, should be declared in the AndroidManifest.xml as: <applicationandroid:name=”.NNApplication”… >…</application> This means that the entire app will be based on the NNApplication class. This provides core functionality such […]

Kotlin Coroutines

Coroutines are Kotlin’s way of dealing with asynchronous tasks. They can execute tasks sequentially. Coroutines require a: Job – cancellable background task with a lifecycle that culminates in its completion. Jobs can be arranged in a parent-child hierarchy so that cancellation of the parent cancels all child jobs Dispatcher – sends off coroutines to run […]

Lock orientation of the screen for your app

In AndroidManifest.xml: <manifest xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” package=”com.example.android.myapp”> <application android:allowBackup=”true” tools:ignore=”GoogleAppIndexingWarning”> <!– Screen locked to landscape for easier play –> <!– configChanges attribute makes the following actions NOT cause a config change –> <!– screenOrientation attribute sets the default animation–> <activity android:name=”.MainActivity” android:configChanges=”keyboardHidden|orientation|screenSize” android:screenOrientation=”landscape”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity> </application> </manifest>  

Combining data binding with Lifecycle components

We can use data binding along with Lifecycle components (e.g. ViewModel and LiveData) to remove the controller (Activity or Fragment) as middle-man from the process of passing data from the ViewModel to the View. Without data binding (at least, only using data binding to avoid findViewById): import … class MyFragment : Fragment() { private lateinit […]

Encapsulate LiveData

Create internal and external version of the variables that need to be passed out of our class, so that other classes cannot modify the internal data. import … class MyViewModel : ViewModel() { // The variable to be passed out of the class private val _variable = MutableLiveData<String>() // Private internal class, mutable val variable: […]

Room

Room is one of the Android App Architecture Components. The Room persistence library (Object Relational Mapping library) provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite

Setting Preference Summary/Label for ListPreference

ListPreference items in Preference screens do not automatically provide a label showing their current value. You can create labels for all list Preference items as so