Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
* enhance code style
Browse files Browse the repository at this point in the history
  • Loading branch information
alhazmy13 committed Dec 9, 2017
1 parent bfb05b3 commit 63912b9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import net.alhazmy13.mediapicker.Image.ImagePicker;
import net.alhazmy13.mediapicker.Video.VideoPicker;
import net.alhazmy13.mediapicker.rxjava.image.ImagePickerHelper;

import java.util.List;

import rx.Subscriber;

import static android.app.Activity.RESULT_OK;

Expand Down Expand Up @@ -54,17 +49,17 @@ public void onClick(View v) {

private void pickImage() {
// new ImagePickerHelper(
new ImagePicker.Builder(getActivity())
.mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
.allowMultipleImages(true)
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
.directory(ImagePicker.Directory.DEFAULT)
.extension(ImagePicker.Extension.PNG)
.allowOnlineImages(false)
.scale(600, 600)
.allowMultipleImages(true)
.enableDebuggingMode(true)
.build();
new ImagePicker.Builder(getActivity())
.mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
.allowMultipleImages(true)
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
.directory(ImagePicker.Directory.DEFAULT)
.extension(ImagePicker.Extension.PNG)
.allowOnlineImages(false)
.scale(600, 600)
.allowMultipleImages(true)
.enableDebuggingMode(true)
.build();
// .getObservable()
// .subscribe(new Subscriber<List<String>>() {
// @Override
Expand Down Expand Up @@ -92,7 +87,7 @@ private void pickImage() {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
if(requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
mPath = (List<String>) data.getSerializableExtra(ImagePicker.EXTRA_IMAGE_PATH);

loadImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.VisibleForTesting;
import android.support.design.widget.TabLayout;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
Expand Down Expand Up @@ -45,6 +46,7 @@ public int getCount() {
return NUM_PAGES;
}

@VisibleForTesting
@Override
public Fragment getItem(int position) {
switch (position) {
Expand All @@ -55,6 +57,7 @@ public Fragment getItem(int position) {
}
}

@VisibleForTesting
int getTitle(int position) {
switch (position) {
case 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
import android.widget.VideoView;

import net.alhazmy13.mediapicker.Video.VideoPicker;
import net.alhazmy13.mediapicker.rxjava.video.VideoPickerHelper;

import java.util.List;

import rx.Subscriber;

import static android.app.Activity.RESULT_OK;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ protected void onPostExecute(Void aVoid) {
new CompressImageTask(destinationPaths, mImgConfig, mContext.get()).execute();
}

boolean filenotfoundexecption = false;
boolean filenotfoundexecption;

//For Google Drive
boolean saveFile(Uri sourceuri, String destination) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class ImageProcessing {

private static final String TAG = "ImageProcessing";
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static List<String> processMultiImage(Context context, Intent data) {
List<String> listOfImgs = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -36,7 +37,6 @@
* MediaPicker
*/
public class VideoActivity extends AppCompatActivity {
private static final String TAG = "VideoActivity";

private File destination;
private Uri mVideoUri;
Expand Down Expand Up @@ -82,6 +82,8 @@ private void pickVideo() {
case CAMERA_AND_GALLERY:
showFromCameraOrGalleryAlert();
break;
default:
break;
}
}

Expand Down Expand Up @@ -170,27 +172,28 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
}
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mVideoConfig.debug)
Log.d(VideoTags.Tags.TAG, "onActivityResult() called with: " + "requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
if (resultCode == RESULT_OK) {
switch (requestCode) {
case VideoTags.IntentCode.CAMERA_REQUEST:
new VideoActivity.CompressImageTask(destination.getAbsolutePath(), mVideoConfig
new VideoActivity.CompresVideoTask(destination.getAbsolutePath(), mVideoConfig
, VideoActivity.this).execute();
break;
case VideoTags.IntentCode.REQUEST_CODE_SELECT_PHOTO:
processOneImage(data);
processOneVideo(data);
break;
case VideoTags.IntentCode.REQUEST_CODE_SELECT_MULTI_PHOTO:
//Check if the intent contain only one image
if (data.getClipData() == null) {
processOneImage(data);
processOneVideo(data);
} else {
//intent has multi images
listOfImgs = VideoProcessing.processMultiImage(this, data);
new VideoActivity.CompressImageTask(listOfImgs,
mListOfVideos = VideoProcessing.processMultiVideos(this, data);
new VideoActivity.CompresVideoTask(mListOfVideos,
mVideoConfig, VideoActivity.this).execute();
}
break;
Expand Down Expand Up @@ -295,7 +298,7 @@ private boolean addPermission(List<String> permissionsList, String permission) {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case VideoTags.IntentCode.REQUEST_CODE_ASK_PERMISSIONS: {
case VideoTags.IntentCode.REQUEST_CODE_ASK_PERMISSIONS:
Map<String, Integer> perms = new HashMap<String, Integer>();
// Initial
perms.put(Manifest.permission.CAMERA, PackageManager.PERMISSION_GRANTED);
Expand All @@ -313,8 +316,8 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
Toast.makeText(VideoActivity.this, getString(R.string.media_picker_some_permission_is_denied), Toast.LENGTH_SHORT)
.show();
}
}
break;

break;
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* MediaPicker
*/
class VideoProcessing {

private static final String TAG = "ImageProcessing";


@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
static List<String> processMultiVideos(Context context, Intent data) {
List<String> listOfImgs = new ArrayList<>();
Expand Down

0 comments on commit 63912b9

Please sign in to comment.