Example #1
0
        private void ListView_ItemClick(object sender, int position)
        {
            switch (result[position].Kind)
            {
            case YtKind.Video:
                YoutubeManager.Play(result[position].song);
                break;

            case YtKind.Playlist:
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
                MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
                MainActivity.instance.FindViewById <TabLayout>(Resource.Id.tabs).Visibility  = ViewStates.Gone;
                MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, PlaylistTracks.NewInstance(result[position].playlist)).AddToBackStack("Playlist Track").Commit();
                break;

            case YtKind.Channel:
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
                MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
                MainActivity.instance.FindViewById <TabLayout>(Resource.Id.tabs).Visibility  = ViewStates.Gone;
                MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(result[position].channel)).AddToBackStack("Channel Details").Commit();
                break;

            default:
                break;
            }
        }
Example #2
0
 internal Game()
 {
     ClientManager            = new GameClientManager();
     BanManager               = new ModerationBanManager();
     RoleManager              = new RoleManager();
     Catalog                  = new Catalog();
     CatalogPremium           = new CatalogPremium();
     Navigator                = new Navigator();
     NewNavigatorManager      = new NewNavigatorManager();
     ItemManager              = new ItemManager();
     RoomManager              = new RoomManager();
     GroupManager             = new GroupManager();
     newsManager              = new NewsManager();
     ModerationTool           = new ModerationTool();
     questManager             = new QuestManager();
     youtubeManager           = new YoutubeManager();
     piñataManager            = new PiñataHandler();
     roomRankConfig           = new RoomRankConfig();
     AchievementManager       = new AchievementManager();
     talentManager            = new TalentManager();
     AlfaManager              = new AlfaManager();
     MuteManager              = new MuteManager();
     PromotionalBadgesManager = new PromotionalBadges();
     TargetedOfferManager     = new TargetedOfferManager();
     RoomQueueManager         = new RoomQueueManager();
     CraftableProductsManager = new CraftableProductsManager();
     ClothingManager          = new ClothingManager();
     UserLookManager          = new UserLook();
     PrisaoManager            = new PrisaoManager();
     LandingTopUsersManager   = new LandingTopUsers();
     corManager               = new CorManager();
     giftManager              = new GiftModeloManager();
 }
Example #3
0
        public void Init()
        {
            var aYouTubeService = new ThirdPartyYoutubeClass();
            var aYouTubeProxy   = new CachedYoutubeClass(aYouTubeService);
            var manager         = new YoutubeManager(aYouTubeProxy);

            manager.reactOnUserInput(3);
        }
Example #4
0
        //Header more click
        public bool OnMenuItemClick(IMenuItem menuItem)
        {
            switch (menuItem.ItemId)
            {
            case Resource.Id.download:
                YoutubeManager.DownloadPlaylist(item, true, true);
                break;

            case Resource.Id.fork:
                if (isForked)
                {
                    PlaylistManager.Unfork(item);
                }
                else
                {
                    PlaylistManager.ForkPlaylist(item);
                }

                isForked = !isForked;
                break;

            case Resource.Id.addToQueue:
                if (useHeader)
                {
                    PlaylistManager.AddToQueue(item);
                }
                else
                {
                    SongManager.AddToQueue(adapter.tracks);
                }
                break;

            case Resource.Id.name:
                PlaylistManager.Rename(item, () =>
                {
                    MainActivity.instance.FindViewById <TextView>(Resource.Id.headerTitle).Text = item.Name;
                });
                break;

            case Resource.Id.sync:
                PlaylistManager.StopSyncingDialog(item, () =>
                {
                    MainActivity.instance.SupportFragmentManager.PopBackStack();
                });
                break;

            case Resource.Id.delete:
                PlaylistManager.Delete(item, () =>
                {
                    MainActivity.instance.SupportFragmentManager.PopBackStack();
                });
                break;
            }
            return(true);
        }
