added grid layout for tablets and landscape mode
This commit is contained in:
parent
86cf1eecd8
commit
81e5d92a97
6 changed files with 37 additions and 5 deletions
|
|
@ -68,16 +68,18 @@ android {
|
|||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
debuggable true
|
||||
debuggable false
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
|
||||
dev {
|
||||
initWith buildTypes.release
|
||||
debuggable true
|
||||
}
|
||||
|
||||
debug {
|
||||
initWith buildTypes.release
|
||||
debuggable true
|
||||
proguardFiles 'baseline-profiles-rules.pro'
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.deniscerri.ytdlnis.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
|
|
@ -12,6 +13,7 @@ import android.widget.Toast
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.work.WorkManager
|
||||
|
|
@ -66,13 +68,23 @@ class DownloadQueueActivity : AppCompatActivity(), ActiveDownloadAdapter.OnItemC
|
|||
this@DownloadQueueActivity
|
||||
)
|
||||
|
||||
val landScapeOrTablet = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || resources.getBoolean(R.bool.isTablet)
|
||||
|
||||
|
||||
activeRecyclerView = findViewById(R.id.active_recyclerview)
|
||||
activeRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
if (landScapeOrTablet){
|
||||
activeRecyclerView.layoutManager = GridLayoutManager(context, 2)
|
||||
}else{
|
||||
activeRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
activeRecyclerView.adapter = activeDownloads
|
||||
|
||||
queuedRecyclerView = findViewById(R.id.queued_recyclerview)
|
||||
queuedRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
if (landScapeOrTablet){
|
||||
queuedRecyclerView.layoutManager = GridLayoutManager(context, 2)
|
||||
}else{
|
||||
queuedRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
queuedRecyclerView.adapter = queuedDownloads
|
||||
|
||||
noResults = findViewById(R.id.no_results)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.deniscerri.ytdlnis.ui
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
|
|
@ -15,6 +16,7 @@ import androidx.appcompat.widget.SearchView
|
|||
import androidx.core.content.FileProvider
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.deniscerri.ytdlnis.MainActivity
|
||||
|
|
@ -106,7 +108,11 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
|||
requireActivity()
|
||||
)
|
||||
recyclerView = view.findViewById(R.id.recyclerviewhistorys)
|
||||
recyclerView?.layoutManager = LinearLayoutManager(context)
|
||||
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || resources.getBoolean(R.bool.isTablet)){
|
||||
recyclerView?.layoutManager = GridLayoutManager(context, 2)
|
||||
}else{
|
||||
recyclerView?.layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
recyclerView?.adapter = historyAdapter
|
||||
|
||||
noResults?.visibility = GONE
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.content.Context
|
|||
import android.content.Context.CLIPBOARD_SERVICE
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
|
|
@ -20,6 +21,7 @@ import androidx.appcompat.widget.SearchView
|
|||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.work.WorkManager
|
||||
|
|
@ -121,7 +123,11 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
requireActivity()
|
||||
)
|
||||
recyclerView = view.findViewById(R.id.recyclerViewHome)
|
||||
recyclerView?.layoutManager = LinearLayoutManager(context)
|
||||
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || resources.getBoolean(R.bool.isTablet)){
|
||||
recyclerView?.layoutManager = GridLayoutManager(context, 2)
|
||||
}else{
|
||||
recyclerView?.layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
recyclerView?.adapter = homeAdapter
|
||||
|
||||
resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java]
|
||||
|
|
|
|||
3
app/src/main/res/values-sw720dp/attrs.xml
Normal file
3
app/src/main/res/values-sw720dp/attrs.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<bool name="isTablet">true</bool>
|
||||
</resources>
|
||||
3
app/src/main/res/values/attrs.xml
Normal file
3
app/src/main/res/values/attrs.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<bool name="isTablet">false</bool>
|
||||
</resources>
|
||||
Loading…
Reference in a new issue