Minor changes

This commit is contained in:
inorichi 2016-01-30 00:41:39 +01:00
parent 38bb0b61d4
commit 78a2eae719
2 changed files with 21 additions and 22 deletions

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.io; package eu.kanade.tachiyomi.data.io;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;

View File

@ -27,7 +27,7 @@ import eu.kanade.tachiyomi.R;
import eu.kanade.tachiyomi.data.cache.CoverCache; import eu.kanade.tachiyomi.data.cache.CoverCache;
import eu.kanade.tachiyomi.data.database.models.Manga; import eu.kanade.tachiyomi.data.database.models.Manga;
import eu.kanade.tachiyomi.data.source.base.Source; import eu.kanade.tachiyomi.data.source.base.Source;
import eu.kanade.tachiyomi.io.IOHandler; import eu.kanade.tachiyomi.data.io.IOHandler;
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment; import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment;
import eu.kanade.tachiyomi.util.ToastUtil; import eu.kanade.tachiyomi.util.ToastUtil;
import nucleus.factory.RequiresPresenter; import nucleus.factory.RequiresPresenter;
@ -35,7 +35,6 @@ import nucleus.factory.RequiresPresenter;
@RequiresPresenter(MangaInfoPresenter.class) @RequiresPresenter(MangaInfoPresenter.class)
public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> { public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
private static final int REQUEST_IMAGE_OPEN = 101;
@Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh; @Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh;
@Bind(R.id.manga_artist) TextView artist; @Bind(R.id.manga_artist) TextView artist;
@Bind(R.id.manga_author) TextView author; @Bind(R.id.manga_author) TextView author;
@ -48,6 +47,8 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
@Bind(R.id.action_favorite) Button favoriteBtn; @Bind(R.id.action_favorite) Button favoriteBtn;
@Bind(R.id.fab_edit) FloatingActionButton fabEdit; @Bind(R.id.fab_edit) FloatingActionButton fabEdit;
private static final int REQUEST_IMAGE_OPEN = 101;
public static MangaInfoFragment newInstance() { public static MangaInfoFragment newInstance() {
return new MangaInfoFragment(); return new MangaInfoFragment();
} }
@ -71,11 +72,11 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
.color(ContextCompat.getColor(this.getContext(), R.color.white)) .color(ContextCompat.getColor(this.getContext(), R.color.white))
.sizeDp(24); .sizeDp(24);
// Update image of fab buttons // Update image of fab button
fabEdit.setImageDrawable(edit); fabEdit.setImageDrawable(edit);
// Set listener. // Set listener.
fabEdit.setOnClickListener(v -> MangaInfoFragment.this.selectImage()); fabEdit.setOnClickListener(v -> selectImage());
favoriteBtn.setOnClickListener(v -> getPresenter().toggleFavorite()); favoriteBtn.setOnClickListener(v -> getPresenter().toggleFavorite());
@ -150,27 +151,25 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
} }
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_IMAGE_OPEN) {
// Get the file's content URI from the incoming Intent
Uri selectedImageUri = data.getData();
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // Convert to absolute path to prevent FileNotFoundException
if (resultCode == Activity.RESULT_OK) { String result = IOHandler.getFilePath(selectedImageUri,
if (requestCode == REQUEST_IMAGE_OPEN) { getContext().getContentResolver(), getContext());
// Get the file's content URI from the incoming Intent
Uri selectedImageUri = data.getData();
// Convert to absolute path to prevent FileNotFoundException // Get file from filepath
String result = IOHandler.getFilePath(selectedImageUri, this.getContext().getContentResolver(), this.getContext()); File picture = new File(result != null ? result : "");
// Get file from filepath try {
File picture = new File(result != null ? result : ""); // Update cover to selected file
getPresenter().editCoverWithLocalFile(picture, cover);
} catch (IOException e) {
try { e.printStackTrace();
// Update cover to selected file
getPresenter().editCoverWithLocalFile(picture, cover);
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
} }