Example #5
0
        public async void PlaylistMore(PlaylistItem item)
        {
            BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
            View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);

            bottomView.FindViewById <TextView>(Resource.Id.bsTitle).Text  = item.Name;
            bottomView.FindViewById <TextView>(Resource.Id.bsArtist).Text = item.Owner;
            Picasso.With(MainActivity.instance).Load(item.ImageURL).Placeholder(Resource.Color.background_material_dark).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            bottomSheet.SetContentView(bottomView);

            List <BottomSheetAction> actions = new List <BottomSheetAction>
            {
                new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.Resources.GetString(Resource.String.play_in_order), (sender, eventArg) =>
                {
                    PlaylistManager.PlayInOrder(item);
                    bottomSheet.Dismiss();
                }),
                new BottomSheetAction(Resource.Drawable.Shuffle, MainActivity.instance.Resources.GetString(Resource.String.random_play), (sender, eventArg) =>
                {
                    PlaylistManager.Shuffle(item);
                    bottomSheet.Dismiss();
                }),
                new BottomSheetAction(Resource.Drawable.Queue, MainActivity.instance.Resources.GetString(Resource.String.add_to_queue), (sender, eventArg) =>
                {
                    PlaylistManager.AddToQueue(item);
                    bottomSheet.Dismiss();
                }),
                new BottomSheetAction(Resource.Drawable.Download, MainActivity.instance.Resources.GetString(Resource.String.download), (sender, eventArg) =>
                {
                    YoutubeManager.DownloadPlaylist(item, true, false);
                    bottomSheet.Dismiss();
                })
            };

            if (await PlaylistManager.IsForked(item))
            {
                actions.Add(new BottomSheetAction(Resource.Drawable.Delete, MainActivity.instance.Resources.GetString(Resource.String.unfork), (sender, eventArg) =>
                {
                    PlaylistManager.Unfork(item);
                    bottomSheet.Dismiss();
                }));
            }
            else
            {
                actions.Add(new BottomSheetAction(Resource.Drawable.LibraryAdd, MainActivity.instance.Resources.GetString(Resource.String.add_to_library), (sender, eventArg) =>
                {
                    PlaylistManager.ForkPlaylist(item);
                    bottomSheet.Dismiss();
                }));
            }

            bottomSheet.FindViewById <ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
            bottomSheet.Show();
        }
Example #6
0
        private async void SetMetaData(int position, string title, string artist, ThumbnailSet thumbnails)
        {
            string filePath = queue[position].Path;

            await Task.Run(async() =>
            {
                Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
                var meta      = TagLib.File.Create(new StreamFileAbstraction(filePath, stream, stream));

                meta.Tag.Title      = title;
                meta.Tag.Performers = new string[] { artist };
                meta.Tag.Album      = title + " - " + artist;
                meta.Tag.Comment    = queue[position].YoutubeID;
                IPicture[] pictures = new IPicture[1];
                Bitmap bitmap       = Picasso.With(this).Load(await YoutubeManager.GetBestThumb(thumbnails)).Transform(new RemoveBlackBorder(true)).MemoryPolicy(MemoryPolicy.NoCache).Get();
                byte[] data;
                using (var MemoryStream = new MemoryStream())
                {
                    bitmap.Compress(Bitmap.CompressFormat.Png, 0, MemoryStream);
                    data = MemoryStream.ToArray();
                }
                bitmap.Recycle();
                pictures[0]       = new Picture(data);
                meta.Tag.Pictures = pictures;

                meta.Save();
                stream.Dispose();
            });

            MediaScannerConnection.ScanFile(this, new string[] { filePath }, null, this);

            if (queue[position].PlaylistName == null)
            {
                queue[position].State = DownloadState.Completed;
            }
            else
            {
                queue[position].State = DownloadState.Playlist;
            }

            if (!queue.Exists(x => x.State == DownloadState.None || x.State == DownloadState.Downloading || x.State == DownloadState.Initialization || x.State == DownloadState.MetaData || x.State == DownloadState.Playlist))
            {
                StopForeground(true);
                DownloadQueue.instance?.Finish();
                queue.Clear();
            }
            else
            {
                UpdateList(position);
            }
        }
