Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/bitfire/vcard4android/contactrow/DataRowHandler.kt')
-rw-r--r--src/main/java/at/bitfire/vcard4android/contactrow/DataRowHandler.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/at/bitfire/vcard4android/contactrow/DataRowHandler.kt b/src/main/java/at/bitfire/vcard4android/contactrow/DataRowHandler.kt
new file mode 100644
index 0000000..d8401b8
--- /dev/null
+++ b/src/main/java/at/bitfire/vcard4android/contactrow/DataRowHandler.kt
@@ -0,0 +1,35 @@
+package at.bitfire.vcard4android.contactrow
+
+import android.content.ContentValues
+import androidx.annotation.CallSuper
+import at.bitfire.vcard4android.Contact
+
+/**
+ * Handler for a raw contact's data row.
+ *
+ * @param provider content provider client that has been used to fetch the data row;
+ * may be used by the handler to fetch further data (like a photo)
+ *
+ */
+abstract class DataRowHandler {
+
+ abstract fun forMimeType(): String
+
+ /**
+ * Processes the given data.
+ *
+ * @param values values to process
+ * @param contact contact that is modified according to the values
+ */
+ @CallSuper
+ open fun handle(values: ContentValues, contact: Contact) {
+ // remove empty strings
+ val it = values.keySet().iterator()
+ while (it.hasNext()) {
+ val obj = values[it.next()]
+ if (obj is String && obj.isEmpty())
+ it.remove()
+ }
+ }
+
+} \ No newline at end of file