Skip to content

Commit

Permalink
#1 Implement usage of the ImageContentProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Nya Elimu committed Apr 7, 2020
1 parent 7685866 commit 669ee31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'ai.elimu:model:1.2.42'
implementation 'ai.elimu:model:1.2.46'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand Down
16 changes: 6 additions & 10 deletions app/src/main/java/ai/elimu/vitabu/ui/StoryBooksActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
Expand Down Expand Up @@ -112,16 +114,10 @@ protected void onStart() {
coverImageCursor.close();
Log.i(getClass().getName(), "cursor.isClosed(): " + coverImageCursor.isClosed());

String coverImageFilename = coverImageGson.getId() + "_" + coverImageGson.getRevisionNumber() + "." + coverImageGson.getImageFormat().toString().toLowerCase();
Log.i(getClass().getName(), "coverImageFilename: " + coverImageFilename);

// File storyBookCoverFile = MultimediaHelper.getFile(storyBook.getCoverImage());
// Log.i(getClass().getName(), "storyBookCoverFile: " + storyBookCoverFile);
// if (storyBookCoverFile.exists()) {
// ImageView storyBookImageView = (ImageView) storyBookView.findViewById(R.id.storyBookCoverImageView);
// Bitmap bitmap = BitmapFactory.decodeFile(storyBookCoverFile.getAbsolutePath());
// storyBookImageView.setImageBitmap(bitmap);
// }
byte[] bytes = coverImageGson.getBytes();
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
ImageView storyBookImageView = storyBookView.findViewById(R.id.storyBookCoverImageView);
storyBookImageView.setImageBitmap(bitmap);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public static ImageGson getImage(Cursor cursor) {
String title = cursor.getString(columnTitle);
Log.i(CursorToImageGsonConverter.class.getName(), "title: \"" + title + "\"");

int columnBytes = cursor.getColumnIndex("bytes");
byte[] bytes = cursor.getBlob(columnBytes);
Log.i(CursorToImageGsonConverter.class.getName(), "bytes: " + bytes);
Log.i(CursorToImageGsonConverter.class.getName(), "bytes.length: " + bytes.length);

int columnImageFormat = cursor.getColumnIndex("imageFormat");
String imageFormatAsString = cursor.getString(columnImageFormat);
Log.i(CursorToImageGsonConverter.class.getName(), "imageFormatAsString: " + imageFormatAsString);
Expand All @@ -37,6 +42,7 @@ public static ImageGson getImage(Cursor cursor) {
image.setId(id);
image.setRevisionNumber(revisionNumber);
image.setTitle(title);
image.setBytes(bytes);
image.setImageFormat(imageFormat);

return image;
Expand Down

0 comments on commit 669ee31

Please sign in to comment.