Exemplo n.º 1
0
        public static TableViewCell AsCell(this PlatformView view, int cellTypeId)
        {
#if __ANDROID__
            return(new TableViewCell(view));
#endif
#if __IOS__
            return(new TableViewCell(TableViewUtil.ToTableViewCell(view, cellTypeId)));
#endif
        }
Exemplo n.º 2
0
        void GetRandomTuples(ITuple[] into, int numTuples, ITableColumns columns)
        {
            // If this mehtod is called from different threads, each thead needs its own random generator instance
            var random = new System.Random((int)DateTime.Now.Ticks);

            for (int i = 0; i < numTuples; i++)
            {
                var tuple = TableViewUtil.CreateTupleWithEmptyValues <BasicTuple>(columns.ColumnsCount);
                GetRandomValuesIntoTuple(columns, tuple, random);
                into[i] = tuple;
            }
        }
Exemplo n.º 3
0
        IEnumerator SimulateReadDataFromServerIntoExistingTuples_Coroutine(BasicTuple[] into, int firstItemIndex, int countToRead, Action onDone)
        {
            yield return(null);

            var adapter = _Adapters[0];
            var columns = adapter.Columns;

            // WebGL doesn't support threads, so we simulate it directly through this coroutine (which is slower, but there's no other choice)
#if UNITY_WEBGL
            // If this mehtod is called from different threads, each thead needs its own random generator instance
            var random = new System.Random((int)DateTime.Now.Ticks);
            for (int i = 0; i < countToRead; i++)
            {
                if (i % 20 == 0)
                {
                    yield return(null);                    // wait 1 frame
                }
                var tuple = TableViewUtil.CreateTupleWithEmptyValues <BasicTuple>(columns.ColumnsCount);
                GetRandomValuesIntoTuple(columns, tuple, random);
                into[i] = tuple;
            }
#else
            bool abort = false;
            bool done  = false;
            new System.Threading.Thread(
                () =>
            {
                System.Threading.Thread.Sleep(500);                         // simulate delay

                // Abort if the adapter was disposed or changed its data externally
                if (abort)
                {
                    return;
                }

                GetRandomTuples(into, countToRead, columns);

                // Abort if the adapter was disposed or changed its data externally
                if (abort)
                {
                    return;
                }

                done = true;
            }
                ).Start();

            while (!done)
            {
                if (adapter == null || !adapter.IsInitialized)                 // adapter was disposed/destroyed => abort
                {
                    abort = true;
                    yield break;
                }

                if (adapter.Columns != columns)                 // data was changed externally => abort
                {
                    abort = true;
                    yield break;
                }

                // Wait a bit until next check
                yield return(new UnityEngine.WaitForSeconds(.2f));
            }
#endif

            // onDone should be called on main thread. A coroutine is perfect for this
            if (onDone != null)
            {
                onDone();
            }
        }