/* * Unfourtunalty that will not work because accourding to * https://dmtopolog.com/ios-app-extensions-data-sharing/ * and * https://medium.com/@deep_blue_day/how-to-create-an-ios-app-group-for-xamarin-app-a117c172b4 * * to access the database i must have an apple developer account account to make an app group and make the database shared between the app and the extension * (sadly i don't have one) * there is no other way except having the data coming from an api * * private Task RefreshDataFromDatabase() => Task.Run(async () => * { * * try * { * var database = Ioc.Container.Resolve<ILocalDatabaseService>() as LocalDatabaseService; * if (database != null) _notesList = await database.GetAll<Note>(); * isDataReady = true; * } * catch (Exception ex) * { * Debug.WriteLine($"Errroooooooorrr{ex.Message}"); * isDataReady = false; * throw ex; * } * }); */ void SetDatasource() { NotesTableView.Source = new TableSource(_notesList, base.ExtensionContext); NotesTableView.RowHeight = UITableView.AutomaticDimension; ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded); NotesTableView.ReloadData(); }
void SeriesReady( ) { // only do image work on the main thread InvokeOnMainThread(delegate { ActivityIndicator.Hidden = true; ActivityIndicator.RemoveFromSuperview( ); // if there are now series entries, we're good if (RockLaunchData.Instance.Data.NoteDB.SeriesList.Count > 0) { // setup each series entry in our table SetupSeriesEntries(RockLaunchData.Instance.Data.NoteDB.SeriesList); // only update the table if we're still visible if (IsVisible == true) { NotesTableView.Hidden = false; NotesTableView.Source = new TableSource(this, SeriesEntries, ImageMainPlaceholder, ImageThumbPlaceholder); NotesTableView.ReloadData( ); } } else if (IsVisible == true) { // jhm hack : Show our stupid error message ResultView.Show(MessagesStrings.Series_Error_Title, PrivateControlStylingConfig.Result_Symbol_Failed, MessagesStrings.Series_Error_Message + "\n" + RockLaunchData.HackNotesErrorCheck, GeneralStrings.Retry); } }); }
public override void LayoutChanged( ) { base.LayoutChanged( ); // if the layout is changed, the simplest way to fix the UI is to recreate the table source NotesTableView.Source = new TableSource(this, SeriesEntries, ImageMainPlaceholder, ImageThumbPlaceholder); NotesTableView.ReloadData( ); ResultView.SetBounds(View.Bounds.ToRectF( )); }
public void WidgetActiveDisplayModeDidChange(NCWidgetDisplayMode activeDisplayMode, CGSize maxSize) { int _notesListCount = _notesList.Count < 5 ? _notesList.Count : 5; if (_notesListCount == 0) { _notesListCount += 1; } PreferredContentSize = activeDisplayMode == NCWidgetDisplayMode.Expanded ? new CGSize(maxSize.Width, 60.0f * _notesListCount) : maxSize; NotesTableView.ReloadData(); }
bool TryLoadImage(ref UIImage rImage, string filename) { bool result = false; // does the file exist? if (FileCache.Instance.FileExists(filename) == true) { result = ImageLoader.Load(filename, ref rImage); if (result) { // let the table refresh NotesTableView.ReloadData( ); } } return(result); }