Commit f0733818 authored by 林生雨's avatar 林生雨

commit

parent 2f543fef
This diff is collapsed.
......@@ -50,4 +50,5 @@ dependencies {
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
}
......@@ -3,6 +3,7 @@
<application>
<activity android:name=".act.VideoActivity" />
<activity android:name=".act.PreviewActivity"/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
......
......@@ -14,6 +14,7 @@ import android.provider.MediaStore
import android.support.v4.content.FileProvider
import android.util.Log
import android.widget.Toast
import com.example.gengmei_flutter_plugin.act.PreviewActivity
import com.example.gengmei_flutter_plugin.act.VideoActivity
import com.example.gengmei_flutter_plugin.result.ResultManager
import com.example.gengmei_flutter_plugin.sharedPrefernces.SharedManager
......@@ -66,6 +67,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
const val GET_BOOLEAN_SHARED = "GET_BOOLEAN_SHARED"
const val GET_STRINGLIST_SHARED = "GET_STRINGLIST_SHARED"
const val ALBUM_PLAY_VIDEO = "play_album_video"
const val PREVIEW_IMAGE = "PREVIEW_IMAGE"
const val CLEAR_SHARE = "CLEAR_SHARE"
const val PREMISSION = 10090
......@@ -248,6 +250,24 @@ class GengmeiFlutterPlugin : MethodCallHandler {
resign.activity().startActivity(intent)
}
}
PREVIEW_IMAGE -> {
val result = resultKey;
val path = call.arguments as String?
path?.run {
val intent=Intent(resign.activity(),PreviewActivity::class.java)
intent.putExtra("PATH",this)
resign.activity().startActivity(intent)
ResultManager.getInstance().resultSuccess(result, true)
// ImageRespository.getInstance().getPreviewImg(resign.context().applicationContext,this, 800.0f).subscribe({
// val resutlMap=HashMap<String,String>(5);
// resutlMap.put("path",path)
// resutlMap.put("realImagePath",it)
// ResultManager.getInstance().resultSuccess(result, resutlMap);
// }, {
// DebugUtil.printStackTrace(it);
// }).addTo(disposable);
}
}
else -> result.notImplemented()
}
}
......@@ -357,7 +377,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// 最后通知图库更新
resign.context().applicationContext.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.fromFile(nativeImage)))
ImageRespository.getInstance().recordImageListMap.add(map)
ImageRespository.getInstance().recordImageListMap.add(0,map)
ResultManager.getInstance().resultSuccess(gotoNativeCameraKey, map);
}, {
DebugUtil.printStackTrace(it)
......
......@@ -19,5 +19,6 @@ data class MediaFile(
var realPath: String? = null,
var isVideo: Boolean? = null,
var width: Int? = 0,
var height: Int? = 0
var height: Int? = 0,
var degree: Int? = 0
)
......@@ -30,7 +30,9 @@ class ImageScanner(var context: Context) : AbsMediaScanner<MediaFile>(context) {
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.SIZE,
MediaStore.Audio.Media._ID)
MediaStore.Audio.Media._ID,
MediaStore.Images.Media.ORIENTATION
)
override val selection: String
get() =
......@@ -63,7 +65,8 @@ class ImageScanner(var context: Context) : AbsMediaScanner<MediaFile>(context) {
val folderName = cursor.getString(1)
val dateToken = cursor.getLong(2)
val size = cursor.getLong(3)
val id = cursor.getInt(4);
val id = cursor.getInt(4)
val degree = cursor.getInt(5)
val mediaFile = MediaFile()
mediaFile.id = id
// mediaFile.mime = mime
......@@ -73,6 +76,7 @@ class ImageScanner(var context: Context) : AbsMediaScanner<MediaFile>(context) {
mediaFile.size = size
mediaFile.realPath = path
mediaFile.isVideo = false
mediaFile.degree = degree
// val dir = Environment.getExternalStorageDirectory().absolutePath + "/GMAlbum/.album";
//// val dir = getImageCacheDir(context, Luban.DEFAULT_DISK_CACHE_DIR)!!.absolutePath;
// val tempFilePngString = dir + "/" + getFileName(path)!! + ".png";
......
......@@ -3,11 +3,13 @@ package com.example.gengmei_flutter_plugin.ImagePlugin.repository.local;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.media.ExifInterface;
import android.provider.MediaStore;
import android.util.Log;
import com.example.myimagepicker.bean.MediaFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
......
package com.example.gengmei_flutter_plugin.act
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.example.gengmei_flutter_plugin.R
import com.example.gengmei_flutter_plugin.act.view.PinchImageView
import com.example.gengmei_flutter_plugin.utils.MyUtil
/**
* @author lsy
* @date 2019-11-02
*/
class PreviewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.FLUTTERAPPTHEMEM)
MyUtil.setTransparent(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.preview_act)
findViewById<LinearLayout>(R.id.main).setBackgroundColor(0xff000000.toInt())
val path=intent.getStringExtra("PATH")
if(path==null){
finish()
}else{
Glide.with(this).load(path).into(findViewById<PinchImageView>(R.id.image))
}
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.example.gengmei_flutter_plugin.utils.MyUtil
class VideoActivity : AppCompatActivity() {
lateinit var videoView: VideoView
var pathIsNull = false;
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.FLUTTERAPPTHEMEM)
......@@ -25,15 +26,22 @@ class VideoActivity : AppCompatActivity() {
findViewById<LinearLayout>(R.id.main).setBackgroundColor(0xff000000.toInt());
videoView = findViewById(R.id.video)
val path = intent.getStringExtra("PATH")
videoView.setVideoPath(path);
val mediaController = MediaController(this);
videoView.setMediaController(mediaController);
videoView.requestFocus();
if (path == null) {
pathIsNull = true
finish()
} else {
videoView.setVideoPath(path);
val mediaController = MediaController(this);
videoView.setMediaController(mediaController);
videoView.requestFocus();
}
}
override fun onResume() {
super.onResume()
videoView.start()
if (!pathIsNull) {
videoView.start()
}
}
}
\ No newline at end of file
......@@ -19,7 +19,13 @@ import android.view.WindowManager
import android.os.Build
import android.annotation.TargetApi
import android.graphics.Color
import android.graphics.Matrix
import android.view.View
import android.R.attr.bitmap
import android.opengl.ETC1.getHeight
import android.opengl.ETC1.getWidth
/**
......@@ -31,6 +37,7 @@ class MyUtil {
companion object {
val matrix = Matrix()
fun getImageCacheDir(context: Context, cacheName: String): File? {
val cacheDir = context.externalCacheDir
if (cacheDir != null) {
......@@ -88,7 +95,7 @@ class MyUtil {
return filePath
}
fun scareImg(imgPath: String, scareSize: Float, filePath: String, quality: Int): String {
fun scareImg(imgPath: String, scareSize: Float, filePath: String, quality: Int,degree:Int): String {
val newOpts = BitmapFactory.Options()
// 开始读入图片,此时把options.inJustDecodeBounds 设回true,即只读边不读内容
newOpts.inJustDecodeBounds = true
......@@ -123,7 +130,16 @@ class MyUtil {
val file = File(filePath)
try {
val out = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.PNG, quality, out)
if(degree!=0){
matrix.reset()
matrix.postRotate(degree.toFloat());
val resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.width, bitmap.height, matrix, true)
resizedBitmap.compress(Bitmap.CompressFormat.PNG, quality, out)
resizedBitmap.recycle()
}else{
bitmap.compress(Bitmap.CompressFormat.PNG, quality, out)
}
out.flush()
out.close()
bitmap.recycle()
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.example.gengmei_flutter_plugin.act.view.PinchImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
\ No newline at end of file
......@@ -385,15 +385,16 @@ class AlbumModel {
if (albumLive.data[index].isVideo) {
GengmeiFlutterPlugin.playAlbumVideo(path);
} else {
if (previewItemClick) {
return;
}
previewItemClick = true;
iosItem(path, context, (value) {
var realPath = value["realImagePath"];
Navigator.push(
context, CustomRoute(AlbumPreviewPage(realPath, pageName)));
});
GengmeiFlutterPlugin.previewImage(path);
// if (previewItemClick) {
// return;
// }
// previewItemClick = true;
// iosItem(path, context, (value) {
// var realPath = value["realImagePath"];
// Navigator.push(
// context, CustomRoute(AlbumPreviewPage(realPath, pageName)));
// });
}
// Navigator.push(
// context, CustomRoute(AlbumPreviewPage(albumLive.data[index].path, pageName)));
......@@ -401,14 +402,14 @@ class AlbumModel {
}
void iosItem(String path, BuildContext context, Function fun) {
GengmeiFlutterPlugin.ios_album_item(path).then((value) {
if (value != null) {
fun(Map<String, String>.from(value));
}
previewItemClick = false;
}).catchError((error) {
previewItemClick = false;
print(error);
});
// GengmeiFlutterPlugin.ios_album_item(path).then((value) {
// if (value != null) {
// fun(Map<String, String>.from(value));
// }
// previewItemClick = false;
// }).catchError((error) {
// previewItemClick = false;
// print(error);
// });
}
}
This diff is collapsed.
......@@ -12,7 +12,7 @@
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
@interface MyPlayerViewController()
@property(nonatomic)dispatch_queue_t queue;;
@property(nonatomic)dispatch_queue_t queue;
@end
@implementation MyPlayerViewController
......@@ -20,7 +20,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_SERIAL);
self.queue = dispatch_queue_create("com.GM", DISPATCH_QUEUE_SERIAL);
// UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// button.frame = CGRectMake(100, 100, 100, 100);
// [button setTitle:@"TICK" forState:UIControlStateNormal];
......
//
// MyPreviewController.h
// Pods
//
// Created by Apple on 2019/11/3.
//
#ifndef MyPreviewController_h
#define MyPreviewController_h
#endif /* MyPreviewController_h */
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
@interface MyPreviewController : UIViewController
-(void)setImagePre:(PHAsset*) assets;
- (void)setImagePrePath:(NSString*)path;
@end
//
// MyPreviewController.m
// gengmei_flutter_plugin
//
// Created by Apple on 2019/11/3.
//
#import <Foundation/Foundation.h>
#include "MyPreviewController.h"
@interface MyPreviewController()<UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView * scrollView;
@property (nonatomic, strong) UIView * titleView;
@property (nonatomic, strong) UILabel * titleLab;
@property (nonatomic, strong) NSMutableArray * playerArray;
@property (nonatomic, strong) UIImageView * videoOverLay;
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, assign) BOOL isHidden;
@property (nonatomic, strong) id timeObserver;
@property(nonatomic,strong)UIImageView* imageView;
@end
@implementation MyPreviewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
self.isHidden = NO;
_imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
_imageView.clipsToBounds = YES;
_imageView.contentMode = UIViewContentModeScaleAspectFit;
_imageView.contentScaleFactor = [[UIScreen mainScreen] scale];
_imageView.backgroundColor = [UIColor clearColor];
_imageView.tag = 1000;
[self.view addSubview:_imageView];
// [self configUI];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
#pragma mark - 手势处理
- (void)doubleTapGestureCallback:(UITapGestureRecognizer *)gesture
{
[self resetIndex];
UIScrollView *scrollView = [_scrollView viewWithTag:100+_index];
CGFloat zoomScale = scrollView.zoomScale;
if (zoomScale == scrollView.maximumZoomScale) {
zoomScale = 0;
} else {
zoomScale = scrollView.maximumZoomScale;
}
[UIView animateWithDuration:0.35 animations:^{
scrollView.zoomScale = zoomScale;
}];
}
#pragma mark - 图像加载|移除
- (void)setImagePrePath:(NSString*)path{
self->_imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfFile:path]];
}
- (void)setImagePre:(PHAsset*)asset
{
PHImageRequestOptions *imageRequestOption = [[PHImageRequestOptions alloc] init];
imageRequestOption.synchronous =NO;
imageRequestOption.networkAccessAllowed = YES;
imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeHighQualityFormat;
imageRequestOption.resizeMode=PHImageRequestOptionsResizeModeFast;
imageRequestOption.version=PHImageRequestOptionsVersionUnadjusted;
int picWidth=[asset pixelWidth];
int picHeight=[asset pixelHeight];
float tempScareSize=1;
float limit=1560.0;
float max=MAX(picWidth, picHeight);
if(max>limit){
tempScareSize=limit/max;
}
CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
self->_imageView.image = result;
}];
}
- (void)resetIndex
{
CGFloat pageWidth = _scrollView.frame.size.width;
_index = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
}
#pragma mark - UIScrollViewDelegate
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return [scrollView viewWithTag:1000];
}
#pragma mark -
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
......@@ -47,13 +47,13 @@ class ScanImagePlugn {
return await channel.invokeMethod("IOS_IMAGE_BY_PATH", path);
}
static Future<Map> ios_album_item(MethodChannel channel, String path) async {
return await channel.invokeMethod("IOS_IMAGE_ITEM", path);
}
static Future<bool> playAlbumVideo(MethodChannel channel, String path) async {
return await channel.invokeMethod("play_album_video", path);
}
static Future<bool> previewImage(MethodChannel channel, String path) async {
return await channel.invokeMethod("PREVIEW_IMAGE", path);
}
}
class ScanImageItem {
......
......@@ -27,8 +27,8 @@ class GengmeiFlutterPlugin {
return await ScanImagePlugn.ios_album_path(_channel, path);
}
static Future<Map> ios_album_item(String path) async {
return await ScanImagePlugn.ios_album_item(_channel, path);
static Future<bool> previewImage(String path) async {
return await ScanImagePlugn.previewImage(_channel, path);
}
static Future<bool> playAlbumVideo(String path) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment