reader/android: use the vdl-generated code directly
The FakeFile class in the FakeDB was doing exactly the same things as
the vdl-generated File class does. Now it uses the generated File
class directly where applicable.
Change-Id: Ia66ac930ce7938ad5d5439f2172422e6bb20911a
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 4f479d9..86ae087 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -70,5 +70,5 @@
vdl {
inputPaths += System.getenv("JIRI_ROOT") + '/release/go/src'
inputPaths += '../..'
- packageTranslations += 'vdl->io.v.android.apps.reader'
+ packageTranslations += 'vdl->io.v.android.apps.reader.vdl'
}
diff --git a/android/app/src/main/java/io/v/android/apps/reader/PdfListAdapter.java b/android/app/src/main/java/io/v/android/apps/reader/PdfListAdapter.java
index 3299752..ee19389 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/PdfListAdapter.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/PdfListAdapter.java
@@ -15,7 +15,7 @@
import io.v.android.apps.reader.db.DB;
import io.v.android.apps.reader.db.DB.DBList;
import io.v.android.apps.reader.model.Listener;
-import io.v.android.apps.reader.model.File;
+import io.v.android.apps.reader.vdl.File;
/**
* Adapter that binds the list of pdf files to the corresponding card views.
diff --git a/android/app/src/main/java/io/v/android/apps/reader/db/DB.java b/android/app/src/main/java/io/v/android/apps/reader/db/DB.java
index b04232f..4b19874 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/db/DB.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/db/DB.java
@@ -9,7 +9,7 @@
import android.content.Intent;
import io.v.android.apps.reader.model.Listener;
-import io.v.android.apps.reader.model.File;
+import io.v.android.apps.reader.vdl.File;
/**
* Provides high-level methods for getting and setting the state of PDF reader.
diff --git a/android/app/src/main/java/io/v/android/apps/reader/db/FakeDB.java b/android/app/src/main/java/io/v/android/apps/reader/db/FakeDB.java
index 63507f9..642f2de 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/db/FakeDB.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/db/FakeDB.java
@@ -12,8 +12,7 @@
import java.util.List;
import io.v.android.apps.reader.model.Listener;
-import io.v.android.apps.reader.model.File;
-import io.v.v23.services.syncbase.nosql.BlobRef;
+import io.v.android.apps.reader.vdl.File;
/**
* A fake implementation of the DB interface for manual testing.
@@ -31,71 +30,29 @@
mFileList = new FakeFileList();
}
- class FakeFile implements File {
+ static class FakeFileList implements DBList<File> {
- private String mId;
- private BlobRef mRef;
- private String mTitle;
- private long mSize;
- private String mType;
-
- public FakeFile(String title) {
- this(null, null, title, 0, null);
- }
-
- public FakeFile(String id, BlobRef ref, String title, long size, String type) {
- mId = id;
- mRef = ref;
- mTitle = title;
- mSize = size;
- mType = type;
- }
-
- @Override
- public String getId() {
- return mId;
- }
-
- @Override
- public BlobRef getRef() {
- return mRef;
- }
-
- @Override
- public String getTitle() {
- return mTitle;
- }
-
- @Override
- public long getSize() {
- return mSize;
- }
-
- @Override
- public String getType() {
- return mType;
- }
- }
-
- class FakeFileList implements DBList<File> {
-
- private List<FakeFile> mFiles;
+ private List<File> mFiles;
private Listener mListener;
public FakeFileList() {
mFiles = new ArrayList<>();
for (String fileName : FILE_NAMES) {
- mFiles.add(new FakeFile(fileName));
+ mFiles.add(createFile(fileName));
}
}
+ private static File createFile(String title) {
+ return new File(null, null, title, 0L, null);
+ }
+
@Override
public int getItemCount() {
return mFiles.size();
}
@Override
- public FakeFile getItem(int position) {
+ public File getItem(int position) {
return mFiles.get(position);
}
diff --git a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
index 2ca0bde..f0c5ccf 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
@@ -14,7 +14,7 @@
import com.google.common.collect.ImmutableMap;
import io.v.android.apps.reader.model.Listener;
-import io.v.android.apps.reader.model.File;
+import io.v.android.apps.reader.vdl.File;
import io.v.android.libs.security.BlessingsManager;
import io.v.android.v23.V;
import io.v.android.v23.services.blessing.BlessingCreationException;
diff --git a/android/app/src/main/java/io/v/android/apps/reader/model/File.java b/android/app/src/main/java/io/v/android/apps/reader/model/File.java
deleted file mode 100644
index 6fca3dd..0000000
--- a/android/app/src/main/java/io/v/android/apps/reader/model/File.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package io.v.android.apps.reader.model;
-
-import io.v.v23.services.syncbase.nosql.BlobRef;
-
-/**
- * Represents a PDF file and its metadata.
- */
-public interface File {
- String getId();
- BlobRef getRef();
- String getTitle();
- long getSize();
- String getType();
-}