Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/dictionaries/lenovo.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

47 changes: 17 additions & 30 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MediaPickerProject

[![](https://jitpack.io/v/Achenglove/MediaPickerPoject.svg)](https://jitpack.io/#Achenglove/MediaPickerPoject)
仿微信视频图片选择器,代码撸的非常简洁清爽好改,支持cordova调用。

同类的库很多很多,但都过于强大而笨重,代码不容易在特别短的时间里面改动,所以我创建了这个简单而轻量的库。
Expand All @@ -21,6 +21,8 @@ repositories {

dependencies {
   compile 'com.dmcBig:mediapicker:+'

或者implementation 'com.github.Achenglove:MediaPickerPoject:v1.0.1'
}
```

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "dmc.mediapickerpoject"
minSdkVersion 16
Expand All @@ -24,7 +24,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':mediapicker')
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/dmc/mediapickerpoject/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public void onClick(View v) {
ArrayList<Media> select;
void go(){
Intent intent =new Intent(MainActivity.this, PickerActivity.class);
intent.putExtra(PickerConfig.SELECT_MODE,PickerConfig.PICKER_IMAGE_VIDEO);//default image and video (Optional)
long maxSize=188743680L;//long long long
intent.putExtra(PickerConfig.MAX_SELECT_SIZE,maxSize); //default 180MB (Optional)
intent.putExtra(PickerConfig.MAX_SELECT_COUNT,15); //default 40 (Optional)
intent.putExtra(PickerConfig.SELECT_MODE,PickerConfig.PICKER_VIDEO);//default image and video (Optional)
PickerConfig.setMaxSize(10485760L);//设置最大选着文件
intent.putExtra(PickerConfig.MAX_SELECT_SIZE,PickerConfig.getMaxSize()); //default 180MB (Optional)
intent.putExtra(PickerConfig.MAX_SELECT_COUNT,1); //default 40 (Optional)
intent.putExtra(PickerConfig.DEFAULT_SELECTED_LIST,select); // (Optional)
MainActivity.this.startActivityForResult(intent,200);
}
Expand Down
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -17,6 +19,13 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
maven { url "https://dl.bintray.com/thelasterstar/maven/" }
maven {
url "https://maven.google.com"
}
google()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
22 changes: 12 additions & 10 deletions mediapicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream(
version = "3.0" //发布版本号
group = "com.dmcBig" //最终引用形式,如compile 'com.**;
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 26
buildToolsVersion '26.0.2'

defaultConfig {
minSdkVersion 16
Expand All @@ -31,15 +31,17 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.android.support:support-v4:25.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
compile 'pub.devrel:easypermissions:1.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.5.0'
implementation 'com.android.support:support-v4:26.1.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
implementation 'pub.devrel:easypermissions:1.0.0'
implementation 'com.github.chrisbanes.photoview:library:1.2.4'

}

bintray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PickerConfig {
*/
public static final String MAX_SELECT_SIZE = "max_select_size";

public static final long DEFAULT_SELECTED_MAX_SIZE = 188743680;
public static long DEFAULT_SELECTED_MAX_SIZE = 188743680;

/**
* 图片选择模式,默认选视频和图片
Expand All @@ -45,4 +45,16 @@ public class PickerConfig {
public static final int PICKER_IMAGE_VIDEO = 101;
public static int GridSpanCount = 3;
public static int GridSpace = 4;

public static void setMaxSize(long MaxSize){
// "B";
// 1024 + "KB";
// 1048576 + "MB";
// 1073741824 + "GB";

DEFAULT_SELECTED_MAX_SIZE=MaxSize;
}
public static long getMaxSize(){
return DEFAULT_SELECTED_MAX_SIZE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public MediaGridAdapter(ArrayList<Media> list, Context context, ArrayList<Media>
public class MyViewHolder extends RecyclerView.ViewHolder {
public ImageView media_image, check_image;
public View mask_view;
public TextView textView_size;
public TextView textView_size,textView_duration;
public RelativeLayout gif_info;
public RelativeLayout video_info;

Expand All @@ -61,6 +61,7 @@ public MyViewHolder(View view) {
video_info = (RelativeLayout) view.findViewById(R.id.video_info);
gif_info = (RelativeLayout) view.findViewById(R.id.gif_info);
textView_size = (TextView) view.findViewById(R.id.textView_size);
textView_duration = (TextView) view.findViewById(R.id.textView_duration);
itemView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getItemWidth())); //让图片是个正方形
}
}
Expand Down Expand Up @@ -89,6 +90,7 @@ public void onBindViewHolder(final MyViewHolder holder, int position) {
holder.gif_info.setVisibility(View.INVISIBLE);
holder.video_info.setVisibility(View.VISIBLE);
holder.textView_size.setText(fileUtils.getSizeByUnit(media.size));
holder.textView_duration.setText(fileUtils.timeParseMinute(media.duration));
} else {
holder.video_info.setVisibility(View.INVISIBLE);
holder.gif_info.setVisibility(".gif".equalsIgnoreCase(media.extension) ? View.VISIBLE : View.INVISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
*/

public class MediaLoader extends LoaderM implements LoaderManager.LoaderCallbacks {
private static final String DURATION = "duration";
String[] MEDIA_PROJECTION = {
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.DISPLAY_NAME,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.SIZE,
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.PARENT};
MediaStore.Files.FileColumns.PARENT,
DURATION};

Context mContext;
DataCallback mLoader;
Expand Down Expand Up @@ -72,12 +74,13 @@ public void onLoadFinished(Loader loader, Object o) {
long dateTime = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATE_ADDED));
int mediaType = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MEDIA_TYPE));
long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE));
long duration = cursor.getLong(cursor.getColumnIndexOrThrow(DURATION));
int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns._ID));

if (size < 1) continue;
if(path == null || path.equals("")) continue;
String dirName = getParent(path);
Media media = new Media(path, name, dateTime, mediaType, size, id, dirName);
Media media = new Media(path, name, dateTime, mediaType, size,duration, id, dirName);
allFolder.addMedias(media);
if (mediaType == 3) {
allVideoDir.addMedias(media);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
*/

public class VideoLoader extends LoaderM implements LoaderManager.LoaderCallbacks {
private static final String DURATION = "duration";
String[] MEDIA_PROJECTION = {
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.DISPLAY_NAME,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.SIZE,
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.PARENT};
MediaStore.Files.FileColumns.PARENT,
DURATION};

Context mContext;
DataCallback mLoader;
Expand Down Expand Up @@ -69,12 +71,13 @@ public void onLoadFinished(Loader loader, Object o) {
long dateTime = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATE_ADDED));
int mediaType = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MEDIA_TYPE));
long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE));
long duration = cursor.getLong(cursor.getColumnIndexOrThrow(DURATION));
int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns._ID));

if (size < 1) continue;
if (path == null || path.equals("")) continue;
String dirName = getParent(path);
Media media = new Media(path, name, dateTime, mediaType, size, id, dirName);
Media media = new Media(path, name, dateTime, mediaType, size,duration, id, dirName);
allFolder.addMedias(media);

int index = hasDir(folders, dirName);
Expand Down
Loading