├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── net │ │ └── petitviolet │ │ └── monad_example │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── net │ │ │ └── petitviolet │ │ │ └── monad_example │ │ │ ├── MainActivity.java │ │ │ ├── MainActivityFragment.java │ │ │ └── SampleFragment.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── content_main.xml │ │ ├── fragment_main.xml │ │ ├── fragment_plus_one.xml │ │ └── input_column.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── net │ └── petitviolet │ └── maybe_example │ └── ExampleUnitTest.java ├── bintray.gradle.skelton ├── build.gradle ├── circle.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── monad ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── net │ │ └── petitviolet │ │ └── monad │ │ ├── Functor.java │ │ ├── Identity.java │ │ ├── Monad.java │ │ ├── Tuple.java │ │ ├── func │ │ └── Function.java │ │ ├── list │ │ └── ListM.java │ │ ├── maybe │ │ ├── Just.java │ │ ├── Maybe.java │ │ └── None.java │ │ ├── state │ │ └── State.java │ │ └── type │ │ ├── IntM.java │ │ └── Monoid.java │ └── test │ └── java │ └── net │ └── petitviolet │ └── monad │ ├── IdentityTest.java │ ├── list │ └── ListMTest.java │ ├── maybe │ └── MaybeTest.java │ └── state │ └── StateTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | ### https://raw.github.com/github/gitignore/2544a6b71027a1832e01f5c7f78bdfcea727f4ec/android.gitignore 10 | 11 | # Built application files 12 | *.apk 13 | *.ap_ 14 | 15 | # Files for the Dalvik VM 16 | *.dex 17 | 18 | # Java class files 19 | *.class 20 | 21 | # Generated files 22 | bin/ 23 | gen/ 24 | 25 | # Gradle files 26 | .gradle/ 27 | build/ 28 | 29 | # Local configuration file (sdk path, etc) 30 | local.properties 31 | 32 | # Proguard folder generated by Eclipse 33 | proguard/ 34 | 35 | 36 | /gradle.properties 37 | bintray.gradle 38 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Android-Monad -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Monad 2 | 3 | [![Circle CI](https://circleci.com/gh/petitviolet/Android-Monad/tree/master.svg?style=svg)](https://circleci.com/gh/petitviolet/Android-Monad/tree/master) 4 | [![Download](https://api.bintray.com/packages/petitviolet/maven/android-monad/images/download.svg) ](https://bintray.com/petitviolet/maven/android-monad/\_latestVersion) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--Monad-green.svg?style=true)](https://android-arsenal.com/details/1/2786) 6 | 7 | This repository is Yet Another Android-M. 8 | 9 | Implemented "Monadic" data structures. 10 | 11 | # Set up 12 | 13 | ```groovy 14 | dependencies { 15 | compile 'net.petitviolet.android:monad:latest-version' 16 | } 17 | ``` 18 | 19 | And, I strongly recommend to use [orfjackal/retrolambda](https://github.com/orfjackal/retrolambda) together. 20 | 21 | # How to Use 22 | 23 | ## Maybe 24 | 25 | The name of `Maybe` is derived from Haskell. 26 | In Scala, `Option`. 27 | 28 | ```java 29 | // with lambda 30 | Maybe maybeInt = Maybe.of(x); 31 | maybeInt.flatMap(integer -> Maybe.of(integer % 2 == 0 ? integer : null)) 32 | .map(integer -> integer + 5) 33 | .filter(integer -> integer % 3 == 0) 34 | .foreach(integer -> Log.d(TAG, "result: " + integer)); 35 | 36 | // without lambda 37 | maybeInt.flatMap(new Function.F1>() { 38 | @Override 39 | public Maybe invoke(Integer integer) { 40 | return Maybe.of(integer % 2 == 0 ? integer : null); 41 | } 42 | }).map(new Function.F1() { 43 | @Override 44 | public Integer invoke(Integer integer) { 45 | return integer + 5; 46 | } 47 | }).filter(new Function.F1() { 48 | @Override 49 | public Boolean invoke(Integer integer) { 50 | return integer % 3 == 0; 51 | } 52 | }).foreach(new Function.F() { 53 | @Override 54 | public void invoke(Integer integer) { 55 | Log.d(TAG, "result: " + integer); 56 | } 57 | }); 58 | ``` 59 | 60 | More detailes of `Maybe` interface is shown in [MaybeTest.java](https://github.com/petitviolet/Android-Monad/blob/master/monad%2Fsrc%2Ftest%2Fjava%2Fnet%2Fpetitviolet%2Fmaybe%2FMaybeTest.java). 61 | 62 | ## ListM 63 | 64 | Implemented `ListM` based on `ArrayList` as a implementation of `List` interface. 65 | 66 | ```java 67 | ListM listM = ListM.unit(); 68 | listM.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); 69 | ListM result = listM.filter(i -> i % 3 == 0) 70 | .flatMap(i -> ListM.of(i * 10)) 71 | .map(s -> s + "!"); 72 | .foldRight((a, acc) -> a + ", " + acc, " <= end"); 73 | // result -> 90!, 60!, 30!, <= end 74 | ``` 75 | 76 | More detailes of `ListM` interface is shown in [ListMTest.java](https://github.com/petitviolet/Android-Monad/blob/master/monad%2Fsrc%2Ftest%2Fjava%2Fnet%2Fpetitviolet%2Flist%2FListMTest.java). 77 | 78 | ## State 79 | 80 | State monad. 81 | Sequencial computations share a state, and each of them uses the state and modify or not, then pass it to next computation. 82 | 83 | ```java 84 | // state is List, and value is Integer 85 | Tuple> result = 86 | State.init((List strings) -> { 87 | // modify state 88 | strings.add("nice"); 89 | // value is 1 90 | return Tuple.of(1, strings); 91 | }).map(i -> { 92 | // apply function to value of State 93 | return i + 10; 94 | }).map(i -> { 95 | // apply function to value of State 96 | return i * 2; 97 | }).flatMap(integer -> { 98 | // apply function to value of State 99 | return State.init(strings -> { 100 | if (integer % 2 == 0) { 101 | // modify state 102 | strings.add("awesome"); 103 | return Tuple.of(integer, strings); 104 | } else { 105 | // modify state 106 | strings.add("Oops"); 107 | return Tuple.of(-100, strings); 108 | } 109 | }); 110 | // empty list is given as the first state of above sequencial computations 111 | }).apply(new ArrayList<>()); 112 | assert result._1 == 22; 113 | assert result._2 == List("nice", "awesome"); // dummy code 114 | ``` 115 | 116 | # Identity 117 | 118 | Id monad. 119 | Have a value and do nothing. 120 | Just monadic. 121 | 122 | ```java 123 | Identity id = Identity.id("hoge"); 124 | Identity result = id.flatMap(new Function.F1>() { 125 | @Override 126 | public Identity invoke(String s) { 127 | return Identity.id(s.length()); 128 | } 129 | }); 130 | assert result.value.equals(4); 131 | ``` 132 | 133 | # Lisence 134 | 135 | This code is licensed under the Apache Software License 2.0. 136 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'me.tatarka.retrolambda' 3 | 4 | android { 5 | compileSdkVersion 23 6 | buildToolsVersion "23.0.1" 7 | 8 | defaultConfig { 9 | applicationId "net.petitviolet.maybe_example" 10 | minSdkVersion 15 11 | targetSdkVersion 23 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | compileOptions { 22 | sourceCompatibility JavaVersion.VERSION_1_8 23 | targetCompatibility JavaVersion.VERSION_1_8 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(dir: 'libs', include: ['*.jar']) 29 | testCompile 'junit:junit:4.12' 30 | compile project(':monad') 31 | // compile 'net.petitviolet.android:monad:0.1.0' 32 | compile 'com.android.support:appcompat-v7:23.1.0' 33 | compile 'com.android.support:design:23.1.0' 34 | compile 'com.android.support:support-v4:23.1.0' 35 | } 36 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/petitviolet/android-sdks/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.unit.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/net/petitviolet/monad_example/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.petitviolet.monad_example; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/net/petitviolet/monad_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.petitviolet.monad_example; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.Log; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | 12 | import net.petitviolet.monad.Tuple; 13 | import net.petitviolet.monad.func.Function; 14 | import net.petitviolet.monad.list.ListM; 15 | import net.petitviolet.monad.maybe.Maybe; 16 | import net.petitviolet.monad.state.State; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | public class MainActivity extends AppCompatActivity { 23 | private static final String TAG = MainActivity.class.getSimpleName(); 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_main); 29 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 30 | setSupportActionBar(toolbar); 31 | 32 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 33 | fab.setOnClickListener(view -> { 34 | testMaybeWithLambda(3); 35 | testMaybeWithLambda(100); 36 | testMaybeOldStyle(null); 37 | testListMWithLambda(); 38 | sampleState(); 39 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 40 | .setAction("Action", null).show(); 41 | }); 42 | } 43 | 44 | private Maybe findByNumber(Integer target) { 45 | List sourceList = Arrays.asList(2, 3, 5, 7, 9, 11); 46 | return Maybe.of(sourceList.contains(target) ? sourceList.indexOf(target) : null); 47 | } 48 | 49 | private void testMaybeWithLambda(Integer x) { 50 | Log.d(TAG, "lambda start↓↓↓↓↓↓↓↓↓↓"); 51 | Maybe maybeInt = Maybe.of(x); 52 | Log.d(TAG, "maybeInt:" + maybeInt); 53 | maybeInt 54 | .flatMap(this::findByNumber) 55 | .map(integer -> integer + 5) 56 | .filter(integer -> integer % 2 == 0) 57 | .foreach(integer -> Log.d(TAG, "result: " + integer)); 58 | Log.d(TAG, "lambda end↑↑↑↑↑↑↑↑↑↑"); 59 | } 60 | 61 | private void testMaybeOldStyle(Integer x) { 62 | Log.d(TAG, "oldstyle start↓↓↓↓↓↓↓↓↓↓"); 63 | 64 | Maybe maybeInt = Maybe.of(x); 65 | Log.d(TAG, "maybeInt:" + maybeInt); 66 | maybeInt.flatMap(new Function.F1>() { 67 | @Override 68 | public Maybe invoke(Integer integer) { 69 | return Maybe.of(integer * 2); 70 | } 71 | }).map(new Function.F1() { 72 | @Override 73 | public Integer invoke(Integer integer) { 74 | return integer + 5; 75 | } 76 | }).filter(new Function.F1() { 77 | @Override 78 | public Boolean invoke(Integer integer) { 79 | return integer % 2 == 0; 80 | } 81 | }).foreach(new Function.F() { 82 | @Override 83 | public void invoke(Integer integer) { 84 | Log.d(TAG, "result: " + integer); 85 | } 86 | }); 87 | 88 | Log.d(TAG, "oldstyle end↑↑↑↑↑↑↑↑↑↑"); 89 | } 90 | 91 | private void testListMWithLambda() { 92 | ListM listM = ListM.unit(); 93 | listM.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); 94 | ListM seed = listM.filter(i -> i % 2 == 0) 95 | .flatMap(this::alphabets) 96 | .map(s -> s + "!") 97 | .map(s -> { 98 | Log.d(TAG, s); 99 | return s; 100 | }); 101 | String rightResult = seed.foldRight((a, acc) -> a + ", " + acc, " <= end"); 102 | String leftResult = seed.foldLeft("start -> ", (acc, a) -> acc + ", " + a); 103 | Log.d(TAG, "resultRight => " + rightResult); 104 | Log.d(TAG, "resultLeft => " + leftResult); 105 | } 106 | 107 | private static final ListM ALPHABETS = ListM.unit(); 108 | 109 | static { 110 | for (char a = 'a'; a <= 'z'; a++) { 111 | ALPHABETS.add(String.valueOf(a)); 112 | } 113 | } 114 | 115 | private ListM alphabets(int num) { 116 | return ALPHABETS.subList(0, num <= ALPHABETS.size() ? num : ALPHABETS.size()); 117 | } 118 | 119 | private void sampleState() { 120 | Tuple> result = 121 | State.init((List strings) -> { 122 | strings.add("nice"); 123 | return Tuple.of(1, strings); 124 | 125 | }).map(i -> { 126 | return i + 6; 127 | }).map(i -> { 128 | return i * 3; 129 | }).flatMap(integer -> { 130 | return State.init(strings -> { 131 | if (integer == 42) { 132 | strings.add("awesome"); 133 | return Tuple.of(integer, strings); 134 | } else { 135 | strings.add("Oops"); 136 | return Tuple.of(-100, strings); 137 | } 138 | }); 139 | }).apply(new ArrayList<>()); 140 | Log.d(TAG, "State -> " + result.toString()); 141 | } 142 | 143 | private void combineMaybeListM() { 144 | ListM.of(1, 2, 3, 4, 5) 145 | .map(i -> i * 2) 146 | .bindMaybe(Maybe::of) 147 | .foreach(System.out::println); 148 | } 149 | 150 | @Override 151 | public boolean onCreateOptionsMenu(Menu menu) { 152 | // Inflate the menu; this adds items to the action bar if it is present. 153 | getMenuInflater().inflate(R.menu.menu_main, menu); 154 | return true; 155 | } 156 | 157 | @Override 158 | public boolean onOptionsItemSelected(MenuItem item) { 159 | int id = item.getItemId(); 160 | 161 | if (id == R.id.action_settings) { 162 | return true; 163 | } 164 | 165 | return super.onOptionsItemSelected(item); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /app/src/main/java/net/petitviolet/monad_example/MainActivityFragment.java: -------------------------------------------------------------------------------- 1 | package net.petitviolet.monad_example; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.ListFragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | /** 10 | * A placeholder fragment containing a simple view. 11 | */ 12 | public class MainActivityFragment extends ListFragment { 13 | 14 | public MainActivityFragment() { 15 | } 16 | 17 | @Override 18 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 19 | Bundle savedInstanceState) { 20 | return inflater.inflate(R.layout.fragment_main, container, false); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/net/petitviolet/monad_example/SampleFragment.java: -------------------------------------------------------------------------------- 1 | package net.petitviolet.monad_example; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.text.TextUtils; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | import android.widget.CheckBox; 11 | import android.widget.EditText; 12 | import android.widget.TextView; 13 | 14 | import net.petitviolet.monad.Tuple; 15 | import net.petitviolet.monad.list.ListM; 16 | 17 | public class SampleFragment extends Fragment { 18 | private Button mAddFormButton; 19 | private TextView mSumTextView; 20 | private TextView mIncomeTextView; 21 | private TextView mOutcomeTextView; 22 | private ListM mFormLayoutList; 23 | 24 | public SampleFragment() { 25 | } 26 | 27 | public static SampleFragment newInstance() { 28 | SampleFragment fragment = new SampleFragment(); 29 | Bundle args = new Bundle(); 30 | fragment.setArguments(args); 31 | return fragment; 32 | } 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | } 38 | 39 | @Override 40 | public View onCreateView(final LayoutInflater inflater, final ViewGroup container, 41 | Bundle savedInstanceState) { 42 | View view = inflater.inflate(R.layout.fragment_plus_one, container, false); 43 | mAddFormButton = (Button) view.findViewById(R.id.button_add_form); 44 | mSumTextView = (TextView) view.findViewById(R.id.textview_sum); 45 | mIncomeTextView = (TextView) view.findViewById(R.id.textview_income); 46 | mOutcomeTextView = (TextView) view.findViewById(R.id.textview_outcome); 47 | final ViewGroup formContainer = (ViewGroup) view.findViewById(R.id.form_container); 48 | mFormLayoutList = ListM.of(formContainer); 49 | 50 | mAddFormButton.setOnClickListener(v -> { 51 | Tuple, ListM> partitionLayouts = mFormLayoutList.partition(layout -> ((CheckBox) layout.findViewById(R.id.select_plus_or_minus)).isChecked()); 52 | 53 | int income = partitionLayouts._1 54 | .map(layout -> ((EditText) layout.findViewById(R.id.input_number)).getText().toString()) 55 | .filter(s -> !TextUtils.isEmpty(s)) 56 | .map(Integer::parseInt) 57 | .foldLeft(0, (acc, i) -> acc + i); 58 | 59 | int outcome = partitionLayouts._2 60 | .map(layout -> ((EditText) layout.findViewById(R.id.input_number)).getText().toString()) 61 | .filter(s -> !TextUtils.isEmpty(s)) 62 | .map(Integer::parseInt) 63 | .foldRight((acc, i) -> acc + i, 0); 64 | 65 | mIncomeTextView.setText("¥" + income); 66 | mOutcomeTextView.setText("¥ -" + outcome); 67 | mSumTextView.setText("¥" + (income - outcome)); 68 | 69 | View formLayout = inflater.inflate(R.layout.input_column, container, false); 70 | formContainer.addView(formLayout); 71 | mFormLayoutList.add(formLayout); 72 | }); 73 | 74 | return view; 75 | } 76 | 77 | @Override 78 | public void onResume() { 79 | super.onResume(); 80 | } 81 | 82 | @Override 83 | public void onDetach() { 84 | super.onDetach(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | 20 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_plus_one.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | 15 | 23 | 24 | 32 | 33 | 41 | 42 | 43 |