Ejemplo n.º 1
0
        /// <summary>
        /// Fill controls values in card
        /// </summary>
        /// <param name="listViewHolder"></param>
        /// <param name="position"></param>
        private void OnListViewSetControls(ListViewAdapter.ListViewHolder listViewHolder, int position)
        {
            ListItemSong listItemSong = null;

            if (IsFolderButtonPressed)
            {
                listItemSong = SongFoldersList[position];
                string pathOnlyName = GetFolderNameFromPath(listItemSong.getSongPath());
                string fileName     = listItemSong.getSongName();

                listViewHolder.FirstLine.SetText(pathOnlyName, TextView.BufferType.Normal);
                listViewHolder.SecondLine.SetText(listItemSong.getArtist(), TextView.BufferType.Normal);
                listViewHolder.ThirdLine.SetText(listItemSong.getSongPath(), TextView.BufferType.Normal);
            }
            else
            {
                KeyValuePair <string, ListItemSong> songItem = ListItemsRecycler[position];
                listItemSong = songItem.Value;

                string songLenght = (listItemSong.getDuration() == "") ? listItemSong.getArtist() : listItemSong.getDuration();
                string songName   = listItemSong.getSongName();

                listViewHolder.FirstLine.SetText(songName, TextView.BufferType.Normal);
                listViewHolder.SecondLine.SetText(songLenght, TextView.BufferType.Normal);
                listViewHolder.ThirdLine.SetText(listItemSong.getSongPath(), TextView.BufferType.Normal);
            }
        }
