Skip to content

Commit

Permalink
refactor: update publish to maven local settings
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyMuse committed Oct 4, 2022
1 parent a1af3fb commit e4fa008
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ inline fun <T> MutableLiveData<DBResult<T>>.onSuccess(action: (T) -> Unit) {
is DBResult.Success -> {
action(it.value)
}

else -> {}
}
}
}
Expand All @@ -126,6 +128,8 @@ inline fun <T> LiveData<DBResult<T>>.onSuccess(action: (model: T) -> Unit = { _
is DBResult.Success -> {
action(it.value)
}

else -> {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.activity.result.contract.ActivityResultContract
* Created by crazy on 10/14/20 to long live and prosper !
*/

class AccessibilityContract : ActivityResultContract<Nothing, Nothing>() {
override fun createIntent(context: Context, input: Nothing?): Intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
override fun parseResult(resultCode: Int, intent: Intent?): Nothing? = null
class AccessibilityContract : ActivityResultContract<Nothing, Unit>() {
override fun createIntent(context: Context, input: Nothing): Intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
override fun parseResult(resultCode: Int, intent: Intent?): Unit = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ shortToast(R.string.enable_location_access)
* function call enableLocation(null)
*/
class LocationSettingsContract : ActivityResultContract<Nothing, Nothing>() {
class LocationSettingsContract : ActivityResultContract<Nothing, Unit>() {

override fun createIntent(context: Context, input: Nothing?): Intent {
override fun createIntent(context: Context, input: Nothing): Intent {
return Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
}

override fun parseResult(resultCode: Int, intent: Intent?): Nothing? {
return null
}
override fun parseResult(resultCode: Int, intent: Intent?) = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.core.content.getSystemService
* Created by crazy on 10/30/20 to long live and prosper !
*/

@RequiresApi(Build.VERSION_CODES.M)
fun Context.hasUsageStatsPermission(): Boolean {
val appOps = getSystemService<AppOpsManager>() ?: return false
val mode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open class GridItemDecoration : RecyclerView.ItemDecoration() {
fun getPortraitItemOffsets(outRect: Rect, view: View, baseEdge: Int) {
val length = (baseEdge - gridSpacingPx.toFloat().times(gridSize.minus(1))).div(gridSize).toInt()
val padding = baseEdge.div(gridSize).minus(length)
val itemPosition = (view.layoutParams as RecyclerView.LayoutParams).viewAdapterPosition
val itemPosition = (view.layoutParams as RecyclerView.LayoutParams).bindingAdapterPosition

outRect.top = if (itemPosition < gridSize) 0 else gridSpacingPx
outRect.bottom = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class GridEntrust(leftRight: Int, topBottom: Int, mColor: Int) :

for (i in 0 until childCount) {
val child = parent.getChildAt(i)
val params = child.layoutParams as RecyclerView.LayoutParams
val position = parent.getChildAdapterPosition(child)
val spanSize = lookup.getSpanSize(position)
val spanIndex = lookup.getSpanIndex(position, layoutManager.spanCount)
Expand Down Expand Up @@ -66,7 +65,6 @@ class GridEntrust(leftRight: Int, topBottom: Int, mColor: Int) :
} else {
for (i in 0 until childCount) {
val child = parent.getChildAt(i)
val params = child.layoutParams as RecyclerView.LayoutParams
val position = parent.getChildAdapterPosition(child)
val spanSize = lookup.getSpanSize(position)
val spanIndex = lookup.getSpanIndex(position, layoutManager.spanCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class LinearEntrust(leftRight: Int, topBottom: Int, mColor: Int) :
if (layoutManager.orientation == GridLayoutManager.VERTICAL) {
for (i in 0 until childCount - 1) {
val child = parent.getChildAt(i)
val params = child.layoutParams as RecyclerView.LayoutParams
val center = (layoutManager.getTopDecorationHeight(child) + 1 - topBottom) / 2
left = layoutManager.getLeftDecorationWidth(child)
right = parent.width - layoutManager.getLeftDecorationWidth(child)
Expand All @@ -40,7 +39,6 @@ class LinearEntrust(leftRight: Int, topBottom: Int, mColor: Int) :
} else {
for (i in 0 until childCount - 1) {
val child = parent.getChildAt(i)
val params = child.layoutParams as RecyclerView.LayoutParams
val center = (layoutManager.getLeftDecorationWidth(child) + 1 - leftRight) / 2
left = (child.right + center)
right = left + leftRight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ sealed class ApiResult<out T> {


data class Success<T>(val value: T) : ApiResult<T>() {
val isValueAListAndNullOrEmpty get() = value is List<*> && value.isNullOrEmpty()
val isValueAListAndNotNullOrEmpty get() = value is List<*> && !value.isNullOrEmpty()
val isValueAListAndNullOrEmpty get() = value is List<*> && value.isEmpty()
val isValueAListAndNotNullOrEmpty get() = value is List<*> && value.isNotEmpty()
} // handle UI changes when everything is loaded

object Loading : ApiResult<Nothing>() // handle loading state
data class Error(val throwable: Throwable) : ApiResult<Nothing>() //this one gets thrown when there's an error on your side or an error we throw from http
data class Error(val throwable: Throwable) :
ApiResult<Nothing>() //this one gets thrown when there's an error on your side or an error we throw from http

data class ApiError(val responseCode: Int, val errorBody: ResponseBody?) : ApiResult<Nothing>() //whenever the api throws an error
object Idle : ApiResult<Nothing>()
}
Expand Down

0 comments on commit e4fa008

Please sign in to comment.