|
|
|
@ -3,7 +3,9 @@ package net.pokeranalytics.android.ui.fragment.components |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
|
|
|
|
import android.widget.Toast |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
|
|
|
import io.realm.RealmResults |
|
|
|
import kotlinx.android.synthetic.main.bottom_sheet_double_list.* |
|
|
|
import kotlinx.android.synthetic.main.bottom_sheet_double_list.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
@ -14,6 +16,8 @@ import net.pokeranalytics.android.ui.adapter.components.DisplayableDelegate |
|
|
|
|
|
|
|
|
|
|
|
class BottomSheetListFragment : BottomSheetFragment(), DisplayableDelegate { |
|
|
|
class BottomSheetListFragment : BottomSheetFragment(), DisplayableDelegate { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var realmData: RealmResults<*>? = null |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
initData() |
|
|
|
initData() |
|
|
|
@ -31,21 +35,32 @@ class BottomSheetListFragment : BottomSheetFragment(), DisplayableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun data(position: Int): DisplayableDataSource { |
|
|
|
override fun data(position: Int): DisplayableDataSource { |
|
|
|
|
|
|
|
realmData?.let { |
|
|
|
|
|
|
|
return it[position] as DisplayableDataSource |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//TODO: Change that |
|
|
|
return Game() |
|
|
|
return Game() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int) { |
|
|
|
override fun onRowSelected(position: Int) { |
|
|
|
|
|
|
|
realmData?.let { |
|
|
|
|
|
|
|
Toast.makeText(requireContext(), "Select: ${it[position]}", Toast.LENGTH_SHORT).show() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun size(): Int { |
|
|
|
override fun size(): Int { |
|
|
|
return 0 |
|
|
|
return realmData?.size ?: 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Init data |
|
|
|
* Init data |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
val data = getData() |
|
|
|
|
|
|
|
|
|
|
|
val bottomSheetData = getData() |
|
|
|
|
|
|
|
if (bottomSheetData.isNotEmpty() && bottomSheetData.first().data != null) { |
|
|
|
|
|
|
|
this.realmData = bottomSheetData.first().data |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|