コード例 #1
0
        private static IDbConnection OpenBitsplatConnectionIn(
            string folderPath)
        {
            var factory = new SqLiteDatabase(folderPath);

            return(factory.Connect());
        }
コード例 #2
0
        private void SimulateStartup()
        {
            try
            {
                DbDatabase = new SqLiteDatabase();
                DbDatabase.Connect();

                if (!string.IsNullOrEmpty(AppSettings.Lang))
                {
                    LangController.SetApplicationLang(this, AppSettings.Lang);
                }
                else
                {
                    UserDetails.LangName = Resources.Configuration.Locale.Language.ToLower();
                    LangController.SetApplicationLang(this, UserDetails.LangName);
                }

                Methods.Path.Chack_MyFolder();

                var result = DbDatabase.Get_data_Login();
                if (result != null)
                {
                    UserDetails.UserId      = Client.UserId = result.UserId;
                    UserDetails.AccessToken = Current.AccessToken = result.AccessToken;
                    UserDetails.Cookie      = result.Cookie;

                    switch (result.Status)
                    {
                    case "Active":
                        UserDetails.IsLogin = true;
                        StartActivity(new Intent(this, typeof(TabbedMainActivity)));
                        break;

                    case "Pending":
                        StartActivity(new Intent(this, typeof(TabbedMainActivity)));
                        break;

                    default:
                        StartActivity(new Intent(this, typeof(FirstActivity)));
                        break;
                    }
                }
                else
                {
                    StartActivity(new Intent(this, typeof(FirstActivity)));
                }
                DbDatabase.Dispose();

                if (AppSettings.ShowAdMobBanner || AppSettings.ShowAdMobInterstitial || AppSettings.ShowAdMobRewardVideo || AppSettings.ShowAdMobNative)
                {
                    MobileAds.Initialize(this, GetString(Resource.String.admob_app_id));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
コード例 #3
0
ファイル: ApiRequest.cs プロジェクト: divitiae/playtube
        public static async void Logout(Activity context)
        {
            try
            {
                if (RunLogout == false)
                {
                    RunLogout = true;

                    await RemoveData("Logout");

                    context.RunOnUiThread(() =>
                    {
                        Methods.Path.DeleteAll_MyFolderDisk();

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();

                        Java.Lang.Runtime.GetRuntime().RunFinalization();
                        Java.Lang.Runtime.GetRuntime().Gc();
                        TrimCache(context);

                        dbDatabase.ClearAll();
                        dbDatabase.DropAll();

                        ListUtils.ClearAllList();

                        UserDetails.ClearAllValueUserDetails();

                        dbDatabase.Connect();
                        dbDatabase.Dispose();

                        var intentService = new Intent(context, typeof(ScheduledApiService));
                        context.StopService(intentService);

                        MainSettings.SharedData.Edit().Clear().Commit();

                        Intent intent = new Intent(context, typeof(FirstActivity));
                        intent.AddCategory(Intent.CategoryHome);
                        intent.SetAction(Intent.ActionMain);
                        intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);
                        context.StartActivity(intent);
                        context.FinishAffinity();
                    });

                    RunLogout = false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #4
0
            public void WhenTargetDatabaseMissing_ShouldAddHistoryTable()
            {
                // Arrange
                using var folder = new AutoTempFolder();
                Expect(folder)
                .Not.To.Have.Contents();
                // Act
                Create(folder);
                // Assert
                Expect(folder)
                .To.Have.Contents();
                var dataLayer = new SqLiteDatabase(folder.Path);

                using var conn = dataLayer.Connect();
                Expect(() =>
                       conn.Query <HistoryItem>($"select * from {Table.NAME};")
                       )
                .Not.To.Throw();
            }
コード例 #5
0
        protected override void OnResume()
        {
            try
            {
                base.OnResume();

                DbDatabase = new SqLiteDatabase();
                DbDatabase.Connect();

                // Check if we're running on Android 5.0 or higher
                if ((int)Build.VERSION.SdkInt < 23)
                {
                    new Handler(Looper.MainLooper).Post(new Runnable(SimulateStartup));
                }
                else
                {
                    if (CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Granted && CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Granted)
                    {
                        new Handler(Looper.MainLooper).Post(new Runnable(SimulateStartup));
                    }
                    else
                    {
                        RequestPermissions(new[]
                        {
                            Manifest.Permission.ReadExternalStorage,
                            Manifest.Permission.WriteExternalStorage,
                            Manifest.Permission.AccessMediaLocation,
                            Manifest.Permission.Camera,
                            Manifest.Permission.RecordAudio,
                        }, 100);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #6
0
            public override void OnReceive(Context context, Intent intent)
            {
                try
                {
                    if (intent.Action == DownloadManager.ActionDownloadComplete)
                    {
                        if (ActivityContext == null)
                        {
                            return;
                        }

                        DownloadManager       downloadManagerExcuter = (DownloadManager)ActivityContext.GetSystemService(Context.DownloadService);
                        long                  downloadId             = intent.GetLongExtra(DownloadManager.ExtraDownloadId, -1);
                        DownloadManager.Query query = new DownloadManager.Query();
                        query.SetFilterById(downloadId);
                        ICursor c         = downloadManagerExcuter.InvokeQuery(query);
                        var     sqlEntity = new SqLiteDatabase();

                        if (c.MoveToFirst())
                        {
                            int columnIndex = c.GetColumnIndex(DownloadManager.ColumnStatus);
                            if (c.GetInt(columnIndex) == (int)DownloadStatus.Successful)
                            {
                                string downloadedPath = c.GetString(c.GetColumnIndex(DownloadManager.ColumnLocalUri));

                                ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
                                ActivityManager.GetMyMemoryState(appProcessInfo);
                                if (appProcessInfo.Importance == Importance.Foreground || appProcessInfo.Importance == Importance.Background)
                                {
                                    sqlEntity.Update_WatchOfflineVideos(Video.VideoId, downloadedPath);
                                    if (TypeActivity == "Main")
                                    {
                                        TabbedMainActivity.GetInstance()?.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                        TabbedMainActivity.GetInstance().VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                        TabbedMainActivity.GetInstance()?.LibrarySynchronizer.AddToWatchOffline(Video);
                                    }
                                    else if (TypeActivity == "GlobalPlayer")
                                    {
                                        GlobalPlayerActivity.GetInstance()?.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                        GlobalPlayerActivity.GetInstance().VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                        GlobalPlayerActivity.GetInstance()?.LibrarySynchronizer.AddToWatchOffline(Video);
                                    }
                                    else
                                    {
                                        if (ActivityContext is FullScreenVideoActivity fullScreen)
                                        {
                                            fullScreen.VideoActionsController.DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red);
                                            fullScreen.VideoActionsController.DownloadIcon.Tag = "Downloaded";
                                            //fullScreen tabbedMain.LibrarySynchronizer.OfflineVideoList.Add(Video);
                                        }
                                    }
                                }
                                else
                                {
                                    sqlEntity.Connect();
                                    sqlEntity.Update_WatchOfflineVideos(Video.VideoId, downloadedPath);
                                    sqlEntity.Close();
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }