List of usage examples for android.view ViewGroup setOnLongClickListener
public void setOnLongClickListener(@Nullable OnLongClickListener l)
From source file:com.bullmobi.message.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.easynotification_scene_music, container, false); assert sceneView != null; }//from w ww .j a v a 2 s .c o m mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.acdisplay_scene_music, container, false); assert sceneView != null; }/* w w w . ja va 2 s .c o m*/ mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (draggedBrick != null && dragTargetPosition == position) { return insertionView; }//from w ww . j a va 2 s. c om listItemCount = position + 1; Object item = getItem(position); if (item instanceof ScriptBrick && (!initInsertedBrick || position != positionOfInsertedBrick)) { View scriptBrickView = ((Brick) item).getView(context, position, this); if (draggedBrick == null) { scriptBrickView.setOnClickListener(this); } return scriptBrickView; } View currentBrickView; // dirty HACK // without the footer, position can be 0, and list.get(-1) caused an Indexoutofboundsexception // no clean solution was found if (position == 0) { if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position) instanceof DeadEndBrick) { currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this); } else { currentBrickView = ((Brick) item).getView(context, position, this); } } else { if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position - 1) instanceof DeadEndBrick) { currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this); } else { currentBrickView = ((Brick) item).getView(context, position, this); } } // this one is working but causes null pointer exceptions on movement and control bricks?! // currentBrickView.setOnLongClickListener(longClickListener); // Hack!!! // if wrapper isn't used the longClick event won't be triggered ViewGroup wrapper = (ViewGroup) View.inflate(context, R.layout.brick_wrapper, null); if (currentBrickView.getParent() != null) { ((ViewGroup) currentBrickView.getParent()).removeView(currentBrickView); } wrapper.addView(currentBrickView); if (draggedBrick == null) { if ((selectMode == ListView.CHOICE_MODE_NONE)) { wrapper.setOnClickListener(this); if (!(item instanceof DeadEndBrick)) { wrapper.setOnLongClickListener(dragAndDropListView); } } } if (position == positionOfInsertedBrick && initInsertedBrick && (selectMode == ListView.CHOICE_MODE_NONE)) { initInsertedBrick = false; addingNewBrick = true; dragAndDropListView.setInsertedBrick(position); dragAndDropListView.setDraggingNewBrick(); dragAndDropListView.onLongClick(currentBrickView); return insertionView; } if (animatedBricks.contains(brickList.get(position))) { Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink); wrapper.startAnimation(animation); animatedBricks.remove(brickList.get(position)); } return wrapper; }
From source file:com.samsistemas.calendarview.widget.CalendarView.java
/** * This method prepare and populate the days in the CalendarView *//* w w w.ja v a 2 s . c o m*/ private void setDaysInCalendar() { Calendar calendar = Calendar.getInstance(getLocale()); calendar.setTime(mCalendar.getTime()); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.setFirstDayOfWeek(mFirstDayOfWeek); int firstDayOfMonth = calendar.get(Calendar.DAY_OF_WEEK); // Calculate dayOfMonthIndex int dayOfMonthIndex = CalendarUtility.getWeekIndex(firstDayOfMonth, calendar); int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); final Calendar startCalendar = (Calendar) calendar.clone(); //Add required number of days startCalendar.add(Calendar.DATE, -(dayOfMonthIndex - 1)); int monthEndIndex = 42 - (actualMaximum + dayOfMonthIndex - 1); DayView dayView; ViewGroup dayOfMonthContainer; for (int i = 1; i < 43; i++) { dayOfMonthContainer = (ViewGroup) mView .findViewWithTag(mContext.getString(R.string.day_of_month_container) + i); dayView = (DayView) mView.findViewWithTag(mContext.getString(R.string.day_of_month_text) + i); if (dayView == null) continue; //Apply the default styles dayOfMonthContainer.setOnClickListener(null); dayView.bind(startCalendar.getTime(), getDecoratorsList()); dayView.setVisibility(View.VISIBLE); if (null != getTypeface()) { dayView.setTypeface(getTypeface()); } if (CalendarUtility.isSameMonth(calendar, startCalendar)) { dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener); dayOfMonthContainer.setOnLongClickListener(onDayOfMonthLongClickListener); dayView.setBackgroundColor(mCalendarBackgroundColor); mIsCommonDay = true; if (totalDayOfWeekend().length != 0) { for (int weekend : totalDayOfWeekend()) { if (startCalendar.get(Calendar.DAY_OF_WEEK) == weekend) { dayView.setTextColor(mWeekendColor); mIsCommonDay = false; } } } if (mIsCommonDay) { dayView.setTextColor(mDayOfWeekTextColor); } } else { dayView.setBackgroundColor(mDisabledDayBackgroundColor); dayView.setTextColor(mDisabledDayTextColor); if (!isOverflowDateVisible()) dayView.setVisibility(View.GONE); else if (i >= 36 && ((float) monthEndIndex / 7.0f) >= 1) { dayView.setVisibility(View.GONE); } } dayView.decorate(); //Set the current day color if (mCalendar.get(Calendar.MONTH) == startCalendar.get(Calendar.MONTH)) setCurrentDay(mCalendar.getTime()); startCalendar.add(Calendar.DATE, 1); dayOfMonthIndex++; } // If the last week row has no visible days, hide it or show it in case ViewGroup weekRow = (ViewGroup) mView.findViewWithTag("weekRow6"); dayView = (DayView) mView.findViewWithTag("dayOfMonthText36"); if (dayView.getVisibility() != VISIBLE) { weekRow.setVisibility(GONE); } else { weekRow.setVisibility(VISIBLE); } }