public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = fragment.Activity.LayoutInflater.Inflate(Resource.Layout.item_tilelist, null); } BandTile tile = mList[position]; ImageView tileImage = view.FindViewById <ImageView>(Resource.Id.imageTileListImage); TextView tileTitle = view.FindViewById <TextView>(Resource.Id.textTileListTitle); if (tile.TileIcon != null) { tileImage.SetImageBitmap(tile.TileIcon.Icon); } else { BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(fragment.Resources, Resource.Raw.badge)); tileImage.SetImageBitmap(tileIcon.Icon); } tileImage.SetBackgroundColor(Color.Blue); tileTitle.Text = tile.TileName; return(view); }
async Task AddTileAsync() { string tileName = "8Ball"; try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); //BandIcon badgeIcon = mCheckboxBadging.Checked ? BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)) : null; BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); uuid = Java.Util.UUID.RandomUUID(); BandTile tile = new BandTile.Builder(uuid, tileName, tileIcon) .SetTileSmallIcon(badgeIcon) // .SetTheme(mCheckboxCustomTheme.Checked ? mThemeView.Theme : null) .Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(this, tile); if (result) { Toast.MakeText(this, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(this, "Add tile", ex); } // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(this, "Add tile", e); } }
private async void OnAddTileClick(object sender, EventArgs e) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } BandTile tile = builder.Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } }
private async void OnAddBarcodeButtonClick(object sender, EventArgs e) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); // create layout 1 Barcode barcode1 = new Barcode(new PageRect(0, 0, 221, 70), BarcodeType.Code39); barcode1.Margins = new Margins(3, 0, 0, 0); barcode1.ElementId = 11; TextBlock textBlock1 = new TextBlock(new PageRect(0, 0, 230, 30), TextBlockFont.Small, 0); textBlock1.Color = Color.Red; textBlock1.ElementId = 21; FlowPanel flowPanel1 = new FlowPanel(new PageRect(15, 0, 245, 105), FlowPanelOrientation.Vertical); flowPanel1.AddElements(barcode1); flowPanel1.AddElements(textBlock1); PageLayout pageLayout1 = new PageLayout(flowPanel1); // create layout 2 Barcode barcode2 = new Barcode(0, 0, 221, 70, BarcodeType.Pdf417); barcode2.Margins = new Margins(3, 0, 0, 0); barcode2.ElementId = 11; TextBlock textBlock2 = new TextBlock(0, 0, 230, 30, TextBlockFont.Small, 0); textBlock2.Color = Color.Red; textBlock2.ElementId = 21; FlowPanel flowPanel2 = new FlowPanel(15, 0, 245, 105, FlowPanelOrientation.Vertical); flowPanel2.AddElements(barcode2); flowPanel2.AddElements(textBlock2); PageLayout pageLayout2 = new PageLayout(flowPanel2); // create the tile BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } builder.SetPageLayouts(pageLayout1, pageLayout2); BandTile tile = builder.Build(); // add tile try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } PageData pageData1 = new PageData(Java.Util.UUID.RandomUUID(), 0); pageData1.Update(new BarcodeData(11, "MK12345509", BarcodeType.Code39)); pageData1.Update(new TextButtonData(21, "MK12345509")); PageData pageData2 = new PageData(Java.Util.UUID.RandomUUID(), 1); pageData2.Update(new BarcodeData(11, "901234567890123456", BarcodeType.Pdf417)); pageData2.Update(new TextButtonData(21, "901234567890123456")); await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData1, pageData2); Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show(); // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } }
private async void OnAddButtonTileClick(object sender, EventArgs e) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); FilledButton button = new FilledButton(0, 5, 210, 45); button.BackgroundColor = Color.Red; button.Margins = new Margins(0, 5, 0, 0); button.ElementId = 12; TextButton button2 = new TextButton(0, 0, 210, 45); button2.PressedColor = Color.Blue; button2.Margins = new Margins(0, 5, 0, 0); button2.ElementId = 21; FlowPanel flowPanel = new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.Vertical); flowPanel.AddElements(button); flowPanel.AddElements(button2); PageLayout pageLayout = new PageLayout(flowPanel); BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } builder.SetPageLayouts(pageLayout); BandTile tile = builder.Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } PageData pageData = new PageData(Java.Util.UUID.RandomUUID(), 0); pageData.Update(new FilledButtonData(12, Color.Yellow)); pageData.Update(new TextButtonData(21, "Text Button")); await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData); Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show(); // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.fragment_tiles, container, false); mListTiles = rootView.FindViewById <ListView>(Resource.Id.listTiles); RelativeLayout header = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_tiles_header, null); mTextRemainingCapacity = header.FindViewById <TextView>(Resource.Id.textAvailableCapacity); mButtonAddTile = header.FindViewById <Button>(Resource.Id.buttonAddTile); mButtonAddTile.Click += async delegate { try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = mCheckboxBadging.Checked ? BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)) : null; BandTile tile = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon) .SetTileSmallIcon(badgeIcon) .SetTheme(mCheckboxCustomTheme.Checked ? mThemeView.Theme : null) .Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Add tile", e); } }; mButtonRemoveTile = header.FindViewById <Button>(Resource.Id.buttonRemoveTile); mButtonRemoveTile.Click += async delegate { try { await Model.Instance.Client.TileManager.RemoveTileTaskAsync(mSelectedTile.TileId); mSelectedTile = null; Toast.MakeText(Activity, "Tile removed", ToastLength.Short).Show(); await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Remove tile", e); } }; mCheckboxBadging = header.FindViewById <CheckBox>(Resource.Id.cbBadging); mThemeView = header.FindViewById <BandThemeView>(Resource.Id.viewCustomTheme); mThemeView.Theme = BandTheme.CyberTheme; mCheckboxCustomTheme = header.FindViewById <CheckBox>(Resource.Id.cbCustomTheme); mCheckboxCustomTheme.CheckedChange += (sender, e) => { mThemeView.Visibility = e.IsChecked ? ViewStates.Visible : ViewStates.Gone; }; mEditTileName = header.FindViewById <EditText>(Resource.Id.editTileName); mEditTileName.TextChanged += (sender, e) => RefreshControls(); RelativeLayout footer = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_tiles_footer, null); mEditTitle = footer.FindViewById <EditText>(Resource.Id.editTitle); mEditBody = footer.FindViewById <EditText>(Resource.Id.editBody); mCheckboxWithDialog = footer.FindViewById <CheckBox>(Resource.Id.cbWithDialog); mButtonSendMessage = footer.FindViewById <Button>(Resource.Id.buttonSendMessage); mButtonSendMessage.Click += async delegate { try { await Model.Instance.Client.NotificationManager.SendMessageTaskAsync( mSelectedTile.TileId, mEditTitle.Text, mEditBody.Text, DateTime.Now, mCheckboxWithDialog.Checked); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Send message", e); } }; mButtonSendDialog = footer.FindViewById <Button>(Resource.Id.buttonSendDialog); mButtonSendDialog.Click += async delegate { try { await Model.Instance.Client.NotificationManager.ShowDialogTaskAsync(mSelectedTile.TileId, mEditTitle.Text, mEditBody.Text); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Show dialog", e); } }; mListTiles.AddHeaderView(header); mListTiles.AddFooterView(footer); mTileListAdapter = new TileListAdapter(this); mListTiles.Adapter = mTileListAdapter; mListTiles.ItemClick += (sender, e) => { var position = e.Position - 1; // ignore the header if (position >= 0 && position < mTileListAdapter.Count) { mSelectedTile = (BandTile)mTileListAdapter.GetItem(position); RefreshControls(); } }; return(rootView); }