@Override public void onClick(View v) { ToastUtils.show(getActivity(), "已删除:" + getItem(position).getTitle()); SongManager.with(getActivity()).deleteSong(getItem(position).getId()); PullRightLayout.collapseAll(); updateList(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null); holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name); holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist); holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration); holder.aboveView = convertView.findViewById(R.id.item_root); holder.behindView = convertView.findViewById(R.id.behind); convertView.setTag(holder); convertViewList.add((PullRightLayout) convertView); } else { holder = (ViewHolder) convertView.getTag(); } if (HideApplication.showListAnim) { startAnim(convertView); } SongInfo info = SongManager.with(getActivity()).getSongByIndex(position); holder.mTvName.setText(info.getTitle()); holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum()); holder.mTvDuration.setText( CommonUtils.durationToString(info.getDuration()) + " - " + CommonUtils.getFileSize(info.getPath())); setItemSelected(holder, info.getId() == playingId); convertView.setOnClickListener(new OnItemClick(position)); holder.behindView.setOnClickListener(new OnBehindClick(position)); return convertView; }
@Override public void onReceive(Context context, Intent intent) { AnimationDrawable drawable = (AnimationDrawable) mIvScan.getBackground(); drawable.stop(); ToastUtils.show(context, "找到" + SongManager.with(getActivity()).getSongSize() + "首歌"); updateList(); }
@Override public void onMusicPlaying(int progress, long max) { if (mSongAdapter != null && mSongAdapter.getPlayingId() == 0) { SongInfo song = SongManager.with(getActivity()).getCurrentSong(); if (song != null) { mSongAdapter.setPlaying(song.getId()); } } }
@Override public void onClick(View v) { AnimationDrawable drawable = (AnimationDrawable) mIvScan.getBackground(); if (drawable.isRunning()) { ToastUtils.show(getActivity(), "正在搜索中..."); } else { drawable.start(); Intent intent = new Intent(getActivity(), ScanService.class); intent.putExtras(new Bundle()); SongManager.with(getActivity()).clearSong(); updateList(); getActivity().startService(intent); } }
private View getFooterView() { if (mFooterView == null) { FrameLayout fl = new FrameLayout(getActivity()); TextView tv = new TextView(getActivity()); tv.setGravity(Gravity.CENTER); tv.setTextColor(0xFFaaaaaa); tv.setBackgroundColor(0xFFffffff); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, (int) CommonUtils.dpToPx(getActivity(), 50)); fl.addView(tv, params); mFooterView = fl; } TextView tv = (TextView) mFooterView.getChildAt(0); tv.setText("共有" + SongManager.with(getActivity()).getSongSize() + "首歌"); return mFooterView; }
@Override public SongInfo getItem(int position) { return SongManager.with(getActivity()).getSongByIndex(position); }
@Override public int getCount() { return SongManager.with(getActivity()).getSongSize(); }
@Override protected void onLoading() { SongManager.with(getActivity()).fetchSongFromDb(); }