Add view manager helper
This commit is contained in:
parent
d3466f9cce
commit
ff995e383d
|
@ -12,6 +12,7 @@ import org.libre.agosto.p2play.adapters.VideosAdapter
|
||||||
import org.libre.agosto.p2play.ajax.Actions
|
import org.libre.agosto.p2play.ajax.Actions
|
||||||
import org.libre.agosto.p2play.ajax.Channels
|
import org.libre.agosto.p2play.ajax.Channels
|
||||||
import org.libre.agosto.p2play.ajax.Videos
|
import org.libre.agosto.p2play.ajax.Videos
|
||||||
|
import org.libre.agosto.p2play.helpers.getViewManager
|
||||||
import org.libre.agosto.p2play.models.ChannelModel
|
import org.libre.agosto.p2play.models.ChannelModel
|
||||||
import org.libre.agosto.p2play.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
class ChannelActivity : AppCompatActivity() {
|
class ChannelActivity : AppCompatActivity() {
|
||||||
|
@ -32,7 +33,7 @@ class ChannelActivity : AppCompatActivity() {
|
||||||
|
|
||||||
channelId = this.intent.extras?.getString("channel")!!
|
channelId = this.intent.extras?.getString("channel")!!
|
||||||
|
|
||||||
viewManager = LinearLayoutManager(this)
|
viewManager = getViewManager(this, resources)
|
||||||
|
|
||||||
subcriptionBtn.setOnClickListener {
|
subcriptionBtn.setOnClickListener {
|
||||||
subscribeAction()
|
subscribeAction()
|
||||||
|
|
|
@ -29,6 +29,7 @@ import kotlinx.android.synthetic.main.mini_player.mini_player_title
|
||||||
import kotlinx.android.synthetic.main.nav_header_main.*
|
import kotlinx.android.synthetic.main.nav_header_main.*
|
||||||
import org.libre.agosto.p2play.adapters.VideosAdapter
|
import org.libre.agosto.p2play.adapters.VideosAdapter
|
||||||
import org.libre.agosto.p2play.ajax.Videos
|
import org.libre.agosto.p2play.ajax.Videos
|
||||||
|
import org.libre.agosto.p2play.helpers.getViewManager
|
||||||
import org.libre.agosto.p2play.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
import org.libre.agosto.p2play.singletons.PlaybackSingleton
|
import org.libre.agosto.p2play.singletons.PlaybackSingleton
|
||||||
|
|
||||||
|
@ -54,17 +55,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
|
|
||||||
nav_view.setNavigationItemSelectedListener(this)
|
nav_view.setNavigationItemSelectedListener(this)
|
||||||
|
|
||||||
val screenSize = resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK
|
viewManager = getViewManager(this, resources)
|
||||||
viewManager = if (screenSize > Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
|
||||||
val orientation = resources.configuration.orientation
|
|
||||||
val gridItems = when (orientation) {
|
|
||||||
Configuration.ORIENTATION_LANDSCAPE -> 4
|
|
||||||
else -> 3
|
|
||||||
}
|
|
||||||
GridLayoutManager(this, gridItems)
|
|
||||||
} else {
|
|
||||||
LinearLayoutManager(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init RecyclerView
|
// Init RecyclerView
|
||||||
this.initRecycler()
|
this.initRecycler()
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.libre.agosto.p2play.helpers
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.content.res.Resources
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||||
|
|
||||||
|
fun getViewManager (context: Context, resources: Resources): LayoutManager {
|
||||||
|
val screenSize = resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK
|
||||||
|
val manager = if (screenSize > Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
||||||
|
val orientation = resources.configuration.orientation
|
||||||
|
val gridItems = when (orientation) {
|
||||||
|
Configuration.ORIENTATION_LANDSCAPE -> 4
|
||||||
|
else -> 3
|
||||||
|
}
|
||||||
|
GridLayoutManager(context, gridItems)
|
||||||
|
} else {
|
||||||
|
LinearLayoutManager(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
return manager
|
||||||
|
}
|
|
@ -6,21 +6,14 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".LoginActivity">
|
tools:context=".LoginActivity">
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginTop="32dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintWidth_max="500dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView2"
|
android:id="@+id/imageView2"
|
||||||
|
@ -39,7 +32,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/loginInfo"
|
android:text="@string/loginInfo"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"/>
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" />
|
||||||
|
|
||||||
<androidx.legacy.widget.Space
|
<androidx.legacy.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -50,7 +43,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/userTxt">
|
android:hint="@string/userTxt"
|
||||||
|
android:maxWidth="600dp">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/userText"
|
android:id="@+id/userText"
|
||||||
|
@ -66,15 +60,17 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
app:endIconMode="password_toggle"
|
android:hint="@string/passwordTxt"
|
||||||
android:hint="@string/passwordTxt" >
|
android:maxWidth="600dp"
|
||||||
|
android:maxEms="10"
|
||||||
|
app:endIconMode="password_toggle">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/passwordText"
|
android:id="@+id/passwordText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:inputType="textPassword"/>
|
android:inputType="textPassword" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
|
@ -98,5 +94,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue