Skip to content

Commit fdc9b98

Browse files
author
Kaushik Gopal
committed
chore: setup demo activity operations
1 parent c26b5f5 commit fdc9b98

File tree

6 files changed

+112
-48
lines changed

6 files changed

+112
-48
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.morihacky.android.rxjava;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import com.morihacky.android.rxjava.app.R;
11+
12+
import butterknife.ButterKnife;
13+
14+
public class DemoAccumulateEventFragment
15+
extends Fragment {
16+
17+
@Override
18+
public View onCreateView(LayoutInflater inflater,
19+
@Nullable ViewGroup container,
20+
@Nullable Bundle savedInstanceState) {
21+
View layout = inflater.inflate(R.layout.fragment_accumulate, container, false);
22+
ButterKnife.inject(this, layout);
23+
return layout;
24+
}
25+
}
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
package com.morihacky.android.rxjava;
22

3-
import android.app.Activity;
43
import android.os.Bundle;
5-
import android.view.Menu;
6-
import android.view.MenuItem;
4+
import android.support.v4.app.FragmentActivity;
75

86
import com.morihacky.android.rxjava.app.R;
97

10-
11-
public class DemoActivity extends Activity {
8+
public class DemoActivity
9+
extends FragmentActivity {
1210

1311
@Override
1412
protected void onCreate(Bundle savedInstanceState) {
1513
super.onCreate(savedInstanceState);
1614
setContentView(R.layout.activity_demo);
17-
}
18-
19-
20-
@Override
21-
public boolean onCreateOptionsMenu(Menu menu) {
22-
// Inflate the menu; this adds items to the action bar if it is present.
23-
getMenuInflater().inflate(R.menu.demo, menu);
24-
return true;
25-
}
26-
27-
@Override
28-
public boolean onOptionsItemSelected(MenuItem item) {
29-
// Handle action bar item clicks here. The action bar will
30-
// automatically handle clicks on the Home/Up button, so long
31-
// as you specify a parent activity in AndroidManifest.xml.
32-
int id = item.getItemId();
33-
if (id == R.id.action_settings) {
34-
return true;
35-
}
36-
return super.onOptionsItemSelected(item);
15+
getSupportFragmentManager().beginTransaction()
16+
.addToBackStack(this.toString())
17+
.replace(R.id.activity_container, new DemoFragment(), this.toString())
18+
.commit();
3719
}
3820
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.morihacky.android.rxjava;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import com.morihacky.android.rxjava.app.R;
11+
12+
import butterknife.ButterKnife;
13+
import butterknife.OnClick;
14+
15+
public class DemoFragment
16+
extends Fragment {
17+
18+
@Override
19+
public View onCreateView(LayoutInflater inflater,
20+
@Nullable ViewGroup container,
21+
@Nullable Bundle savedInstanceState) {
22+
View layout = inflater.inflate(R.layout.fragment_demo, container, false);
23+
ButterKnife.inject(this, layout);
24+
return layout;
25+
}
26+
27+
@OnClick(R.id.demo_accumulate_event)
28+
public void demoAccumulationOfEvents() {
29+
getActivity().getSupportFragmentManager()
30+
.beginTransaction()
31+
.addToBackStack(this.toString())
32+
.replace(R.id.activity_container,
33+
new DemoAccumulateEventFragment(),
34+
this.toString())
35+
.commit();
36+
}
37+
38+
}
Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
<LinearLayout
2-
android:orientation="vertical"
1+
<FrameLayout
2+
android:id="@+id/activity_container"
33
android:layout_height="match_parent"
44
android:layout_width="match_parent"
5-
android:paddingTop="@dimen/activity_vertical_margin"
6-
android:paddingBottom="@dimen/activity_vertical_margin"
7-
android:paddingLeft="@dimen/activity_horizontal_margin"
8-
android:paddingRight="@dimen/activity_horizontal_margin"
9-
xmlns:android="http://schemas.android.com/apk/res/android"
10-
xmlns:tools="http://schemas.android.com/tools"
11-
tools:context=".DemoActivity">
12-
13-
<Button
14-
android:id="@+id/demo_long_bg"
15-
android:layout_height="wrap_content"
16-
android:layout_width="wrap_content"
17-
android:text="@string/demo_type_long_bg"/>
18-
19-
<Button
20-
android:id="@+id/demo_accumulate_event"
21-
android:layout_height="wrap_content"
22-
android:layout_width="wrap_content"
23-
android:text="@string/demo_type_accumulate"/>
24-
25-
</LinearLayout>
5+
xmlns:android="http://schemas.android.com/apk/res/android" />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout
4+
android:orientation="vertical"
5+
android:layout_height="match_parent"
6+
android:layout_width="match_parent"
7+
xmlns:android="http://schemas.android.com/apk/res/android">
8+
9+
<TextView
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:text="Accumulate events test" />
13+
14+
</LinearLayout>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<LinearLayout
2+
android:orientation="vertical"
3+
android:layout_height="match_parent"
4+
android:layout_width="match_parent"
5+
android:paddingTop="@dimen/activity_vertical_margin"
6+
android:paddingBottom="@dimen/activity_vertical_margin"
7+
android:paddingLeft="@dimen/activity_horizontal_margin"
8+
android:paddingRight="@dimen/activity_horizontal_margin"
9+
xmlns:android="http://schemas.android.com/apk/res/android"
10+
xmlns:tools="http://schemas.android.com/tools"
11+
tools:context=".DemoActivity">
12+
13+
<Button
14+
android:id="@+id/demo_long_bg"
15+
android:layout_height="wrap_content"
16+
android:layout_width="wrap_content"
17+
android:text="@string/demo_type_long_bg"/>
18+
19+
<Button
20+
android:id="@+id/demo_accumulate_event"
21+
android:layout_height="wrap_content"
22+
android:layout_width="wrap_content"
23+
android:text="@string/demo_type_accumulate"/>
24+
25+
</LinearLayout>

0 commit comments

Comments
 (0)