Skip to content

Commit

Permalink
fix scv export bug
Browse files Browse the repository at this point in the history
  • Loading branch information
panasetskaya committed Jul 22, 2023
1 parent 90a7bc2 commit acefe13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ class CharacterSudokuRepositoryImpl @Inject constructor(
sb += CSV_HEADERS
}
afterFirst = true
sb += "${character.character},${character.pinyin},${character.translation},${character.usages},${character.category}\n"
val pinyinToWrite = getSCVCellFilledWith(character.pinyin)
val translationToWrite = getSCVCellFilledWith(character.translation)
val usagesToWrite = getSCVCellFilledWith(character.usages)
val categoryToWrite = getSCVCellFilledWith(character.category)
sb += "${character.character},$pinyinToWrite,$translationToWrite,$usagesToWrite,$categoryToWrite\n"
}
try {
file.writeText(sb)
Expand Down Expand Up @@ -413,6 +417,10 @@ class CharacterSudokuRepositoryImpl @Inject constructor(
return Environment.MEDIA_MOUNTED == extStorageState
}

private fun getSCVCellFilledWith(s: String): String {
return if (s!="") s else "-"
}


companion object {
private val INITIAL_9_CHAR = listOf("", "", "", "", "", "", "", "", "")
Expand Down
15 changes: 1 addition & 14 deletions app/src/main/res/layout/fragment_records.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@
app:navigationIcon="?attr/homeAsUpIndicator"/>
</com.google.android.material.appbar.AppBarLayout>

<TextView
android:id="@+id/tv_records_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="24dp"
android:text="@string/records_title"
android:textColor="@color/primaryLightColor"
android:textSize="20sp"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewRecords"
Expand All @@ -49,7 +36,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_records_title"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
android:layout_margin="24dp"
tools:listitem="@layout/record_item" />

Expand Down

0 comments on commit acefe13

Please sign in to comment.