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 AgeCalculator { | |
private int days; | |
private int months; | |
private int years; | |
AgeCalculator(int days, int months, int years) { | |
this.days = days; | |
this.months = months; | |
this.years = years; |
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 fillIntentWithParams( | |
intent: Intent, | |
params: Array<out Pair<String, Any?>> | |
) { | |
params.forEach { | |
when (val value = it.second) { | |
is String -> intent.putExtra(it.first, value) | |
is Int -> intent.putExtra(it.first, value) | |
is Double -> intent.putExtra(it.first, value) | |
else -> throw Exception("Invalid intent parameter type for : ${it.first}") |
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 : BaseActivity() { | |
override val layoutId: Int? | |
get() = R.layout.activity_main | |
override fun viewCreated() { | |
bScan.setOnClickListener { | |
startActivityForResult<QRCodeActivity>(REQUEST_CODE_QR) // Kotlin Anko Intent Library | |
} | |
} |
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
private void replaceFragment(FragmentManager fragmentManager, Fragment fragment, String backStackName, String lastAddedStackName) { | |
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); | |
BaseNavigationFragment baseFragment; | |
Fragment fragmentByTag = fragmentManager.findFragmentByTag(backStackName); | |
if (fragmentByTag != null) { | |
baseFragment = (BaseFragment) fragmentByTag; | |
fragmentTransaction | |
.setTransition(FragmentTransaction.TRANSIT_NONE) |
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
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.provider.Settings; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.RequiresApi; | |
import android.support.v4.content.ContextCompat; |