private void createFile(string filename, Java.IO.File extStore)
        {
            Java.IO.File file = new Java.IO.File(extStore + "/" + filename + ".aes");

            if (filename.IndexOf(".") != -1)
            {
                try
                {
                    file.CreateNewFile();
                }
                catch (Java.IO.IOException e)
                {
                    // TODO Auto-generated catch block
                    Android.Util.Log.Error("lv", e.Message);
                }
                Android.Util.Log.Error("lv", "file created");
            }
            else
            {
                file.Mkdir();
                Android.Util.Log.Error("lv", "folder created");
            }

            file.Mkdirs();
        }
Пример #2
0
        public string SafeHTMLToPDF(string html, string filename)
        {
            var dir  = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/eNotes/");
            var file = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), filename + ".pdf");

            //var file = new Java.IO.File(dir + "/" + filename + ".pdf");

            if (!dir.Exists())
            {
                dir.Mkdirs();
            }


            int x = 0;

            /* while (file.Exists())
             * {
             *   x++;
             *   file = new Java.IO.File(dir + "/" + filename + "( " + x + " )" + ".pdf");
             * }*/

            if (webpage == null)
            {
                webpage = new Android.Webkit.WebView(MainActivity.mContext);
            }

            int width  = 2102;
            int height = 2973;

            webpage.Layout(0, 0, width, height);
            webpage.LoadDataWithBaseURL("", html, "text/html", "UTF-8", null);
            webpage.SetWebViewClient(new WebViewCallBack(file.ToString()));

            return(file.ToString());
        }
Пример #3
0
        public async Task <bool> SavePhotoAsync(byte[] data, string folder, string filename)
        {
            try
            {
                Java.IO.File picturesDirectory = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures);
                Java.IO.File folderDirectory   = picturesDirectory;

                if (!string.IsNullOrEmpty(folder))
                {
                    folderDirectory = new Java.IO.File(picturesDirectory, folder);
                    folderDirectory.Mkdirs();
                }

                using (Java.IO.File bitmapFile = new Java.IO.File(folderDirectory, filename))
                {
                    bitmapFile.CreateNewFile();

                    using (FileOutputStream outputStream = new FileOutputStream(bitmapFile))
                    {
                        await outputStream.WriteAsync(data);
                    }

                    // Make sure it shows up in the Photos gallery promptly.
                    MediaScannerConnection.ScanFile(Android.App.Application.Context,
                                                    new string[] { bitmapFile.Path },
                                                    new string[] { "image/png", "image/jpeg" }, null);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
        private static String setMkdir(Context context)
        {
            String filePath;

            if (checkSDCard())
            {
                filePath = Android.OS.Environment.GetExternalStoragePublicDirectory("").ToString() + @"/download";//File.Separator
            }
            else
            {
                filePath = context.CacheDir.AbsolutePath + @"/download";
            }
            Java.IO.File file = new Java.IO.File(filePath);
            if (!file.Exists())
            {
                Boolean b = file.Mkdirs();

                Log.Error("file", "目錄不存在  創建文件    " + b);
            }
            else
            {
                Log.Error("file", "目錄存在");
            }
            return(filePath);
        }
Пример #5
0
        public FileCache(Context context)
        {
            try
            {
                string stuff = Android.OS.Environment.ExternalStorageState;
                if (Android.OS.Environment.ExternalStorageState.Equals(Android.OS.Environment.MediaMounted))
                {
                    m_CacheDir = new File(Android.OS.Environment.ExternalStorageDirectory, "Android/data/" + context.ApplicationContext.PackageName);
                    m_CacheDir = context.ExternalCacheDir;
                }
                else
                {
                    m_CacheDir = context.CacheDir;
                }

                if (m_CacheDir == null)
                {
                    m_CacheDir = context.CacheDir;
                }



                if (!m_CacheDir.Exists())
                {
                    var success = m_CacheDir.Mkdirs();
                }
            }
            catch { }
        }
 private void CreateDirectoryForPictures()
 {
     dir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "Status-Share");
     if (!dir.Exists())
     {
         dir.Mkdirs();
     }
 }
 private void CreateDirectoryForPictures()
 {
     _dir = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "CameraAppDemo");
     if (!_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
Пример #8
0
 //Mediante este metodo verificamos si existe en directorio para guardar las fotografias en caso de no existir lo creamos
 private void CreateDirectoryForPictures()
 {
     _Directorio = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "FacebookDemo");
     if (!_Directorio.Exists())
     {
         _Directorio.Mkdirs();
     }
 }
 private void CreateDirectoryForPictures()
 {
     directory = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "CameraAppDemo");
     if (!directory.Exists())
     {
         directory.Mkdirs();
     }
 }
