Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
Fix bugs in loading from path of cover
Browse files Browse the repository at this point in the history
  • Loading branch information
joielechong committed Nov 20, 2017
1 parent df8b09c commit decefc6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ captures/
.idea/libraries
.idea/markdown-navigator.xml
.idea/markdown-navigator
.idea/*
.idea/misc.xml

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {

```
dependencies {
compile 'com.github.joielechong:shelfview:2.1.5'
compile 'com.github.joielechong:shelfview:2.1.7'
}
```

Expand Down
4 changes: 2 additions & 2 deletions shelfview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.joielechong'
version = '2.1.6'
version = '2.1.7'

android {
compileSdkVersion 26
Expand All @@ -10,7 +10,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 216
versionCode 217
versionName version
}
buildTypes {
Expand Down
11 changes: 9 additions & 2 deletions shelfview/src/main/java/com/rilixtech/shelfview/BookModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ public void setBookSource(BookSource bookSource) {
this.bookSource = bookSource;
}

public static BookModel fileBookModel(String bookCoverSource, String bookId, String bookTitle) {
return new BookModel(bookCoverSource, bookId, bookTitle, BookSource.FILE);
/**
* Set book model from path of image file from external or internal sdcard
* @param coverImagePath path of cover image.
* @param bookId id of the book
* @param bookTitle title of the book
* @return model of the book
*/
public static BookModel fileBookModel(String coverImagePath, String bookId, String bookTitle) {
return new BookModel(coverImagePath, bookId, bookTitle, BookSource.FILE);
}

public static BookModel urlBookModel(String bookCoverSource, String bookId, String bookTitle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static class ViewHolder {
}

private void loadImageWithPicasso(Context context, final ShelfModel model, final ViewHolder holder) {
String bookCover = model.getBookCoverSource().trim();
String bookCover = model.getBookCoverSource();
if (model.getShow() && !bookCover.equals("")) {

Callback callback = new Callback() {
Expand All @@ -115,7 +115,7 @@ private void loadImageWithPicasso(Context context, final ShelfModel model, final
switch (model.getBookSource()) {
case FILE:
Picasso.with(context)
.load(new File(getInternalStorage() + bookCover))
.load(new File(/*getInternalStorage() +*/ bookCover))
.resize(mTargetWidth, mTargetHeight)
.into(holder.imvBookCover, callback);
break;
Expand Down

0 comments on commit decefc6

Please sign in to comment.