|
|
|
@ -19,6 +19,7 @@ import net.pokeranalytics.android.ui.activity.FiltersActivity |
|
|
|
import net.pokeranalytics.android.ui.adapter.LiveRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.adapter.LiveRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.extensions.toast |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.DeletableItemFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.DeletableItemFragment |
|
|
|
import net.pokeranalytics.android.ui.helpers.SwipeToDeleteCallback |
|
|
|
import net.pokeranalytics.android.ui.helpers.SwipeToDeleteCallback |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
@ -41,20 +42,6 @@ class DataListFragment : DeletableItemFragment(), LiveRowRepresentableDataSource |
|
|
|
return this.items |
|
|
|
return this.items |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set fragment data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun setData(dataType: Int) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.dataType = LiveData.values()[dataType] |
|
|
|
|
|
|
|
this.identifiableClass = this.dataType.relatedEntity |
|
|
|
|
|
|
|
setToolbarTitle(this.dataType.localizedTitle(requireContext())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
this.items = realm.sorted(this.identifiableClass) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
return inflater.inflate(R.layout.fragment_data_list, container, false) |
|
|
|
return inflater.inflate(R.layout.fragment_data_list, container, false) |
|
|
|
@ -124,11 +111,17 @@ class DataListFragment : DeletableItemFragment(), LiveRowRepresentableDataSource |
|
|
|
|
|
|
|
|
|
|
|
when (this.dataType) { |
|
|
|
when (this.dataType) { |
|
|
|
LiveData.FILTER -> { |
|
|
|
LiveData.FILTER -> { |
|
|
|
|
|
|
|
if (fromAction) { |
|
|
|
|
|
|
|
// Open filter params |
|
|
|
|
|
|
|
toast("Hey") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Select filter |
|
|
|
val intent = Intent() |
|
|
|
val intent = Intent() |
|
|
|
intent.putExtra(FiltersActivity.IntentKey.FILTER_ID.keyName, (row as Filter).id) |
|
|
|
intent.putExtra(FiltersActivity.IntentKey.FILTER_ID.keyName, (row as Filter).id) |
|
|
|
activity?.setResult(Activity.RESULT_OK, intent) |
|
|
|
activity?.setResult(Activity.RESULT_OK, intent) |
|
|
|
activity?.finish() |
|
|
|
activity?.finish() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
val identifier = (row as Identifiable).id |
|
|
|
val identifier = (row as Identifiable).id |
|
|
|
EditableDataActivity.newInstanceForResult(this, this.dataType, identifier, REQUEST_CODE_DETAILS) |
|
|
|
EditableDataActivity.newInstanceForResult(this, this.dataType, identifier, REQUEST_CODE_DETAILS) |
|
|
|
@ -136,4 +129,29 @@ class DataListFragment : DeletableItemFragment(), LiveRowRepresentableDataSource |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set fragment data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun setData(dataType: Int) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.dataType = LiveData.values()[dataType] |
|
|
|
|
|
|
|
this.identifiableClass = this.dataType.relatedEntity |
|
|
|
|
|
|
|
setToolbarTitle(this.dataType.localizedTitle(requireContext())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
this.items = realm.sorted(this.identifiableClass) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Update UI |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun updateUI(showAddButton: Boolean) { |
|
|
|
|
|
|
|
if (showAddButton) { |
|
|
|
|
|
|
|
this.addButton.show() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.addButton.hide() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |