Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/fragments/BackupImportFragment.kt
- This file was moved from app/src/main/java/it/reyboz/bustorino/fragments/TestSavingFragment.kt.
Show All 24 Lines | |||||
import java.util.* | import java.util.* | ||||
import java.util.zip.ZipEntry | import java.util.zip.ZipEntry | ||||
import java.util.zip.ZipInputStream | import java.util.zip.ZipInputStream | ||||
import java.util.zip.ZipOutputStream | import java.util.zip.ZipOutputStream | ||||
/** | /** | ||||
* A simple [Fragment] subclass. | * A simple [Fragment] subclass. | ||||
* Use the [TestSavingFragment.newInstance] factory method to | * Use the [BackupImportFragment.newInstance] factory method to | ||||
* create an instance of this fragment. | * create an instance of this fragment. | ||||
*/ | */ | ||||
class TestSavingFragment : Fragment() { | class BackupImportFragment : Fragment() { | ||||
private val saveFileLauncher = | private val saveFileLauncher = | ||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | ||||
if (result.resultCode == Activity.RESULT_OK) { | if (result.resultCode == Activity.RESULT_OK) { | ||||
result.data?.data?.also { uri -> | result.data?.data?.also { uri -> | ||||
writeDataZip(uri) | writeDataZip(uri) | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | companion object { | ||||
const val DEBUG_TAG ="BusTO-TestSave" | const val DEBUG_TAG ="BusTO-TestSave" | ||||
const val FAVORITES_NAME = "favorites.csv" | const val FAVORITES_NAME = "favorites.csv" | ||||
const val MAIN_PREF_NAME = "preferences_main.json" | const val MAIN_PREF_NAME = "preferences_main.json" | ||||
const val APP_PREF_NAME = "preferences_app.json" | const val APP_PREF_NAME = "preferences_app.json" | ||||
@JvmStatic | @JvmStatic | ||||
fun newInstance() = | fun newInstance() = | ||||
TestSavingFragment().apply { | BackupImportFragment().apply { | ||||
arguments = Bundle() /*.apply { | arguments = Bundle() /*.apply { | ||||
putString(ARG_PARAM1, param1) | putString(ARG_PARAM1, param1) | ||||
putString(ARG_PARAM2, param2) | putString(ARG_PARAM2, param2) | ||||
} | } | ||||
*/ | */ | ||||
} | } | ||||
fun getCurrentDateString(): String{ | fun getCurrentDateString(): String{ | ||||
val dateFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.ITALY) | val dateFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.ITALY) | ||||
val date = Date() | val date = Date() | ||||
return dateFormat.format(date) | return dateFormat.format(date) | ||||
} | } | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register