Example #7
0
        async void DownloadMetaDataFromYT(bool onlyArt)
        {
            if (song.YoutubeID == "" && YoutubeClient.ValidateVideoId(song.YoutubeID))
            {
                Toast.MakeText(this, Resource.String.metdata_error_noid, ToastLength.Long).Show();
                return;
            }

            const string permission = Manifest.Permission.WriteExternalStorage;

            if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, permission) != (int)Permission.Granted)
            {
                string[] permissions = new string[] { permission };
                RequestPermissions(permissions, 2659);

                await Task.Delay(1000);

                while (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, permission) != (int)Permission.Granted)
                {
                    await Task.Delay(500);
                }
            }


            try
            {
                YoutubeClient client = new YoutubeClient();
                Video         video  = await client.GetVideoAsync(youtubeID.Text);

                if (!onlyArt)
                {
                    title.Text  = video.Title;
                    artist.Text = video.Author;
                    album.Text  = video.Title + " - " + video.Author;
                }

                ytThumbUri = await YoutubeManager.GetBestThumb(video.Thumbnails);

                Picasso.With(this).Load(ytThumbUri).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Into(albumArt);
            }
            catch (YoutubeExplode.Exceptions.VideoUnavailableException)
            {
                Toast.MakeText(this, Resource.String.metdata_error_noid, ToastLength.Long).Show();
            }
        }
Example #8
0
        private async void More(object s, EventArgs e)
        {
            Song item = await MusicPlayer.GetItem();

            BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
            View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);

            bottomView.FindViewById <TextView>(Resource.Id.bsTitle).Text  = item.Title;
            bottomView.FindViewById <TextView>(Resource.Id.bsArtist).Text = item.Artist;
            if (item.AlbumArt == -1 || item.IsYt)
            {
                Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            }
            else
            {
                var songCover       = Android.Net.Uri.Parse("content://media/external/audio/albumart");
                var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);

                Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            }
            bottomSheet.SetContentView(bottomView);

            List <BottomSheetAction> actions = new List <BottomSheetAction>
            {
                new BottomSheetAction(Resource.Drawable.Timer, Resources.GetString(Resource.String.timer), (sender, eventArg) => { SleepDialog(); bottomSheet.Dismiss(); }),
                new BottomSheetAction(Resource.Drawable.PlaylistAdd, Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); })
            };

            if (item.IsYt)
            {
                actions.AddRange(new BottomSheetAction[]
                {
                    new BottomSheetAction(Resource.Drawable.PlayCircle, Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
                    {
                        YoutubeManager.CreateMixFromSong(item);
                        bottomSheet.Dismiss();
                    }),
                    new BottomSheetAction(Resource.Drawable.Download, Resources.GetString(Resource.String.download), (sender, eventArg) =>
                    {
                        Console.WriteLine("&Trying to download " + item.Title);
                        YoutubeManager.Download(new[] { item });
                        bottomSheet.Dismiss();
                    }),
                    new BottomSheetAction(Resource.Drawable.OpenInBrowser, Resources.GetString(Resource.String.open_youtube), (sender, eventArg) =>
                    {
                        Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("vnd.youtube://" + MusicPlayer.queue[MusicPlayer.CurrentID()].YoutubeID));
                        StartActivity(intent);
                        bottomSheet.Dismiss();
                    })
                });

                if (item.ChannelID != null && item.ChannelID != "")
                {
                    actions.Add(new BottomSheetAction(Resource.Drawable.account, Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
                    {
                        ChannelManager.OpenChannelTab(item.ChannelID);
                        bottomSheet.Dismiss();
                    }));
                }
            }
            else
            {
                actions.Add(new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
                {
                    LocalManager.EditMetadata(item, MusicPlayer.CurrentID());
                    bottomSheet.Dismiss();
                }));
            }

            bottomSheet.FindViewById <ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
            bottomSheet.Show();
        }
