commit
0c7c58a0db
@ -0,0 +1,64 @@ |
||||
package net.pokeranalytics.android.ui.adapter |
||||
|
||||
import android.util.SparseArray |
||||
import android.view.ViewGroup |
||||
import androidx.fragment.app.FragmentManager |
||||
import androidx.fragment.app.FragmentStatePagerAdapter |
||||
import net.pokeranalytics.android.ui.fragment.HistoryFragment |
||||
import net.pokeranalytics.android.ui.fragment.SettingsFragment |
||||
import net.pokeranalytics.android.ui.fragment.StatsFragment |
||||
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
||||
import java.lang.ref.WeakReference |
||||
|
||||
/** |
||||
* Home Adapter |
||||
*/ |
||||
class HomePagerAdapter(fragmentManager: FragmentManager) : FragmentStatePagerAdapter(fragmentManager) { |
||||
|
||||
var weakReferences = SparseArray<WeakReference<PokerAnalyticsFragment>>() |
||||
|
||||
override fun getItem(position: Int): PokerAnalyticsFragment { |
||||
return when (position) { |
||||
0 -> HistoryFragment.newInstance() |
||||
1 -> StatsFragment.newInstance() |
||||
2 -> SettingsFragment.newInstance() |
||||
else -> HistoryFragment.newInstance() |
||||
} |
||||
} |
||||
|
||||
override fun getCount(): Int { |
||||
return 5 |
||||
} |
||||
|
||||
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { |
||||
super.destroyItem(container, position, `object`) |
||||
weakReferences.remove(position) |
||||
} |
||||
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any { |
||||
val fragment = super.instantiateItem(container, position) as PokerAnalyticsFragment |
||||
weakReferences.put(position, WeakReference(fragment)) |
||||
return fragment |
||||
} |
||||
|
||||
override fun getItemPosition(obj: Any): Int { |
||||
val fragment = obj as PokerAnalyticsFragment |
||||
return when (fragment) { |
||||
HistoryFragment::class.java -> 0 |
||||
StatsFragment::class.java -> 1 |
||||
SettingsFragment::class.java -> 2 |
||||
else -> -1 |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Return the fragment at the position key |
||||
*/ |
||||
fun getFragment(key: Int): PokerAnalyticsFragment? { |
||||
if (weakReferences.get(key) != null) { |
||||
return weakReferences.get(key).get() |
||||
} |
||||
return null |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,56 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
||||
|
||||
import android.os.Bundle |
||||
import android.text.InputType |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import androidx.core.widget.addTextChangedListener |
||||
import kotlinx.android.synthetic.main.bottom_sheet_edit_text_multi_lines.* |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||
|
||||
|
||||
class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() { |
||||
|
||||
private var value = "" |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
editText1.requestFocus() |
||||
} |
||||
|
||||
override fun getValue(): Any? { |
||||
return value.trim() |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
setAddButtonVisible(false) |
||||
|
||||
LayoutInflater.from(requireContext()).inflate(net.pokeranalytics.android.R.layout.bottom_sheet_edit_text_multi_lines, view?.bottomSheetContainer, true) |
||||
|
||||
val data = getData() |
||||
|
||||
if (data.size == 1) { |
||||
data[0].hint?.let { editText1.hint = getString(it) } |
||||
editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
||||
editText1.addTextChangedListener { value = it?.toString() ?: "" } |
||||
editText1.setText((data[0].defaultValue ?: "").toString()) |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,33 @@ |
||||
package net.pokeranalytics.android.ui.view |
||||
|
||||
import android.content.Context |
||||
import android.util.AttributeSet |
||||
import android.view.MotionEvent |
||||
import androidx.viewpager.widget.ViewPager |
||||
|
||||
/** |
||||
* Poker Analytics ViewPager |
||||
*/ |
||||
class PokerAnalyticsViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) { |
||||
|
||||
var enablePaging: Boolean = false |
||||
|
||||
init { |
||||
this.enablePaging = false |
||||
} |
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean { |
||||
return if (this.enablePaging) { |
||||
super.onTouchEvent(event) |
||||
} else false |
||||
|
||||
} |
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { |
||||
return if (this.enablePaging) { |
||||
super.onInterceptTouchEvent(event) |
||||
} else false |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,13 +1,15 @@ |
||||
<?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"> |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<fragment |
||||
android:id="@+id/dataListFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:name="net.pokeranalytics.android.ui.fragment.DataListFragment" /> |
||||
android:id="@+id/dataListFragment" |
||||
android:name="net.pokeranalytics.android.ui.fragment.DataListFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:layout="@layout/fragment_data_list" /> |
||||
|
||||
</LinearLayout> |
||||
@ -1,13 +1,15 @@ |
||||
<?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"> |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:orientation="vertical"> |
||||
|
||||
<fragment |
||||
android:id="@+id/editableDataFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:name="net.pokeranalytics.android.ui.fragment.EditableDataFragment" /> |
||||
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> |
||||
@ -1,13 +0,0 @@ |
||||
<?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/newSessionFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:name="net.pokeranalytics.android.ui.fragment.SessionFragment" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,15 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:orientation="vertical"> |
||||
|
||||
<fragment |
||||
android:id="@+id/newSessionFragment" |
||||
android:name="net.pokeranalytics.android.ui.fragment.SessionFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:layout="@layout/fragment_session" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,28 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content" |
||||
android:orientation="vertical" |
||||
tools:background="@color/gray_darker"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/editText1" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:gravity="top|start" |
||||
android:inputType="textMultiLine" |
||||
android:minLines="10" |
||||
android:maxLines="10" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="10" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,70 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.appcompat.widget.LinearLayoutCompat 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:id="@+id/rowHeaderTitleAmount.container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="56dp" |
||||
android:orientation="vertical"> |
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="@color/green_header"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/rowHeaderTitleAmount.title" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowTitle" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:textSize="20sp" |
||||
android:fontFamily="@font/roboto_medium" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Title" /> |
||||
|
||||
<net.pokeranalytics.android.ui.view.PokerAnalyticsTextView |
||||
android:id="@+id/rowHeaderTitleAmount.value" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowValue" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:ellipsize="end" |
||||
android:fontFamily="@font/roboto_medium" |
||||
android:textSize="20sp" |
||||
android:gravity="end" |
||||
android:maxLines="1" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" |
||||
app:layout_constraintStart_toEndOf="@+id/rowHeaderTitleAmount.title" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Value" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="16dp" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/rowHeaderTitleAmount.separator" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp" |
||||
android:visibility="gone" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
tools:visibility="visible" /> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
@ -1,63 +1,66 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/rowTitleSwitch.container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground"> |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:id="@+id/rowTitleSwitch.container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/rowTitleSwitch.title" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:textSize="16sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Data Type Title"/> |
||||
android:id="@+id/rowTitleSwitch.title" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowTitle" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="16dp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/rowTitleSwitch.switch" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintVertical_bias="0.0" |
||||
tools:text="Data Type Title" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp"/> |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="16dp"/> |
||||
<Switch |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:id="@+id/rowTitleSwitch.switch" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="@+id/rowTitleSwitch.title" |
||||
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="356dp"/> |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="16dp" /> |
||||
|
||||
<androidx.appcompat.widget.SwitchCompat |
||||
android:id="@+id/rowTitleSwitch.switch" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/guidelineEnd" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/rowTitleSwitch.separator" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp" |
||||
android:visibility="gone" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
tools:visibility="visible"> |
||||
android:id="@+id/rowTitleSwitch.separator" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp" |
||||
android:visibility="gone" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
tools:visibility="visible"> |
||||
|
||||
<View |
||||
android:layout_width="match_parent" |
||||
android:layout_height="1dp" |
||||
android:layout_gravity="center" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@color/kaki" /> |
||||
android:layout_width="match_parent" |
||||
android:layout_height="1dp" |
||||
android:layout_gravity="center" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@color/kaki" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
|
||||
@ -0,0 +1,4 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="google_places_api" translatable="false">AIzaSyCg-vgW4YnFsQ_s1iWjgzSq2vT0te3R1Hw</string> |
||||
</resources> |
||||
Loading…
Reference in new issue