Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemilla committed Apr 17, 2024
1 parent 3038b1d commit ee08547
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencyResolutionManagement {

```gradle
dependencies {
implementation 'com.github.trycourier:courier-android:3.1.2'
implementation 'com.github.trycourier:courier-android:3.1.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/courier/android/Courier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Courier private constructor(internal val context: Context) : Application.A
companion object {

var USER_AGENT = CourierAgent.NATIVE_ANDROID
internal const val VERSION = "3.1.2"
internal const val VERSION = "3.1.3"
internal const val TAG = "Courier SDK"
internal const val COURIER_PENDING_NOTIFICATION_KEY = "courier_pending_notification_key"
internal val eventBus by lazy { NotificationEventBus() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.courier.android.Courier
import com.courier.android.Courier.Companion.coroutineScope
import com.courier.android.R
import com.courier.android.models.CourierAgent
import com.courier.android.models.CourierException
import com.courier.android.models.CourierPreferenceChannel
import com.courier.android.models.CourierPreferenceStatus
Expand All @@ -42,32 +41,39 @@ class CourierPreferences @JvmOverloads constructor(context: Context, attrs: Attr

private var state = State.LOADING
set(value) {
field = value
when (field) {
State.LOADING -> {
refreshLayout.isVisible = false
infoView.isVisible = false
loadingIndicator.isVisible = true
}
State.ERROR -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
loadingIndicator.isVisible = false
}
State.CONTENT -> {
refreshLayout.isVisible = true
infoView.isVisible = false
detailTextView.text = null
loadingIndicator.isVisible = false
}
State.EMPTY -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
loadingIndicator.isVisible = false

coroutineScope.launch(Dispatchers.Main) {

field = value

when (field) {
State.LOADING -> {
refreshLayout.isVisible = false
infoView.isVisible = false
loadingIndicator.isVisible = true
}
State.ERROR -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
loadingIndicator.isVisible = false
}
State.CONTENT -> {
refreshLayout.isVisible = true
infoView.isVisible = false
detailTextView.text = null
loadingIndicator.isVisible = false
}
State.EMPTY -> {
refreshLayout.isVisible = false
infoView.isVisible = true
detailTextView.text = field.title
loadingIndicator.isVisible = false
}
}

}

}

sealed class Mode {
Expand Down Expand Up @@ -290,7 +296,6 @@ class CourierPreferences @JvmOverloads constructor(context: Context, attrs: Attr

preferencesAdapter = ConcatAdapter(sections)
recyclerView.adapter = preferencesAdapter
preferencesAdapter.notifyDataSetChanged()

state = if (preferences.items.isEmpty()) State.EMPTY.apply { title = "No preferences found" } else State.CONTENT
refreshLayout.isRefreshing = false
Expand Down Expand Up @@ -483,27 +488,27 @@ class CourierPreferences @JvmOverloads constructor(context: Context, attrs: Attr
// }
// }

@SuppressLint("NotifyDataSetChanged")
private fun RecyclerView.forceReactNativeLayoutFix() {

if (Courier.USER_AGENT != CourierAgent.REACT_NATIVE_ANDROID) {
return
}

try {

// Forces the layout to refresh
// This is a react native bug
adapter?.notifyDataSetChanged()
scrollBy(0, 0)

} catch (e: Exception) {

Courier.error(e.toString())

}

}
// @SuppressLint("NotifyDataSetChanged")
// private fun RecyclerView.forceReactNativeLayoutFix() {
//
// if (Courier.USER_AGENT != CourierAgent.REACT_NATIVE_ANDROID) {
// return
// }
//
// try {
//
// // Forces the layout to refresh
// // This is a react native bug
// adapter?.notifyDataSetChanged()
// scrollBy(0, 0)
//
// } catch (e: Exception) {
//
// Courier.error(e.toString())
//
// }
//
// }

// override fun onAttachedToWindow() {
// super.onAttachedToWindow()
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/res/layout/courier_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:layout_height="0dp"
android:layout_weight="1">

<!-- Inbox -->
<!-- Preferences -->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
Expand Down

0 comments on commit ee08547

Please sign in to comment.