Skip to content

Instantly share code, notes, and snippets.

View Char0394's full-sized avatar

Charlin Agramonte Char0394

View GitHub Profile
<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<local:VideoPlayerView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
AbsoluteLayout.LayoutBounds="0, 0, 1, 0.9" x:Name="videoPlayer"
AbsoluteLayout.LayoutFlags="All" />
<StackLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
AbsoluteLayout.LayoutBounds="0, 0, 1, 0.9"
AbsoluteLayout.LayoutFlags="All"
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SelectMultiIpleImagesApp.MainPage"
xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"
xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
<ContentPage.Content>
<StackLayout Padding="20">
<Button TextColor="White" BackgroundColor="Blue" Text="Select From Gallery" Clicked="Handle_Clicked"/>
public partial class MainPage : ContentPage
{
List<string> _images = new List<string>();
public MainPage()
{
InitializeComponent();
//Remember to remove the temporal files
//DependencyService.Get<IMediaService>().ClearFiles(_images);
}
await DependencyService.Get<IMediaService>().OpenGallery();
public interface IMediaService
{
Task OpenGallery();
}
[assembly: Xamarin.Forms.Dependency(typeof(MediaService))]
namespace SelectMultiIpleImagesApp.Droid
{
public class MediaService : Java.Lang.Object, IMediaService
{
public async Task OpenGallery()
{
try
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Storage);
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.selectmultiipleimagesapp">
<uses-sdk android:minSdkVersion="15" />
<application android:label="SelectMultiIpleImagesApp">
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == OPENGALLERYCODE && resultCode == Result.Ok)
{
List<string> images = new List<string>();
if (data != null)
{
public static class ImageHelpers
{
public static string SaveFile(string collectionName, byte[] imageByte, string fileName)
{
var fileDir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), collectionName);
if (!fileDir.Exists())
{
fileDir.Mkdirs();
}
void IMediaService.ClearFiles(List<string> filePaths)
{
foreach (var p in filePaths)
{
if (Directory.Exists(p))
{
File.Delete(p);
}
}
}