Ejemplo n.º 2
0
        private List <ListItemSong> FillSongsFolders()
        {
            List <ListItemSong> list         = new List <ListItemSong>();
            ListItemSong        listItemSong = null;


            RestoreSongsList();

            List <string> paths = ListItemsRecycler.Select(a => a.Value.getSongPath()).ToList();

            paths = paths.Distinct().ToList();


            for (int i = 0; i < paths.Count; i++)
            {
                string path           = paths[i];
                string parentPathName = GetFolderNameFromPath(path);

                try
                {
                    string songsCount = ListItemsRecycler.Count(a => a.Value.getSongPath() == path).ToString() + " " + "שירים";

                    listItemSong = new ListItemSong();

                    listItemSong.setSongName(parentPathName);       // First line
                    listItemSong.setArtist(songsCount.ToString());  // Second line - Song count
                    listItemSong.setSongPath(path);                 // Third line

                    list.Add(listItemSong);
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                }
            }

            listItemSong = new ListItemSong();
            listItemSong.setSongName("כל השירים");                                      // First line
            listItemSong.setArtist(ListItemsRecycler.Count.ToString() + " " + "שירים"); // Second line - Song count
            listItemSong.setSongPath(MUSIC_PATH);                                       // Third line

            list.Insert(0, listItemSong);

            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set the Song props - Name, Artist, Album, Duration
        /// </summary>
        /// <param name="listPositionIndex"></param>
        private void SetSongControls(int listPositionIndex)
        {
            ListItemSong item = ListItemsRecycler[listPositionIndex].Value;

            if (mediaPlayer != null)
            {
                SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
                item.setDuration(dateFormat.Format(new Date(mediaPlayer.Duration)));
            }

            lblSongName.Text = item.getSongName();
            ScrollSongName.SCROLL_END_POINT = lblSongName.Text.Length * 9;
            lblSongArtist.Text = item.getArtist();
            lblAlbum.Text      = GetFolderNameFromPath(item.getSongPath());

            //ScrollSongName.StartPosstion();


            if (lblSongName.Text.Length > SONG_NAME_CHARS_LENGTH_TO_SCROLL)
            {
                scrHorizonSongName.FullScroll(FocusSearchDirection.Right);
                ScrollSongName.Start();
            }
            else
            {
                scrHorizonSongName.FullScroll(FocusSearchDirection.Right);
            }

            UpdateProgressControls();



            //Drawable drawable;
            //Bitmap bitmap;
            //if (item.getPicsToSongPathsArray().size() > 0)
            //{
            //    bitmap = ConvertPictureFileToDrawable(item.getPicsToSongPathsArray().get(0));
            //    imgSongArtist1.setImageBitmap(bitmap);
            //}
            //else
            //{
            //    imgSongArtist1.setImageDrawable(getDrawable(R.drawable.default1));
            //}

            //MainActivity.FadeInPicture(getApplicationContext(), imgSongArtist1, 1);

            //if (item.getPicsToSongPathsArray().size() > 1)
            //{
            //    bitmap = ConvertPictureFileToDrawable(item.getPicsToSongPathsArray().get(1));
            //    imgSongArtist2.setImageBitmap(bitmap);
            //}
            //else
            //{
            //    imgSongArtist2.setImageDrawable(getDrawable(R.drawable.default2));
            //}


            //if (item.getPicsToSongPathsArray().size() > 2)
            //{
            //    bitmap = ConvertPictureFileToDrawable(item.getPicsToSongPathsArray().get(2));
            //    imgSongArtist2.setImageBitmap(bitmap);
            //}
            //else
            //{
            //    imgSongArtist3.setImageDrawable(getDrawable(R.drawable.default3));
            //}

            //keepX = 0;
        }
Ejemplo n.º 4
0
        private void LoadSongsFilesFromPhone()
        {
            //Java.IO.File[] jjj = context.GetExternalFilesDirs("MUSIC");
            //Java.IO.File[] mmm = context.GetExternalMediaDirs();
            //string zzz = System.Environment.SystemDirectory;
            //string aaa = System.Environment.CurrentDirectory;
            //string bbb = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonMusic);
            //string fff = System.IO.Directory.GetCurrentDirectory();
            //string hjhj = LOG_FILE_PATH = System.IO.Directory.GetCurrentDirectory();
            //Java.IO.File hdhd = Android.OS.Environment.DataDirectory;
            //string folderNameDocuments = Android.OS.Environment.DirectoryDocuments;
            //Java.IO.File externalPath = Android.OS.Environment.ExternalStorageDirectory;


            string folderBackup = Android.OS.Environment.DirectoryMusic;        // "ProjTaskReminder"

            ////MUSIC_PATH = Android.OS.Environment.GetExternalStoragePublicDirectory(folderBackup).AbsolutePath;

            lblSongName.Text = "טוען שירים ...";

            MH_Utils.Utils.GetFolderFiles(MUSIC_PATH, "*.mp3", true, "*.jpg");

            lblSongName.Text = "";

            ListItemsPath = MH_Utils.Utils.FilesExtra;

            if (ListItemsPath == null)
            {
                return;
            }

            ListItemsRecycler = new List <KeyValuePair <string, ListItemSong> >();


            for (int i = 0; i < ListItemsPath.Count; i++)
            {
                string fileFullName = ListItemsPath[i].Key;
                string path         = Directory.GetParent(fileFullName).FullName;
                string fileName     = fileFullName.Substring(path.Length + 1);
                string artist       = "Artist " + (i + 1).ToString();
                string album        = Directory.GetParent(fileFullName).Name; // GetFolderNameFromPath(path);


                fileName = MH_Utils.Utils.FixSongName(fileName);
                fileName = fileName.Substring(0, fileName.Length - 4);

                int pos = fileName.IndexOf("-");
                if (pos > -1)
                {
                    if (pos < 4)
                    {
                        artist = album;
                    }
                    else
                    {
                        artist = fileName.Substring(0, pos - 1);
                    }
                }

                ListItemSong listItemSong = new ListItemSong(fileName, artist, album);
                listItemSong.setSongPath(path);
                listItemSong.setSongPathFull(fileFullName);

                ListItemsRecycler.Add(new KeyValuePair <string, ListItemSong>(fileFullName, listItemSong));
            }

            ListItemsPath     = ListItemsPath.OrderBy(a => a.Key).ToList();
            ListItemsRecycler = ListItemsRecycler.OrderBy(a => a.Key).ToList();

            BackupSongList();
        }