private MatrixCursor PreferenceToCursor <T>(T value) where T : Java.Lang.Object { MatrixCursor matrixCursor = new MatrixCursor(PREFERENCE_COLUMNS, 1); MatrixCursor.RowBuilder builder = matrixCursor.NewRow(); builder.Add(value); return(matrixCursor); }
/** * Add a representation of a file to a cursor. * * @param result the cursor to modify * @param docId the document ID representing the desired file (may be null if given file) * @param file the File object representing the desired file (may be null if given docID) */ void IncludeFile(MatrixCursor result, string docId, File file) { if (docId == null) { docId = GetDocIdForFile(file); } else { file = GetFileForDocId(docId); } DocumentContractFlags flags = (DocumentContractFlags)0; if (file.IsDirectory) { // Request the folder to lay out as a grid rather than a list. This also allows a larger // thumbnail to be displayed for each image. // flags |= Document.FLAG_DIR_PREFERS_GRID; // Add FLAG_DIR_SUPPORTS_CREATE if the file is a writable directory. if (file.IsDirectory && file.CanWrite()) { flags |= DocumentContractFlags.DirSupportsCreate; } } else if (file.CanWrite()) { // If the file is writable set FLAG_SUPPORTS_WRITE and // FLAG_SUPPORTS_DELETE flags |= DocumentContractFlags.SupportsWrite; flags |= DocumentContractFlags.SupportsDelete; } string displayName = file.Name; string mimeType = GetTypeForFile(file); if (mimeType.StartsWith("image/")) { // Allow the image to be represented by a thumbnail rather than an icon flags |= DocumentContractFlags.SupportsThumbnail; } MatrixCursor.RowBuilder row = result.NewRow(); row.Add(DocumentsContract.Document.ColumnDocumentId, docId); row.Add(DocumentsContract.Document.ColumnDisplayName, displayName); row.Add(DocumentsContract.Document.ColumnSize, file.Length()); row.Add(DocumentsContract.Document.ColumnMimeType, mimeType); row.Add(DocumentsContract.Document.ColumnLastModified, file.LastModified()); row.Add(DocumentsContract.Document.ColumnFlags, (int)flags); // Add a custom icon row.Add(DocumentsContract.Document.ColumnIcon, Resource.Drawable.icon); }
public override ICursor RunQueryOnBackgroundThread(ICharSequence constraint) { MatrixCursor cursor = new MatrixCursor(mFields); if (constraint == null) { MatrixCursor.RowBuilder builder = cursor.NewRow(); builder.Add("0"); builder.Add("Enter a place"); } else { List <string> suggestions = GetSuggestions(constraint.ToString()).Result; for (int i = 0; i < suggestions.Count; i++) { MatrixCursor.RowBuilder builder = cursor.NewRow(); builder.Add(i.ToString()); builder.Add(suggestions[i]); } } return(cursor); }
/// <summary> /// The matrix cursor. /// </summary> /// <param name="projection"> /// The projection. /// </param> /// <param name="intProjection"> /// The int projection. /// </param> /// <param name="entries"> /// The entries. /// </param> /// <returns> /// The Android.Database.MatrixCursor. /// </returns> private static MatrixCursor MatrixCursor( string[] projection, ApezProjection[] intProjection, ZipFileEntry[] entries) { var mc = new MatrixCursor(projection, entries.Length); foreach (ZipFileEntry zer in entries) { MatrixCursor.RowBuilder rb = mc.NewRow(); for (int i = 0; i < intProjection.Length; i++) { switch (intProjection[i]) { case ApezProjection.File: rb.Add(i); break; case ApezProjection.FileName: rb.Add(zer.FilenameInZip); break; case ApezProjection.ZipFile: rb.Add(zer.ZipFileName); break; case ApezProjection.Modification: rb.Add(ZipFile.DateTimeToDosTime(zer.ModifyTime)); break; case ApezProjection.Crc: rb.Add(zer.Crc32); break; case ApezProjection.CompressedLength: rb.Add(zer.CompressedSize); break; case ApezProjection.UncompressedLength: rb.Add(zer.FileSize); break; case ApezProjection.CompressionType: rb.Add((int)zer.Method); break; } } } return(mc); }
public MatrixCursor GetNowShowingMovieList() { string[] columns = new string[] { "ID", "Title" }; MatrixCursor cursor = new MatrixCursor(columns); SearchContainerWithDates <SearchMovie> results = client.GetMovieNowPlayingListAsync().Result; foreach (SearchMovie result in results.Results) { MatrixCursor.RowBuilder builder = cursor.NewRow(); builder.Add(result.Id); builder.Add(result.Title); } return(cursor); }
public override ICursor QueryRoots(string[] projection) { Log.Verbose(TAG, "queryRoots"); // Create a cursor with either the requested fields, or the default projection. This // cursor is returned to the Android system picker UI and used to display all roots from // this provider. var result = new MatrixCursor(ResolveRootProjection(projection)); // If user is not logged in, return an empty root cursor. This removes our provider from // the list entirely. if (!IsUserLoggedIn()) { return(result); } // It's possible to have multiple roots (e.g. for multiple accounts in the same app) - // just add multiple cursor rows. // Construct one row for a root called "MyCloud". MatrixCursor.RowBuilder row = result.NewRow(); row.Add(DocumentsContract.Root.ColumnRootId, ROOT); row.Add(DocumentsContract.Root.ColumnSummary, Context.GetString(Resource.String.root_summary)); // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating // documents. FLAG_SUPPORTS_RECENTS means your application's most recently used // documents will show up in the "Recents" category. FLAG_SUPPORTS_SEARCH allows users // to search all documents the application shares. row.Add(DocumentsContract.Root.ColumnFlags, (int)DocumentRootFlags.SupportsCreate | (int)DocumentRootFlags.SupportsRecents | (int)DocumentRootFlags.SupportsSearch); // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider). row.Add(DocumentsContract.Root.ColumnTitle, Context.GetString(Resource.String.app_name)); // This document id must be unique within this provider and consistent across time. The // system picker UI may save it and refer to it later. row.Add(DocumentsContract.Root.ColumnDocumentId, GetDocIdForFile(mBaseDir)); // The child MIME types are used to filter the roots and only present to the user roots // that contain the desired type somewhere in their file hierarchy. row.Add(DocumentsContract.Root.ColumnMimeTypes, GetChildMimeTypes(mBaseDir)); row.Add(DocumentsContract.Root.ColumnAvailableBytes, mBaseDir.FreeSpace); row.Add(DocumentsContract.Root.ColumnIcon, Resource.Drawable.icon); return(result); }
public override ICursor QueryChildDocuments(string parentDocumentId, string[] projection, string sortOrder) { System.Diagnostics.Debug.WriteLine($"QUERY CHILD DOCUMENTS {parentDocumentId} - {projection} - {sortOrder}"); var result = new MatrixCursor(projection ?? DEFAULT_DOCUMENT_PROJECTION); var row = result.NewRow(); row.Add(DocumentsContract.Document.ColumnDocumentId, "root/testfile"); row.Add(DocumentsContract.Document.ColumnMimeType, "application/octet-stream"); row.Add(DocumentsContract.Document.ColumnDisplayName, "Test file"); row.Add(DocumentsContract.Document.ColumnLastModified, null); row.Add(DocumentsContract.Document.ColumnFlags, (int)DocumentContractFlags.SupportsMove); row.Add(DocumentsContract.Document.ColumnSize, null); return(result); }
public override ICursor QueryRoots(string[] projection) { System.Diagnostics.Debug.WriteLine($"QUERY ROOTS {projection}"); var result = new MatrixCursor(projection ?? DEFAULT_ROOT_PROJECTION); var row = result.NewRow(); row.Add(DocumentsContract.Root.ColumnRootId, "root"); //row.Add(DocumentsContract.Root.ColumnSummary, "AutoActive archives"); row.Add(DocumentsContract.Root.ColumnFlags, (int)DocumentRootFlags.LocalOnly); row.Add(DocumentsContract.Root.ColumnIcon, Resource.Drawable.Icon); row.Add(DocumentsContract.Root.ColumnTitle, "AutoActive"); row.Add(DocumentsContract.Root.ColumnDocumentId, GetDocIDForFile(archivesRoot)); //row.Add(DocumentsContract.Root.ColumnMimeTypes, "application/octet-stream\n*/*"); //row.Add(DocumentsContract.Root.ColumnAvailableBytes, archivesRoot.FreeSpace); return(result); }
public override ICursor QueryRoots(string[] projection) { // Create a cursor with either the requested fields, or the default projection. This // cursor is returned to the Android system picker UI and used to display all roots from // this provider. var result = new MatrixCursor(ResolveRootProjection(projection)); // It's possible to have multiple roots (e.g. for multiple accounts in the same app) - // just add multiple cursor rows. Construct one row for a root. var row = result.NewRow(); row.Add(DocumentsContract.Root.ColumnRootId, Root); // Если не задано, то показывается размер. //row.Add(DocumentsContract.Root.ColumnSummary, Context.GetString(Resource.String.root_summary)); // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating // documents. FLAG_SUPPORTS_RECENTS means your application's most recently used // documents will show up in the "Recents" category. FLAG_SUPPORTS_SEARCH allows users // to search all documents the application shares. row.Add(DocumentsContract.Root.ColumnFlags, (int)DocumentRootFlags.SupportsCreate | (int)DocumentRootFlags.SupportsRecents | (int)DocumentRootFlags.SupportsSearch); // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider). row.Add(DocumentsContract.Root.ColumnTitle, System.IO.Path.DirectorySeparatorChar.ToString()); // This document id must be unique within this provider and consistent across time. The // system picker UI may save it and refer to it later. row.Add(DocumentsContract.Root.ColumnDocumentId, GetDocIdForFile(_baseFolder)); // The child MIME types are used to filter the roots and only present to the user roots // that contain the desired type somewhere in their file hierarchy. //row.Add(DocumentsContract.Root.ColumnMimeTypes, // "image/*\ntext/*\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document\n"); row.Add(DocumentsContract.Root.ColumnAvailableBytes, _baseFolder?.FreeSpace ?? 0); row.Add(DocumentsContract.Root.ColumnIcon, Resource.Mipmap.ic_launcher); return(result); }
public override ICursor QueryRoots (string[] projection) { Log.Verbose (TAG, "queryRoots"); // Create a cursor with either the requested fields, or the default projection. This // cursor is returned to the Android system picker UI and used to display all roots from // this provider. var result = new MatrixCursor (ResolveRootProjection (projection)); // If user is not logged in, return an empty root cursor. This removes our provider from // the list entirely. if (!IsUserLoggedIn ()) { return result; } // It's possible to have multiple roots (e.g. for multiple accounts in the same app) - // just add multiple cursor rows. // Construct one row for a root called "MyCloud". MatrixCursor.RowBuilder row = result.NewRow (); row.Add (DocumentsContract.Root.ColumnRootId, ROOT); row.Add (DocumentsContract.Root.ColumnSummary, Context.GetString (Resource.String.root_summary)); // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating // documents. FLAG_SUPPORTS_RECENTS means your application's most recently used // documents will show up in the "Recents" category. FLAG_SUPPORTS_SEARCH allows users // to search all documents the application shares. row.Add (DocumentsContract.Root.ColumnFlags, (int)DocumentRootFlags.SupportsCreate | (int)DocumentRootFlags.SupportsRecents | (int)DocumentRootFlags.SupportsSearch); // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider). row.Add (DocumentsContract.Root.ColumnTitle, Context.GetString (Resource.String.app_name)); // This document id must be unique within this provider and consistent across time. The // system picker UI may save it and refer to it later. row.Add (DocumentsContract.Root.ColumnDocumentId, GetDocIdForFile (mBaseDir)); // The child MIME types are used to filter the roots and only present to the user roots // that contain the desired type somewhere in their file hierarchy. row.Add (DocumentsContract.Root.ColumnMimeTypes, GetChildMimeTypes (mBaseDir)); row.Add (DocumentsContract.Root.ColumnAvailableBytes, mBaseDir.FreeSpace); row.Add (DocumentsContract.Root.ColumnIcon, Resource.Drawable.icon); return result; }
/** * Add a representation of a file to a cursor. * * @param result the cursor to modify * @param docId the document ID representing the desired file (may be null if given file) * @param file the File object representing the desired file (may be null if given docID) */ void IncludeFile (MatrixCursor result, string docId, File file) { if (docId == null) { docId = GetDocIdForFile (file); } else { file = GetFileForDocId (docId); } DocumentContractFlags flags = (DocumentContractFlags)0; if (file.IsDirectory) { // Request the folder to lay out as a grid rather than a list. This also allows a larger // thumbnail to be displayed for each image. // flags |= Document.FLAG_DIR_PREFERS_GRID; // Add FLAG_DIR_SUPPORTS_CREATE if the file is a writable directory. if (file.IsDirectory && file.CanWrite ()) { flags |= DocumentContractFlags.DirSupportsCreate; } } else if (file.CanWrite ()) { // If the file is writable set FLAG_SUPPORTS_WRITE and // FLAG_SUPPORTS_DELETE flags |= DocumentContractFlags.SupportsWrite; flags |= DocumentContractFlags.SupportsDelete; } string displayName = file.Name; string mimeType = GetTypeForFile (file); if (mimeType.StartsWith ("image/")) { // Allow the image to be represented by a thumbnail rather than an icon flags |= DocumentContractFlags.SupportsThumbnail; } MatrixCursor.RowBuilder row = result.NewRow (); row.Add (DocumentsContract.Document.ColumnDocumentId, docId); row.Add (DocumentsContract.Document.ColumnDisplayName, displayName); row.Add (DocumentsContract.Document.ColumnSize, file.Length ()); row.Add (DocumentsContract.Document.ColumnMimeType, mimeType); row.Add (DocumentsContract.Document.ColumnLastModified, file.LastModified ()); row.Add (DocumentsContract.Document.ColumnFlags, (int)flags); // Add a custom icon row.Add (DocumentsContract.Document.ColumnIcon, Resource.Drawable.icon); }
/// <summary> /// The matrix cursor. /// </summary> /// <param name="projection"> /// The projection. /// </param> /// <param name="intProjection"> /// The int projection. /// </param> /// <param name="entries"> /// The entries. /// </param> /// <returns> /// The Android.Database.MatrixCursor. /// </returns> private static MatrixCursor MatrixCursor( string[] projection, ApezProjection[] intProjection, ZipFileEntry[] entries) { var mc = new MatrixCursor(projection, entries.Length); foreach (ZipFileEntry zer in entries) { MatrixCursor.RowBuilder rb = mc.NewRow(); for (int i = 0; i < intProjection.Length; i++) { switch (intProjection[i]) { case ApezProjection.File: rb.Add(i); break; case ApezProjection.FileName: rb.Add(zer.FilenameInZip); break; case ApezProjection.ZipFile: rb.Add(zer.ZipFileName); break; case ApezProjection.Modification: rb.Add(ZipFile.DateTimeToDosTime(zer.ModifyTime)); break; case ApezProjection.Crc: rb.Add(zer.Crc32); break; case ApezProjection.CompressedLength: rb.Add(zer.CompressedSize); break; case ApezProjection.UncompressedLength: rb.Add(zer.FileSize); break; case ApezProjection.CompressionType: rb.Add((int)zer.Method); break; } } } return mc; }
private void IncludeFile(MatrixCursor result, string docId, File file, string parentDocumentId) { if (docId == null) { docId = GetDocIdForFile(file); } else { file = GetFileForDocumentId(docId); } var isDirectory = file.IsDirectory; var flags = GetFlags(file.CanWrite(), isDirectory); //if (isDirectory) //{ // // Request the folder to lay out as a grid rather than a list. This also allows a larger // // thumbnail to be displayed for each image (FLAG_DIR_PREFERS_GRID). // flags |= (int) DocumentContractFlags.DirPrefersGrid; //} var displayName = file.Name; var mimeType = GetTypeForFile(file); if (mimeType.StartsWith("image/")) { // Allow the image to be represented by a thumbnail rather than an icon flags |= (int)DocumentContractFlags.SupportsThumbnail; } var row = result.NewRow(); row.Add(DocumentsContract.Document.ColumnDocumentId, docId); row.Add(DocumentsContract.Document.ColumnDisplayName, displayName); row.Add(DocumentsContract.Document.ColumnMimeType, mimeType); row.Add(DocumentsContract.Document.ColumnLastModified, file.LastModified()); row.Add(DocumentsContract.Document.ColumnFlags, flags); var path = file.Path; long fileLength; if (isDirectory) { fileLength = file.TotalSpace; row.Add(DocumentsContract.Root.ColumnAvailableBytes, file.FreeSpace); if (path == ExternalStorageDirectoryPath) { row.Add(Sb49DocumentsContract.Document.ColumnExtraFlags, (int)DocumentContractExtraFlags.ExternalStorageDirectory); } } else { fileLength = file.Length(); } row.Add(DocumentsContract.Document.ColumnSize, fileLength); if (!string.IsNullOrEmpty(parentDocumentId)) { row.Add(Sb49DocumentsContract.Document.ColumnParentDocumentId, parentDocumentId); } }