Example usage for android.view View setOnLongClickListener

List of usage examples for android.view View setOnLongClickListener

Introduction

In this page you can find the example usage for android.view View setOnLongClickListener.

Prototype

public void setOnLongClickListener(@Nullable OnLongClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked and held.

Usage

From source file:com.appstu.sattafestival.swipe_list.SwipeListViewTouchListener.java

/**
 * Sets current item's front view/*from w ww.  j  a  v a 2s .  co m*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView, final AdapterView adapterView) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition, adapterView);
        }
    });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:com.zhanggb.contacts.app.view.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view//from w  w  w .j  a va2 s  .  co  m
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    //        frontView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                swipeListView.onClickFrontView(downPosition);
    //            }
    //        });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:com.chillax.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view/*from   w  ww  .  j a  v a2  s  . c  o  m*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (downPosition >= 0) {
                    openAnimate(downPosition);
                }
                return false;
            }
        });
    }
}

From source file:cn.fantasee.swipwmenulistview.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view/*w  ww. j  av  a 2  s .com*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView, final int childPosition) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });

    frontView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (swipeOpenOnLongPress) {
                if (downPosition >= 0) {
                    openAnimate(childPosition);
                }
            } else {
                swapChoiceState(childPosition);
            }
            return false;
        }

    });
}

From source file:com.google.corp.productivity.specialprojects.android.samples.fft.AnalyzeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //  Debug.startMethodTracing("calc");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  w  ww . j  ava2s . co  m

    DPRatio = getResources().getDisplayMetrics().density;

    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    Log.i(TAG, " max mem = " + maxMemory + "k");

    // set and get preferences in PreferenceActivity
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    // Set variable according to the preferences
    updatePreferenceSaved();

    textRMSChar = new char[getString(R.string.textview_RMS_text).length()];
    textCurChar = new char[getString(R.string.textview_cur_text).length()];
    textRecChar = new char[getString(R.string.textview_rec_text).length()];
    textPeakChar = new char[getString(R.string.textview_peak_text).length()];

    graphView = (AnalyzeView) findViewById(R.id.plot);

    // travel Views, and attach ClickListener to the views that contain android:tag="select"  
    visit((ViewGroup) graphView.getRootView(), new Visit() {
        @Override
        public void exec(View view) {
            view.setOnLongClickListener(AnalyzeActivity.this);
            view.setOnClickListener(AnalyzeActivity.this);
            ((TextView) view).setFreezesText(true);
        }
    }, "select");

    Resources res = getResources();
    getAudioSourceNameFromIdPrepare(res);

    listItemTextSize = res.getDimension(R.dimen.button_text_fontsize);
    listItemTitleTextSize = res.getDimension(R.dimen.button_text_small_fontsize);

    /// initialize pop up window items list
    // http://www.codeofaninja.com/2013/04/show-listview-as-drop-down-android.html
    popupMenuSampleRate = popupMenuCreate(validateAudioRates(res.getStringArray(R.array.sample_rates)),
            R.id.button_sample_rate);
    popupMenuFFTLen = popupMenuCreate(res.getStringArray(R.array.fft_len), R.id.button_fftlen);
    popupMenuAverage = popupMenuCreate(res.getStringArray(R.array.fft_ave_num), R.id.button_average);

    mDetector = new GestureDetectorCompat(this, new AnalyzerGestureListener());

    setTextViewFontSize();
}

From source file:com.achep.acdisplay.ui.widgets.notification.NotificationActions.java

/**
 * Sets new actions./*from   www .  ja  v  a2s  .  c  o  m*/
 *
 * @param notification the host notification
 * @param actions      the actions to set
 */
public void setActions(@Nullable OpenNotification notification, @Nullable Action[] actions) {
    Check.getInstance().isInMainThread();

    mRemoteInputsMap.clear();
    mActionsMap.clear();
    hideRii();

    if (actions == null) {
        // Free actions' container.
        removeAllViews();
        return;
    } else {
        assert notification != null;
    }

    int count = actions.length;
    View[] views = new View[count];

    // Find available views.
    int childCount = getChildCount();
    int a = Math.min(childCount, count);
    for (int i = 0; i < a; i++) {
        views[i] = getChildAt(i);
    }

    // Remove redundant views.
    for (int i = childCount - 1; i >= count; i--) {
        removeViewAt(i);
    }

    LayoutInflater inflater = null;
    for (int i = 0; i < count; i++) {
        final Action action = actions[i];
        View root = views[i];

        if (root == null) {
            // Initialize layout inflater only when we really need it.
            if (inflater == null) {
                inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                assert inflater != null;
            }

            root = inflater.inflate(getActionLayoutResource(), this, false);
            root = onCreateActionView(root);
            // We need to keep all IDs unique to make
            // TransitionManager.beginDelayedTransition(viewGroup, null)
            // work correctly!
            root.setId(getChildCount() + 1);
            addView(root);
        }

        mActionsMap.put(root, action);

        int style = Typeface.NORMAL;
        root.setOnLongClickListener(null);
        if (action.intent != null) {
            root.setEnabled(true);
            root.setOnClickListener(mActionsOnClick);

            RemoteInput remoteInput = getRemoteInput(action);
            if (remoteInput != null) {
                mRemoteInputsMap.put(action, remoteInput);
                root.setOnLongClickListener(mActionsOnLongClick);

                // Highlight the action
                style = Typeface.ITALIC;
            }
        } else {
            root.setEnabled(false);
            root.setOnClickListener(null);
        }

        // Get message view and apply the content.
        TextView textView = root instanceof TextView ? (TextView) root
                : (TextView) root.findViewById(android.R.id.title);
        textView.setText(action.title);
        if (mTypeface == null)
            mTypeface = textView.getTypeface();
        textView.setTypeface(mTypeface, style);

        Drawable icon = NotificationUtils.getDrawable(getContext(), notification, action.icon);
        if (icon != null)
            icon = onCreateActionIcon(icon);

        if (Device.hasJellyBeanMR1Api()) {
            textView.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            textView.setCompoundDrawables(icon, null, null, null);
        }
    }
}

From source file:com.android.music.MediaPlaybackActivity.java

/** Called when the activity is first created. */
@Override//from  w w  w  . j a  v a 2s  .c om
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mAlbumArtWorker = new Worker("album art worker");
    mAlbumArtHandler = new AlbumArtHandler(mAlbumArtWorker.getLooper());

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.audio_player);

    mCurrentTime = (TextView) findViewById(R.id.currenttime);
    mTotalTime = (TextView) findViewById(R.id.totaltime);
    mProgress = (ProgressBar) findViewById(android.R.id.progress);
    mAlbum = (ImageView) findViewById(R.id.album);
    mArtistName = (TextView) findViewById(R.id.artistname);
    mAlbumName = (TextView) findViewById(R.id.albumname);
    mTrackName = (TextView) findViewById(R.id.trackname);

    View v = (View) mArtistName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mAlbumName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mTrackName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);
    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mQueueButton = (ImageButton) findViewById(R.id.curplaylist);
    mQueueButton.setOnClickListener(mQueueListener);
    mShuffleButton = ((ImageButton) findViewById(R.id.shuffle));
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = ((ImageButton) findViewById(R.id.repeat));
    mRepeatButton.setOnClickListener(mRepeatListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    badSymptoms = new BadSymptoms(this);
}

