Skip to content

Instantly share code, notes, and snippets.

View luthfihariz's full-sized avatar
🏠
Working from home

Luthfi Hariz luthfihariz

🏠
Working from home
View GitHub Profile
"scripts" : {
"android-prod": "react-native run-android --variant=prodDebug --appId=com.your.coolapp",
"android-stag": "react-native run-android --variant=stagDebug --appId=com.your.coolapp.stag",
"android-dev": "react-native run-android --variant=devDebug --appId=com.your.coolapp.dev",
}
<resources>
<string name="app_name">@string/APP_DISPLAY_NAME</string>
</resources>
android {
// other snippet
flavorDimensions "default"
productFlavors {
prod {
resValue "string", "build_config_package", "com.your.coolapp"
}
ENV=development
BASE_URL=https://dev.yourcool.app/api/v1
APP_DISPLAY_NAME = "Yourcool App Dev"
API_KEY=som3r4ndomK3y
SOME_3RDPARTY_API_KEY=s0m3r4nd0mK3y
project.ext.envConfigFiles = [
dev: ".env.development",
stag: ".env.staging",
prod: ".env.production"
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
if (isIpAddressDifferentWithLastRecorded(latestIpAddress)) {
Log.d(
WorkManagerHelper.TAG,
"Different IP Address ($latestIpAddress}."
)
insertNewRecordToDb(latestIpAddress)
} else {
if (connManager.getNetworkClass() == ConnectionManager.NETWORK_WIFI) {
// check if its on wifi more than one hour
@luthfihariz
luthfihariz / EventListActivity.kt
Created August 1, 2018 00:30
Observing LiveData
class EventListActivity : BaseActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_event_list)
val viewModel = ViewModelProviders.of(this).get(EventListViewModel::class.java)
// setup recyclerview
rvListOfKajian.layoutManager = LinearLayoutManager(this)
@luthfihariz
luthfihariz / EventListActivity.kt
Created August 1, 2018 00:26
ViewModel & LiveData
class EventListViewModel : ViewModel(){
val eventList = MutableLiveData<List<Event>>()
init {
eventList.postValue(arrayListOf(Event("Google IO 2018"),
Event("Droidcon London 2018"),
Event("GOTO Berlin 2018")))
}
class EventListActivity : BaseActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_event_list)
val viewModel = ViewModelProviders.of(this).get(EventListViewModel::class.java)
rvListOfEvent.layoutManager = LinearLayoutManager(this)
val adapter = EventListAdapter()
class EventListViewModel : ViewModel(){
val eventList = arrayListOf(Event("Google IO 2018"),
Event("Droidcon London 2018"),
Event("GOTO Berlin 2018"))
}