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
data class Person(val name: String, val gender: Gender, | |
var age: Int = 0, var email: String = "") { | |
fun doWork() { | |
println("*working*") | |
} | |
fun doEat() { | |
println("*eating*") | |
} |
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
fun Person.doDance() { | |
println("*dancing*") | |
} | |
val Person.isOld get() = age >= 25 |
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
val lambda: (Person) -> Boolean = { p -> p.name.startsWith("H") } | |
// |
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
fun <T> doConditionally(people: MutableList<T>, | |
condition: (T) -> Boolean, | |
action: (T) -> Unit) { | |
people.forEach { | |
if (condition(it)) action(it) | |
} | |
} |
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
package id.binarykitchen.gemarbelajar; | |
import android.content.Context; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
public class MainActivity extends AppCompatActivity { |
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
package id.binarykitchen.gemarbelajar; | |
import android.content.Context; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
public class MainActivity extends AppCompatActivity { |
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
// we initialize moengage in applicaiton class | |
public class StudentApplication { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
setupMoengage(); | |
} |
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
// this function is called after login success | |
private fun onLoginSuccess(successResponse: LoginSuccessResponse) { | |
if (userRepo.uoc != successResponse.uoc) { | |
MoEHelper.getInstance(mContext).setAlias(successResponse.uoc) | |
} else { | |
MoEHelper.getInstance(mContext).apply { | |
setUniqueId(userRepo.uoc) | |
setFullName(successResponse.name) | |
setEmail(successResponse.email) | |
} |
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
// this function is called when logout | |
public void logout() { | |
MoEHelper.getInstance(mContext).logoutUser(); | |
} |
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
<!-- we added fullBackupContent in application tag accordingly as described in the documentation --> | |
<application | |
android:name=".StudentApplication" | |
android:fullBackupContent="@xml/backup_descriptor"> | |
<!-- ... --> | |
</application |
OlderNewer