protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.RequestWindowFeature(WindowFeatures.IndeterminateProgress); this.SetContentView(Resource.Layout.SimpleItemLayout); this.Prefs = Prefs.From(this); this.payloadRadioGroup = this.FindViewById <RadioGroup>(Resource.Id.group_payload_type); this.itemsListView = this.FindViewById <ListView>(Resource.Id.items_list); this.itemsListView.OnItemClickListener = this; this.scopeParentCheckBox = this.FindViewById <CheckBox>(Resource.Id.checkbox_scope_parent); this.scopeSelfCheckBox = this.FindViewById <CheckBox>(Resource.Id.checkbox_scope_self); this.scopeChildrenCheckBox = this.FindViewById <CheckBox>(Resource.Id.checkbox_scope_children); this.ScopeContainer = this.FindViewById <LinearLayout>(Resource.Id.container_scope); this.FieldNamEditText = this.FindViewById <EditText>(Resource.Id.field_item_field); this.ItemFieldEditText = this.FindViewById <EditText>(Resource.Id.field_item); this.ItemFieldLabel = this.FindViewById <TextView>(Resource.Id.label); this.GetItemsButton = this.FindViewById <Button>(Resource.Id.button_get_item); this.FieldNameContainer = this.FindViewById <LinearLayout>(Resource.Id.container_item_field); this.PayloadContainer = this.FindViewById <LinearLayout>(Resource.Id.container_payload); }
private async void UploadImage(Android.Net.Uri data) { var imageNameField = this.FindViewById <EditText>(Resource.Id.field_media_item_name); var imagePathField = this.FindViewById <EditText>(Resource.Id.field_media_item_path); var imageName = imageNameField.Text; var imagePath = imagePathField.Text; if (string.IsNullOrWhiteSpace(imageName)) { Toast.MakeText(this, "Please select image name before upload", ToastLength.Long).Show(); return; } if (data == null) { Toast.MakeText(this, "Please select image before upload", ToastLength.Long).Show(); return; } try { this.SetProgressBarIndeterminateVisibility(true); using (ISitecoreWebApiSession session = Prefs.From(this).Session) { using (Stream stream = ContentResolver.OpenInputStream(this.imageUri)) { var builder = ItemWebApiRequestBuilder.UploadResourceRequestWithParentPath(imagePath) .ItemDataStream(stream) .ContentType("image/jpg") .ItemName(imageName) .FileName("bugaga.jpg"); var response = await session.UploadMediaResourceAsync(builder.Build()); if (response != null && response.ResultCount > 0) { DialogHelper.ShowSimpleDialog(this, "Image uploaded", "Image path : " + response[0].Path); } else { var title = this.GetString(Resource.String.text_error); DialogHelper.ShowSimpleDialog(this, title, "Failed to upload image"); } } } this.SetProgressBarIndeterminateVisibility(false); } catch (System.Exception exception) { this.SetProgressBarIndeterminateVisibility(false); var title = this.GetString(Resource.String.text_error); DialogHelper.ShowSimpleDialog(this, title, exception.Message); } }
private async void GetRenderingHtml() { var sourceIdField = this.FindViewById <EditText>(Resource.Id.field_source_id); var renderingIdField = this.FindViewById <EditText>(Resource.Id.field_rendering_id); var sourceId = sourceIdField.Text; var renderingId = renderingIdField.Text; if (string.IsNullOrWhiteSpace(sourceId)) { Toast.MakeText(this, "Please enter source ID", ToastLength.Long).Show(); return; } if (string.IsNullOrWhiteSpace(renderingId)) { Toast.MakeText(this, "Please enter rendering ID", ToastLength.Long).Show(); return; } try { this.SetProgressBarIndeterminateVisibility(true); using (ISitecoreWebApiSession session = Prefs.From(this).Session) { var request = ItemWebApiRequestBuilder.RenderingHtmlRequestWithSourceAndRenderingId(sourceId, renderingId) .Build(); var response = await session.ReadRenderingHtmlAsync(request); if (response != null) { var reader = new StreamReader(response); string html = await reader.ReadToEndAsync(); this.webview.LoadDataWithBaseURL(null, html, null, null, null); } else { var title = this.GetString(Resource.String.text_error); DialogHelper.ShowSimpleDialog(this, title, "Failed load rendering html"); } } this.SetProgressBarIndeterminateVisibility(false); } catch (System.Exception exception) { this.SetProgressBarIndeterminateVisibility(false); var title = this.GetString(Resource.String.text_error); DialogHelper.ShowSimpleDialog(this, title, exception.Message); } }
private async void DownloadImage(string itemPath, string widthStr, string heightStr) { if (string.IsNullOrEmpty(itemPath)) { DialogHelper.ShowSimpleDialog(this, Resource.String.text_error, Resource.String.text_empty_path); return; } try { IMediaOptionsBuilder builder = new MediaOptionsBuilder().Set; if (!string.IsNullOrEmpty(widthStr)) { var width = Int32.Parse(widthStr); builder.Width(width); } if (!string.IsNullOrEmpty(heightStr)) { var height = Int32.Parse(heightStr); builder.Height(height); } var requestBuilder = ItemWebApiRequestBuilder.DownloadResourceRequestWithMediaPath(itemPath); IDownloadMediaOptions options = builder.Build(); if (!options.IsEmpty) { requestBuilder.DownloadOptions(options); } this.SetProgressBarIndeterminateVisibility(true); using (var session = Prefs.From(this).Session) { var response = await session.DownloadMediaResourceAsync(requestBuilder.Build()); this.SetProgressBarIndeterminateVisibility(false); using (var imageBitmap = await BitmapFactory.DecodeStreamAsync(response)) { this.targetImageView.SetImageBitmap(imageBitmap); } } } catch (Exception exception) { this.SetProgressBarIndeterminateVisibility(false); var title = this.GetString(Resource.String.text_item_received); DialogHelper.ShowSimpleDialog(this, title, exception.Message); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.RequestWindowFeature(WindowFeatures.IndeterminateProgress); SetContentView(Resource.Layout.activity_delete_item); this.Title = GetString(Resource.String.text_delete_item); this.prefs = Prefs.From(this); var deleteItemByIdButton = FindViewById <Button>(Resource.Id.button_delete_by_id); deleteItemByIdButton.Click += (sender, args) => this.DeleteItemById(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.RequestWindowFeature(WindowFeatures.IndeterminateProgress); this.SetContentView(Resource.Layout.activity_create_item); this.Prefs = Prefs.From(this); this.ItemField = this.FindViewById <EditText>(Resource.Id.field_item); this.ItemNameField = this.FindViewById <EditText>(Resource.Id.field_item_name); this.ItemTitleFieldValue = this.FindViewById <EditText>(Resource.Id.field_item_title_field_name); this.ItemTextFieldValue = this.FindViewById <EditText>(Resource.Id.field_item_text_field_value); var createItemButton = this.FindViewById <Button>(Resource.Id.button_create_item); var updateCreatedItemButton = this.FindViewById <Button>(Resource.Id.button_update_created_item); createItemButton.Click += (sender, args) => this.PerformCreateRequest(); updateCreatedItemButton.Click += (sender, args) => this.PerformUpdateCreatedItemRequest(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.RequestWindowFeature(WindowFeatures.IndeterminateProgress); this.SetContentView(Resource.Layout.SimpleItemLayout); this.Prefs = Prefs.From(this); this.itemsListView = this.FindViewById <ListView>(Resource.Id.items_list); this.itemsListView.OnItemClickListener = this; this.FieldNamEditText = this.FindViewById <EditText>(Resource.Id.field_item_field); this.ItemFieldEditText = this.FindViewById <EditText>(Resource.Id.field_item); this.ItemFieldLabel = this.FindViewById <TextView>(Resource.Id.label); this.GetItemsButton = this.FindViewById <Button>(Resource.Id.button_get_item); this.FieldNameContainer = this.FindViewById <LinearLayout>(Resource.Id.container_item_field); }