Skip to content

Commit

Permalink
Merge pull request #14 from Merseyside/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Merseyside authored Jul 4, 2023
2 parents 27cef3f + 0ba9b23 commit 7223416
Show file tree
Hide file tree
Showing 113 changed files with 1,542 additions and 1,333 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ on:
jobs:
publish:
name: Release build and publish
runs-on: macos-11
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.11
java-version: 1.17
- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Install Cocoapods
run: gem install cocoapods-generate
# - name: Install Cocoapods
# run: gem install cocoapods-generate

- name: Build and publish to mavenCentral
run: ./gradlew publish
run: ./gradlew publish -PRELEASE_SIGNING_ENABLED=true
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
3 changes: 1 addition & 2 deletions archy-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
plugin(kotlin.kapt)
plugin(android.navigation.args)
}
`android-maven-publish-config`
`maven-publish-plugin`
}

android {
Expand All @@ -17,7 +17,6 @@ android {

defaultConfig {
minSdk = Application.minSdk
targetSdk = Application.targetSdk
}

buildFeatures {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import android.os.Bundle
import androidx.annotation.CallSuper
import androidx.databinding.ViewDataBinding
import com.merseyside.archy.presentation.activity.BaseBindingActivity
import com.merseyside.merseyLib.utils.core.koin.state.getStateKey
import com.merseyside.merseyLib.archy.core.presentation.viewModel.BaseViewModel
import com.merseyside.merseyLib.utils.core.koin.state.saveState
import com.merseyside.merseyLib.kotlin.logger.Logger
import com.merseyside.merseyLib.utils.core.state.StateSaver
import com.merseyside.utils.reflection.ReflectionUtils
import org.koin.androidx.viewmodel.ext.android.viewModelForClass
import org.koin.core.context.loadKoinModules
import org.koin.core.module.Module
import org.koin.core.parameter.parametersOf
import kotlin.reflect.KClass

abstract class VMActivity<Binding : ViewDataBinding, Model : BaseViewModel>
Expand All @@ -36,17 +31,16 @@ abstract class VMActivity<Binding : ViewDataBinding, Model : BaseViewModel>
}
}

protected open fun provideViewModel(bundle: Bundle?, vararg params: Any): Model {
return viewModelForClass(
clazz = getViewModelClass(),
parameters = { parametersOf(bundle, *params) }
).value
}
protected abstract fun provideViewModel(
clazz: KClass<Model>,
bundle: Bundle?,
vararg params: Any
): Model

@CallSuper
override fun performInjection(bundle: Bundle?, vararg params: Any) {
loadKoinModules(getKoinModules(bundle, *params))
viewModel = provideViewModel(bundle, *params)
viewModel = provideViewModel(getViewModelClass(), bundle, *params)
}

open fun getKoinModules(bundle: Bundle?, vararg params: Any): List<Module> {
Expand All @@ -55,17 +49,12 @@ abstract class VMActivity<Binding : ViewDataBinding, Model : BaseViewModel>
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
(viewModel as? StateSaver)?.saveState(outState, getStateKey(getViewModelClass()))
}

override fun handleError(throwable: Throwable): Boolean {
return viewModel.onError(throwable)
}

override fun updateLanguage(context: Context) {
//viewModel.updateLanguage(context)
//updateLanguage(context)
}

protected abstract fun loadingObserver(isLoading: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.merseyside.merseyLib.archy.core.presentation.viewModel.entity.TextMes
import dev.icerock.moko.mvvm.dispatcher.EventsDispatcher
import dev.icerock.moko.mvvm.dispatcher.EventsDispatcherOwner
import dev.icerock.moko.mvvm.dispatcher.eventsDispatcherOnMain
import kotlin.reflect.KClass

abstract class VMEventsActivity<B : ViewDataBinding, Model, Listener>
: VMActivity<B, Model>(), EventsViewModel.BaseEventsListener
Expand All @@ -25,12 +26,8 @@ abstract class VMEventsActivity<B : ViewDataBinding, Model, Listener>
)
}

