public View getViewMedia(int position, View convertView, ViewGroup parent) { View v = convertView; ViewHolder holder; /* convertView may be a recycled view but we must recreate it * if it does not correspond to a media view. */ boolean b_createView = true; if (v != null) { holder = (ViewHolder) v.getTag(); if (holder.viewType == VIEW_MEDIA) b_createView = false; } if (b_createView) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.audio_browser_item, parent, false); holder = new ViewHolder(); holder.layout = v.findViewById(R.id.layout_item); holder.title = (TextView) v.findViewById(R.id.title); Util.setAlignModeByPref(mAlignMode, holder.title); holder.cover = (ImageView) v.findViewById(R.id.cover); holder.subtitle = (TextView) v.findViewById(R.id.subtitle); holder.footer = v.findViewById(R.id.footer); holder.more = (ImageView) v.findViewById(R.id.item_more); holder.viewType = VIEW_MEDIA; v.setTag(holder); } else holder = (ViewHolder) v.getTag(); ListItem item = getItem(position); holder.title.setText(item.mTitle); RelativeLayout.LayoutParams paramsCover; if (mItemType == ITEM_WITH_COVER) { Media media = mItems.get(position).mMediaList.get(0); Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64); if (cover == null) cover = BitmapCache.GetFromResource(v, R.drawable.icon); holder.cover.setImageBitmap(cover); int size = (int) mContext.getResources().getDimension(R.dimen.audio_browser_item_size); paramsCover = new RelativeLayout.LayoutParams(size, size); } else paramsCover = new RelativeLayout.LayoutParams(0, RelativeLayout.LayoutParams.WRAP_CONTENT); holder.cover.setLayoutParams(paramsCover); holder.subtitle.setVisibility(item.mSubTitle == null ? TextView.GONE : TextView.VISIBLE); holder.subtitle.setText(item.mSubTitle); // Remove the footer if the item is just above a separator. holder.footer.setVisibility(isMediaItemAboveASeparator(position) ? View.GONE : View.VISIBLE); final int pos = position; holder.more.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mContextPopupMenuListener != null) mContextPopupMenuListener.onPopupMenu(v, pos); } }); return v; }
public void initPlaybackSpeed() { if (mService.getRate() == 1.0f) { mPlaybackSpeed.setText(null); mPlaybackSpeed.setCompoundDrawablesWithIntrinsicBounds( 0, Util.getResourceFromAttribute(mActivity, R.attr.ic_speed_normal_style), 0, 0); } else { mPlaybackSpeed.setText(Strings.formatRateString(mService.getRate())); mPlaybackSpeed.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_speed_on, 0, 0); } }
@Override public void onConnected(PlaybackService service) { mService = service; initSleep(); initPlaybackSpeed(); if (mMode == MODE_VIDEO) { // Init Chapter final MediaPlayer.Chapter[] chapters = mService.getChapters(-1); final int chaptersCount = chapters != null ? chapters.length : 0; if (chaptersCount > 1) { int index = mService.getChapterIdx(); if (chapters[index].name == null || chapters[index].name.equals("")) mChaptersTitle.setText(getResources().getString(R.string.chapter) + " " + index); else mChaptersTitle.setText(chapters[index].name); } else mChaptersTitle.setVisibility(View.GONE); // Init Audio Delay long audiodelay = mService.getAudioDelay() / 1000l; if (audiodelay == 0l) { mAudioDelay.setText(null); mAudioDelay.setCompoundDrawablesWithIntrinsicBounds( 0, Util.getResourceFromAttribute(mActivity, R.attr.ic_audiodelay), 0, 0); } else { mAudioDelay.setText(Long.toString(audiodelay) + " ms"); mAudioDelay.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_audiodelay_on, 0, 0); } // Init Subtitle Delay long spudelay = mService.getSpuDelay() / 1000l; if (spudelay == 0l) { mSpuDelay.setText(null); mSpuDelay.setCompoundDrawablesWithIntrinsicBounds( 0, Util.getResourceFromAttribute(mActivity, R.attr.ic_subtitledelay), 0, 0); } else { mSpuDelay.setText(Long.toString(spudelay) + " ms"); mSpuDelay.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_subtitledelay_on, 0, 0); } } }
public void initSleep() { String text = null; if (VLCApplication.sPlayerSleepTime == null) { mSleep.setCompoundDrawablesWithIntrinsicBounds( 0, Util.getResourceFromAttribute(mActivity, R.attr.ic_sleep_normal_style), 0, 0); } else { mSleep.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_sleep_on, 0, 0); text = DateFormat.getTimeFormat(mActivity).format(VLCApplication.sPlayerSleepTime.getTime()); } mSleep.setText(text); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); registerForContextMenu(mGridView); // init the information for the scan (2/2) IntentFilter filter = new IntentFilter(); filter.addAction(Util.ACTION_SCAN_START); filter.addAction(Util.ACTION_SCAN_STOP); getActivity().registerReceiver(messageReceiverVideoListFragment, filter); if (mMediaLibrary.isWorking()) { Util.actionScanStart(); } mAnimator = new VideoGridAnimator(mGridView); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (VLCApplication.sPlayerSleepTime != null && VLCApplication.sPlayerSleepTime.before(Calendar.getInstance())) VLCApplication.sPlayerSleepTime = null; if (getArguments() != null && getArguments().containsKey(MODE_KEY)) mMode = getArguments().getInt(MODE_KEY); else mMode = MODE_VIDEO; mTheme = (mMode == MODE_VIDEO || Util.isBlackThemeEnabled()) ? R.style.Theme_VLC_Black : R.style.Theme_VLC; setStyle(DialogFragment.STYLE_NO_FRAME, mTheme); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_advanced_options, container, false); getDialog().setCancelable(true); getDialog().setCanceledOnTouchOutside(true); mPlaybackSpeed = (TextView) root.findViewById(R.id.playback_speed); mPlaybackSpeed.setOnFocusChangeListener(mFocusListener); mPlaybackSpeed.setOnClickListener(this); mPlaybackSpeed.setOnLongClickListener(this); mSleep = (TextView) root.findViewById(R.id.sleep); mSleep.setOnClickListener(this); mSleep.setOnFocusChangeListener(mFocusListener); mJumpTitle = (TextView) root.findViewById(R.id.jump_title); mJumpTitle.setOnClickListener(this); if (mMode == MODE_VIDEO) { mPlayAsAudio = (ImageView) root.findViewById(R.id.play_as_audio_icon); mPlayAsAudio.setOnClickListener(this); mChaptersTitle = (TextView) root.findViewById(R.id.jump_chapter_title); mChaptersTitle.setOnFocusChangeListener(mFocusListener); mChaptersTitle.setOnClickListener(this); mAudioDelay = (TextView) root.findViewById(R.id.audio_delay); mAudioDelay.setOnFocusChangeListener(mFocusListener); mAudioDelay.setOnClickListener(this); mSpuDelay = (TextView) root.findViewById(R.id.spu_delay); mSpuDelay.setOnFocusChangeListener(mFocusListener); mSpuDelay.setOnClickListener(this); } else { root.findViewById(R.id.audio_delay).setVisibility(View.GONE); root.findViewById(R.id.spu_delay).setVisibility(View.GONE); root.findViewById(R.id.jump_chapter_title).setVisibility(View.GONE); root.findViewById(R.id.play_as_audio_icon).setVisibility(View.GONE); } if (mMode == MODE_AUDIO) { mEqualizer = (TextView) root.findViewById(R.id.opt_equalizer); mEqualizer.setOnClickListener(this); } else root.findViewById(R.id.opt_equalizer).setVisibility(View.GONE); mTextColor = mSleep.getCurrentTextColor(); if (getDialog() != null) { int dialogWidth = getResources() .getDimensionPixelSize( mMode == MODE_VIDEO ? R.dimen.adv_options_video_width : R.dimen.adv_options_music_width); int dialogHeight = ViewGroup.LayoutParams.WRAP_CONTENT; getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog() .getWindow() .setBackgroundDrawableResource( Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg)); } return root; }