Example #9
0
        public void More(int Position)
        {
            bool         local = Position <= LocalPlaylists.Count;
            PlaylistItem item  = local ?
                                 LocalPlaylists[Position] :
                                 YoutubePlaylists[Position - LocalPlaylists.Count];

            BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
            View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);

            bottomView.FindViewById <TextView>(Resource.Id.bsTitle).Text = item.Name;
            if (!local || item.SyncState != SyncState.False)
            {
                bottomView.FindViewById <TextView>(Resource.Id.bsArtist).Text = item.Owner;
                Picasso.With(MainActivity.instance).Load(item.ImageURL).Placeholder(Resource.Color.background_material_dark).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            }
            else
            {
                bottomView.FindViewById <TextView>(Resource.Id.bsArtist).Text     = item.Count + " element" + (item.Count == 1 ? "" : "s");
                bottomView.FindViewById <ImageView>(Resource.Id.bsArt).Visibility = ViewStates.Gone;
            }
            bottomSheet.SetContentView(bottomView);

            if (item.SyncState == SyncState.Error)
            {
                bottomSheet.FindViewById <ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, new List <BottomSheetAction>
                {
                    //new BottomSheetAction(Resource.Drawable.SyncDisabled, Resources.GetString(Resource.String.stop_sync), (sender, eventArg) =>
                    //{
                    //    PlaylistManager.StopSyncingDialog(item, () =>
                    //    {
                    //        PlaylistItem LocalPlaylist = new PlaylistItem(YoutubePlaylists[Position - LocalPlaylists.Count].Name, item.LocalID, YoutubePlaylists[Position - LocalPlaylists.Count].Count);
                    //        LocalPlaylists.Add(LocalPlaylist);
                    //        if (LocalPlaylists.Count == 3 && LocalPlaylists[1].Name == "EMPTY")
                    //        {
                    //            LocalPlaylists.RemoveAt(1);
                    //            adapter.NotifyItemChanged(1);
                    //        }
                    //        else
                    //            adapter.NotifyItemInserted(LocalPlaylists.Count);

                    //        YoutubePlaylists[Position - LocalPlaylists.Count].LocalID = 0;
                    //        YoutubePlaylists[Position - LocalPlaylists.Count].SyncState = SyncState.False;
                    //        PlaylistHolder holder = (PlaylistHolder)ListView.GetChildViewHolder(ListView.GetChildAt(Position));
                    //        holder.sync.Visibility = ViewStates.Gone;
                    //        holder.SyncLoading.Visibility = ViewStates.Gone;
                    //    });
                    //    bottomSheet.Dismiss();
                    //}),
                    new BottomSheetAction(Resource.Drawable.Delete, Resources.GetString(Resource.String.delete), (sender, eventArg) =>
                    {
                        PlaylistManager.Delete(item, () =>
                        {
                            if (local)
                            {
                                LocalPlaylists.RemoveAt(Position);
                                adapter.NotifyItemRemoved(Position);

                                if (LocalPlaylists.Count == 1)
                                {
                                    LocalPlaylists.Add(new PlaylistItem("EMPTY", -1)
                                    {
                                        Owner = Resources.GetString(Resource.String.local_playlist_empty)
                                    });
                                    adapter.NotifyItemInserted(1);
                                }
                            }
                            else
                            {
                                YoutubePlaylists.RemoveAt(Position - LocalPlaylists.Count);
                                adapter.NotifyItemRemoved(Position);

                                if (YoutubePlaylists.Count == 1)
                                {
                                    YoutubePlaylists.Add(new PlaylistItem("EMPTY", null)
                                    {
                                        Owner = Resources.GetString(Resource.String.youtube_playlist_empty)
                                    });
                                    adapter.NotifyItemInserted(LocalPlaylists.Count + YoutubePlaylists.Count);
                                }
                            }
                        });
                        bottomSheet.Dismiss();
                    })
                });
                bottomSheet.Show();
                return;
            }


            List <BottomSheetAction> actions = new List <BottomSheetAction>
            {
                new BottomSheetAction(Resource.Drawable.Play, Resources.GetString(Resource.String.play_in_order), (sender, eventArg) =>
                {
                    PlaylistManager.PlayInOrder(item);
                    bottomSheet.Dismiss();
                }),
                new BottomSheetAction(Resource.Drawable.Shuffle, Resources.GetString(Resource.String.random_play), (sender, eventArg) =>
                {
                    PlaylistManager.Shuffle(item);
                    bottomSheet.Dismiss();
                }),
                new BottomSheetAction(Resource.Drawable.Queue, Resources.GetString(Resource.String.add_to_queue), (sender, eventArg) =>
                {
                    PlaylistManager.AddToQueue(item);
                    bottomSheet.Dismiss();
                })
            };

            if (local || item.HasWritePermission)
            {
                actions.AddRange(new BottomSheetAction[] { new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.rename), (sender, eventArg) =>
                    {
                        PlaylistManager.Rename(item, () =>
                        {
                            adapter.NotifyItemChanged(Position);
                        });
                        bottomSheet.Dismiss();
                    }),
                                                           new BottomSheetAction(Resource.Drawable.Delete, Resources.GetString(Resource.String.delete), (sender, eventArg) =>
                    {
                        PlaylistManager.Delete(item, () =>
                        {
                            if (local)
                            {
                                LocalPlaylists.RemoveAt(Position);
                                adapter.NotifyItemRemoved(Position);

                                if (LocalPlaylists.Count == 1)
                                {
                                    LocalPlaylists.Add(new PlaylistItem("EMPTY", -1)
                                    {
                                        Owner = Resources.GetString(Resource.String.local_playlist_empty)
                                    });
                                    adapter.NotifyItemInserted(1);
                                }
                            }
                            else
                            {
                                YoutubePlaylists.RemoveAt(Position - LocalPlaylists.Count);
                                adapter.NotifyItemRemoved(Position);

                                if (YoutubePlaylists.Count == 1)
                                {
                                    YoutubePlaylists.Add(new PlaylistItem("EMPTY", null)
                                    {
                                        Owner = Resources.GetString(Resource.String.youtube_playlist_empty)
                                    });
                                    adapter.NotifyItemInserted(LocalPlaylists.Count + YoutubePlaylists.Count);
                                }
                            }
                        });
                        bottomSheet.Dismiss();
                    }) });
            }

            if (item.SyncState == SyncState.True)
            {
                actions.AddRange(new BottomSheetAction[] { new BottomSheetAction(Resource.Drawable.Sync, Resources.GetString(Resource.String.sync_now), (sender, eventArg) =>
                    {
                        YoutubeManager.DownloadPlaylist(item, true, true);
                        bottomSheet.Dismiss();
                    }),
                                                           new BottomSheetAction(Resource.Drawable.SyncDisabled, Resources.GetString(Resource.String.stop_sync), (sender, eventArg) =>
                    {
                        PlaylistManager.StopSyncingDialog(item, () =>
                        {
                            PlaylistItem LocalPlaylist = new PlaylistItem(YoutubePlaylists[Position - LocalPlaylists.Count].Name, item.LocalID, YoutubePlaylists[Position - LocalPlaylists.Count].Count);
                            LocalPlaylists.Add(LocalPlaylist);
                            if (LocalPlaylists.Count == 3 && LocalPlaylists[1].Name == "EMPTY")
                            {
                                LocalPlaylists.RemoveAt(1);
                                adapter.NotifyItemChanged(1);
                            }
                            else
                            {
                                adapter.NotifyItemInserted(LocalPlaylists.Count);
                            }

                            YoutubePlaylists[Position - LocalPlaylists.Count].LocalID   = 0;
                            YoutubePlaylists[Position - LocalPlaylists.Count].SyncState = SyncState.False;
                            PlaylistHolder holder         = (PlaylistHolder)ListView.GetChildViewHolder(ListView.GetChildAt(Position));
                            holder.sync.Visibility        = ViewStates.Gone;
                            holder.SyncLoading.Visibility = ViewStates.Gone;
                        });
                        bottomSheet.Dismiss();
                    }) });
            }
            else if (!local)
            {
                actions.Add(new BottomSheetAction(Resource.Drawable.Sync, Resources.GetString(Resource.String.sync), (sender, eventArg) =>
                {
                    YoutubeManager.DownloadPlaylist(item, true, true);
                    bottomSheet.Dismiss();
                }));

                if (!item.HasWritePermission)
                {
                    actions.Add(new BottomSheetAction(Resource.Drawable.Delete, Resources.GetString(Resource.String.unfork), (sender, eventArg) =>
                    {
                        if (item.SyncState == SyncState.Error)
                        {
                            PlaylistManager.StopSyncing(item);
                        }

                        PlaylistManager.Unfork(item);
                        YoutubePlaylists.RemoveAt(Position - LocalPlaylists.Count);
                        adapter.NotifyItemRemoved(Position);
                        bottomSheet.Dismiss();
                    }));
                }
            }

            bottomSheet.FindViewById <ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
            bottomSheet.Show();
        }
