|
|
@@ -2,12 +2,15 @@ package kr.co.zumo.app.lifeplus.view.screen.event;
|
|
|
|
|
|
import android.Manifest;
|
|
|
import android.content.Context;
|
|
|
+import android.content.CursorLoader;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
+import android.database.Cursor;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.provider.MediaStore;
|
|
|
import android.provider.Settings;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
@@ -226,7 +229,6 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
|
|
|
}
|
|
|
else {
|
|
|
if (false == ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
|
|
- // TODO: 추후 기획 반영 임시로 다시보지 않음 클릭 후 커스텀 알럿 띄움
|
|
|
presenter.onEvent(new Event.Builder(Event.DIALOG).build());
|
|
|
}
|
|
|
}
|
|
|
@@ -248,8 +250,11 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
|
|
|
if (requestCode == GET_ALBUM_PHOTO) {
|
|
|
try {
|
|
|
Uri uri = data.getData();
|
|
|
- //Uri 프리젠터로 보내기
|
|
|
- //presenter.onEvent(new Event.Builder(Event.IMAGE ).string(uri.toString()).build());
|
|
|
+ String urlString = data.getData().getPath();
|
|
|
+ // Log.e("APP# EventQuestionFragment | onActivityResult", "| urlString" + urlString); // /external/images/media/196
|
|
|
+ //Log.e("APP# EventQuestionFragment | onActivityResult", "| uri" + uri); // content://media/external/images/media/196
|
|
|
+ //Log.e("APP# EventQuestionFragment | onActivityResult", "| 실제경로" + getPath(uri));// /storage/emulated/0/Pictures/Screenshots/Screenshot_2018-12-21-10-35-03.jpg
|
|
|
+ presenter.onEvent(new Event.Builder(Event.URI).string(getPath(uri)).build());
|
|
|
|
|
|
InputStream inputStream = getContext().getContentResolver().openInputStream(data.getData());
|
|
|
uploadImage = BitmapFactory.decodeStream(inputStream);
|
|
|
@@ -262,6 +267,16 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String getPath(Uri uri) {
|
|
|
+ String[] projection = {MediaStore.Images.Media.DATA};
|
|
|
+ CursorLoader cursorLoader = new CursorLoader(getContext(), uri, projection, null, null, null);
|
|
|
+ Cursor cursor = cursorLoader.loadInBackground();
|
|
|
+ int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
|
+ cursor.moveToFirst();
|
|
|
+ return cursor.getString(columnIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private String getTimeString(String timeString) {
|
|
|
return Formatter.format(timeString, EventBean.DATE_FORMAT, "yyyy.MM.dd");
|
|
|
}
|