[fenix] No issue: Fix crash on bookmark folder selection and Snackbar color

pull/600/head
Colin Lee 6 years ago
parent f3ad87cbd2
commit e346070dee

@ -92,8 +92,8 @@ class EditBookmarkFragment : Fragment(), CoroutineScope {
bookmark_name_edit.setText(bookmarkNode!!.title)
bookmark_url_edit.setText(bookmarkNode!!.url)
if (sharedViewModel.selectedFolder != null) {
val bookmarkPair = Pair(bookmarkNode?.title!!, bookmarkNode?.url!!)
if (sharedViewModel.selectedFolder != null && bookmarkNode?.title != null) {
val bookmarkPair = Pair(bookmarkNode?.title, bookmarkNode?.url)
updateBookmarkNode(bookmarkPair)
}
}
@ -160,7 +160,7 @@ class EditBookmarkFragment : Fragment(), CoroutineScope {
}
}
private fun updateBookmarkNode(pair: Pair<String, String>) {
private fun updateBookmarkNode(pair: Pair<String?, String?>) {
launch(IO) {
try {
requireComponents.let {

@ -15,7 +15,7 @@ import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.ktx.android.content.res.pxToDp
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getColorFromAttr
import org.mozilla.fenix.ext.getColorIntFromAttr
import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel
class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) :
@ -86,9 +86,9 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
fun bind(folder: BookmarkNodeWithDepth, selected: Boolean, selectionInterface: SelectionInterface) {
val backgroundTint =
if (selected) {
R.attr.accent.getColorFromAttr(containerView!!.context)
R.attr.accentBright.getColorIntFromAttr(containerView!!.context)
} else {
R.attr.neutral.getColorFromAttr(containerView!!.context)
R.attr.neutral.getColorIntFromAttr(containerView!!.context)
}
val backgroundTintList = ContextCompat.getColorStateList(containerView.context, backgroundTint)

@ -4,6 +4,6 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?accent" />
<solid android:color="?accentBright" />
<corners android:radius="8dp" />
</shape>

@ -1,7 +1,6 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="17" android:viewportWidth="20"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#20123A"
android:pathData="M17.5,3L10.719,3L8.23,0.674C7.7673,0.2413 7.1575,0.0004 6.524,0L2.5,0C1.8361,0 1.1994,0.2641 0.7305,0.734C0.2615,1.2039 -0.0013,1.8411 0,2.505L0,14.5C0,15.8807 1.1193,17 2.5,17L17.5,17C18.8807,17 20,15.8807 20,14.5L20,5.505C20.0013,4.8411 19.7385,4.2039 19.2695,3.734C18.8006,3.2641 18.1639,3 17.5,3ZM2.5,2L6.524,2C6.6503,2.0004 6.7718,2.0487 6.864,2.135L8.86,4L2,4L2,2.505C1.9987,2.3715 2.0508,2.2431 2.1447,2.1482C2.2386,2.0534 2.3665,2 2.5,2ZM18,14.5C18,14.7761 17.7761,15 17.5,15L2.5,15C2.2239,15 2,14.7761 2,14.5L2,5L17.5,5C17.6335,5 17.7614,5.0534 17.8553,5.1482C17.9492,5.2431 18.0013,5.3715 18,5.505L18,14.5Z"
android:strokeColor="#00000000" android:strokeWidth="1"/>
<path android:fillColor="?primaryText"
android:pathData="M17.5,3L10.719,3L8.23,0.674C7.7673,0.2413 7.1575,0.0004 6.524,0L2.5,0C1.8361,0 1.1994,0.2641 0.7305,0.734C0.2615,1.2039 -0.0013,1.8411 0,2.505L0,14.5C0,15.8807 1.1193,17 2.5,17L17.5,17C18.8807,17 20,15.8807 20,14.5L20,5.505C20.0013,4.8411 19.7385,4.2039 19.2695,3.734C18.8006,3.2641 18.1639,3 17.5,3ZM2.5,2L6.524,2C6.6503,2.0004 6.7718,2.0487 6.864,2.135L8.86,4L2,4L2,2.505C1.9987,2.3715 2.0508,2.2431 2.1447,2.1482C2.2386,2.0534 2.3665,2 2.5,2ZM18,14.5C18,14.7761 17.7761,15 17.5,15L2.5,15C2.2239,15 2,14.7761 2,14.5L2,5L17.5,5C17.6335,5 17.7614,5.0534 17.8553,5.1482C17.9492,5.2431 18.0013,5.3715 18,5.505L18,14.5Z" />
</vector>

Loading…
Cancel
Save