This file contains hidden or 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 MyDialogFragment extends DialogFragment { | |
| public interface DialogListener { | |
| void onFinishDialog(String data); | |
| } | |
| public MyDialogFragment() {} | |
| ... |
This file contains hidden or 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 FragmentActivity | |
| implements MyDialogFragment.DialogListener { | |
| ... | |
| public void showMyDialog() { | |
| DialogFragment newFragment = new MyDialogFragment(); | |
| newFragment.show(getSupportFragmentManager(), "idStringFragment"); | |
| } |
This file contains hidden or 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
| /** | |
| * Enables TLS v1.2 when creating SSLSockets. | |
| * | |
| * For some reason, android supports TLS v1.2 from API 16, but enables it by | |
| * default only from API 20. | |
| * @link https://developer.android.com/reference/javax/net/ssl/SSLSocket.html | |
| * @see SSLSocketFactory | |
| */ | |
| class Tls12SocketFactory(private val delegate: SSLSocketFactory) : SSLSocketFactory() { |
This file contains hidden or 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 OkHttpClient.Builder.enableTls12OnPreLollipop(): OkHttpClient.Builder { | |
| if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 22) { | |
| try { | |
| val sc = SSLContext.getInstance("TLSv1.2") | |
| sc.init(null, null, null) | |
| this.sslSocketFactory(Tls12SocketFactory(sc.socketFactory)) | |
| val cs = ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) | |
| .tlsVersions(TlsVersion.TLS_1_2) | |
| .build() |
This file contains hidden or 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 LocationSettingDispatcher(activity: Activity) { | |
| private val maybeSubscribe = UpdateLocationMaybeSubscribe(activity) | |
| private val subject = PublishSubject.create<Boolean>() | |
| companion object { | |
| val REQUEST_CHECK_SETTINGS = 0x1 | |
| } | |
| fun onActivityResult(requestCode: Int, resultCode: Int) { |
This file contains hidden or 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 LocationDeviceInteractor(activity: Activity) { | |
| private val provider = LocationServices.getFusedLocationProviderClient(activity) | |
| private val settingDispatcher = LocationSettingDispatcher(activity) | |
| private val lastLocationMaybe = Maybe.create<Location> { emitter -> | |
| try { | |
| provider.lastLocation.apply { | |
| addOnSuccessListener { location -> | |
| if (location != null) emitter.onSuccess(location) |
This file contains hidden or 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
| @Singleton | |
| class GooglePlayServicesAvailable @Inject constructor(private val context: Context) { | |
| companion object { | |
| private val PLAY_SERVICES_RESOLUTION_REQUEST = 4948 | |
| } | |
| sealed class Result { | |
| object True : Result() | |
| object False : Result() |
This file contains hidden or 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
| ... | |
| @Inject | |
| internal lateinit var googlePlayServicesAvailable: GooglePlayServicesAvailable | |
| ... | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| ... | |
| googlePlayServicesAvailable.isAvailableShowDialog(this).let { | |
| when (it) { | |
| is GooglePlayServicesAvailable.Result.True -> RiseSetActivityPermissionsDispatcher.locationPermissionWithCheck(this) |
This file contains hidden or 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
| @MustBeDocumented | |
| @Target(AnnotationTarget.FUNCTION, | |
| AnnotationTarget.PROPERTY_GETTER, | |
| AnnotationTarget.PROPERTY_SETTER) | |
| @Retention(AnnotationRetention.RUNTIME) | |
| @MapKey | |
| annotation class ViewModelKey(val value: KClass<out ViewModel>) |
This file contains hidden or 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
| @Module | |
| abstract class DemoModule { | |
| @Binds | |
| @IntoMap | |
| @ViewModelKey(DemoViewModel::class) | |
| internal abstract fun demoViewModel(viewModel: DemoViewModel): ViewModel | |
| ... |
OlderNewer