Skip to content

Commit 4847da0

Browse files
Swiched between menu phenomena fixed
Keyboard open issue fixed Some code formation updated Readme.md file updated for version bump
1 parent c7e37f1 commit 4847da0

4 files changed

Lines changed: 51 additions & 44 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Reverse Curve
4949
5050
```
5151
dependencies {
52-
implementation 'com.github.simformsolutions:SSCustomBottomNavigation:3.4'
52+
implementation 'com.github.simformsolutions:SSCustomBottomNavigation:3.5'
5353
}
5454
```
5555

custombottomnavigation/src/main/java/com/simform/custombottomnavigation/BezierView.kt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class BezierView : View {
170170

171171
override fun onDraw(canvas: Canvas) {
172172
super.onDraw(canvas)
173-
mainPath!!.reset()
174-
shadowPath!!.reset()
173+
mainPath?.reset()
174+
shadowPath?.reset()
175175

176176
if (progress == 0f) {
177177
drawInner(canvas, true)
@@ -193,18 +193,22 @@ class BezierView : View {
193193
color = this@BezierView.color
194194
}
195195
calculateInner()
196-
197-
path!!.lineTo(innerArray[0].x, innerArray[0].y)
198-
path.lineTo(innerArray[1].x, innerArray[1].y)
199-
path.cubicTo(innerArray[2].x, innerArray[2].y, innerArray[3].x, innerArray[3].y, innerArray[4].x, innerArray[4].y)
200-
path.cubicTo(innerArray[5].x, innerArray[5].y, innerArray[6].x, innerArray[6].y, innerArray[7].x, innerArray[7].y)
201-
path.lineTo(innerArray[8].x, innerArray[8].y)
202-
path.lineTo(innerArray[9].x, innerArray[9].y)
203-
path.lineTo(innerArray[10].x, innerArray[10].y)
196+
path?.apply {
197+
lineTo(innerArray[0].x, innerArray[0].y)
198+
lineTo(innerArray[1].x, innerArray[1].y)
199+
cubicTo(innerArray[2].x, innerArray[2].y, innerArray[3].x, innerArray[3].y, innerArray[4].x, innerArray[4].y)
200+
cubicTo(innerArray[5].x, innerArray[5].y, innerArray[6].x, innerArray[6].y, innerArray[7].x, innerArray[7].y)
201+
lineTo(innerArray[8].x, innerArray[8].y)
202+
lineTo(innerArray[9].x, innerArray[9].y)
203+
lineTo(innerArray[10].x, innerArray[10].y)
204+
}
204205

205206
progressArray = innerArray.clone()
206-
207-
canvas.drawPath(path, paint!!)
207+
path?.let { it1 ->
208+
paint?.let { it2 ->
209+
canvas.drawPath(it1, it2)
210+
}
211+
}
208212
}
209213

210214
private fun calculateInner() {
@@ -226,16 +230,21 @@ class BezierView : View {
226230
private fun drawProgress(canvas: Canvas, isShadow: Boolean) {
227231
val paint = if (isShadow) shadowPaint else mainPaint
228232
val path = if (isShadow) shadowPath else mainPath
233+
path?.apply {
234+
lineTo(progressArray[0].x, progressArray[0].y)
235+
lineTo(progressArray[1].x, progressArray[1].y)
236+
cubicTo(progressArray[2].x, progressArray[2].y, progressArray[3].x, progressArray[3].y, progressArray[4].x, progressArray[4].y)
237+
cubicTo(progressArray[5].x, progressArray[5].y, progressArray[6].x, progressArray[6].y, progressArray[7].x, progressArray[7].y)
238+
lineTo(progressArray[8].x, progressArray[8].y)
239+
lineTo(progressArray[9].x, progressArray[9].y)
240+
lineTo(progressArray[10].x, progressArray[10].y)
241+
}
242+
path?.let { it1 ->
243+
paint?.let { it2 ->
244+
canvas.drawPath(it1, it2)
245+
}
246+
}
229247

230-
path!!.lineTo(progressArray[0].x, progressArray[0].y)
231-
path.lineTo(progressArray[1].x, progressArray[1].y)
232-
path.cubicTo(progressArray[2].x, progressArray[2].y, progressArray[3].x, progressArray[3].y, progressArray[4].x, progressArray[4].y)
233-
path.cubicTo(progressArray[5].x, progressArray[5].y, progressArray[6].x, progressArray[6].y, progressArray[7].x, progressArray[7].y)
234-
path.lineTo(progressArray[8].x, progressArray[8].y)
235-
path.lineTo(progressArray[9].x, progressArray[9].y)
236-
path.lineTo(progressArray[10].x, progressArray[10].y)
237-
238-
canvas.drawPath(path, paint!!)
239248
}
240249

241250
private fun calculate(start: Float, end: Float): Float {

custombottomnavigation/src/main/java/com/simform/custombottomnavigation/CustomBottomNavigationIcon.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
146146
set(value) {
147147
field = value
148148
if (allowDraw && field != null)
149-
tv_count.typeface = field
149+
field?.let {
150+
tv_count.typeface = it
151+
}
150152
}
151153

152154
var rippleColor = 0
@@ -170,18 +172,6 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
170172
val scale = (1f - progress) * (-0.2f) + 1f
171173
iv.scaleX = scale
172174
iv.scaleY = scale
173-
174-
/*val d = GradientDrawable()
175-
d.setColor(circleColor)
176-
d.shape = GradientDrawable.OVAL
177-
178-
ViewCompat.setBackground(v_circle, d)
179-
180-
ViewCompat.setElevation(v_circle, if (progress > 0.7f) dipf(context, progress * 4f) else 0f)
181-
182-
val m = dip(context, 24)
183-
v_circle.x = (1f - progress) * (if (isFromLeft) -m else m) + ((measuredWidth - dip(context, 48)) / 2f)
184-
v_circle.y = (1f - progress) * measuredHeight + dip(context, 6)*/
185175
}
186176

187177
var isEnabledCell = false

custombottomnavigation/src/main/java/com/simform/custombottomnavigation/SSCustomBottomNavigation.kt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import android.content.Context
1010
import android.graphics.Color
1111
import android.graphics.Typeface
1212
import android.os.Build
13+
import android.text.TextUtils
1314
import android.util.AttributeSet
1415
import android.util.LayoutDirection
1516
import android.util.Log
1617
import android.view.Gravity
18+
import android.view.inputmethod.InputMethodManager
1719
import android.widget.FrameLayout
1820
import android.widget.LinearLayout
1921
import androidx.annotation.IdRes
@@ -23,6 +25,7 @@ import androidx.navigation.NavController
2325
import androidx.navigation.NavDestination
2426
import androidx.navigation.NavGraph
2527
import androidx.navigation.NavOptions
28+
import com.google.android.material.internal.ContextUtils.getActivity
2629
import kotlin.math.abs
2730

2831
internal typealias IBottomNavigationListener = (model: Model) -> Unit
@@ -216,17 +219,17 @@ class SSCustomBottomNavigation : FrameLayout {
216219
isReverseCurve = getBoolean(R.styleable.SSCustomBottomNavigation_ss_reverseCurve, isReverseCurve)
217220
val iconTextTypeFace =
218221
getString(R.styleable.SSCustomBottomNavigation_ss_iconTextTypeface)
219-
if (iconTextTypeFace != null && iconTextTypeFace.isNotEmpty())
222+
if (TextUtils.isEmpty(iconTextTypeFace))
220223
iconTextTypeface = Typeface.createFromAsset(context.assets, iconTextTypeFace)
221224

222225
val typeface = getString(R.styleable.SSCustomBottomNavigation_ss_countTypeface)
223-
if (typeface != null && typeface.isNotEmpty())
226+
if (TextUtils.isEmpty(typeface))
224227
countTypeface = Typeface.createFromAsset(context.assets, typeface)
225228

226229
val drawable =
227230
a.getDrawable(R.styleable.SSCustomBottomNavigation_ss_backgroundBottomDrawable)
228-
if (drawable != null) {
229-
backgroundBottomDrawable = drawable
231+
drawable?.let {
232+
backgroundBottomDrawable = it
230233
}
231234
}
232235
} finally {
@@ -270,7 +273,8 @@ class SSCustomBottomNavigation : FrameLayout {
270273
}
271274
if (selectedIndex != -1) {
272275
Log.e("selectedIndex", " $selectedIndex")
273-
show(selectedIndex, false)
276+
val imm: InputMethodManager = getActivity(context)?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
277+
if (!imm.isAcceptingText) show(selectedIndex, false)
274278
}
275279
}
276280

@@ -378,7 +382,9 @@ class SSCustomBottomNavigation : FrameLayout {
378382
private fun matchDestination(destination: NavDestination, @IdRes destinationId: Int): Boolean {
379383
var currentDestination = destination
380384
while (currentDestination.id != destinationId && currentDestination.parent != null) {
381-
currentDestination = currentDestination.parent!!
385+
currentDestination.parent?.let {
386+
currentDestination = it
387+
}
382388
}
383389

384390
return currentDestination.id == destinationId
@@ -389,7 +395,9 @@ class SSCustomBottomNavigation : FrameLayout {
389395
private fun findStartDestination(graph: NavGraph): NavDestination {
390396
var startDestination: NavDestination = graph
391397
while (startDestination is NavGraph) {
392-
startDestination = graph.findNode(graph.startDestinationId)!!
398+
graph.findNode(graph.startDestinationId)?.let {
399+
startDestination = it
400+
}
393401
}
394402

395403
return startDestination
@@ -513,10 +521,10 @@ class SSCustomBottomNavigation : FrameLayout {
513521
val model = models[i]
514522
val cell = cells[i]
515523
if (model.id == id) {
516-
anim(cell, id, enableAnimation)
517-
cell.enableCell()
518524
onShowListener(model)
519525
menuItemClickListener?.invoke(cbnMenuItems[i], i)
526+
anim(cell, id, enableAnimation)
527+
cell.enableCell()
520528
} else {
521529
cell.disableCell()
522530
}

0 commit comments

Comments
 (0)