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


C# ICursor.Close方法代码示例

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


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

示例1: cursorToList

 private static List<Transaction> cursorToList(ICursor c)
 {
     List<Transaction> transactions = new List<Transaction>();
     if (c != null)
     {
         while (c.MoveToNext())
         {
             Transaction purchase = BillingDB.createTransaction(c);
             transactions.Add(purchase);
         }
         c.Close();
     }
     return transactions;
 }
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:14,代码来源:TransactionManager.cs

示例2: OnSpeakersQueryComplete

		private void OnSpeakersQueryComplete (ICursor cursor)
		{
			try {
				mSpeakersCursor = true;
				// TODO: remove any existing speakers from layout, since this cursor
				// might be from a data change notification.
				ViewGroup speakersGroup = mRootView.FindViewById<ViewGroup> (Resource.Id.session_speakers_block);
				LayoutInflater inflater = Activity.LayoutInflater;
	
				bool hasSpeakers = false;
	
				while (cursor.MoveToNext()) {
					String speakerName = cursor.GetString (SpeakersQuery.SPEAKER_NAME);
					if (TextUtils.IsEmpty (speakerName)) {
						continue;
					}
	
					String speakerImageUrl = cursor.GetString (SpeakersQuery.SPEAKER_IMAGE_URL);
					String speakerCompany = cursor.GetString (SpeakersQuery.SPEAKER_COMPANY);
					String speakerUrl = cursor.GetString (SpeakersQuery.SPEAKER_URL);
					String speakerAbstract = cursor.GetString (SpeakersQuery.SPEAKER_ABSTRACT);
	
					String speakerHeader = speakerName;
					if (!TextUtils.IsEmpty (speakerCompany)) {
						speakerHeader += ", " + speakerCompany;
					}
	
					var speakerView = inflater.Inflate (Resource.Layout.speaker_detail, speakersGroup, false);
					var speakerHeaderView = speakerView.FindViewById<TextView> (Resource.Id.speaker_header);
					var speakerImgView = speakerView.FindViewById<ImageView> (Resource.Id.speaker_image);
					var speakerUrlView = speakerView.FindViewById<TextView> (Resource.Id.speaker_url);
					var speakerAbstractView = speakerView.FindViewById<TextView> (Resource.Id.speaker_abstract);
					
					if (!TextUtils.IsEmpty (speakerImageUrl)) {
						BitmapUtils.FetchImage (Activity, new Java.Lang.String (speakerImageUrl), null, null, (result) => {
							Activity.RunOnUiThread (() => {
								speakerImgView.SetImageBitmap (result);
							});
						});
					}
	
					speakerHeaderView.Text = speakerHeader;
					UIUtils.SetTextMaybeHtml (speakerAbstractView, speakerAbstract);
	
					if (!TextUtils.IsEmpty (speakerUrl)) {
						UIUtils.SetTextMaybeHtml (speakerUrlView, speakerUrl);
						speakerUrlView.Visibility = ViewStates.Visible;
					} else {
						speakerUrlView.Visibility = ViewStates.Gone;
					}
	
					speakersGroup.AddView (speakerView);
					hasSpeakers = true;
					mHasSummaryContent = true;
				}
	
				speakersGroup.Visibility = (hasSpeakers ? ViewStates.Visible : ViewStates.Gone);
	
				// Show empty message when all data is loaded, and nothing to show
				if (mSessionCursor && !mHasSummaryContent) {
					mRootView.FindViewById (Android.Resource.Id.Empty).Visibility = ViewStates.Visible;
				}
			} finally {
				if (null != cursor) {
					cursor.Close ();
				}
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:68,代码来源:SessionDetailFragment.cs

示例3: OnTrackQueryComplete

		/**
	     * Handle {@link TracksQuery} {@link Cursor}.
	     */
		private void OnTrackQueryComplete (ICursor cursor)
		{
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Use found track to build title-bar
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				activityHelper.SetActionBarTitle (new Java.Lang.String (cursor.GetString (TracksQuery.TRACK_NAME)));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (TracksQuery.TRACK_COLOR)));
			} finally {
				cursor.Close ();
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:18,代码来源:SessionDetailFragment.cs

示例4: OnSessionQueryComplete

		/**
	     * Handle {@link SessionsQuery} {@link Cursor}.
	     */
		private void OnSessionQueryComplete (ICursor cursor)
		{
			try {
				mSessionCursor = true;
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Format time block this session occupies
				long blockStart = cursor.GetLong (SessionsQuery.BLOCK_START);
				long blockEnd = cursor.GetLong (SessionsQuery.BLOCK_END);
				String roomName = cursor.GetString (SessionsQuery.ROOM_NAME);
				String subtitle = UIUtils.FormatSessionSubtitle (blockStart, blockEnd, roomName, Activity);
	
				mTitleString = cursor.GetString (SessionsQuery.TITLE);
				mTitle.Text = mTitleString;
				mSubtitle.Text = subtitle;
	
				mUrl = cursor.GetString (SessionsQuery.URL);
				if (TextUtils.IsEmpty (mUrl)) {
					mUrl = "";
				}
	
				mHashtag = cursor.GetString (SessionsQuery.HASHTAG);
				mTagDisplay = mRootView.FindViewById<TextView> (Resource.Id.session_tags_button);
				if (!TextUtils.IsEmpty (mHashtag)) {
					// Create the button text
					SpannableStringBuilder sb = new SpannableStringBuilder ();
					sb.Append (GetString (Resource.String.tag_stream) + " ");
					int boldStart = sb.Length ();
					sb.Append (GetHashtagsString ());
					sb.SetSpan (sBoldSpan, boldStart, sb.Length (), SpanTypes.ExclusiveExclusive);
	
					mTagDisplay.Text = (string)sb;
					mTagDisplay.Click += (sender, e) => {
						Intent intent = new Intent (Activity, typeof(TagStreamActivity));
						intent.PutExtra (TagStreamFragment.EXTRA_QUERY, GetHashtagsString ());
						StartActivity (intent);	
					};
					
				} else {
					mTagDisplay.Visibility = ViewStates.Gone;
				}
	
				mRoomId = cursor.GetString (SessionsQuery.ROOM_ID);
	
				// Unregister around setting checked state to avoid triggering
				// listener since change isn't user generated.
				mStarred.CheckedChange += null;
				mStarred.Checked = cursor.GetInt (SessionsQuery.STARRED) != 0;
				mStarred.CheckedChange += HandleCheckedChange;
	
				String sessionAbstract = cursor.GetString (SessionsQuery.ABSTRACT);
				if (!TextUtils.IsEmpty (sessionAbstract)) {
					UIUtils.SetTextMaybeHtml (mAbstract, sessionAbstract);
					mAbstract.Visibility = ViewStates.Visible;
					mHasSummaryContent = true;
				} else {
					mAbstract.Visibility = ViewStates.Gone;
				}
	
				View requirementsBlock = mRootView.FindViewById (Resource.Id.session_requirements_block);
				String sessionRequirements = cursor.GetString (SessionsQuery.REQUIREMENTS);
				if (!TextUtils.IsEmpty (sessionRequirements)) {
					UIUtils.SetTextMaybeHtml (mRequirements, sessionRequirements);
					requirementsBlock.Visibility = ViewStates.Visible;
					mHasSummaryContent = true;
				} else {
					requirementsBlock.Visibility = ViewStates.Gone;
				}
	
				// Show empty message when all data is loaded, and nothing to show
				if (mSpeakersCursor && !mHasSummaryContent) {
					mRootView.FindViewWithTag (Android.Resource.Id.Empty).Visibility = ViewStates.Visible;
				}
	
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTitleString);
	
				UpdateLinksTab (cursor);
				UpdateNotesTab ();
	
			} finally {
				cursor.Close ();
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:88,代码来源:SessionDetailFragment.cs

示例5: OnQueryComplete

		/**
	     * {@inheritDoc}
	     */
		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
				return;
			}
	
			if (token == SessionsQuery._TOKEN) {
				OnSessionQueryComplete (cursor);
			} else if (token == TracksQuery._TOKEN) {
				OnTrackQueryComplete (cursor);
			} else if (token == SpeakersQuery._TOKEN) {
				OnSpeakersQueryComplete (cursor);
			} else {
				cursor.Close ();
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:19,代码来源:SessionDetailFragment.cs

示例6: OnQueryComplete

		/**
	     * {@inheritDoc}
	     */
		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
				return;
			}
	
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				mNameString = cursor.GetString (VendorsQuery.NAME);
				mName.Text = mNameString;
	
				// Unregister around setting checked state to avoid triggering
				// listener since change isn't user generated.
				mStarred.CheckedChange += null;
				mStarred.Checked = cursor.GetInt (VendorsQuery.STARRED) != 0;
				mStarred.CheckedChange += HandleCheckedChange;
	
				// Start background fetch to load vendor logo
				String logoUrl = cursor.GetString (VendorsQuery.LOGO_URL);
	
				if (!TextUtils.IsEmpty (logoUrl)) {
					BitmapUtils.FetchImage (Activity, new Java.Lang.String (logoUrl), null, null, (result) => {
						Activity.RunOnUiThread (() => {
							if (result == null) {
								mLogo.Visibility = ViewStates.Gone;
							} else {
								mLogo.Visibility = ViewStates.Visible;
								mLogo.SetImageBitmap (result);
							}
						});
					});
				}
	
				mUrl.Text = cursor.GetString (VendorsQuery.URL);
				mDesc.Text = cursor.GetString (VendorsQuery.DESC);
				mProductDesc.Text = cursor.GetString (VendorsQuery.PRODUCT_DESC);
	
				mTrackId = cursor.GetString (VendorsQuery.TRACK_ID);
	
				// Assign track details when found
				// TODO: handle vendors not attached to track
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				activityHelper.SetActionBarTitle (new Java.Lang.String (cursor.GetString (VendorsQuery.TRACK_NAME)));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (VendorsQuery.TRACK_COLOR)));
	
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sandbox/Vendors/" + mNameString);
	
			} finally {
				cursor.Close ();
			}
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:57,代码来源:VendorDetailFragment.cs

