diff --git a/android/sample/AndroidManifest.xml b/android/sample/AndroidManifest.xml index 96361f720..c7e79a8dd 100644 --- a/android/sample/AndroidManifest.xml +++ b/android/sample/AndroidManifest.xml @@ -60,6 +60,15 @@ + + + + + + + + diff --git a/android/sample/src/main/java/com/facebook/flipper/sample/IncrementActivity.java b/android/sample/src/main/java/com/facebook/flipper/sample/IncrementActivity.java new file mode 100644 index 000000000..7e35ac7b3 --- /dev/null +++ b/android/sample/src/main/java/com/facebook/flipper/sample/IncrementActivity.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.flipper.sample; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +public class IncrementActivity extends Activity { + + int count = 0; + TextView text; + Button button; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_increment); + + text = (TextView) findViewById(R.id.count); + + button = (Button) findViewById(com.facebook.flipper.sample.R.id.btn_inc); + button.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View view) { + IncrementActivity.this.text.setText(String.valueOf(++count)); + } + }); + } +} diff --git a/android/sample/src/main/java/com/facebook/flipper/sample/RootComponentSpec.java b/android/sample/src/main/java/com/facebook/flipper/sample/RootComponentSpec.java index 408b3a97b..af0fb1ec2 100644 --- a/android/sample/src/main/java/com/facebook/flipper/sample/RootComponentSpec.java +++ b/android/sample/src/main/java/com/facebook/flipper/sample/RootComponentSpec.java @@ -109,10 +109,17 @@ public class RootComponentSpec { .clickHandler(RootComponent.openAnimationsActivity(c))) .child( Text.create(c) - .text("Crash this app") + .text("Navigate to increment activity") .key("11") .marginDip(YogaEdge.ALL, 10) .textSizeSp(20) + .clickHandler(RootComponent.openIncrementActivity(c))) + .child( + Text.create(c) + .text("Crash this app") + .key("12") + .marginDip(YogaEdge.ALL, 10) + .textSizeSp(20) .clickHandler(RootComponent.triggerCrash(c))) .child( FrescoImage.create(c) @@ -190,4 +197,10 @@ public class RootComponentSpec { final Intent intent = new Intent(c.getAndroidContext(), AnimationsActivity.class); c.getAndroidContext().startActivity(intent); } + + @OnEvent(ClickEvent.class) + static void openIncrementActivity(final ComponentContext c) { + final Intent intent = new Intent(c.getAndroidContext(), IncrementActivity.class); + c.getAndroidContext().startActivity(intent); + } } diff --git a/android/sample/src/main/res/layout/activity_increment.xml b/android/sample/src/main/res/layout/activity_increment.xml new file mode 100644 index 000000000..d35ff207f --- /dev/null +++ b/android/sample/src/main/res/layout/activity_increment.xml @@ -0,0 +1,26 @@ + + + + + + +