commit
27203dcf40
@ -0,0 +1,47 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import io.realm.Realm |
||||||
|
import io.realm.kotlin.where |
||||||
|
import kotlinx.android.synthetic.main.activity_data_list.* |
||||||
|
import kotlinx.android.synthetic.main.activity_editable_data.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.Session |
||||||
|
import net.pokeranalytics.android.ui.fragment.DataListFragment |
||||||
|
import net.pokeranalytics.android.ui.fragment.EditableDataFragment |
||||||
|
import net.pokeranalytics.android.util.PokerAnalyticsActivity |
||||||
|
import net.pokeranalytics.android.util.data.sessionDao |
||||||
|
import java.util.* |
||||||
|
|
||||||
|
class EditableDataActivity : PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
fun newInstance(context: Context, dataType: Int, primaryKey:String?) { |
||||||
|
val intent = Intent(context, EditableDataActivity::class.java) |
||||||
|
intent.putExtra("dataType", dataType) |
||||||
|
primaryKey?.let { |
||||||
|
intent.putExtra("primaryKey", it) |
||||||
|
} |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_editable_data) |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val dataType = intent.getIntExtra("dataType", 0) |
||||||
|
val primaryKey = intent.getStringExtra("primaryKey") |
||||||
|
val fragment = editableDataFragment as EditableDataFragment |
||||||
|
fragment.setData(dataType, primaryKey) |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,66 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager |
||||||
|
import io.realm.Realm |
||||||
|
import io.realm.RealmObject |
||||||
|
import kotlinx.android.synthetic.main.fragment_new_session.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.* |
||||||
|
import net.pokeranalytics.android.ui.adapter.components.* |
||||||
|
import net.pokeranalytics.android.util.PokerAnalyticsFragment |
||||||
|
|
||||||
|
class EditableDataFragment : PokerAnalyticsFragment() { |
||||||
|
|
||||||
|
private var item: RealmObject? = null |
||||||
|
private var dataType: SettingRow = SettingRow.BANKROLL |
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
return inflater.inflate(R.layout.fragment_data_list, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initData() |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
private fun initData() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val viewManager = LinearLayoutManager(requireContext()) |
||||||
|
// val dynamicListAdapter = DynamicListAdapter(this, this) |
||||||
|
|
||||||
|
recyclerView.apply { |
||||||
|
setHasFixedSize(true) |
||||||
|
layoutManager = viewManager |
||||||
|
// adapter = dynamicListAdapter |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set fragment data |
||||||
|
*/ |
||||||
|
fun setData(dataType: Int, primaryKey: String?) { |
||||||
|
this.dataType = SettingRow.values()[dataType] |
||||||
|
primaryKey?.let { |
||||||
|
val realm = Realm.getDefaultInstance() |
||||||
|
this.item = realm.copyFromRealm( when (this.dataType) { |
||||||
|
SettingRow.BANKROLL -> realm.where(Bankroll::class.java).equalTo("id", it).findFirst() |
||||||
|
SettingRow.GAME -> realm.where(Game::class.java).equalTo("id", it).findFirst() |
||||||
|
SettingRow.LOCATION -> realm.where(Location::class.java).equalTo("id", it).findFirst() |
||||||
|
SettingRow.TOURNAMENT_TYPE -> realm.where(TournamentFeature::class.java).equalTo("id", it).findFirst() |
||||||
|
SettingRow.TRANSACTION_TYPE-> realm.where(TransactionType::class.java).equalTo("id", it).findFirst() |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:orientation="vertical" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<fragment |
||||||
|
android:id="@+id/editableDataFragment" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:name="net.pokeranalytics.android.ui.fragment.EditableDataFragment" /> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
@ -0,0 +1,71 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:fillViewport="true" |
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"> |
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="400dp"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView |
||||||
|
android:id="@+id/title" |
||||||
|
style="@style/Title" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginStart="8dp" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:layout_marginEnd="8dp" |
||||||
|
android:text="Edit Data" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView |
||||||
|
android:id="@+id/recyclerView" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout |
||||||
|
android:id="@+id/appBar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="128dp" |
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout |
||||||
|
android:id="@+id/collapsingToolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
app:contentScrim="?attr/colorPrimary" |
||||||
|
app:expandedTitleGravity="bottom" |
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
app:title="Poker Analytics" |
||||||
|
app:titleTextColor="@color/white" |
||||||
|
app:layout_collapseMode="pin" /> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
||||||
Loading…
Reference in new issue