示例7: OnQueryComplete

		protected override void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			var listener = mListener == null ? null : mListener.Target as AsyncQueryListener;
	        if (listener != null) {
	            listener.OnQueryComplete(token, cookie, cursor);
	        } else if (cursor != null) {
	            cursor.Close();
	        }
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:9,代码来源:NotifyingAsyncQueryHandler.cs

示例8: OnQueryComplete

		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
	            return;
	        }
			
			Day day = (Day) cookie;
			
			// Clear out any existing sessions before inserting again
	        day.BlocksView.RemoveAllBlocks();
			
			try {
	            while (cursor.MoveToNext()) {
	                string type = cursor.GetString(BlocksQuery.BLOCK_TYPE);
	                
					// TODO: place random blocks at bottom of entire layout
					int column;
					try {
						column = TypeColumnMap[type];
					} catch {
						continue;
					}
	                
	                string blockId = cursor.GetString(BlocksQuery.BLOCK_ID);
	                string title = cursor.GetString(BlocksQuery.BLOCK_TITLE);
	                long start = cursor.GetLong(BlocksQuery.BLOCK_START);
	                long end = cursor.GetLong(BlocksQuery.BLOCK_END);
	                bool containsStarred = cursor.GetInt(BlocksQuery.CONTAINS_STARRED) != 0;
	
	                BlockView blockView = new BlockView(Activity, blockId, title, start, end, containsStarred, column);
	
	                int sessionsCount = cursor.GetInt(BlocksQuery.SESSIONS_COUNT);
					
	                if (sessionsCount > 0) {
	                    blockView.Click += HandleClick;
	                } else {
	                    blockView.Focusable = false;
	                    blockView.Enabled = false;
	                    LayerDrawable buttonDrawable = (LayerDrawable) blockView.Background;
	                    buttonDrawable.GetDrawable(0).SetAlpha(DISABLED_BLOCK_ALPHA);
	                    buttonDrawable.GetDrawable(2).SetAlpha(DISABLED_BLOCK_ALPHA);
	                }
	
	                day.BlocksView.AddView(blockView);
	            }
	        } finally {
	            cursor.Close();
	        }

		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:50,代码来源:ScheduleFragment.cs