override fun provideViewModel(bundle: Bundle?, vararg params: Any): Model {
return super.provideViewModel(
bundle,
*params,
eventsDispatcherOnMain<EventsDispatcher<Listener>>()
)
override fun performInjection(bundle: Bundle?, vararg params: Any) {
super.performInjection(bundle, *params, eventsDispatcherOnMain<EventsDispatcher<Listener>>())
}

override fun onAlert(alert: Alert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,9 @@ abstract class VMDialog<Binding : ViewDataBinding, Model : BaseViewModel>
}

override fun performInjection(bundle: Bundle?, vararg params: Any) {
loadKoinModules(getKoinModules(bundle, *params))
viewModel = provideViewModel(bundle, *params)
}

open fun getKoinModules(bundle: Bundle?, vararg params: Any): List<Module> {
return emptyList<Module>().also {
Logger.logInfo("VMFragment", "Empty fragment's koin modules")
}
}

protected open fun provideViewModel(bundle: Bundle?, vararg params: Any): Model {
return viewModelForClass(
clazz = getViewModelClass(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ abstract class VMEventsFragment<Binding : ViewDataBinding, Model, Listener> :
)
}

override fun provideViewModel(bundle: Bundle?, vararg params: Any): Model {
return super.provideViewModel(
bundle,
*params,
eventsDispatcherOnMain<EventsDispatcher<Listener>>()
)
override fun performInjection(bundle: Bundle?, vararg params: Any) {
super.performInjection(bundle, eventsDispatcherOnMain<EventsDispatcher<Listener>>(), *params)
}

override fun onAlert(alert: Alert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@ import android.os.Bundle
import android.view.View
import androidx.databinding.ViewDataBinding
import com.merseyside.archy.presentation.fragment.BaseBindingFragment
import com.merseyside.merseyLib.utils.core.koin.state.getStateKey
import com.merseyside.merseyLib.utils.core.koin.state.saveState
import com.merseyside.merseyLib.archy.core.presentation.viewModel.BaseViewModel
import com.merseyside.merseyLib.kotlin.logger.Logger
import com.merseyside.merseyLib.utils.core.state.StateSaver
import com.merseyside.utils.reflection.ReflectionUtils
import org.koin.androidx.viewmodel.ext.android.viewModelForClass
import org.koin.core.context.loadKoinModules
import org.koin.core.module.Module
import org.koin.core.parameter.parametersOf
import kotlin.reflect.KClass

abstract class VMFragment<Binding : ViewDataBinding, Model : BaseViewModel>
Expand All @@ -37,31 +29,20 @@ abstract class VMFragment<Binding : ViewDataBinding, Model : BaseViewModel>
}

override fun performInjection(bundle: Bundle?, vararg params: Any) {
loadKoinModules(getKoinModules(bundle, *params))
viewModel = provideViewModel(bundle, *params)
viewModel = provideViewModel(getViewModelClass(), bundle, *params)
}

open fun getKoinModules(bundle: Bundle?, vararg params: Any): List<Module> {
return emptyList<Module>().also { Logger.logInfo("$this", "Empty fragment's koin modules") }
}

protected open fun provideViewModel(bundle: Bundle?, vararg params: Any): Model {
return viewModelForClass(
clazz = getViewModelClass(),
parameters = { parametersOf(*params, bundle) }
).value
}
protected abstract fun provideViewModel(
clazz: KClass<Model>,
bundle: Bundle?,
vararg params: Any
): Model

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
initDataBinding(requireBinding())
super.onViewCreated(view, savedInstanceState)
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
(viewModel as? StateSaver)?.saveState(outState, getStateKey(getViewModelClass()))
}

override fun updateLanguage(context: Context) {
super.updateLanguage(context)
//viewModel.updateLanguage(context)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.merseyside.merseyLib.archy.android.presentation.recycler

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.merseyside.merseyLib.kotlin.utils.safeLet

abstract class PaginationUpDownScrollListener(
protected val loadItemsCountDownOffset: Int = 5,
protected val loadItemsCountUpOffset: Int = loadItemsCountDownOffset,
) : RecyclerView.OnChildAttachStateChangeListener {

abstract val recyclerView: RecyclerView
abstract val onLoadNextPageDown: () -> Unit
abstract val onLoadNextPageUp: () -> Unit

override fun onChildViewAttachedToWindow(view: View) {
if (needToLoadDownNextPage(view)) onLoadNextPageDown()
if (needToLoadUpNextPage(view)) onLoadNextPageUp()
}

override fun onChildViewDetachedFromWindow(view: View) {}

private fun needToLoadDownNextPage(view: View): Boolean {
with(recyclerView) {
val lastPosition = getChildAdapterPosition(view)
val itemCount = adapter?.itemCount
return safeLet(itemCount) { counts ->
(counts - lastPosition) <= loadItemsCountDownOffset
} ?: false
}
}

private fun needToLoadUpNextPage(view: View): Boolean {
with(recyclerView) {
val lastPosition = getChildAdapterPosition(view)
return lastPosition == loadItemsCountUpOffset
}
}

}
3 changes: 1 addition & 2 deletions archy-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
plugin(moko.multiplatform)
plugin(sqldelight)
}
`maven-publish-config`
`maven-publish-plugin`
}

android {
Expand All @@ -19,7 +19,6 @@ android {

defaultConfig {
minSdk = Application.minSdk
targetSdk = Application.targetSdk
}
}

Expand Down
29 changes: 3 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
plugins {
`nexus-config`
}

allprojects {
group = "io.github.merseyside"
version = "1.5.3"
}

buildscript { // disable pod install tasks until find a solution
repositories {
gradlePluginPortal()
}

if (!isBuildIos()) {
with(project.gradle.startParameter.excludedTaskNames) {
add("podImport")
add("podInstall")
add("podGenIOS")
// add("podSetupBuildReachabilityIphoneos")
// add("podSetupBuildReachabilityIphonesimulator")
// add("podBuildReachabilityIphoneos")
// add("podBuildReachabilityIphonesimulator")
// add("cinteropReachabilityIosX64")
// add("cinteropReachabilityIosSimulatorArm64")
// add("cinteropReachabilityIosArm64")
}
plugins.withId("org.gradle.maven-publish") {
group = "io.github.merseyside"
version = multiplatformLibs.versions.mersey.kmm.get()
}
}

Expand Down
3 changes: 1 addition & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ dependencies {
implementation(kotlin.gradle)
implementation(kotlin.serialization)
implementation(moko.resourcesGenerator)
implementation(sqldelight)
implementation(nexusPublish)
implementation(android.navigation.safeArgs)
implementation(maven.publish.plugin)
}
}
4 changes: 1 addition & 3 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enableFeaturePreview("VERSION_CATALOGS")

pluginManagement {
repositories {
mavenCentral()
Expand All @@ -16,7 +14,7 @@ dependencyResolutionManagement {
gradlePluginPortal()
}

val catalogVersions = "1.6.4"
val catalogVersions = "1.7.5"
val group = "io.github.merseyside"
versionCatalogs {

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Application {
const val applicationId = "com.merseyside.sample"

const val compileSdk = 33
const val targetSdk = 33
const val compileSdk = 34
const val targetSdk = 34
const val minSdk = 21
}
Loading

0 comments on commit 7223416

Please sign in to comment.