This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity(R.layout.activity_main) { | |
private val viewModel by viewModels<MainViewModel>() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
viewModel.liveData.observe(this, Observer { | |
Log.d("MAIN", "Display $it in view") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The MIT License (MIT) | |
Copyright (c) 2016 Pierre Degand | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | |
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, | |
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2014 Pierre Degand | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output.assemble << { // Clean the assets folder of all apk | |
ant.delete(includeEmptyDirs: 'true') { | |
fileset(dir: file('./src/main/assets/'), includes: '*.apk') | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variant.outputs.each { output -> | |
task("handle${variant.name.capitalize()}WearDesc") << { | |
def apkFileName = "wear-${variant.flavorName}-${variant.buildType.name}.apk" | |
File wearDescFile = file("${output.processResources.resDir}/xml/wear_desc.xml") | |
String content = wearDescFile.getText('UTF-8') | |
content = content.replaceAll(/APPICATION_ID/, "${variant.mergedFlavor.applicationId}") | |
content = content.replaceAll(/VERSION_CODE/, "${variant.mergedFlavor.versionCode}") | |
content = content.replaceAll(/VERSION_NAME/, "${variant.mergedFlavor.versionName}") | |
content = content.replaceAll(/WEAR_BUILD/, apkFileName) | |
wearDescFile.write(content, 'UTF-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- This file is filled automatically at build time --> | |
<wearableApp package="APPICATION_ID"> | |
<versionCode>VERSION_CODE</versionCode> | |
<versionName>VERSION_NAME</versionName> | |
<path>WEAR_BUILD</path> | |
</wearableApp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project.afterEvaluate { | |
android.applicationVariants.all { variant -> | |
if (variant.buildType.name == 'release') { | |
tasks["generate${variant.name.capitalize()}Assets"] | |
.dependsOn(":wear:assemble${variant.name.capitalize()}") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.applicationVariants.all { variant -> | |
if (variant.buildType.name == 'release') { | |
variant.outputs.each { output -> | |
output.assemble << { | |
println "Copying Wear APK inside mobile" | |
copy { | |
from output.outputFile.path | |
into "../mobile/src/main/assets" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
... | |
defaultConfig { | |
... | |
versionCode appVersionCode | |
versionName appVersionName | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext { | |
appVersionCode = 1 | |
appVersionName = "1.0" | |
} |
NewerOlder