示例9: OnTrackQueryComplete

		/**
	     * Handle {@link TracksQuery} {@link Cursor}.
	     */
		private void OnTrackQueryComplete (ICursor cursor)
		{
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Use found track to build title-bar
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				String trackName = cursor.GetString (TracksQuery.TRACK_NAME);
				activityHelper.SetActionBarTitle (new Java.Lang.String (trackName));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (TracksQuery.TRACK_COLOR)));
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Tracks/" + trackName);
			} finally {
				cursor.Close ();
			}
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:20,代码来源:SessionsFragment.cs

示例10: OnQueryComplete

		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
				return;
			}
	
			if (token == VendorsQuery._TOKEN || token == SearchQuery._TOKEN) {
				OnVendorsOrSearchQueryComplete (cursor);
			} else if (token == TracksQuery._TOKEN) {
				OnTrackQueryComplete (cursor);
			} else {
				cursor.Close ();
			}
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:14,代码来源:VendorsFragment.cs

示例11: DeleteAllRecordsFromProvider

        /*
           This helper function Deletes all records from both database tables using the ContentProvider.
           It also queries the ContentProvider to make sure that the database has been successfully
           Deleted, so it cannot be used until the Query and Delete functions have been written
           in the ContentProvider.

           Students: Replace the calls to DeleteAllRecordsFromDB with this one after you have written
           the Delete functionality in the ContentProvider.
         */
        public void DeleteAllRecordsFromProvider()
        {
            context.ContentResolver.Delete (
                WeatherContractOpen.WeatherEntryOpen.CONTENT_URI,
                null,
                null
            );
            context.ContentResolver.Delete (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null,
                null
            );

            cursor = context.ContentResolver.Query (
                WeatherContractOpen.WeatherEntryOpen.CONTENT_URI,
                null,
                null,
                null,
                null
            );
            Assert.AreEqual (0, cursor.Count, "Error: Records not Deleted from Weather table during Delete");
            cursor.Close ();

            cursor = context.ContentResolver.Query (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null,
                null,
                null,
                null
            );
            Assert.AreEqual (0, cursor.Count, "Error: Records not Deleted from Location table during Delete");
            cursor.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:42,代码来源:TestProvider.cs

示例12: testUpdateLocation

        /*
        This test uses the provider to insert and then update the data. Uncomment this test to
        see if your update location is functioning correctly.
         */
        public void testUpdateLocation()
        {
            const string LOG_TAG = "Provider Test";

            // Create a new map of values, where column names are the keys
            ContentValues values = TestUtilitiesOpen.createNorthPoleLocationValues ();

            Android.Net.Uri locationUri = context.ContentResolver.
                        Insert (WeatherContractOpen.LocationEntryOpen.CONTENT_URI, values);
            long locationRowId = ContentUris.ParseId (locationUri);

            // Verify we got a row back.
            Assert.IsTrue (locationRowId != -1);
            Log.Debug (LOG_TAG, "New row id: " + locationRowId);

            ContentValues updatedValues = new ContentValues (values);
            updatedValues.Put (WeatherContractOpen.LocationEntryOpen._ID, locationRowId);
            updatedValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME, "Santa's Village");

            // Create a cursor with observer to make sure that the content provider is notifying
            // the observers as expected
            var location = context.ContentResolver.Query (WeatherContractOpen.LocationEntryOpen.CONTENT_URI, null, null, null, null);

            TestUtilitiesOpen.TestContentObserver tco = TestUtilitiesOpen.getTestContentObserver ();
            location.RegisterContentObserver (tco);

            int count = context.ContentResolver.Update (
                            WeatherContractOpen.LocationEntryOpen.CONTENT_URI, updatedValues, WeatherContractOpen.LocationEntryOpen._ID + "= ?",
                            new String[] { locationRowId.ToString () });
            Assert.AreEqual (count, 1);

            // Test to make sure our observer is called.  If not, we throw an assertion.
            //
            // Students: If your code is failing here, it means that your content provider
            // isn't calling getContext().ContentResolver.notifyChange(uri, null);
            tco.waitForNotificationOrFail ();

            location.UnregisterContentObserver (tco);
            location.Close ();

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null,   // projection
                WeatherContractOpen.LocationEntryOpen._ID + " = " + locationRowId,
                null,   // Values for the "where" clause
                null    // sort order
            );

            Assert.IsTrue (location.MoveToFirst (), "Cursor is empty");
            TestUtilitiesOpen.validateCurrentRecord ("testUpdateLocation.  Error validating location entry update.",
                cursor, updatedValues);

            cursor.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:59,代码来源:TestProvider.cs

