Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Add ancillaryFactory Activity to Playground to test Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
KarinaDavtyan committed Nov 5, 2019
1 parent 6eccd65 commit 779ec2a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions android/playground/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
</activity>
<activity android:name="com.kiwi.mobile.rnandroidplayground.HotelsActivityFragment">
</activity>
<activity android:name="com.kiwi.mobile.rnandroidplayground.AncillaryFactoryAcivity">
</activity>
<activity android:name=".HotelsStay22Activity" />
<activity android:name="com.kiwi.mobile.rnandroidplayground.AccountSettingsActivity" />
<activity android:name="com.kiwi.mobile.rnandroidplayground.AccountPriceAlertsActivity" />
Expand Down
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
}
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class MainActivity : AppCompatActivity() {
button_account_price_alerts.setOnClickListener {
startActivity(Intent(this, AccountPriceAlertsActivity.getViewModelClass()))
}

button_ancillary_factory.setOnClickListener {
startActivity(Intent(this, AncillaryFactoryAcivity.getViewModelClass()))
}
}

override fun onDestroy() {
Expand Down
6 changes: 6 additions & 0 deletions android/playground/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@
android:layout_height="wrap_content"
android:text="Account price alerts" />

<Button
android:id="@+id/button_ancillary_factory"
android:layout_width="199dp"
android:layout_height="wrap_content"
android:text="ancillary factory" />

</LinearLayout>

0 comments on commit 779ec2a

Please sign in to comment.