예제 #1
0
        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);
        }
예제 #2
0
        /**
         * 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);
        }
예제 #4
0
파일: TMDbHandler.cs 프로젝트: xilef/oden
        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);
        }
예제 #5
0
        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 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);
        }