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

Commit

Permalink
* fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
alhazmy13 committed Apr 18, 2018
1 parent 8fea126 commit 7373fb4
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class ImageFragment extends Fragment {


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.image_layout, container, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
public class MainActivity extends AppCompatActivity {
private Fragment videoFragment = new VideoFragment();
private Fragment imageFragment = new ImageFragment();
private ViewPager mPager;
private PagerAdapter mPagerAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mPager = findViewById(R.id.pager);
mPagerAdapter = new PickerAdapter(getSupportFragmentManager());
ViewPager mPager = findViewById(R.id.pager);
PagerAdapter mPagerAdapter = new PickerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mPager);
Expand Down
7 changes: 1 addition & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Sep 10 13:03:48 EAT 2016
isDubgMode=true
org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
systemProp.http.proxyPort=9050
android.useDeprecatedNdk=true
org.gradle.jvmargs=-Xmx1536m
22 changes: 11 additions & 11 deletions libary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
apply plugin: 'com.android.library'
//apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.novoda.bintray-release'
//apply from: '../deps.gradle'

//./gradlew bintrayUpload
//publish {
// userOrg = 'alhazmy13'
// groupId = 'net.alhazmy13.MediaPicker'
// artifactId = 'libary'
// uploadName = 'MediaPicker'
// publishVersion = '2.4.1-beta'
// desc = 'MediaPicker'
// dryRun = false
// website = 'https://github.com/alhzmy13/MediaPicker'
//}
publish {
userOrg = 'alhazmy13'
groupId = 'net.alhazmy13.MediaPicker'
artifactId = 'libary'
uploadName = 'MediaPicker'
publishVersion = '2.4.2-beta'
desc = 'MediaPicker'
dryRun = false
website = 'https://github.com/alhzmy13/MediaPicker'
}

android {
compileSdkVersion 27
Expand Down
63 changes: 0 additions & 63 deletions libary/src/jni/hello-jni.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) {
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
private static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {

Cursor cursor = null;
final String column = "_data";
Expand All @@ -134,23 +134,23 @@ public static String getDataColumn(Context context, Uri uri, String selection,
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}

/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}

/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}

Expand All @@ -174,9 +174,9 @@ public static void copyDirectory(File sourceLocation , File targetLocation) {
}

String[] children = sourceLocation.list();
for (int i = 0; i < children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
for (String aChildren : children) {
copyDirectory(new File(sourceLocation, aChildren),
new File(targetLocation, aChildren));
}
} else {

Expand All @@ -192,6 +192,6 @@ public static void copyDirectory(File sourceLocation , File targetLocation) {
in.close();
out.close();
}
}catch (Exception ex){}
}catch (Exception ignored){}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ImageConfig implements Serializable {
protected boolean allowOnlineImages;
protected boolean debug;

public ImageConfig() {
ImageConfig() {
this.extension = ImagePicker.Extension.PNG;
this.compressLevel = ImagePicker.ComperesLevel.NONE;
this.mode = ImagePicker.Mode.CAMERA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ public class ImagePicker {
*/
public static final String EXTRA_IMAGE_PATH = "EXTRA_IMAGE_PATH";

private final ImageConfig imageConfig;

/**
* Instantiates a new Image picker.
*
* @param builder the builder
*/
public ImagePicker(Builder builder) {
ImagePicker(Builder builder) {

// Required
WeakReference<Activity> context = builder.context;

// Optional
imageConfig = builder.imageConfig;
ImageConfig imageConfig = builder.imageConfig;
Intent callingIntent = ImageActivity.getCallingIntent(context.get(), imageConfig);

context.get().startActivityForResult(callingIntent, IMAGE_PICKER_REQUEST_CODE);
Expand Down Expand Up @@ -203,17 +201,6 @@ public int getValue() {
return value;
}

/**
* Gets enum.
*
* @param value the value
* @return the enum
*/
public static ComperesLevel getEnum(int value) {
for (ComperesLevel v : values())
if (v.getValue() == value) return v;
throw new IllegalArgumentException();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static List<String> processMultiImage(Context context, Intent data) {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) && (null == data.getData()))
{
ClipData clipdata = data.getClipData();
for (int i=0; i<clipdata.getItemCount();i++)
for (int i = 0; i< (clipdata != null ? clipdata.getItemCount() : 0); i++)
{
Uri selectedImage = clipdata.getItemAt(i).getUri();
String selectedImagePath = FileProcessing.getPath(context, selectedImage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
package net.alhazmy13.mediapicker.Image;

public class ImageTags {
public static final class Tags{
public static final class Tags {
public static final String TAG = "ImagePicker";
public static final String LEVEL = "level";
public static final String EXTENSION = "extension";
public static final String MODE = "mode";
public static final String DIRECTORY = "DIRECTORY";
public static final String CAMERA_IMAGE_URI = "cameraImageUri";
public static final String COMPRESS_LEVEL = "COMPRESS_LEVEL";
public static final String REQUESTED_WIDTH = "REQUESTED_WIDTH";
public static final String REQUESTED_HEIGHT = "REQUESTED_HEIGHT";
public static final String IMAGE_PATH = "IMAGE_PATH";
public static final String ALLOW_MULTIPLE = "ALLOW_MULTIPLE";
public static final String DEBUG = "DEBUG";
public static final String IMAGE_PICKER_DIR = "/mediapicker/images/";
public static final String IMG_CONFIG = "IMG_CONFIG";
public static final String PICK_ERROR = "PICK_ERROR";
public static final String IS_ALERT_SHOWING = "IS_ALERT_SHOWING";
}

public static final class Action{
public static final class Action {
public static final String SERVICE_ACTION = "net.alhazmy13.mediapicker.rxjava.image.service";
}

public final class IntentCode{
public final class IntentCode {
public static final int REQUEST_CODE_SELECT_MULTI_PHOTO = 5341;
public static final int CAMERA_REQUEST = 1888;
public static final int REQUEST_CODE_ASK_PERMISSIONS = 123;
public static final int REQUEST_CODE_SELECT_PHOTO = 43;


}


}
17 changes: 0 additions & 17 deletions libary/src/main/java/net/alhazmy13/mediapicker/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static String compressImage(String path) throws IOException {
}

public static String getRandomString() {
// return SystemClock.currentThreadTimeMillis()+"";
return UUID.randomUUID().toString();
}

Expand All @@ -51,22 +50,6 @@ public static void createFolder(String path) {

}

public static String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
assert cursor != null;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}

@WorkerThread
public static void compressAndRotateIfNeeded(File sourceFile, File destinationFile, int value, int reqWidth, int reqHeight) throws IOException {

Expand Down
Loading

0 comments on commit 7373fb4

Please sign in to comment.