Skip to content

Commit

Permalink
Improve fragments navigation and bump
Browse files Browse the repository at this point in the history
Signed-off-by: enricocid <enrico2588@gmail.com>
  • Loading branch information
enricocid committed Nov 21, 2020
1 parent 818338f commit 3a7bee3
Show file tree
Hide file tree
Showing 35 changed files with 487 additions and 498 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Latest Release -->
<a href="https://github.com/enricocid/Music-Player-GO/releases">
<img alt="GitHub release"
src="https://img.shields.io/static/v1?label=Tag&message=v4.3.0&color=58F5D1">
src="https://img.shields.io/static/v1?label=Tag&message=v4.3.1&color=58F5D1">
</a>
<!-- Minimum SDK -->
<a>
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/153.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- You can now use the tabs even when details/equalizer are opened (thanks Drhaal)
- Fix embedded cover option on/off summary (thanks Ricardo)
- Update translations
11 changes: 0 additions & 11 deletions fastlane/metadata/android/in/changelogs/152.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions fastlane/metadata/android/it/changelogs/153.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Ora puoi usare le tabs anche quando equalizzatore e dettagli artista sono aperti (grazie Drhaal)
- Corretto il sommario dell'opzione per gestire le cover (grazie Ricardo)
- Aggiornate le traduzioni
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 0 additions & 11 deletions fastlane/metadata/android/nl/changelogs/152.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 0 additions & 11 deletions fastlane/metadata/android/pl/changelogs/152.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.iven.musicplayergo"
minSdkVersion 21
targetSdkVersion 30
versionCode 152
versionName "4.3.0"
versionCode 153
versionName "4.3.1"

vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import kotlin.math.max
// https://antonioleiva.com/kotlin-ongloballayoutlistener/
inline fun <T : View> T.afterMeasured(crossinline f: T.() -> Unit) {
viewTreeObserver.addOnGlobalLayoutListener(object :
ViewTreeObserver.OnGlobalLayoutListener {
ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
if (measuredWidth > 0 && measuredHeight > 0) {
viewTreeObserver.removeOnGlobalLayoutListener(this)
Expand All @@ -63,43 +63,43 @@ private val ioDispatcher = Dispatchers.IO + viewModelJob + handler
private val ioScope = CoroutineScope(ioDispatcher)

fun Context.getImageLoader() = ImageLoader.Builder(this)
.bitmapPoolingEnabled(false)
.crossfade(true)
.build()
.bitmapPoolingEnabled(false)
.crossfade(true)
.build()

fun ImageView.loadCover(
imageLoader: ImageLoader,
music: Music?,
defaultCover: Bitmap,
isCircleCrop: Boolean,
isLoadDelay: Boolean
imageLoader: ImageLoader,
music: Music?,
defaultCover: Bitmap,
isCircleCrop: Boolean,
isLoadDelay: Boolean
) {

val request = ImageRequest.Builder(context)
.data(music?.getCover(context) ?: defaultCover)
.allowHardware(false)

.target(
onSuccess = { result ->
// Handle the successful result.
load(result) {

if (isCircleCrop) {
transformations(RoundedCornersTransformation(resources.getDimension(R.dimen.md_corner_radius)))
}
}
.data(music?.getCover(context) ?: defaultCover)
.allowHardware(false)

.target(
onSuccess = { result ->
// Handle the successful result.
load(result) {

if (isCircleCrop) {
transformations(RoundedCornersTransformation(resources.getDimension(R.dimen.md_corner_radius)))
}
)
.build()
}
}
)
.build()

ioScope.launch {
withContext(ioDispatcher) {
delay(
if (isLoadDelay) {
1000
} else {
0
}
if (isLoadDelay) {
1000
} else {
0
}
)
imageLoader.execute(request)
}
Expand All @@ -112,8 +112,8 @@ fun Int.decodeColor(context: Context) = ContextCompat.getColor(context, this)
@Suppress("DEPRECATION")
fun String.toSpanned(): Spanned = if (VersioningHelper.isNougat()) {
Html.fromHtml(
this,
Html.FROM_HTML_MODE_LEGACY
this,
Html.FROM_HTML_MODE_LEGACY
)
} else Html.fromHtml(this)

Expand All @@ -125,18 +125,14 @@ fun MenuItem.setTitleColor(color: Int) {
}
}

fun FragmentManager.addFragment(fragment: Fragment, tag: String?, isReplace: Boolean) {
fun FragmentManager.addFragment(fragment: Fragment, tag: String?) {
beginTransaction().apply {
addToBackStack(null)
if (isReplace) {
replace(R.id.container, fragment, tag)
} else {
add(
R.id.container,
fragment,
tag
)
}
add(
R.id.container,
fragment,
tag
)
commit()
}
}
Expand Down Expand Up @@ -183,22 +179,22 @@ fun View.createCircularReveal(isErrorFragment: Boolean, show: Boolean): Animator
0
}
val animator =
ViewAnimationUtils.createCircularReveal(
this,
cx,
cy,
startRadius,
finalRadius
).apply {
interpolator = FastOutSlowInInterpolator()
duration = revealDuration
doOnEnd {
if (!show) {
handleViewVisibility(false)
}
ViewAnimationUtils.createCircularReveal(
this,
cx,
cy,
startRadius,
finalRadius
).apply {
interpolator = FastOutSlowInInterpolator()
duration = revealDuration
doOnEnd {
if (!show) {
handleViewVisibility(false)
}
start()
}
start()
}

val windowBackground = R.color.windowBackground.decodeColor(context)
val closeColor = ThemeHelper.resolveColorAttr(context, R.attr.colorControlHighlight)
Expand Down Expand Up @@ -227,11 +223,11 @@ fun View.createCircularReveal(isErrorFragment: Boolean, show: Boolean): Animator
if (isErrorFragment) {
doOnEnd {
background =
ThemeHelper.createColouredRipple(
context,
R.color.red.decodeColor(context),
R.drawable.ripple
)
ThemeHelper.createColouredRipple(
context,
R.color.red.decodeColor(context),
R.drawable.ripple
)
}
}
start()
Expand All @@ -253,7 +249,7 @@ fun RecyclerView.smoothSnapToPosition(position: Int) {
override fun onStop() {
super.onStop()
findViewHolderForAdapterPosition(position)
?.itemView?.performClick()
?.itemView?.performClick()
}
}
smoothScroller.targetPosition = position
Expand All @@ -262,11 +258,11 @@ fun RecyclerView.smoothSnapToPosition(position: Int) {

//add swipe features to a RecyclerView
fun RecyclerView.addBidirectionalSwipeHandler(
isRightToLeftEnabled: Boolean,
onSwiped: (
viewHolder: RecyclerView.ViewHolder,
direction: Int
) -> Unit
isRightToLeftEnabled: Boolean,
onSwiped: (
viewHolder: RecyclerView.ViewHolder,
direction: Int
) -> Unit
) {
val swipeLeftCallback = instantiateSwipeHandler(ItemTouchHelper.RIGHT, onSwiped)
val swipeLeftHelper = ItemTouchHelper(swipeLeftCallback)
Expand All @@ -279,26 +275,26 @@ fun RecyclerView.addBidirectionalSwipeHandler(
}

private fun instantiateSwipeHandler(
direction: Int,
onSwiped: (
viewHolder: RecyclerView.ViewHolder,
direction: Int
) -> Unit
direction: Int,
onSwiped: (
viewHolder: RecyclerView.ViewHolder,
direction: Int
) -> Unit
): ItemTouchHelper.SimpleCallback {
return object : ItemTouchHelper.SimpleCallback(
0,
direction
0,
direction
) {

override fun onMove(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean = false

override fun onSwiped(
viewHolder: RecyclerView.ViewHolder,
direction: Int
viewHolder: RecyclerView.ViewHolder,
direction: Int
) {
onSwiped(viewHolder, direction)
}
Expand All @@ -314,7 +310,7 @@ fun View.handleViewVisibility(show: Boolean) {
}

fun String.toToast(
context: Context
context: Context
) {
Toast.makeText(context, this, Toast.LENGTH_LONG).show()
}
Loading

0 comments on commit 3a7bee3

Please sign in to comment.