This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ancillaryFactory Activity to Playground to test Fragment
- Loading branch information
1 parent
6eccd65
commit 779ec2a
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
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
57 changes: 56 additions & 1 deletion
57
...d/playground/src/main/java/com/kiwi/mobile/rnandroidplayground/AncillaryFactoryAcivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,59 @@ | ||
package com.kiwi.mobile.rnandroidplayground | ||
|
||
class AncillaryFactoryAcivity { | ||
import android.annotation.TargetApi | ||
import android.os.Build | ||
import android.os.Bundle | ||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler | ||
import com.facebook.react.modules.core.PermissionAwareActivity | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.facebook.react.modules.core.PermissionListener | ||
|
||
|
||
class AncillaryFactoryAcivity : AppCompatActivity(), DefaultHardwareBackBtnHandler, PermissionAwareActivity { | ||
|
||
private var mPermissionListener: PermissionListener? = null | ||
|
||
companion object { | ||
fun getViewModelClass(): Class<AncillaryFactoryAcivity> = | ||
AncillaryFactoryAcivity::class.java | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_fragment) | ||
|
||
if (savedInstanceState == null) { | ||
addFragment() | ||
} | ||
} | ||
|
||
private fun addFragment() { | ||
val fragmentManager = getSupportFragmentManager() | ||
fragmentManager.beginTransaction().add(R.id.container_main, AncillaryFactoryFragment()).commit() | ||
} | ||
|
||
// region BackButton | ||
override fun invokeDefaultOnBackPressed() { | ||
super.onBackPressed() | ||
} | ||
|
||
override fun onBackPressed() { | ||
(application as PlaygroundApplication).reactNativeHost.reactInstanceManager.onBackPressed() | ||
} | ||
// endregion | ||
|
||
// region PermissionAwareActivity | ||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) { | ||
super.onRequestPermissionsResult(requestCode, permissions, grantResults) | ||
if (mPermissionListener != null && mPermissionListener!!.onRequestPermissionsResult(requestCode, permissions, grantResults)) { | ||
mPermissionListener = null | ||
} | ||
} | ||
|
||
@TargetApi(Build.VERSION_CODES.M) | ||
override fun requestPermissions(permissions: Array<String>, requestCode: Int, listener: PermissionListener) { | ||
mPermissionListener = listener | ||
requestPermissions(permissions, requestCode) | ||
} | ||
// endregion | ||
} |
8 changes: 7 additions & 1 deletion
8
.../playground/src/main/java/com/kiwi/mobile/rnandroidplayground/AncillaryFactoryFragment.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
package com.kiwi.mobile.rnandroidplayground | ||
|
||
class AncillaryFactoryFragment { | ||
import com.facebook.react.ReactNativeHost | ||
import com.kiwi.rnkiwimobile.ancillaries.RNAncillaryFactoryFragment | ||
import com.kiwi.rnkiwimobile.ancillaries.RNAncillaryFactoryInitialProperties | ||
|
||
|
||
class AncillaryFactoryFragment: RNAncillaryFactoryFragment(RNAncillaryFactoryInitialProperties(service = "fast_track", bookingId = 123, kwAuthToken = "mock")) { | ||
override fun getReactNativeHost(): ReactNativeHost = (activity?.application as PlaygroundApplication).reactNativeHost | ||
} |
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 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