|
|
@@ -1,12 +1,14 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.screen.event.entry;
|
|
|
|
|
|
import android.Manifest;
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.net.Uri;
|
|
|
+import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.provider.Settings;
|
|
|
import android.support.annotation.NonNull;
|
|
|
@@ -53,6 +55,8 @@ import kr.co.zumo.app.lifeplus.view.screen.event.IEventQuestionView;
|
|
|
public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter> implements IEventQuestionView {
|
|
|
|
|
|
private static final int GET_ALBUM_PHOTO = 1;
|
|
|
+ private static final int GALLERY_INTENT_CALLED = 2;
|
|
|
+ private static final int GALLERY_KITKAT_INTENT_CALLED = 3;
|
|
|
private LinearLayout layoutContainer;
|
|
|
private LayoutInflater inflater;
|
|
|
private View layoutSubmit;
|
|
|
@@ -235,7 +239,7 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
|
|
|
//공지사항 영역
|
|
|
View noticeView = inflater.inflate(R.layout.event_participation_item_notice, null);
|
|
|
String notice = detailBean.getNotice();
|
|
|
-
|
|
|
+
|
|
|
if (notice != null && notice.trim().length() != 0) {
|
|
|
EventQuestionNoticeView eventQuestionNoticeView = new EventQuestionNoticeView(noticeView);
|
|
|
eventQuestionNoticeView.draw(notice);
|
|
|
@@ -322,27 +326,53 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
|
|
|
*/
|
|
|
@Override
|
|
|
public void requestAlbumImage() {
|
|
|
- Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
- intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
- intent.setType("image/*");
|
|
|
- startActivityForResult(intent, GET_ALBUM_PHOTO);
|
|
|
+// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
+// intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
+// intent.setType("image/*");
|
|
|
+// startActivityForResult(intent, GET_ALBUM_PHOTO);
|
|
|
+
|
|
|
+ if (Build.VERSION.SDK_INT < 19) {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setType("image/jpeg");
|
|
|
+ intent.setAction(Intent.ACTION_GET_CONTENT);
|
|
|
+ startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.empty_string)), GALLERY_INTENT_CALLED);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
+ intent.setType("image/jpeg");
|
|
|
+ startActivityForResult(intent, GALLERY_KITKAT_INTENT_CALLED);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- if (requestCode == GET_ALBUM_PHOTO) {
|
|
|
- try {
|
|
|
- Uri uri = data.getData();
|
|
|
-
|
|
|
- InputStream inputStream = getContext().getContentResolver().openInputStream(data.getData());
|
|
|
- Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
|
|
- inputStream.close();
|
|
|
-
|
|
|
- presenter.onImageReceived(uri, bitmap);
|
|
|
- } catch (Exception e) {
|
|
|
- //e.printStackTrace();
|
|
|
- Log.e("APP# EventQuestionFragment | onActivityResult", "Log.getStackTraceString(e) |" + Log.getStackTraceString(e));
|
|
|
- }
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (null == data) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Uri uri = data.getData();
|
|
|
+ if (requestCode == GALLERY_INTENT_CALLED) {
|
|
|
+ {} // nothing
|
|
|
+ }
|
|
|
+ else if (requestCode == GALLERY_KITKAT_INTENT_CALLED) {
|
|
|
+ final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
|
+ // Check for the freshest data.
|
|
|
+ getContext().getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ InputStream inputStream = getContext().getContentResolver().openInputStream(uri);
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
|
|
+ inputStream.close();
|
|
|
+
|
|
|
+ presenter.onImageReceived(uri, bitmap);
|
|
|
+ } catch (Exception e) {
|
|
|
+ //e.printStackTrace();
|
|
|
+ Log.e("APP# EventQuestionFragment | onActivityResult", "Log.getStackTraceString(e) |" + Log.getStackTraceString(e));
|
|
|
}
|
|
|
}
|
|
|
|