experimenting with data binding
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -10,7 +10,7 @@
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/activity_main.xml" value="0.425" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/app_bar_main.xml" value="0.19607843137254902" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/content_main.xml" value="0.425" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_add_charge.xml" value="0.67" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_add_charge.xml" value="0.5" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_gallery.xml" value="0.425" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_home.xml" value="0.425" />
|
||||
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_settings.xml" value="0.425" />
|
||||
|
||||
@@ -6,27 +6,58 @@ import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.sockenklaus.batterytracker.databinding.FragmentAddChargeBinding
|
||||
import com.sockenklaus.batterytracker.R
|
||||
import java.text.DateFormat
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import java.util.*
|
||||
|
||||
class AddChargeFragment : Fragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance() = AddChargeFragment()
|
||||
}
|
||||
private var _binding: FragmentAddChargeBinding? = null
|
||||
|
||||
private lateinit var viewModel: AddChargeViewModel
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_add_charge, container, false)
|
||||
|
||||
_binding = FragmentAddChargeBinding.inflate(inflater, container, false)
|
||||
|
||||
val current = LocalDate.now()
|
||||
val formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
|
||||
val formatted = current.format(formatter) ?: ""
|
||||
|
||||
binding.editDate.setText(formatted)
|
||||
|
||||
binding.fab.setOnClickListener{
|
||||
buttonClicked()
|
||||
}
|
||||
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
viewModel = ViewModelProvider(this).get(AddChargeViewModel::class.java)
|
||||
viewModel = ViewModelProvider(this)[AddChargeViewModel::class.java]
|
||||
// TODO: Use the ViewModel
|
||||
}
|
||||
|
||||
private fun buttonClicked() {
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,72 +7,72 @@
|
||||
tools:context=".ui.add_charge.AddChargeFragment">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName4"
|
||||
android:id="@+id/edit_battery_id"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="Battery ID"
|
||||
android:inputType="textShortMessage"
|
||||
android:minHeight="48dp"
|
||||
android:text="Name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView4"
|
||||
app:layout_constraintStart_toEndOf="@+id/text_battery_id"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName5"
|
||||
android:id="@+id/edit_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="Date"
|
||||
android:inputType="text"
|
||||
android:minHeight="48dp"
|
||||
android:text="Name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPersonName4"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName4" />
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_battery_id"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_battery_id" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName6"
|
||||
android:id="@+id/edit_charge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="Charge, decimal"
|
||||
android:inputType="number"
|
||||
android:minHeight="48dp"
|
||||
android:text="Name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPersonName5"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName5" />
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_date"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_date" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:id="@+id/text_battery_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@string/battery_id"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/editTextTextPersonName4"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/edit_battery_id"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:id="@+id/text_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Date"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/editTextTextPersonName5"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView4" />
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/edit_date"
|
||||
app:layout_constraintEnd_toEndOf="@+id/text_battery_id" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:id="@+id/text_charge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Charge"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/editTextTextPersonName6"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView5" />
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/edit_charge"
|
||||
app:layout_constraintEnd_toEndOf="@+id/text_date" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
@@ -87,4 +87,13 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_test"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_charge"
|
||||
tools:layout_editor_absoluteX="103dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user