Skip to content

Commit

Permalink
ci: improve android ci (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudMabrok authored Oct 26, 2024
1 parent da68cde commit 77af822
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 73 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/android ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Android CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: code quality with detekt
run: ./gradlew detekt

# - name: test
# run: ./gradlew test
#
# - name: build app
# run: ./gradlew build
29 changes: 0 additions & 29 deletions .github/workflows/deteckt.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/prepare.yml

This file was deleted.

10 changes: 10 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ dependencies {

apply plugin: "org.jlleitschuh.gradle.ktlint"

detekt {
buildUponDefaultConfig = true
allRules = false
baseline = file("detekt-baseline.xml")
}

tasks.withType(Detekt).configureEach {
jvmTarget = "1.8"
}

tasks.register('detektFormat', Detekt) {
description = "Runs autocorrect enabled detekt build."
source = files("src/main/java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ class HomeActivity : AppCompatActivity() {
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray,
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray,
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == RC_STORAGE && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ReadLogFragment : DataLoadingBaseFragment() {
private val quranRepository: QuranRepository by inject()
private var logAdapter: ReadLogAdapter = ReadLogAdapter()

private val binding by viewBinding (FragmentReadLogBinding::bind )
private val binding by viewBinding(FragmentReadLogBinding::bind)

override fun onCreateView(
inflater: LayoutInflater,
Expand Down Expand Up @@ -62,7 +62,6 @@ class ReadLogFragment : DataLoadingBaseFragment() {
showMessage(getString(R.string.msg_deleted))
}
}).attachToRecyclerView(rvReadLog)

} }

private fun showMessage(message: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SettingActivity : AppCompatActivity() {

private val binding by viewBinding(ActivitySettingBinding::inflate)


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PageAdapter(
val oldSize = list.size
list.clear()
list.addAll(newList)
notifyItemRangeRemoved(0 , oldSize)
notifyItemRangeInserted(0,newList.size)
notifyItemRangeRemoved(0, oldSize)
notifyItemRangeInserted(0, newList.size)
}

override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): PageViewHolder {
Expand All @@ -41,8 +41,6 @@ class PageAdapter(
holder.topLinear?.visibility = vis*/
}



override fun getItemCount(): Int {
return list.size
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
import education.mahmoud.quranyapp.databinding.PageItemBinding
import education.mahmoud.quranyapp.utils.Util

class PageViewHolder(private val binding:PageItemBinding, iBookmark: PageAdapter.IBookmark?):RecyclerView.ViewHolder(binding.root) {
class PageViewHolder(private val binding: PageItemBinding, iBookmark: PageAdapter.IBookmark?) : RecyclerView.ViewHolder(binding.root) {

// defined here to not be created with each bind call.
init {
Expand Down Expand Up @@ -36,4 +36,4 @@ class PageViewHolder(private val binding:PageItemBinding, iBookmark: PageAdapter
binding.tvAyahs.justificationMode = LineBreaker.JUSTIFICATION_MODE_INTER_WORD
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SuraListFragment : Fragment(R.layout.fragment_sura_list) {
val bg = CompositeDisposable()
private lateinit var screen: RecyclerViewSkeletonScreen

private val binding by viewBinding (FragmentSuraListBinding::bind )
private val binding by viewBinding(FragmentSuraListBinding::bind)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fun Int.getSuraNameFromIndex(): String {
return Data.SURA_NAMES[this - 1].orEmpty()
}


inline fun <T : ViewBinding> AppCompatActivity.viewBinding(
crossinline bindingInflater: (LayoutInflater) -> T) =
crossinline bindingInflater: (LayoutInflater) -> T
) =
lazy(LazyThreadSafetyMode.NONE) {
bindingInflater.invoke(layoutInflater)
}

0 comments on commit 77af822

Please sign in to comment.