Пример #10
0
 private void CreateDirectoryForPictures()
 {
     _dir = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "CameraAppDemo");
     if (!_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
Пример #11
0
        void DirChecker(String dir)
        {
            var file = new Java.IO.File(_location + dir);

            if (!file.IsDirectory)
            {
                file.Mkdirs();
            }
        }
Пример #12
0
 private static void CreateDirectoryForPictures()
 {
     _dir = new Java.IO.File(
         Android.OS.Environment.GetExternalStoragePublicDirectory(
             Android.OS.Environment.DirectoryPictures), "LegionApp");
     if (!_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
Пример #13
0
 private void CreateDirectoryForPictures()
 {
     _dir = new Java.IO.File(
         Android.OS.Environment.GetExternalStoragePublicDirectory(
             Android.OS.Environment.DirectoryPictures), "JungleExplorer");
     if (!_dir.Exists())
     {
         _dir.Mkdirs( );
     }
 }
 private void CreateDirectoryForPictures()
 {
     _dir = new File(
         Environment.GetExternalStoragePublicDirectory(
             Environment.DirectoryPictures), "PlanetHeart");
     if (!_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
Пример #15
0
        public static void WritFile(string fileName, string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }
            string filePath = PATH + fileName;

            Java.IO.File file2 = new Java.IO.File(PATH);
            if (!file2.Exists())
            {
                try {
                    file2.Mkdirs();//.CreateNewFile();
                } catch (System.IO.IOException e)
                {
                }
            }

            Java.IO.File     file             = new Java.IO.File(filePath);
            FileOutputStream fileOutputStream = null;

            if (!file.Exists())
            {
                try
                {
                    file.CreateNewFile();
                    Runtime runtime = Runtime.GetRuntime();
                    runtime.Exec("chmod 0666 " + file);
                }
                catch (Java.Lang.Exception ex)
                {
                    Log.Info("create fall", ex.Message);
                }
            }
            try
            {
                fileOutputStream = new FileOutputStream(file);
                fileOutputStream.Write(Encoding.ASCII.GetBytes(data));
            }
            catch (Java.Lang.Exception e)
            {
                e.PrintStackTrace();
            }
            finally
            {
                try
                {
                    fileOutputStream.Close();
                }
                catch (Java.Lang.Exception e)
                {
                }
            }
        }
Пример #16
0
        private static File PegarArquivoImagem()
        {
            var diretorio = new Java.IO.File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "Imagens");

            if (!diretorio.Exists())
            {
                diretorio.Mkdirs();
            }

            return(new Java.IO.File(diretorio, "MinhaFoto.jpg"));
        }
Пример #17
0
        public static void WritFile2(string fileName, byte[] data)
        {
            if (data == null && data.Length > 0)
            {
                return;
            }
            Java.IO.File file2 = new Java.IO.File(PATH);
            if (!file2.Exists())
            {
                bool rss = file2.Mkdirs();
            }
            string filePath = PATH + fileName;

            Java.IO.File file = new Java.IO.File(filePath);
            if (!file.Exists())
            {
                try
                {
                    // String aaa=    mkdirs2(PATH);

                    file.CreateNewFile();
                    Runtime runtime = Runtime.GetRuntime();
                    runtime.Exec("chmod 0666 " + file);
                }
                catch (Java.Lang.Exception ex)
                {
                    ex.PrintStackTrace();
                }
            }
            RandomAccessFile randomAccessFile = null;

            try
            {
                randomAccessFile = new RandomAccessFile(filePath, "rw");
                randomAccessFile.Write(data);
            }
            catch (Java.Lang.Exception e)
            {
                e.PrintStackTrace();
            }
            finally
            {
                try
                {
                    if (randomAccessFile != null)
                    {
                        randomAccessFile.Close();
                    }
                }
                catch (Java.Lang.Exception e)
                {
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Return app cache directory
        /// </summary>
        /// <param name="context">Current context</param>
        /// <returns>Cache directory</returns>
        private static Java.IO.File GetDocumentCacheDir(Context context)
        {
            Java.IO.File dir = new Java.IO.File(context.CacheDir, "documents");

            if (!dir.Exists())
            {
                dir.Mkdirs();
            }

            return(dir);
        }
Пример #19
0
        public static void CopyAssetsToFolder(AssetManager assetManager, string sourceFolder, string destinationFolder)
        {
            string[] assets = assetManager.List(sourceFolder);

            File destFolderFile = new File(destinationFolder);

            if (!destFolderFile.Exists())
            {
                destFolderFile.Mkdirs();
            }
            CopyAsset(assetManager, sourceFolder, destinationFolder, assets);
        }
        public Java.IO.File CreateDirectoryForPictures()
        {
            Java.IO.File _dir = new Java.IO.File(
                Android.OS.Environment.GetExternalStoragePublicDirectory(
                    Android.OS.Environment.DirectoryPictures), "TheDataProjectImages");
            if (!_dir.Exists())
            {
                _dir.Mkdirs();
            }

            return(_dir);
        }
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.take_a_picture);
     FindViews();
     HandleEvents();
     imageDirectory = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "ImageDescription");
     if (!imageDirectory.Exists())
     {
         imageDirectory.Mkdirs();
     }
 }
        public override void OnCreate()
        {
            base.OnCreate();

            // TODO: Avoid file I/O in the main thread.
            var imagesDir = new File(FilesDir, "images");

            imagesDir.Mkdirs();
            mGifFile  = GetFileForResource(this, Resource.Raw.animated_gif, imagesDir, "image.gif");
            mPngFile  = GetFileForResource(this, Resource.Raw.dessert_android, imagesDir, "image.png");
            mWebpFile = GetFileForResource(this, Resource.Raw.animated_webp, imagesDir, "image.webp");
        }
Пример #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="requestCode"></param>
        /// <param name="resultCode"></param>
        /// <param name="data"></param>
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            //LoginActivity
            if (requestCode == TAKE_PHOTO_REQ && data != null)
            {
                if (resultCode == Result.Ok)
                {
                    try
                    {
                        Bitmap srcBitmap = (Bitmap)data.Extras.Get("data");
                        profilePic.SetImageBitmap(srcBitmap);

                        var sdpath = Application.Context.GetExternalFilesDir(null).AbsolutePath;

                        File folder = new File(sdpath + File.Separator + "Profile Images");

                        if (!folder.Exists())
                        {
                            folder.Mkdirs();
                        }

                        File file = new File(folder.AbsolutePath, auth.CurrentUser.Uid + ".jpg");


                        var stream = new FileStream(file.AbsolutePath, FileMode.Create);
                        srcBitmap.Compress(Bitmap.CompressFormat.Png, 80, stream);

                        //Upload to firestore
                        //var task = storage.Reference.Child("profile/").Child(auth.Uid).PutFile(Android.Net.Uri.FromFile(new File(path)));
                        var reference = db.Collection("users").Document(auth.CurrentUser.Uid);
                        reference.Update("PhotoUrl", file.AbsolutePath);

                        profilePic.SetImageBitmap(srcBitmap);
                        stream.Flush();
                        stream.Close();
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine("Error saving profile image: " + ex);
                    }
                    finally
                    {
                    }
                }
                else if (resultCode == Result.Canceled)
                {
                    ;
                }
            }
        }
        private void Save(string windowname)
        {
            if (windowname != "")
            {
                try
                {
                    Java.IO.File path = new Java.IO.File(App._dir, windowname);
                    if (!path.Exists())
                    {
                        path.Mkdirs();
                    }
                    else
                    {
                        MessageBox.Confirm(this, "警告", "该文件夹已存在,是否覆盖?", delegate
                        {
                            path.Mkdirs();
                        }, delegate { });
                    }

                    SavePics(path.ToString());

                    SaveResult.SaveGeologicalData(path.ToString());

                    SaveResult.SaveGeometricalData(path.ToString());

                    SaveResult.SaveStatisticalResult(path.ToString());

                    MessageBox.Show(this, "成功", "保存成功");
                }
                catch
                {
                    MessageBox.Show(this, "失败", "保存失败");
                }
            }
            else
            {
                MessageBox.Show(this, "注意", "测窗名称不能为空!");
            }
        }
Пример #25
0
        //Sid ADD
        private void DirCheck(string AppDir)
        {
            Java.IO.File AppDirCheck = new Java.IO.File(AppDir);
            bool         ap          = AppDirCheck.Exists();
            bool         si          = Directory.Exists(AppDir + "/Slides");
            bool         dc          = Directory.Exists(AppDir + "/Documents");

            if (!AppDirCheck.Exists() || !Directory.Exists(AppDir + "/Slides") || !Directory.Exists(AppDir + "/Documents"))
            {
                AppDirCheck.Mkdirs();
                Directory.CreateDirectory(AppDir + "/Slides");
                Directory.CreateDirectory(AppDir + "/Documents");
            }
        }
Пример #26
0
        public bool UnzipFiles(string path, string zipname)
        {
            var f = new Java.IO.File(path);

            if (!f.Exists())
            {
                f.Mkdir();
            }
            try
            {
                String filename;
                var    inputstream = System.IO.File.Open(Path.Combine(path, zipname + ".zip"), FileMode.Open);
                var    zis         = new Java.Util.Zip.ZipInputStream(inputstream);
                Java.Util.Zip.ZipEntry ze;
                byte[] buffer = new byte[1024];
                int    count;

                while ((ze = zis.NextEntry) != null)
                {
                    filename = ze.Name;
                    // Need to create directories if not exists, or
                    // it will generate an Exception...
                    if (ze.IsDirectory)
                    {
                        Java.IO.File fmd = new Java.IO.File(Path.Combine(Path.Combine(path, zipname), filename));
                        fmd.Mkdirs();
                        continue;
                    }

                    var fout = new Java.IO.FileOutputStream(Path.Combine(Path.Combine(path, zipname), filename));
                    while ((count = zis.Read(buffer)) != -1)
                    {
                        fout.Write(buffer, 0, count);
                    }

                    fout.Close();
                    zis.CloseEntry();
                }

                zis.Close();
            }
            catch (Java.IO.IOException iox)
            {
                System.Console.WriteLine(iox.Message);
                return(false);
            }

            return(true);
        }
Пример #27
0
        private static File PegarArquivoImagem()
        {
            File arquivoImagem;

            Java.IO.File diretorio = new Java.IO.File(
                Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "Imagens");

            if (!diretorio.Exists())
            {
                diretorio.Mkdirs();
            }

            arquivoImagem = new Java.IO.File(
                diretorio, "MinhaFoto.jpg");
            return(arquivoImagem);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
           
            global::Xamarin.Forms.Forms.Init(this, bundle);
            Xamarin.Forms.Forms.SetTitleBarVisibility(AndroidTitleBarVisibility.Never);
            curentActivity = this;
			CrossPushNotification.Initialize<CrossPushNotificationListener>("572461137328");
            ImageCircleRenderer.Init();
			AdvancedTimer.Forms.Plugin.Droid.AdvancedTimerImplementation.Init ();

            File testFile = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.ExternalStorageDirectory.ToString() + "/PurposeColor/");
            App.DownloadsPath = testFile.AbsolutePath + "/";
			var dir =  new Java.IO.File( App.DownloadsPath  );
			if (!dir.Exists ()) {
				dir.Mkdirs ();
			} else {

				// clearing temp storage of app.
				try {
					DateTime fileLastUse = DateTime.UtcNow.AddDays(-2); // DateTime.UtcNow.AddMinutes(-60); 
					DateTime fileCreateDate = DateTime.UtcNow.AddDays(-7); // DateTime.UtcNow.AddMinutes(-60); 
					System.IO.DirectoryInfo tempFileDir = new System.IO.DirectoryInfo(testFile.AbsolutePath);

					System.IO.FileInfo[] tempFiles = tempFileDir.GetFiles();
					foreach (System.IO.FileInfo tempFile in tempFiles)
					{
						try
						{
							if (tempFile.LastAccessTime < fileLastUse || tempFile.CreationTime < fileCreateDate)
							{
								System.IO.File.Delete(tempFile.FullName);
							}
						}
						catch (Exception ex) {
							var test = ex.Message;
						}
					}
				} catch (Exception ex) {
					var test = ex.Message;
				}
			}

            LoadApplication(new App());
        }
Пример #29
0
        public async Task <bool> SavePhotoAsnyc(byte[] data, string folder, string filename)
        {
            try
            {
                if (ContextCompat.CheckSelfPermission(MainActivity.Instance, Manifest.Permission.WriteExternalStorage) != PermissionChecker.PermissionGranted)
                {
                    ActivityCompat.RequestPermissions(MainActivity.Instance, new string[] { Manifest.Permission.WriteExternalStorage }, 1000);
                }


                File picturesDirectory = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures);
                File folderDirectory;

                if (!string.IsNullOrEmpty(folder))
                {
                    folderDirectory = new File(picturesDirectory.ToString(), folder);
                    folderDirectory.Mkdirs();
                }
                else
                {
                    folderDirectory = picturesDirectory;
                }

                using (File bitmapFile = new File("/storage/emulated/0/Download", filename))
                {
                    bitmapFile.CreateNewFile();

                    using (FileStream outputStream = new FileStream(bitmapFile.ToString(), FileMode.Open))
                    {
                        await outputStream.WriteAsync(data);
                    }

                    // Make sure it shows up in the Photos gallery promptly.
                    MediaScannerConnection.ScanFile(MainActivity.Instance,
                                                    new string[] { bitmapFile.Path },
                                                    new string[] { "image/png", "image/jpeg" }, null);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        private string GetFilename()
        {
            WvlLogger.Log(LogType.TraceAll, "GetFilename()");
            string filepath = Android.OS.Environment.ExternalStorageDirectory.Path;

            Java.IO.File file = new Java.IO.File(filepath, AUDIO_RECORDER_FOLDER);

            if (!file.Exists())
            {
                file.Mkdirs();
            }

            var result = (file.AbsolutePath + "/" + DateTime.Now.Millisecond.ToString() + AUDIO_RECORDER_FILE_EXT_WAV);

            wavFileName = result;
            WvlLogger.Log(LogType.TraceAll, "GetFilename() : " + result);
            return(result);
        }
Пример #31
0
        public void OnPictureTaken(byte[] data, Camera camera)
        {
            Java.IO.File ExternalStorageUserRootFolder;
            Java.IO.File ImageFolderExternalStorage;

            try
            {
                // Obtém o caminho da pasta raiz do aplicativo
                ExternalStorageUserRootFolder = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + Java.IO.File.Separator + "SeeLocker");

                // Obtém oc aminho da pasta de imagens do aplicativo
                var strImagePath = ExternalStorageUserRootFolder.ToString() + Java.IO.File.Separator + "Images";

                // Se a pasta de iamgens não existe
                if (!System.IO.Directory.Exists(strImagePath))
                {
                    // Cria a pasta de imagens
                    ImageFolderExternalStorage = new Java.IO.File(strImagePath);
                    ImageFolderExternalStorage.Mkdirs();
                }

                Android.Graphics.Bitmap bitmapPicture = Android.Graphics.BitmapFactory.DecodeByteArray(data, 0, data.Length);

                bitmapPictureBackup = Android.Graphics.BitmapFactory.DecodeByteArray(data, 0, data.Length);

                String PhotoName = String.Format("{0}.jpg", Guid.NewGuid());

                System.IO.Stream fos = new System.IO.FileStream(strImagePath + "/" + PhotoName, System.IO.FileMode.Create);
                bitmapPicture.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 50, fos);
                fos.Flush();
                fos.Close();
                bitmapPicture.Dispose();

                //Toast.MakeText(Application.Context, "Success", ToastLength.Long).Show();
            }

            catch (Exception ex)
            {
            }
            finally
            {
                camera.StartPreview();
            }
        }
Пример #32
0
        public string SafeHTMLToPDF(string html, string filename, int flag)
        {
            int width  = 0;
            int height = 0;

            Android.Webkit.WebView webpage = null;
            var dir  = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/KegIdFiles/");
            var file = new Java.IO.File(dir + "/" + filename + ".pdf");

            if (!dir.Exists())
            {
                dir.Mkdirs();
            }

            int x = 0;

            while (file.Exists())
            {
                x++;
                file = new Java.IO.File(dir + "/" + filename + "( " + x + " )" + ".pdf");
            }

            if (webpage == null)
            {
                webpage = new Android.Webkit.WebView(CrossCurrentActivity.Current.AppContext);
            }

            if (flag == 0)
            {
                width  = 2959;
                height = 3873;
            }
            else
            {
                width  = 3659;
                height = 4573;
            }
            webpage.Layout(0, 0, width, height);
            webpage.LoadDataWithBaseURL("", html, "text/html", "UTF-8", null);
            webpage.SetWebViewClient(new WebViewCallBack(file.ToString(), flag));

            return(file.ToString());
        }
		public override void OnCreate ()
		{
			base.OnCreate ();
			#region 极光推送相关
			//注册Jpush
			JPushInterface.SetDebugMode (true);
			JPushInterface.Init (ApplicationContext);
			//设置基本样式
			SetNotificationStyleBasic();
			//自定义推送通知栏样式 test
			SetNotificationStyleCustom();
			//设置保留最近5条通知
			JPushInterface.SetLatestNotificationNumber(ApplicationContext,5);
			#endregion
			#region imageloader 使用二级缓存
			//var configuration = ImageLoaderConfiguration.CreateDefault(ApplicationContext);//创建默认的ImageLoader配置参数 
			//使用自定义参数/sdcard/eldYoung
			//File  cacheDir = StorageUtils.GetOwnCacheDirectory(ApplicationContext, "/sdcard/eldYoung/Cache/HeadImage");  //自定义缓存路径
			var cachePath =  Android.OS.Environment.ExternalStorageDirectory.ToString()+"/"+"eldyoung/Cache/HeadImage/";
			Java.IO.File file = new Java.IO.File(cachePath);
			if(!file.Exists())
				file.Mkdirs();// 创建文件夹
			File  cacheDir = StorageUtils.GetOwnCacheDirectory(ApplicationContext, cachePath);  //自定义缓存路径
			var configuration = new ImageLoaderConfiguration.Builder(ApplicationContext).MemoryCacheExtraOptions(480,800)
				.ThreadPoolSize(3).ThreadPriority(Thread.NormPriority -2).DenyCacheImageMultipleSizesInMemory()
				.MemoryCache(new UsingFreqLimitedMemoryCache(2*1024*1024)).MemoryCacheSize(2 * 1024 * 1024).DiskCacheSize(50 * 1024 * 1024)
				.DiskCacheFileNameGenerator(new Md5FileNameGenerator()).TasksProcessingOrder(QueueProcessingType.Lifo).DiskCacheFileCount(100)
				.DiskCache(new UnlimitedDiskCache(cacheDir)).DefaultDisplayImageOptions(DisplayImageOptions.CreateSimple()).ImageDownloader(new BaseImageDownloader(ApplicationContext, 5 * 1000, 30 * 1000))
				.Build();
			ImageLoader.Instance.Init(configuration);

			#endregion

			#region 百度地图使用
			SDKInitializer.Initialize(ApplicationContext);
			#endregion

		}
Пример #34
0
		private void SetPicToLocalAndServer(Bitmap mBitmap) 
		{

			var sdStatus = Android.OS.Environment.ExternalStorageState;
			//检测sd是否可用
			if (!sdStatus.Equals (Android.OS.Environment.MediaMounted)) {
				return;
			}
			System.IO.FileStream MyFileStream = null;

			Java.IO.File file = new Java.IO.File(path);
			if(!file.Exists())
				file.Mkdirs();// 创建文件夹
			string fileName = path + "myHead.jpg";
			try{
				MyFileStream = new System.IO.FileStream(fileName, System.IO.FileMode.OpenOrCreate);  
				//保存照片  
				mBitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, MyFileStream); 

				byte[] buffer = new byte[MyFileStream.Length];
				// 设置当前流的位置为流的开始
				MyFileStream.Seek(0, SeekOrigin.Begin);
				MyFileStream.Read(buffer, 0, buffer.Length);


				var  headimgStr = Convert.ToBase64String(buffer);
				//调用restapi提交头像
				var headImgPostParam = new HeadImgPostParam () {
					UId = Global.MyInfo.UId,ImageStr = headimgStr
				};
				SetRestRequestParams (headImgPostParam);
				var restSharpRequestHelp = new RestSharpRequestHelp(headImgPostParam.Url,requestParams);
				restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => {
					if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK)
					{
						//获取并解析返回resultJson获取安全码结果值
						var result = response.Content;
						var headimgJson = JsonConvert.DeserializeObject<HeadImgJson>(result);
						if(headimgJson.statuscode == "1")
							Global.MyInfo.HeadImgUrl = headimgJson.data[0].HeadImgUrl;
						else
						{
							Activity.RunOnUiThread(()=>
								{
									Toast.MakeText(Activity,"头像上传失败",ToastLength.Short).Show();
								});
						}

					}
	
				});
			}
			catch(Java.IO.FileNotFoundException e) {
				e.PrintStackTrace ();
			}
			finally {
				MyFileStream.Flush ();
				MyFileStream.Close ();
			}	

		}
