Ejemplo n.º 1
0
        //static AndroidToast? toast;
        //static DateTime hideTime;

        //static int GetHideTimeByDuration(int duration, AndroidToastLength duration2)
        //{
        //    if (duration2 == AndroidToastLength.Long)
        //    {
        //        return (int)ToastLength.Long;
        //    }
        //    else if (duration2 == AndroidToastLength.Short)
        //    {
        //        return (int)ToastLength.Short;
        //    }
        //    return duration;
        //}

        protected override void PlatformShow(string text, int duration)
        {
            var context   = XEPlatform.CurrentActivity?.ApplicationContext ?? XEPlatform.AppContext;
            var duration2 = (AndroidToastLength)duration;

            // https://blog.csdn.net/android157/article/details/80267737
            try
            {
                //if (toast == null)
                //{
                var toast = AndroidToast.MakeText(context, text, duration2);
                //if (toast == null) throw new NullReferenceException("toast markeText Fail");
                //}
                //else
                //{
                //    toast.Duration = duration2;
                //}
                SetTextAndShow(toast !, text);
            }
            catch (JException e)
            {
                Log.Error(TAG, e, "ShowDroidToast Error, text: {0}, IsMainThread: {1}", text, IsMainThread);
                // 解决在子线程中调用Toast的异常情况处理
                Looper.Prepare();
                var _toast = AndroidToast.MakeText(context, text, duration2)
                             ?? throw new NullReferenceException("toast markeText Fail(2)");
                SetTextAndShow(_toast, text);
                Looper.Loop();
            }
Ejemplo n.º 2
0
        protected override void PlatformShow(string text, int duration)
        {
            var context   = AndroidApplication.Context;
            var duration2 = (AndroidToastLength)duration;

            // https://blog.csdn.net/android157/article/details/80267737
            try
            {
                if (toast == null)
                {
                    toast = AndroidToast.MakeText(context, text, duration2);
                    if (toast == null)
                    {
                        throw new NullReferenceException("toast markeText Fail");
                    }
                }
                else
                {
                    toast.Duration = duration2;
                }
                SetTextAndShow(toast, text);
            }
            catch (JException e)
            {
                Log.Error(TAG, e, "ShowDroidToast Error, text: {0}", text);
                // 解决在子线程中调用Toast的异常情况处理
                Looper.Prepare();
                var _toast = AndroidToast.MakeText(context, text, duration2)
                             ?? throw new NullReferenceException("toast markeText Fail(2)");
                SetTextAndShow(_toast, text);
                Looper.Loop();
            }
Ejemplo n.º 3
0
 public void OnLoadmore(IRefreshLayout refreshlayout)
 {
     refreshlayout.Layout.PostDelayed(() => {
         _activity.mAdapter.Loadmore(_activity.loadModels());
         refreshlayout.FinishLoadmore();
         if (_activity.mAdapter.ItemCount > 12)
         {
             Toast.MakeText(_activity.Application, "数据全部加载完毕", ToastLength.Short).Show();
             refreshlayout.SetLoadmoreFinished(true);//将不会再次触发加载更多事件
         }
     }, 2000);
 }
 public void OnLoadmore(IRefreshLayout refreshLayout)
 {
     ((View)refreshLayout).PostDelayed(() => {
         activity.mAdapter.Loadmore(activity.initData);
         refreshLayout.FinishLoadmore();
         if (activity.mAdapter.Count > 60)
         {
             Toast.MakeText(activity.Application, "数据全部加载完毕", ToastLength.Short).Show();
             refreshLayout.SetLoadmoreFinished(true);//将不会再次触发加载更多事件
         }
     }, 2000);
 }
Ejemplo n.º 5
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     // Check which request we're responding to
     if (requestCode == Tango.TangoIntentActivitycode)
     {
         // Make sure the request was successful
         if (resultCode == Result.Canceled)
         {
             Toast.MakeText(this, motiontrackingcsharp.Resource.String.motiontrackingpermission, Android.Widget.ToastLength.Short).Show();
             Finish();
         }
     }
 }
Ejemplo n.º 6
0
 public ADFDataSource(Context context)
 {
     mContext = context;
     mTango   = new Tango(context);
     try
     {
         mFullUUIDList = mTango.ListAreaDescriptions();
     }
     catch (TangoErrorException)
     {
         Toast.MakeText(mContext, Resource.String.tango_error, Android.Widget.ToastLength.Short).Show();
     }
     if (mFullUUIDList.Count == 0)
     {
         Toast.MakeText(context, Resource.String.no_adfs_tango_error, Android.Widget.ToastLength.Short).Show();
     }
 }
Ejemplo n.º 7
0
 public virtual void deleteADFandUpdateList(string uuid)
 {
     try
     {
         mTango.DeleteAreaDescription(uuid);
     }
     catch (TangoErrorException)
     {
         Toast.MakeText(mContext, Resource.String.no_uuid_tango_error, Android.Widget.ToastLength.Short).Show();
     }
     mFullUUIDList.Clear();
     try
     {
         mFullUUIDList = mTango.ListAreaDescriptions();
     }
     catch (TangoErrorException)
     {
         Toast.MakeText(mContext, Resource.String.tango_error, Android.Widget.ToastLength.Short).Show();
     }
 }