Skip to content

Commit

Permalink
Changed BasePresenter
Browse files Browse the repository at this point in the history
  • Loading branch information
MadRatSRP committed Feb 8, 2019
1 parent cc68e27 commit 193f08e
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,4 @@ class BaseFragment : Fragment(), BaseVP.View {
.remove(fragment)
.commit()
}

override fun setEgeBundle(maths: EditText,
russian: EditText,
physics: EditText?,
computerScience: EditText?,
socialScience: EditText?) : Bundle {

val bundle = Bundle()
bundle.putInt("maths", maths.text.toString().toInt())
bundle.putInt("russian", russian.text.toString().toInt())
physics?.text.toString().toIntOrNull()?.let { bundle.putInt("physics", it) }
computerScience?.text.toString().toIntOrNull()?.let { bundle.putInt("computerScience", it) }
socialScience?.text.toString().toIntOrNull()?.let { bundle.putInt("socialScience", it) }
return bundle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ class BasePresenter(context: Context,
bvi.setFragment(fragment, fragmentManager, id)
}

override fun addEgeBundle(maths: EditText,
override fun returnBundle(maths: EditText,
russian: EditText,
physics: EditText?,
computerScience: EditText?,
socialScience: EditText?): Bundle {

return bvi.setEgeBundle(maths,
russian,
physics,
computerScience,
socialScience)
val bundle = Bundle()
bundle.putInt("maths", maths.text.toString().toInt())
bundle.putInt("russian", russian.text.toString().toInt())
physics?.text.toString().toIntOrNull()?.let { bundle.putInt("physics", it) }
computerScience?.text.toString().toIntOrNull()?.let { bundle.putInt("computerScience", it) }
socialScience?.text.toString().toIntOrNull()?.let { bundle.putInt("socialScience", it) }
return bundle
}

override fun removeFragment(fragment: Fragment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ interface BaseVP {
interface View {
fun setFragment(fragment: Fragment, fragmentManager: FragmentManager, id: Int)
fun unsetFragment(fragment: Fragment, fragmentManager: FragmentManager)

fun setEgeBundle(maths: EditText, russian: EditText, physics: EditText?,
computerScience: EditText?, socialScience: EditText?): Bundle
}

interface Presenter {
fun addFragment(fragment: Fragment, id: Int)
fun removeFragment(fragment: Fragment)

fun addEgeBundle(maths: EditText, russian: EditText, physics: EditText?,
fun returnBundle(maths: EditText, russian: EditText, physics: EditText?,
computerScience: EditText?, socialScience: EditText?): Bundle
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.madrat.abiturhelper.ui.result

import android.content.Context
import android.os.Bundle

class ResultPresenter (private var rv: ResultVP.View, private val arguments: Bundle) : ResultVP.Presenter {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.madrat.abiturhelper.ui.setup_additional

class SetupAdditional {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.madrat.abiturhelper.ui.setup_additional

class SetupAdditionalPresenter {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.madrat.abiturhelper.ui.setup_additional

interface SetupAdditionalVP {
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SetupScore : Fragment(), SetupScoreVP.View {
}

override fun setFieldsValues() {
ResultView.instance.arguments = basePresenter.addEgeBundle(maths, russian, physics,
ResultView.instance.arguments = basePresenter.returnBundle(maths, russian, physics,
computer_science, social_science)
}

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/fragment_setup_additional.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
134 changes: 134 additions & 0 deletions diplom3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<LinearLayout
android:id="@+id/maths"
android:orientation="horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/maths_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hint_maths"
android:textSize="19dp"/>
<EditText
android:id="@+id/maths_value"
android:ems="10"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:id="@+id/russian"
android:orientation="horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toBottomOf="@id/maths"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/russian_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hint_russian"
android:textSize="19dp"/>
<EditText
android:id="@+id/russian_value"
android:ems="10"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:id="@+id/physics"
android:orientation="horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toBottomOf="@id/russian"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/physics_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hint_physics"
android:textSize="19dp"/>
<EditText
android:id="@+id/physics_value"
android:ems="10"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:id="@+id/computer_science"
android:orientation="horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toBottomOf="@id/physics"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/computer_science_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hint_computer_science"
android:textSize="19dp"/>
<EditText
android:id="@+id/computer_science_value"
android:ems="10"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:id="@+id/social_science"
android:orientation="horizontal"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toBottomOf="@id/computer_science"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/social_science_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hint_social_science"
android:textSize="19dp"/>
<EditText
android:id="@+id/social_science_value"
android:ems="10"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

0 comments on commit 193f08e

Please sign in to comment.