parent
06413d08d6
commit
091184da51
@ -0,0 +1,38 @@ |
||||
package net.pokeranalytics.android.ui.fragment |
||||
|
||||
import net.pokeranalytics.android.exceptions.TypeException |
||||
import net.pokeranalytics.android.model.realm.Location |
||||
import net.pokeranalytics.android.ui.helpers.PlacePickerManager |
||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||
import net.pokeranalytics.android.ui.view.rowrepresentable.LocationRow |
||||
|
||||
/** |
||||
* Custom EditableDataFragment to manage the LOCATE_ME case |
||||
*/ |
||||
class LocationDataFragment: EditableDataFragment() { |
||||
|
||||
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
||||
when(row) { |
||||
LocationRow.LOCATE_ME -> { |
||||
if (item is Location) { |
||||
(item as Location).isLookingForPlaces = true |
||||
PlacePickerManager.create(parentActivity, row, this) |
||||
rowRepresentableAdapter.refreshRow(row) |
||||
} else { |
||||
throw TypeException("Need to manage LocationRow.LOCATE_ME for ${item::class.java}") |
||||
} |
||||
} |
||||
else -> super.onRowSelected(position, row, fromAction) |
||||
} |
||||
} |
||||
|
||||
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
||||
super.onRowValueChanged(value, row) |
||||
when (row) { |
||||
LocationRow.LOCATE_ME -> { |
||||
rowRepresentableAdapter.notifyDataSetChanged() |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -1,15 +1,7 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:orientation="vertical"> |
||||
android:layout_height="match_parent"> |
||||
|
||||
<fragment |
||||
android:id="@+id/editableDataFragment" |
||||
android:name="net.pokeranalytics.android.ui.fragment.EditableDataFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:layout="@layout/fragment_editable_data" /> |
||||
|
||||
</LinearLayout> |
||||
</FrameLayout> |
||||
Loading…
Reference in new issue