Skip to content

Instantly share code, notes, and snippets.

View prbale's full-sized avatar
☺️
Learning

Prashant Bale prbale

☺️
Learning
View GitHub Profile
@prbale
prbale / BaseActivity.Java
Last active April 22, 2018 03:23
Handle Back Press in Fragments
protected OnBackPressedListener onBackPressedListener;
//...
public void setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {
this.onBackPressedListener = onBackPressedListener;
}
//...
@prbale
prbale / AndroidManifest.xml
Last active February 25, 2018 18:04
Android Deep Linking
<!-- Deep Link Activity : Start -->
<activity
android:name=".deeplinks.LinkDispatcherActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:noHistory="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
@prbale
prbale / Activity.kt
Last active December 11, 2017 16:01
Kotlin Useful Extensions
/**
* The `fragment` is added to the container view with id `frameId`.
* The operation is performed by the `fragmentManager`.
*/
fun AppCompatActivity.addFragment(
fragmentManager: FragmentManager,
fragment: Fragment,
frameId: Int) {
@prbale
prbale / AccountDetailsActivity.kt
Created December 10, 2017 16:29
Starting Activity in Kotlin
class AccountDetailsActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val accountNumber = intent.getStringExtra(ACCOUNT_NUMBER)
?: throw IllegalStateException("ACCOUNT_NUMBER is mandatory in the Intent")
}
companion object {
private val ACCOUNT_NUMBER = "ACCOUNT_NUMBER"
@prbale
prbale / Response.kt
Created December 10, 2017 13:06
Android Kotlin - Sealed Classes
/**
* Declaring Response class as sealed class means,
* It is an Abstract class like in Java. We can have all the features
* in Sealed class which Abstract class has.
* In this example, added one property field to sealed class "Tag" and
* This is overridden in the classes extended to this sealed class.
* Sealed classes are used to have restricted hierarchy.
*/
sealed class Response {
open var tag: String = ""