private bool CheckFilter(Music music) { try { switch (music.Type) { case string type when type == Resources.GetString(Resource.String.MusicType_Vocal): if (MusicTypeFilter[0] == false) { return(false); } break; case string type when type == Resources.GetString(Resource.String.MusicType_Dance): if (MusicTypeFilter[1] == false) { return(false); } break; case string type when type == Resources.GetString(Resource.String.MusicType_Session): if (MusicTypeFilter[2] == false) { return(false); } break; } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } return(true); }
private void CheckPermission() { try { string[] check = { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage, Manifest.Permission.Internet }; ArrayList request = new ArrayList(); foreach (string permission in check) { if (CheckSelfPermission(permission) == Permission.Denied) { request.Add(permission); } } request.TrimToSize(); if (request.Count == 0) { InitLoad(); } else { RequestPermissions((string[])request.ToArray(typeof(string)), 0); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); Toast.MakeText(this, Resource.String.Permission_Error, ToastLength.Long).Show(); } }
private void CardView_Click(object sender, EventArgs e) { CardView cv = sender as CardView; try { switch (cv.Id) { case Resource.Id.Main_Dic_MusicDBCardView: ETC.LoadDBSync(ETC.MusicList, Path.Combine(ETC.DBPath, "Song.tsgp"), true); Activity.StartActivity(typeof(Dic_MusicMain)); Activity.OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut); break; case Resource.Id.Main_Dic_CharacterDBCardView: ETC.LoadDBSync(ETC.CharacterList, Path.Combine(ETC.DBPath, "Character.tsgp"), true); Activity.StartActivity(typeof(Dic_StarMain)); Activity.OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut); break; } } catch (Exception ex) { ETC.LogError(Activity, ex.ToString()); } }
private async Task InitLoad() { try { Status.Text = "초기화 중"; ETC.BasicInitializeApp(this); Status.Text = "서버 확인 중"; await ETC.CheckServerNetwork(); if (ETC.IsServerDown == false) { Status.Text = "업데이트 확인 중"; if (await ETC.CheckDBVersion() == true) { await ETC.UpdateDB(this); } } StartActivity(typeof(MainActivity)); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); Finish(); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private async Task DownloadProcess() { if (ETC.IsServerDown == true) { return; } string[] url = { Path.Combine(ETC.Server, "Resource", "Images", "Character", "Crop", "Normal", $"{star.DicNumber}.png"), Path.Combine(ETC.Server, "Resource", "Images", "Character", "Crop", "Awakening", $"{star.DicNumber}.png"), //Path.Combine(ETC.Server, "Resource", "Images", "Character", "Skill", $"{star.SkillCode}.tsgp") }; string[] target = { Path.Combine(ETC.CachePath, "Character", "Crop", "Normal", $"{star.DicNumber}.tsgp"), Path.Combine(ETC.CachePath, "Character", "Crop", "Awakening", $"{star.DicNumber}.tsgp"), //Path.Combine(ETC.CachePath, "Character", "Skill", $"{star.SkillCode}.tsgp") }; using (WebClient wc = new WebClient()) { try { for (int i = 0; i < url.Length; ++i) { await wc.DownloadFileTaskAsync(url[i], target[i]); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } } }
private void LineUpSelector_Click(object sender, EventArgs e) { LinearLayout layout = sender as LinearLayout; try { ImageView iv_name = FindViewById <ImageView>(Resource.Id.MusicDicLineUpIndicator_Name); ImageView iv_update = FindViewById <ImageView>(Resource.Id.MusicDicLineUpIndicator_Update); switch (layout.Id) { case Resource.Id.MusicDicLineUpSelector_Name: LineUpStyle = LineUp.Name; iv_name.Visibility = ViewStates.Visible; iv_update.Visibility = ViewStates.Invisible; break; case Resource.Id.MusicDicLineUpSelector_Update: LineUpStyle = LineUp.Update; iv_name.Visibility = ViewStates.Invisible; iv_update.Visibility = ViewStates.Visible; break; } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } ListMusic(SearchText.Text); }
private void MainNavigationView_NavigationItemSelected(object sender, NavigationView.NavigationItemSelectedEventArgs e) { try { ft = SupportFragmentManager.BeginTransaction(); switch (e.MenuItem.ItemId) { case Resource.Id.Main_Main: ft.Replace(Resource.Id.MainFragmentContainer, Main_F, "Main"); break; case Resource.Id.Main_Dic: ft.Replace(Resource.Id.MainFragmentContainer, Dic_F, "Dic"); break; case Resource.Id.Main_AppInfo: StartActivity(typeof(AppInfo)); OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut); break; case Resource.Id.Main_Setting: break; } ft.Commit(); MainDrawerLayout.CloseDrawer(GravityCompat.Start); } catch (Exception ex) { ETC.LogError(ex.ToString()); } }
private async Task CheckAppVersion() { bool HasUpdate = false; await Task.Delay(100); try { var context = ApplicationContext; string[] now_ver = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName.Split('.'); string[] server_ver = new string[now_ver.Length]; NowVersion.Text = $"{Resources.GetString(Resource.String.AppInfo_NowAppVersion)} : {context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName} Alpha - "; #if DEBUG NowVersion.Text += "Debug"; #else NowVersion.Text += "Release"; #endif string url = Path.Combine(ETC.Server, "AppVer.txt"); string target = Path.Combine(ETC.tempPath, "AppVer.txt"); using (WebClient wc = new WebClient()) await wc.DownloadFileTaskAsync(url, target); using (StreamReader sr = new StreamReader(new FileStream(target, FileMode.Open, FileAccess.Read))) server_ver = (sr.ReadToEnd()).Split('.'); for (int i = 0; i < server_ver.Length; ++i) { if (int.Parse(now_ver[i]) < int.Parse(server_ver[i])) { HasUpdate = true; } else if (int.Parse(now_ver[i]) == int.Parse(server_ver[i])) { continue; } else { HasUpdate = false; break; } } if (HasUpdate == true) { UpdateButton.Visibility = ViewStates.Visible; ServerVersion.Text = string.Format("{0} : {1}.{2}.{3}", Resources.GetString(Resource.String.AppInfo_NewVersion), server_ver[0], server_ver[1], server_ver[2]); } else { ServerVersion.Text = Resources.GetString(Resource.String.AppInf_LatestUpdateVersion); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); ServerVersion.Text = Resources.GetString(Resource.String.Update_CheckFail); } }
private async Task MusicCropImageDownloadProcess() { View v = LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null); Android.Support.V7.App.AlertDialog.Builder pd = new Android.Support.V7.App.AlertDialog.Builder(this, ETC.DialogBG_Download); pd.SetTitle(Resource.String.MusicDic_CropImageDownloadTitle); pd.SetCancelable(false); pd.SetView(v); dialog = pd.Create(); dialog.Show(); try { totalProgressBar = v.FindViewById <ProgressBar>(Resource.Id.TotalProgressBar); totalProgress = v.FindViewById <TextView>(Resource.Id.TotalProgressPercentage); nowProgressBar = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar); nowProgress = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage); p_now = 0; p_total = 0; p_total = Download_List.Count; totalProgressBar.Max = 100; totalProgressBar.Progress = 0; using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += Wc_DownloadProgressChanged; wc.DownloadFileCompleted += Wc_DownloadFileCompleted; for (int i = 0; i < p_total; ++i) { string url = Path.Combine(ETC.Server, "Resource", "Images", "Music", "Album", $"{Download_List[i]}.png"); string target = Path.Combine(ETC.CachePath, "Music", "Album", "Crop", $"{Download_List[i]}.tsgp"); await wc.DownloadFileTaskAsync(url, target); } } await Task.Delay(500); ListMusic(SearchText.Text); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } finally { dialog.Dismiss(); dialog = null; totalProgressBar = null; totalProgress = null; nowProgressBar = null; nowProgress = null; } }
private void MusicTypeSelector_Click(object sender, EventArgs e) { LinearLayout layout = sender as LinearLayout; try { switch (layout.Id) { case Resource.Id.MusicDicMusicTypeSelector_Vocal: MusicTypeFilter[0] = !MusicTypeFilter[0]; ImageView iv_vocal = FindViewById <ImageView>(Resource.Id.MusicDicMusicTypeIndicator_Vocal); if (MusicTypeFilter[0] == true) { iv_vocal.Visibility = ViewStates.Visible; } else { iv_vocal.Visibility = ViewStates.Invisible; } break; case Resource.Id.MusicDicMusicTypeSelector_Dance: MusicTypeFilter[1] = !MusicTypeFilter[1]; ImageView iv_dance = FindViewById <ImageView>(Resource.Id.MusicDicMusicTypeIndicator_Dance); if (MusicTypeFilter[1] == true) { iv_dance.Visibility = ViewStates.Visible; } else { iv_dance.Visibility = ViewStates.Invisible; } break; case Resource.Id.MusicDicMusicTypeSelector_Session: MusicTypeFilter[2] = !MusicTypeFilter[2]; ImageView iv_session = FindViewById <ImageView>(Resource.Id.MusicDicMusicTypeIndicator_Session); if (MusicTypeFilter[2] == true) { iv_session.Visibility = ViewStates.Visible; } else { iv_session.Visibility = ViewStates.Invisible; } break; } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } ListMusic(SearchText.Text); }
private async void ListMusic(string searchText) { SubList.Clear(); searchText = searchText.ToUpper(); try { for (int i = 0; i < RootList.Count; ++i) { Music music = RootList[i]; if (CheckFilter(music) == false) { continue; } if (searchText != "") { string name = music.Name.ToUpper(); if (name.Contains(searchText) == false) { continue; } } SubList.Add(music); } SubList.Sort(SortMusic); var adapter = new MusicListAdapter(SubList, this); if (adapter.HasOnItemClick() == false) { adapter.ItemClick += Adapter_ItemClick; } await Task.Delay(100); RunOnUiThread(() => { MusicRecyclerView.SetAdapter(adapter); }); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private void CreateListObject() { try { foreach (DataRow dr in ETC.MusicList.Rows) { RootList.Add(new Music(dr)); } RootList.TrimExcess(); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private async Task LoadNotification() { try { LoadingLayout.Visibility = ViewStates.Visible; await Task.Delay(500); using (WebClient wc = new WebClient()) ETC.Notification_String = await wc.DownloadStringTaskAsync(Path.Combine(ETC.Server, "Notification.txt")); } catch (Exception ex) { ETC.LogError(Activity, ex.ToString()); ETC.Notification_String = "Loading Fail..."; } finally { NotificationView.Text = ETC.Notification_String; LoadingLayout.Visibility = ViewStates.Gone; } }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { MusicListViewHolder vh = holder as MusicListViewHolder; var item = items[position]; try { string AlbumImagePath = Path.Combine(ETC.CachePath, "Music", "Album", "Crop", $"{item.CodeName}.tsgp"); if (File.Exists(AlbumImagePath) == true) { vh.AlbumImage.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(AlbumImagePath)); } vh.Name.Text = item.Name; vh.Artist.Text = item.Artist; } catch (Exception ex) { ETC.LogError(context, ex.ToString()); Toast.MakeText(context, "Error Create View", ToastLength.Short).Show(); } }
private void HelpFAB_Click(object sender, EventArgs e) { try { FloatingActionButton fab = sender as FloatingActionButton; Intent intent = null; string url = ""; switch (fab.Id) { case Resource.Id.DiscordFAB: url = "https://discord.gg/5cJ5WQD"; break; } intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(url)); StartActivity(intent); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private async Task InitLoadProcess() { try { try { string album_path = Path.Combine(ETC.CachePath, "Music", "Album", $"{music.CodeName}.tsgp"); if (File.Exists(album_path) == false) { if (ETC.IsServerDown == false) { using (WebClient wc = new WebClient()) await wc.DownloadFileTaskAsync(Path.Combine(ETC.Server, "Resource", "Images", "Music", "Album_Big", $"{music.CodeName}_big.png"), album_path); BigAlbumView.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(album_path)); } else { BigAlbumView.SetImageResource(Resource.Drawable.No_Album_Big); } } else { BigAlbumView.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(album_path)); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } FindViewById <TextView>(Resource.Id.MusicDetailMusicName).Text = music.Name; FindViewById <TextView>(Resource.Id.MusicDetailMusicArtist).Text = music.Artist; FindViewById <TextView>(Resource.Id.MusicDetailMusicBPM).Text = $"BPM\n{music.BPM}"; FindViewById <TextView>(Resource.Id.MusicDetailMusicAddVersion).Text = $"최초수록\n{music.AddVersion_Full}"; int[] LevelIcon_Id = { Resource.Id.MusicDetailLevel_Easy, Resource.Id.MusicDetailLevel_Normal, Resource.Id.MusicDetailLevel_Hard, Resource.Id.MusicDetailLevel_Expert }; for (int i = 0; i < LevelIcon_Id.Length; ++i) { int id = 0; switch (music.Level[i]) { case 1: id = Resource.Drawable.Number_1; break; case 2: id = Resource.Drawable.Number_2; break; case 3: id = Resource.Drawable.Number_3; break; case 4: id = Resource.Drawable.Number_4; break; case 5: id = Resource.Drawable.Number_5; break; case 6: id = Resource.Drawable.Number_6; break; case 7: id = Resource.Drawable.Number_7; break; case 8: id = Resource.Drawable.Number_8; break; case 9: id = Resource.Drawable.Number_9; break; case 10: id = Resource.Drawable.Number_10; break; } FindViewById <ImageView>(LevelIcon_Id[i]).SetImageResource(id); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private async Task InitLoadProcess() { try { try { string crop_normal_path = Path.Combine(ETC.CachePath, "Character", "Crop", "Normal", $"{star.DicNumber}.tsgp"); if (File.Exists(crop_normal_path) == false) { StarCropImage.SetImageResource(Resource.Drawable.No_StarCrop); } else { StarCropImage.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromPath(crop_normal_path)); } int GradeId = 0; switch (star.BornGrade) { default: case 1: GradeId = Resource.Drawable.GradeStar_1; break; case 2: GradeId = Resource.Drawable.GradeStar_2; break; case 3: GradeId = Resource.Drawable.GradeStar_3; break; case 4: GradeId = Resource.Drawable.GradeStar_4; break; case 5: GradeId = Resource.Drawable.GradeStar_5; break; } FindViewById <ImageView>(Resource.Id.StarDetailStarGrade).SetImageResource(GradeId); FindViewById <TextView>(Resource.Id.StarDetailStarName).Text = star.Name; TextView attribute = FindViewById <TextView>(Resource.Id.StarDetailStarAttribute); int attr_color_id = 0; switch (star.Attribute) { default: case "Support": attr_color_id = Resource.Color.Attr_SupportColor; break; case "Vocal": attr_color_id = Resource.Color.Attr_VocalColor; break; case "Session": attr_color_id = Resource.Color.Attr_SessionColor; break; case "Dance": attr_color_id = Resource.Color.Attr_DanceColor; break; } attribute.Text = star.Attribute.ToUpper(); attribute.SetBackgroundResource(attr_color_id); int TypeIconId = 0; switch (star.Type) { case "Tap": TypeIconId = Resource.Drawable.Type_Tap_Icon; break; case "Long": TypeIconId = Resource.Drawable.Type_Long_Icon; break; case "Slide": TypeIconId = Resource.Drawable.Type_Slide_Icon; break; case "Flick": TypeIconId = Resource.Drawable.Type_Flick_Icon; break; case "Support": TypeIconId = Resource.Drawable.Type_Support_Icon; break; default: case "Special": TypeIconId = Resource.Drawable.Type_Special_Icon; break; } FindViewById <ImageView>(Resource.Id.StarDetailStarTypeIcon).SetImageResource(TypeIconId); FindViewById <TextView>(Resource.Id.StarDetailStarType).Text = star.Type.ToUpper(); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }
private void MusicPreviewButton_Click(object sender, EventArgs e) { Button bt = sender as Button; bt.Enabled = false; try { if (mp == null) { mp = new MediaPlayer(); } string preview_path = Path.Combine(ETC.CachePath, "Music", "Preview", $"{music.CodeName}.tsgp"); try { mp.SetDataSource(preview_path); } catch (Exception) { if (ETC.IsServerDown == false) { try { using (WebClient wc = new WebClient()) wc.DownloadFile(Path.Combine(ETC.Server, "Resource", "Music", "Preview", $"{music.CodeName}.opus"), preview_path); mp.SetDataSource(preview_path); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); Toast.MakeText(this, $"Preview 음원 {Resources.GetString(Resource.String.Download_Fail)}", ToastLength.Short).Show(); return; } } else { Toast.MakeText(this, Resource.String.Server_Down_Error, ToastLength.Short).Show(); return; } } finally { } mp.Completion += delegate { bt.Enabled = true; mp.Release(); mp.Dispose(); }; mp.Prepare(); mp.Start(); } catch (Exception ex) { ETC.LogError(this, ex.ToString()); } }