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 goes here | |
buildTypes { | |
debug { | |
buildConfigField "String", 'BASE_URL', "https://dev-api.yourbackend.com" | |
} | |
staging { | |
buildConfigField "String", 'BASE_URL', "https://stg-api.yourbackend.com" | |
} | |
release { |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
dependencies { | |
// other dependencies | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |
} |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
ext.kotlin_version = '1.2.20' | |
repositories { | |
google() | |
jcenter() | |
} | |
dependencies { |
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
peopleRepository.loadPeopleAsync().enqueue(object: Callback<PeopleResponse> { | |
override fun onFailure(call: Call<PeopleResponse>, t: Throwable) { } | |
override fun onResponse(call: Call<PeopleResponse>, response: Response<PeopleResponse>) { | |
if (response.isSuccessful) { | |
val result = response.body()?.results | |
result?.let { characters -> | |
characters.forEach { character -> | |
peopleRepository.loadPerson(character.url).enqueue(object: Callback<PersonResponse>{ | |
override fun onFailure(call: Call<PersonResponse>, t: Throwable) {} | |
override fun onResponse(call: Call<PersonResponse>, response: Response<PersonResponse>) { |
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
tmdbApi.loadPeople() | |
.map { movie -> movie.urls } | |
.map { url -> tmdbApi.movieDetails(url) } | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(onSuccess = { details -> view. showMovieDetails(details) }, | |
onError = { view. showErrorMessage() }) |
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
// declaring views | |
@BindView(R.id.description) TextView description; | |
@BindView(R.id.signInButton) Button signInButton; | |
@BindView(R.id.cancelButton) Button cancelButton; | |
// onCreate() | |
ButterKnife.bind(this) |
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
public class MainActivity extends Activity { | |
private TextView description; | |
private Button signInButton; | |
private Button cancelButton; | |
// onCreate() | |
description = (TextView) findViewById(R.id.description); | |
signInButton = (Button) findViewById(R.id.signInButton); | |
cancelButton = (Button) findViewById(R.id.cancelButton); |
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 { | |
// ... | |
viewBinding.enabled = true | |
// ... | |
} |
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() { | |
private lateinit var binding: ActivityMainBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(LayoutInflater.from(this)) | |
setContentView(binding.root) | |
binding.bindUserButton.setOnClickListener { | |
viewModel.onBindUserButtonClicked( |
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"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<!-- region Guidelines --> | |
<androidx.constraintlayout.widget.Guideline |
OlderNewer