示例13: testBulkInsert

        public void testBulkInsert()
        {
            // first, let's create a location value
            ContentValues testValues = TestUtilitiesOpen.createNorthPoleLocationValues ();
            Android.Net.Uri locationUri = context.ContentResolver.Insert (WeatherContractOpen.LocationEntryOpen.CONTENT_URI, testValues);
            long locationRowId = ContentUris.ParseId (locationUri);

            // Verify we got a row back.
            Assert.IsTrue (locationRowId != -1);

            // Data's inserted.  IN THEORY.  Now pull some out to stare at it and verify it made
            // the round trip.

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                null  // sort order
            );

            Assert.IsTrue (cursor.MoveToFirst (), "Cursor is empty");
            TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert. Error validating WeatherContractOpen.LocationEntryOpen.",
                cursor, testValues);

            // Now we can bulkInsert some weather.  In fact, we only implement BulkInsert for weather
            // entries.  With ContentProviders, you really only have to implement the features you
            // use, after all.
            ContentValues[] bulkInsertContentValues = createBulkInsertWeatherValues (locationRowId);

            // Register a content observer for our bulk insert.
            TestUtilitiesOpen.TestContentObserver weatherObserver = TestUtilitiesOpen.getTestContentObserver ();
            context.ContentResolver.RegisterContentObserver (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, true, weatherObserver);

            int insertCount = context.ContentResolver.BulkInsert (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, bulkInsertContentValues);

            // Students:  If this fails, it means that you most-likely are not calling the
            // getContext().ContentResolver.notifyChange(uri, null); in your BulkInsert
            // ContentProvider method.
            weatherObserver.waitForNotificationOrFail ();
            context.ContentResolver.UnregisterContentObserver (weatherObserver);

            Assert.AreEqual (insertCount, BULK_INSERT_RECORDS_TO_INSERT);

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.WeatherEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                WeatherContractOpen.WeatherEntryOpen.COLUMN_DATE + " ASC"  // sort order == by DATE ASCENDING
            );

            // we should have as many records in the database as we've inserted
            Assert.AreEqual (cursor.Count, BULK_INSERT_RECORDS_TO_INSERT);

            // and let's make sure they match the ones we created
            cursor.MoveToFirst ();
            for (int i = 0; i < BULK_INSERT_RECORDS_TO_INSERT; i++, cursor.MoveToNext ()) {
                TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert.  Error validating WeatherContractOpen.WeatherEntryOpen " + i,
                    cursor, bulkInsertContentValues [i]);
            }
            cursor.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:65,代码来源:TestProvider.cs


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