Пример #35
0
		//Mediante este metodo verificamos si existe en directorio para guardar las fotografias en caso de no existir lo creamos
		private void CreateDirectoryForPictures()
		{
			_Directorio = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "FacebookDemo");
			if (!_Directorio.Exists())
			{
				_Directorio.Mkdirs();
			}
		}
Пример #36
0
        public override void OnCreate()
        {
            base.OnCreate ();

                AndroidEnvironment.UnhandledExceptionRaiser += MyApp_UnhandledExceptionHandler;

                TapGlobal tapglobal = new TapGlobal (this);
                taputil= new TapUtil (this);
                GlobalVariable staticvalue = new GlobalVariable ();
                networknamager = new NetworkManager ();
                imagemanager = new ImageManager ();
                debugreport = new DebugReport (this);

                string databasename="tap5050seller.db";
                string path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/Tap5050/";
                Java.IO.File basefile = new Java.IO.File (global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath+"/Tap5050/");

                Java.IO.File internalbasefile = new Java.IO.File (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal));
                string appinternalpath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
                var personalpath=appinternalpath+databasename;

                bool success = true;
                if (!internalbasefile.Exists()){
                    success=internalbasefile.Mkdirs();
                    Java.IO.File file =new Java.IO.File(personalpath);
                    file.CreateNewFile ();
                }

                if (success){
                    databasemanager = new DatabaseManager (personalpath);
                }

                INSTANCE = this;
        }