From source file:com.example.zhangyipeng.swipelibrary.SwipeRecycleViewTouchListener.java

/**
 * Sets current item's front view// w  w w .j a v  a 2s .co  m
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView, final int childPosition) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeRecycleView.onClickFrontView(downPosition);
        }
    });

    frontView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (swipeOpenOnLongPress) {
                if (downPosition >= 0) {
                    openAnimate(childPosition);
                }
            } else {
                swapChoiceState(childPosition);
            }
            return false;
        }

    });
}

From source file:com.fortysevendeg.swipelistview.SwipeRecyclerTouchListener.java

/**
 * Sets current item's front view/* w  w w.  j  a  v a2s.co  m*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView, final int childPosition) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeRecyclerView.onClickFrontView(downPosition);
        }
    });

    frontView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (swipeOpenOnLongPress) {
                if (downPosition >= 0) {
                    openAnimate(childPosition);
                }
            } else {
                swapChoiceState(childPosition);
            }
            return false;
        }

    });
}

From source file:com.gcloud.gaadi.ui.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view//from  w  w w.  j  a v  a  2 s.c  o m
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView, final int childPosition) {
    if (frontView == null) {
        return;
    }
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });

    frontView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (swipeOpenOnLongPress) {
                if (downPosition >= 0) {
                    openAnimate(childPosition);
                }
            } else {
                swapChoiceState(childPosition);
            }
            return false;
        }

    });
}