Example #10
0
        private void btnGetData_Click(object sender, EventArgs e)
        {
            string steamUrl = txtSteamUrl.Text;

            if (string.IsNullOrWhiteSpace(steamUrl))
            {
                MessageBox.Show("No steam url is provided");
                return;
            }

            try
            {
                string steamId = SteamManager.GetId(steamUrl);
                if (string.IsNullOrWhiteSpace(steamId))
                {
                    MessageBox.Show("No id found !");
                    return;
                }

                SteamModel model = SteamManager.LoadGameById(steamId);

                if (!model.Success)
                {
                    MessageBox.Show("No game found on steam");
                    return;
                }

                string screens = model.Data.Screenshots?.Length == 0 ? string.Empty :
                                 string.Join(" ", model.Data.Screenshots.Select(s => $"[url={s.Path_full.WithoutQueryString()}][img={s.Path_thumbnail.WithoutQueryString()}][/url]"));

                string video = YoutubeManager.GetVideoByKeyword(model.Data.Name);
                if (!string.IsNullOrWhiteSpace(video))
                {
                    video = $"[video={video}]";
                }

                _gameGenre = string.Join(", ", model.Data.Genres.Select(g => g.Description));

                IDictionary <string, string> dict = new Dictionary <string, string>
                {
                    { "poster", $"[img={model.Data.Header_image.WithoutQueryString()}]" },
                    { "title", $"[size=4]{model.Data.Name}[/size]" },
                    { "genre", string.IsNullOrWhiteSpace(_gameGenre) ?
                      string.Empty :
                      $"[size=2]Genre: [color=orange]{string.Join(", ", model.Data.Genres.Select(g=>g.Description))}[/color][/size]" },
                    { "description", model.Data.Short_description.ToBbcode() },
                    { "pc_requirements", model.Data.Pc_requirements.Minimum.ToBbcode() },
                    { "screenshots", screens },
                    { "youtube", video },
                    { "url", $"http://store.steampowered.com/app/{model.Data.Steam_appid}/" }
                };

                txtResult.Text = TemplateManager.RenderTemplate(dict);
            }
            catch (TemplateException templEx)
            {
                MessageBox.Show(templEx.Message);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                MessageBox.Show("An error occurred");
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            #region FactoryMethod

            ITransport passengerTransport = new PassengerLogistics().CreateTransport();
            ITransport seaTransport       = new SeaLogistics().CreateTransport();
            ITransport roadTransport      = new RoadLogistics().CreateTransport();
            passengerTransport.Delivery += PrintEvent;
            seaTransport.Delivery       += PrintEvent;
            roadTransport.Delivery      += PrintEvent;
            passengerTransport.Transporting();
            seaTransport.Transporting();
            roadTransport.Transporting();

            #endregion

            #region AbstractFactory

            if (args[0] == "Windows")
            {
                IGuiElement element = new CreatorWinElements();

                GuiMaster master = new GuiMaster(element);
                master.CreateElements();
                master.Paint();
            }

            if (args[0] == "Mac")
            {
                IGuiElement element = new CreatorMacElements();

                GuiMaster master = new GuiMaster(element);
                master.CreateElements();
                master.Paint();
            }
            else
            {
                throw new FormatException(nameof(args));
            }

            #endregion

            #region Builder

            CarBuilder builder  = new CarBuilder();
            Director   director = new Director(builder);
            Car        car      = builder.GetResult();
            Console.WriteLine(director.ToString());
            CarManualBuilder manualBuilder = new CarManualBuilder();
            director = new Director(manualBuilder);
            Manual manual = manualBuilder.GetResult();
            car.Reset();
            Console.WriteLine(director.ToString());
            manual.Reset();

            #endregion

            #region Prototype

            //массив фигур
            Shape[] shapes = new Shape[3];
            //создаем фигуры
            Triangle  triangle  = new Triangle(12.4, 12.4);
            Rectangle rectangle = new Rectangle(5, 10, "Grey", true);
            Circle    circle    = new Circle(256.6, true, "Red");
            //кладём в массив
            shapes.SetValue(triangle, 0);
            shapes.SetValue(circle, 1);
            shapes.SetValue(rectangle, 2);

            //создаем копии
            List <Shape> shapesCopy = new List <Shape>(shapes.Length);
            foreach (Shape shape in shapes)
            {
                shapesCopy.Add(shape.Clone());
            }
            #endregion

            #region Singleton

            DataBase db = DataBase.GetInstance();
            db.Query("SELECT ...");

            #endregion

            #region Adapter
            RoundHole hole = new RoundHole(125.5);
            RoundPeg  peg  = new RoundPeg(175);
            hole.Fits(peg);

            var smallSqpeg = new SquarePage(2);
            var largeSqpeg = new SquarePage(5);
            //hole.Fits(small_sqpeg) // ошибка компиляции, несовместимые типы
            var smallSqpegAdapter = new SquarePegAdapter(smallSqpeg);
            var largeSqpegAdapter = new SquarePegAdapter(largeSqpeg);
            hole.Fits(smallSqpegAdapter);
            hole.Fits(largeSqpegAdapter);

            #endregion

            #region Bridge

            var tv     = new Tv();
            var remote = new AdvancedRemote(tv);
            remote.TooglePower();

            var radio    = new Radio();
            var remoting = new Remote(radio);
            remoting.ChannelDown();
            #endregion

            #region Composite

            var all = new CompoundGraphic();
            all.Add(new Dot(1, 1));
            all.Add(new structure_patterns.Composite.Circle(5, 3, 10.5));

            var group = new CompoundGraphic();
            group.Add(new structure_patterns.Composite.Circle(1, 1, 135.4));
            group.Add(new Dot(15, 15));
            all.Add(group);

            all.Draw();

            #endregion

            #region Decorator

            var source = new FileDataSource("somefile.dat");
            source.WriteData("salaryrecords");
            var decorator = new CompressionDecorator(source);
            source.WriteData("salaryrecords");
            decorator.Compression();

            #endregion

            #region Facade

            var converter  = new VideoConverter();
            var mp4        = converter.Convert("youtubevideo.org", "mp4");
            var fileStream = mp4.OpenRead();
            fileStream.Lock(1, 1);
            #endregion

            #region Cache
            Forest forest = new Forest();
            forest.PlantTree(1, 1, "green", "apple", "textture nature");
            forest.PlantTree(2, 1, "green", "pineapple", "nature");
            forest.Draw(new object());
            #endregion

            #region Proxy

            var service = new ThirdPartyYoutubeClass();
            var proxy   = new CachedYoutubeClass(service);
            var manager = new YoutubeManager(proxy);
            manager.ReactOnUserInput(123);

            #endregion

            #region ChainOfResponsibility

            var dialog = new Dialog("Help Me from Dialog");
            var panel  = new Panel("Help me from Panel");
            var ok     = new Button("Button Ok help text");
            var cancel = new Button("Button canceled help text");
            panel.Add(ok);
            panel.Add(cancel);
            dialog.Add(panel);
            dialog.ShowHelp();
            #endregion
        }
Example #12
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            if (items[position].Kind == YtKind.Video)
            {
                SongHolder holder = (SongHolder)viewHolder;
                Song       song   = items[position].song;

                holder.Title.Text         = song.Title;
                holder.Artist.Text        = song.Artist;
                holder.reorder.Visibility = ViewStates.Gone;

                var songAlbumArtUri = Android.Net.Uri.Parse(song.Album);
                Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt);

                holder.more.Tag = position;
                if (!holder.more.HasOnClickListeners)
                {
                    holder.more.Click += (sender, e) =>
                    {
                        int tagPosition = (int)((ImageView)sender).Tag;
                        MainActivity.instance.More(items[tagPosition].song);
                    };
                }

                if (song.IsLiveStream)
                {
                    holder.Live.Visibility = ViewStates.Visible;
                }
                else
                {
                    holder.Live.Visibility = ViewStates.Gone;
                }

                float scale = MainActivity.instance.Resources.DisplayMetrics.Density;
                if (position + 1 == items.Count)
                {
                    holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), listPadding);
                    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters;
                    layoutParams.SetMargins(0, 0, 0, listPadding);
                    holder.more.LayoutParameters = layoutParams;
                }
                else
                {
                    holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f));
                    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters;
                    layoutParams.SetMargins(0, 0, 0, 0);
                    holder.more.LayoutParameters = layoutParams;
                }
            }
            else if (items[position].Kind == YtKind.Playlist)
            {
                PlaylistHolder holder   = (PlaylistHolder)viewHolder;
                PlaylistItem   playlist = items[position].playlist;

                holder.Title.Text = playlist.Name;
                holder.Owner.Text = playlist.Owner;

                var songAlbumArtUri = Android.Net.Uri.Parse(playlist.ImageURL);
                Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt);

                holder.more.Tag = position;
                if (!holder.more.HasOnClickListeners)
                {
                    holder.more.Click += (sender, e) =>
                    {
                        int tagPosition = (int)((ImageView)sender).Tag;
                        YoutubeSearch.instances[0].PlaylistMore(items[tagPosition].playlist);
                    };
                }
            }
            else if (items[position].Kind == YtKind.Channel)
            {
                RecyclerChannelHolder holder = (RecyclerChannelHolder)viewHolder;
                Channel channel = items[position].channel;

                holder.Title.Text = channel.Name;
                Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Transform(new CircleTransformation(false)).Into(holder.AlbumArt);

                if (!holder.action.HasOnClickListeners)
                {
                    holder.action.Click += (sender, e) =>
                    {
                        YoutubeManager.MixFromChannel(channel.YoutubeID);
                    };
                }
            }
            else if (items[position].Kind == YtKind.ChannelPreview)
            {
                ChannelPreviewHolder holder = (ChannelPreviewHolder)viewHolder;
                Channel channel             = items[position].channel;

                holder.Name.Text = channel.Name;
                Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Transform(new CircleTransformation(true)).Into(holder.Logo);


                DisplayMetrics displayMetrics = new DisplayMetrics();
                MainActivity.instance.WindowManager.DefaultDisplay.GetMetrics(displayMetrics);
                int wholeWidth = (displayMetrics.WidthPixels - MainActivity.instance.DpToPx(15)) / 2;
                int mixHeight  = (int)(wholeWidth * 0.5625); /// width / 16 */ 9
                holder.MixOne.LayoutParameters.Height = mixHeight;
                holder.MixOne.RequestLayout();
                holder.MixTwo.LayoutParameters.Height      = mixHeight;
                holder.ChannelLogo.LayoutParameters.Height = mixHeight * 2;

                Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Fit().CenterCrop().Into(holder.ChannelLogo);

                List <YtFile> files = items.FindAll(x => x.Kind == YtKind.Video && x.song.Artist == channel.Name);
                if (files.Count > 0)
                {
                    Picasso.With(Android.App.Application.Context).Load(files[0].song.Album).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder()).Into(holder.MixOne);
                }
                if (files.Count > 1)
                {
                    Picasso.With(Android.App.Application.Context).Load(files[1].song.Album).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder()).Into(holder.MixTwo);
                }

                if (!holder.ChannelHolder.HasOnClickListeners)
                {
                    holder.ChannelHolder.Click += (sender, e) =>
                    {
                        MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
                        MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
                        MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
                        MainActivity.instance.FindViewById(Resource.Id.tabs).Visibility = ViewStates.Gone;
                        MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(channel)).AddToBackStack("Channel Details").Commit();
                    };
                }

                if (!holder.MixHolder.HasOnClickListeners)
                {
                    holder.MixHolder.Click += (sender, e) =>
                    {
                        YoutubeManager.MixFromChannel(channel.YoutubeID);
                    };
                }
            }
        }