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

修复两个bug #30

Open
wants to merge 6 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
.idea
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

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

12 changes: 9 additions & 3 deletions .idea/misc.xml

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

7 changes: 4 additions & 3 deletions .idea/modules.xml

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

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildscript {

ext.kotlin_version = '1.3.71'
ext.kotlin_version = '1.4.31'

repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
Expand All @@ -14,7 +14,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
1 change: 1 addition & 0 deletions gallery/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
28 changes: 28 additions & 0 deletions gallery/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 30

defaultConfig {
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
api project(path: ':image')
implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta02'
implementation 'com.facebook.fresco:fresco:1.8.1'
}
Empty file added gallery/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions gallery/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.minetsh.gallery

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.gallery.test", appContext.packageName)
}
}
16 changes: 16 additions & 0 deletions gallery/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.minetsh.imaging.gallery">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application>

<activity
android:name=".IMGGalleryActivity"
android:windowSoftInputMode="stateAlwaysHidden" />

</application>

</manifest>

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging;
package me.minetsh.imaging.gallery;

import android.Manifest;
import android.content.Context;
Expand All @@ -16,7 +16,6 @@
import android.view.ViewStub;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
Expand All @@ -38,14 +37,14 @@
import java.util.Map;
import java.util.Set;

import me.minetsh.imaging.core.util.IMGPermissionUtils;
import me.minetsh.imaging.gallery.IMGGalleryMenuWindow;
import me.minetsh.imaging.gallery.IMGScanTask;
import me.minetsh.imaging.gallery.IMGScanner;
import me.minetsh.imaging.gallery.model.IMGChooseMode;
import me.minetsh.imaging.gallery.model.IMGImageInfo;
import me.minetsh.imaging.gallery.model.IMGImageViewModel;
import me.minetsh.imaging.widget.IMGGalleryHolderCallback;
import me.minetsh.imaging.gallery.core.IMGGalleryMenuWindow;
import me.minetsh.imaging.gallery.core.IMGScanTask;
import me.minetsh.imaging.gallery.core.IMGScanner;
import me.minetsh.imaging.gallery.core.model.IMGChooseMode;
import me.minetsh.imaging.gallery.core.model.IMGImageInfo;
import me.minetsh.imaging.gallery.core.model.IMGImageViewModel;
import me.minetsh.imaging.gallery.utils.IMGPermissionUtils;
import me.minetsh.imaging.gallery.widget.IMGGalleryHolderCallback;

/**
* Created by felix on 2017/11/14 上午11:30.
Expand Down Expand Up @@ -136,20 +135,19 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

public void onImages(Map<String, List<IMGImageViewModel>> images) {
Log.i("++++x", "" + images.size());
mImages = images;
if (images != null) {
mAdapter.setModels(images.get(IMGScanner.ALL_IMAGES));
mAdapter.notifyDataSetChanged();

IMGGalleryMenuWindow window = getGalleryMenuWindow();
Set<String> keys = images.keySet();
List<String> items = new ArrayList<>(keys);
if (!items.isEmpty() && !IMGScanner.ALL_IMAGES.equals(items.get(0))) {
items.remove(IMGScanner.ALL_IMAGES);
items.add(0, IMGScanner.ALL_IMAGES);
}
window.setMenuItems(items);
mAdapter.setModels(images.get(IMGScanner.ALL_IMAGES));
mAdapter.notifyDataSetChanged();

IMGGalleryMenuWindow window = getGalleryMenuWindow();
Set<String> keys = images.keySet();
List<String> items = new ArrayList<>(keys);
if (!items.isEmpty() && !IMGScanner.ALL_IMAGES.equals(items.get(0))) {
items.remove(IMGScanner.ALL_IMAGES);
items.add(0, IMGScanner.ALL_IMAGES);
}
window.setMenuItems(items);
}

public void onQuicklyImages(List<IMGImageViewModel> images) {
Expand Down Expand Up @@ -272,6 +270,7 @@ public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
Log.i("++++", "" + models.get(position).toString());
holder.update(models.get(position), mGalleryMode);
}

Expand Down Expand Up @@ -324,6 +323,7 @@ private void update(IMGImageViewModel model, IMGChooseMode mode) {
mCheckBox.setChecked(model.isSelected());
mCheckBox.setVisibility(mode.isSingleChoose() ? View.GONE : View.VISIBLE);

Log.i("++++", model.getUri().toString());
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(model.getUri())
.setLocalThumbnailPreviewsEnabled(true)
.setResizeOptions(new ResizeOptions(300, 300))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.gallery;
package me.minetsh.imaging.gallery.core;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
Expand All @@ -20,7 +20,7 @@
import java.util.List;

import me.minetsh.imaging.R;
import me.minetsh.imaging.widget.IMGViewHolderCallback;
import me.minetsh.imaging.gallery.widget.IMGViewHolderCallback;

/**
* Created by felix on 2018/1/5 下午1:51.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.minetsh.imaging.gallery;
package me.minetsh.imaging.gallery.core;

import android.os.AsyncTask;

import me.minetsh.imaging.IMGGalleryActivity;
import me.minetsh.imaging.gallery.model.IMGImageViewModel;

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;

import me.minetsh.imaging.gallery.IMGGalleryActivity;
import me.minetsh.imaging.gallery.core.model.IMGImageViewModel;

/**
* Created by felix on 2018/1/4 下午2:26.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.gallery;
package me.minetsh.imaging.gallery.core;

import android.content.ContentResolver;
import android.content.Context;
Expand All @@ -7,15 +7,16 @@
import android.net.Uri;
import android.provider.MediaStore;
import android.text.TextUtils;

import me.minetsh.imaging.gallery.model.IMGImageViewModel;
import android.util.Log;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import me.minetsh.imaging.gallery.core.model.IMGImageViewModel;

/**
* Created by felix on 2018/1/4 下午1:27.
*/
Expand Down Expand Up @@ -57,6 +58,8 @@ public static Map<String, List<IMGImageViewModel>> getImages14(Context context,
MediaStore.Images.Media.DATE_MODIFIED + " desc"
);

Log.i("++++", "" + cursor);

List<IMGImageViewModel> allInfos = new ArrayList<>();
images.put(ALL_IMAGES, allInfos);
if (cursor == null) {
Expand All @@ -68,10 +71,14 @@ public static Map<String, List<IMGImageViewModel>> getImages14(Context context,
cursor.getColumnIndex(MediaStore.Images.Media.SIZE)
);

Log.i("++++", "" + size);

String path = cursor.getString(
cursor.getColumnIndex(MediaStore.Images.Media.DATA)
);

Log.i("++++", "" + path);

if (size == 0 || TextUtils.isEmpty(path)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.gallery.model;
package me.minetsh.imaging.gallery.core.model;

import android.os.Parcel;
import android.os.Parcelable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.gallery.model;
package me.minetsh.imaging.gallery.core.model;

import android.net.Uri;
import android.os.Parcel;
Expand Down Expand Up @@ -114,4 +114,16 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) (isEdited ? 1 : 0));
dest.writeParcelable(uri, flags);
}

@Override
public String toString() {
return "IMGImageInfo{" +
"size=" + size +
", width=" + width +
", height=" + height +
", isOriginal=" + isOriginal +
", isEdited=" + isEdited +
", uri=" + uri +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.gallery.model;
package me.minetsh.imaging.gallery.core.model;

import android.net.Uri;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.minetsh.imaging.core.util;
package me.minetsh.imaging.gallery.utils;

import android.content.Context;
import android.content.pm.PackageManager;
Expand Down
Loading