Merge branch 'bug_fixes' into 'master'

Fix some bugs

Closes #282 and #281

See merge request pixeldroid/PixelDroid!313
This commit is contained in:
Matthieu 2021-03-15 19:27:11 +00:00
commit 3f90f16fef
7 changed files with 34 additions and 16 deletions

View File

@ -60,12 +60,6 @@ class SearchDiscoverFragment : BaseFragment() {
adapter = DiscoverRecyclerViewAdapter()
recycler.adapter = adapter
binding.discoverText.setCompoundDrawables(IconicsDrawable(requireContext(), GoogleMaterial.Icon.gmd_explore).apply {
sizeDp = 24
paddingDp = 20
color = IconicsColor.colorRes(R.color.colorDrawing)
}, null, null, null)
return binding.root
}

View File

@ -49,5 +49,5 @@ fun storeInstance(db: AppDatabase, nodeInfo: NodeInfo?, instance: Instance? = nu
)
} ?: throw IllegalArgumentException("Cannot store instance where both are null")
db.instanceDao().insertInstance(dbInstance)
db.instanceDao().insertOrUpdate(dbInstance)
}

View File

@ -1,9 +1,6 @@
package com.h.pixeldroid.utils.db.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.*
import com.h.pixeldroid.utils.db.entities.InstanceDatabaseEntity
@Dao
@ -11,6 +8,19 @@ interface InstanceDao {
@Query("SELECT * FROM instances")
fun getAll(): List<InstanceDatabaseEntity>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertInstance(instance: InstanceDatabaseEntity)
/**
* Insert an instance, if it already exists return -1
*/
@Insert(onConflict = OnConflictStrategy.IGNORE)
fun insertInstance(instance: InstanceDatabaseEntity): Long
@Update
fun updateInstance(instance: InstanceDatabaseEntity)
@Transaction
fun insertOrUpdate(instance: InstanceDatabaseEntity) {
if (insertInstance(instance) == -1L) {
updateInstance(instance)
}
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,10.9c-0.61,0 -1.1,0.49 -1.1,1.1s0.49,1.1 1.1,1.1c0.61,0 1.1,-0.49 1.1,-1.1s-0.49,-1.1 -1.1,-1.1zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM14.19,14.19L6,18l3.81,-8.19L18,6l-3.81,8.19z"
android:fillColor="@color/colorDrawing"/>
</vector>

View File

@ -5,7 +5,9 @@
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/progressBar"

View File

@ -56,7 +56,8 @@
android:text="@string/discover"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/errorLayout" />
app:layout_constraintTop_toBottomOf="@id/errorLayout"
app:drawableStartCompat="@drawable/explore_24dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/discoverList"

View File

@ -18,8 +18,9 @@
<item>বাংলা (বাংলাদেশ)</item>
<item>Català</item>
<item>Deutsch</item>
<item>Esperanto</item>
<item>Español</item>
<item>Euskara</item>
<item>English</item>
<item>فارسی</item>
<item>Français</item>
<item>Gaeilge</item>
@ -42,6 +43,7 @@
<item>de</item>
<item>es</item>
<item>eu</item>
<item>en</item>
<item>fa</item>
<item>fr</item>
<item>gl</item>