当前位置: 首页>>代码示例>>C#>>正文


C# Activity.StartManagingCursor方法代码示例

本文整理汇总了C#中Android.App.Activity.StartManagingCursor方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.StartManagingCursor方法的具体用法?C# Activity.StartManagingCursor怎么用?C# Activity.StartManagingCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.App.Activity的用法示例。


在下文中一共展示了Activity.StartManagingCursor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: putNote

        // puts a note in the content provider
        // return uri
        public static Uri putNote(Activity activity, Note note)
        {
            // verify if the note is already in the content provider

            // TODO make the Query prettier (use querybuilder)
            Uri notes = Tomdroid.CONTENT_URI;
            string[] whereArgs = new string[1];
            whereArgs[0] = note.getGuid();

            // The note identifier is the guid
            ContentResolver cr = activity.ContentResolver;
            ICursor managedCursor = cr.Query(notes,
                    LIST_PROJECTION,
                    Note.GUID + "= ?",
                    whereArgs,
                    null);
            activity.StartManagingCursor(managedCursor);

            string title = note.getTitle();
            string xmlContent = note.getXmlContent();
            string plainContent = stringConverter.encode(Html.FromHtml(title + "\n" + xmlContent).ToString());

            // Preparing the values to be either inserted or updated
            // depending on the result of the previous Query
            ContentValues values = new ContentValues();
            values.Put(Note.TITLE, title);
            values.Put(Note.FILE, note.getFileName());
            values.Put(Note.GUID, note.getGuid().ToString());
            // Notice that we store the date in UTC because sqlite doesn't handle RFC3339 timezone information
            values.Put(Note.MODIFIED_DATE, note.getLastChangeDate().Format3339(false));
            values.Put(Note.NOTE_CONTENT, xmlContent);
            values.Put(Note.NOTE_CONTENT_PLAIN, plainContent);
            values.Put(Note.TAGS, note.getTags());

            Uri uri = null;

            if (managedCursor == null || managedCursor.Count == 0) {

                // This note is not in the database yet we need to insert it
                TLog.v(TAG, "A new note has been detected (not yet in db)");

                uri = cr.Insert(Tomdroid.CONTENT_URI, values);

                TLog.v(TAG, "Note inserted in content provider. ID: {0} TITLE:{1} GUID:{2}", uri, note.getTitle(),
                        note.getGuid());
            } else {

                TLog.v(TAG, "A local note has been detected (already in db)");

                cr.Update(Tomdroid.CONTENT_URI, values, Note.GUID+" = ?", whereArgs);

                uri = Uri.Parse(Tomdroid.CONTENT_URI+"/"+getNoteIdByGUID(activity, note.getGuid()));

                TLog.v(TAG, "Note updated in content provider: TITLE:{0} GUID:{1} TAGS:{2}", note.getTitle(), note.getGuid(), note.getTags());
            }
            managedCursor.Close();
            note = getNote(activity, uri);
            return uri;
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:61,代码来源:NoteManager.cs

示例2: getNoteByGuid

        // gets a note from the content provider, based on guid
        public static Note getNoteByGuid(Activity activity, string guid)
        {
            Uri notes = Tomdroid.CONTENT_URI;

            string[] whereArgs = new string[1];
            whereArgs[0] = guid;

            // The note identifier is the guid
            ContentResolver cr = activity.ContentResolver;
            ICursor cursor = cr.Query(notes,
                    FULL_PROJECTION,
                    Note.GUID + "= ?",
                    whereArgs,
                    null);
            activity.StartManagingCursor(cursor);
            if (cursor == null || cursor.Count == 0) {
                cursor.Close();
                return null;
            }
            else {
                cursor.MoveToFirst();
                string noteContent = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.NOTE_CONTENT));
                string noteTitle = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TITLE));
                string noteChangeDate = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.MODIFIED_DATE));
                string noteTags = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TAGS));
                string noteGUID = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.GUID));
                int noteDbid = cursor.GetInt(cursor.GetColumnIndexOrThrow(Note.ID));

                Note note = new Note();
                note.setTitle(noteTitle);
                note.setXmlContent(stripTitleFromContent(noteContent, noteTitle));
                note.setLastChangeDate(noteChangeDate);
                note.addTag(noteTags);
                note.setGuid(noteGUID);
                note.setDbId(noteDbid);
                cursor.Close();
                return note;
            }
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:40,代码来源:NoteManager.cs

示例3: noteExists

        // check in a note Exists in the content provider
        public static bool noteExists(Activity activity, string guid)
        {
            Uri notes = Tomdroid.CONTENT_URI;

            string[] whereArgs = new string[1];
            whereArgs[0] = guid;

            // The note identifier is the guid
            ContentResolver cr = activity.ContentResolver;
            ICursor cursor = cr.Query(notes,
                    ID_PROJECTION,
                    Note.GUID + "= ?",
                    whereArgs,
                    null);
            activity.StartManagingCursor(cursor);
            return (cursor != null && cursor.Count != 0);
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:18,代码来源:NoteManager.cs

示例4: getListAdapter

        public static IListAdapter getListAdapter(Activity activity, string querys, int selectedIndex)
        {
            bool includeNotebookTemplates = Preferences.GetBoolean(Preferences.Key.INCLUDE_NOTE_TEMPLATES);
            bool includeDeletedNotes = Preferences.GetBoolean(Preferences.Key.INCLUDE_DELETED_NOTES);

            int optionalQueries = 0;
            if(!includeNotebookTemplates)
                optionalQueries++;
            if(!includeDeletedNotes)
                optionalQueries++;

            string[] qargs = null;
            string where = "";
            int count = 0;

            if (querys != null ) {
                // sql statements to search notes
                string[] Query = querys.Split(" ");
                qargs = new string[Query.Length+optionalQueries];
                foreach (string str in Query) {
                    qargs[count++] = "%"+stringConverter.encode(str)+"%";
                    where = where + (where.Length > 0? " AND ":"")+"("+Note.NOTE_CONTENT_PLAIN+" LIKE ?)";
                }
            }
            else
                qargs = new string[optionalQueries];

            if (!includeDeletedNotes) {
                where += (where.Length > 0? " AND ":"")+"(" + Note.TAGS + " NOT LIKE ?)";
                qargs[count++] = "%system:deleted%";
            }
            if (!includeNotebookTemplates) {
                where += (where.Length > 0? " AND ":"")+"(" + Note.TAGS + " NOT LIKE ?)";
                qargs[count++] = "%system:template%";
            }

            // get a cursor representing all notes from the NoteProvider
            Uri notes = Tomdroid.CONTENT_URI;

            ContentResolver cr = activity.ContentResolver;
            ICursor notesCursor = cr.Query(notes,
                    LIST_PROJECTION,
                    where,
                    qargs,
                    sortOrder);
            activity.StartManagingCursor(notesCursor);

            // set up an adapter binding the TITLE field of the cursor to the list item
            string[] from = new string[] { Note.TITLE };
            int[] to = new int[] { Resource.Id.note_title };
            return new NoteListCursorAdapter(activity, Resource.layout.main_list_item, notesCursor, from, to, selectedIndex);
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:52,代码来源:NoteManager.cs


注:本文中的Android.App.Activity.StartManagingCursor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。