Commit 2f543fef authored by 林生雨's avatar 林生雨

commit

parent aaca203f
This diff is collapsed.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gengmei_flutter_plugin">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application>
<activity android:name=".act.VideoActivity" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
......@@ -10,4 +13,5 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
......@@ -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.VideoActivity
import com.example.gengmei_flutter_plugin.result.ResultManager
import com.example.gengmei_flutter_plugin.sharedPrefernces.SharedManager
import com.example.gengmei_flutter_plugin.utils.DebugUtil
......@@ -64,6 +65,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
const val GET_FLOAT_SHARED = "GET_FLOAT_SHARED"
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 CLEAR_SHARE = "CLEAR_SHARE"
const val PREMISSION = 10090
......@@ -238,6 +240,14 @@ class GengmeiFlutterPlugin : MethodCallHandler {
quit_page = true;
ResultManager.getInstance().resultSuccess(resultKey, true)
}
ALBUM_PLAY_VIDEO -> {
val path = call.arguments as String?
path?.run {
val intent = Intent(resign.context(), VideoActivity::class.java)
intent.putExtra("PATH", this)
resign.activity().startActivity(intent)
}
}
else -> result.notImplemented()
}
}
......
......@@ -44,8 +44,8 @@ class ImageRespository {
val fileDir = Environment.getExternalStorageDirectory().absolutePath + "/.GMAlbum/.album";
fun scareImg(realPath: String): Observable<Pair<String, String>> {
return Observable.create(ObservableOnSubscribe<Pair<String, String>> {
val pair = Pair<String,String>(realPath,MyUtil.scareImg(realPath, 200f, fileDir + "/" + getFileName(realPath)!! + ".png", 75))
return Observable.create(ObservableOnSubscribe<Pair<String, String>> {
val pair = Pair<String, String>(realPath, MyUtil.scareImg(realPath, 200f, fileDir + "/" + getFileName(realPath)!! + ".png", 75))
it.onNext(pair)
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
......@@ -112,13 +112,15 @@ class ImageRespository {
var currentSize = 0;
var letSize = 10
var noPathSize = 0;
recordImageListMap.forEach {
val any = it["path"]
if (it["realPath"] == null) {
return@forEach
for (map in recordImageListMap) {
// recordImageListMap.forEach {
if (map["realPath"] == null) {
continue
}
val realPath = it["realPath"] as String
globalThreadPool.execute {
val it = map
val any = it["path"]
val realPath = it["realPath"] as String
if (any == null) {
Log.e("lsy", " THREADMAME " + Thread.currentThread().name)
val tempFilePngString = fileDir + "/" + getFileName(realPath)!! + ".png";
......
package com.example.gengmei_flutter_plugin.act
import android.os.Bundle
import android.provider.CalendarContract
import android.support.v7.app.AppCompatActivity
import android.widget.LinearLayout
import android.widget.MediaController
import android.widget.VideoView
import com.example.gengmei_flutter_plugin.R
import com.example.gengmei_flutter_plugin.utils.MyUtil
/**
* @author lsy
* @date 2019-11-01
*/
class VideoActivity : AppCompatActivity() {
lateinit var videoView: VideoView
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.FLUTTERAPPTHEMEM)
MyUtil.setTransparent(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.video_act)
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();
}
override fun onResume() {
super.onResume()
videoView.start()
}
}
\ No newline at end of file
......@@ -12,6 +12,14 @@ import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.lang.Exception
import android.view.ViewGroup
import android.support.v4.view.ViewCompat.setFitsSystemWindows
import android.app.Activity
import android.view.WindowManager
import android.os.Build
import android.annotation.TargetApi
import android.graphics.Color
import android.view.View
/**
......@@ -126,6 +134,54 @@ class MyUtil {
}
return filePath
}
/**
* 设置状态栏全透明
*
* @param activity 需要设置的activity
*/
fun setTransparent(activity: Activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return
}
transparentStatusBar(activity)
setRootView(activity)
}
/**
* 使状态栏透明
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
private fun transparentStatusBar(activity: Activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
//需要设置这个flag contentView才能延伸到状态栏
activity.window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
//状态栏覆盖在contentView上面,设置透明使contentView的背景透出来
activity.window.statusBarColor = Color.TRANSPARENT
} else {
//让contentView延伸到状态栏并且设置状态栏颜色透明
activity.window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
}
/**
* 设置根布局参数
*/
private fun setRootView(activity: Activity) {
val parent = activity.findViewById<View>(android.R.id.content) as ViewGroup
var i = 0
val count = parent.childCount
while (i < count) {
val childView = parent.getChildAt(i)
if (childView is ViewGroup) {
childView.setFitsSystemWindows(true)
childView.clipToPadding = true
}
i++
}
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main"
>
<View
android:layout_width="1sp"
android:layout_height="0dp"
android:layout_weight="1"/>
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:layout_width="1sp"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
\ No newline at end of file
<resources>
<!-- Base application theme. -->
<style name="FLUTTERAPPTHEMEM" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
......@@ -30,9 +30,11 @@ Map<String, List<ScanImageItem>> paseAlbum(Object event) {
list.forEach((listMap) {
var map2 = Map<String, dynamic>.from(listMap);
ScanImageItem item = new ScanImageItem();
item.path = map2["path"];
item.path = map2["path"] ?? "";
item.realPath = map2["realPath"] ?? "";
item.isVideo = map2["isVideo"] == "T" ? true : false;
item.during = map2["during"] ?? "0";
item.size = map2["size"] ?? 0;
scanList.add(item);
});
newMap[k] = scanList;
......@@ -96,10 +98,32 @@ class AlbumModel {
// }
// });
// }
compute(paseAlbum, event).then((value) {
_mainValue = value;
albumLive.notifyView(_mainValue[_nowDirName]);
});
// if (Platform.isAndroid) {
// var map = (event as Map);
// //Map<String, List<ScanImageItem>>
// if (_mainValue == null || _mainValue.length == 0) {
// _mainValue = map;
// } else {
// _mainValue.forEach((k, itemList) {
// var key = map[k];
// if (key != null) {
// for (int i = 0; i < itemList.length; i++) {
// if (key[i] == null) {
// continue;
// }
// itemList[i].path = key[i]["path"];
// itemList[i].realPath = key[i]["realPath"];
// }
// }
// });
// }
// albumLive.notifyView(_mainValue[_nowDirName]);
// } else {
compute(paseAlbum, event).then((value) {
_mainValue = value;
albumLive.notifyView(_mainValue[_nowDirName]);
});
// }
// _mainValue=newMap;
// var list = map[_nowDirName];
......@@ -351,8 +375,11 @@ class AlbumModel {
String path;
if (Platform.isAndroid) {
path = albumLive.data[index].realPath;
Navigator.push(context, CustomRoute(AlbumPreviewPage(path, pageName)));
if (albumLive.data[index].isVideo) {
GengmeiFlutterPlugin.playAlbumVideo(path);
} else {
Navigator.push(context, CustomRoute(AlbumPreviewPage(path, pageName)));
}
} else {
path = albumLive.data[index].path;
if (albumLive.data[index].isVideo) {
......
......@@ -183,8 +183,8 @@ class AlbumState extends State<AlbumPage> {
}
return GestureDetector(
onTap: (){
// _model.previewItem(context, newIndex, "pageName");
_model.clickItem(context, newIndex);
_model.previewItem(context, newIndex, "pageName");
// _model.clickItem(context, newIndex);
},
child: Container(
decoration: BoxDecoration(
......
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