Example usage for android.view GestureDetector GestureDetector

List of usage examples for android.view GestureDetector GestureDetector

Introduction

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

Prototype

public GestureDetector(Context context, OnGestureListener listener) 

Source Link

Document

Creates a GestureDetector with the supplied listener.

Usage

From source file:com.chrynan.guitarchords.view.GuitarChordView.java

private void init(Context context, AttributeSet attrs) {
    detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override//ww w  .ja va  2 s .co  m
        public boolean onDown(MotionEvent event) {
            boolean isMarkerInChord = false;
            int fret = NO_FRET, string = -1;
            fret = getSelectedFret(event);
            string = getSelectedString(event);
            touchEventMarker = new ChordMarker(string, fret, NO_FINGER);
            return true;
        }

        @Override
        public void onLongPress(MotionEvent event) {
            if (editable && touchEventMarker != null && chord != null && chord.contains(touchEventMarker)) {
                InputMethodManager imm = (InputMethodManager) getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(GuitarChordView.this, InputMethodManager.SHOW_IMPLICIT);
            }
        }
    });
    chord = new Chord();
    showFretNumbers = true;
    showFingerNumbers = true;
    editable = false;
    stringCount = 6;
    listeners = new ArrayList<>();
    fretNumberListeners = new ArrayList<>();
    stringListeners = new ArrayList<>();
    touchEventMarker = null;
    mutedText = MUTED_TEXT;
    openStringText = OPEN_STRING_TEXT;
    initPaint();
    if (attrs != null) {
        //TODO handle custom attribute values
        TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.GuitarChordView, 0, 0);
        try {
            bridgeNutColor = a.getColor(R.styleable.GuitarChordView_bridgeNutColor, DEFAULT_COLOR);
            bridgeNutPaint.setColor(bridgeNutColor);
            fretMarkerColor = a.getColor(R.styleable.GuitarChordView_fretMarkerColor, DEFAULT_COLOR);
            fretMarkerPaint.setColor(fretMarkerColor);
            stringColor = a.getColor(R.styleable.GuitarChordView_stringColor, DEFAULT_COLOR);
            stringPaint.setColor(stringColor);
            fretNumberColor = a.getColor(R.styleable.GuitarChordView_fretNumberColor, DEFAULT_COLOR);
            fretNumberPaint.setColor(fretNumberColor);
            stringMarkerColor = a.getColor(R.styleable.GuitarChordView_stringMarkerColor, DEFAULT_COLOR);
            stringMarkerPaint.setColor(stringMarkerColor);
            noteColor = a.getColor(R.styleable.GuitarChordView_noteColor, DEFAULT_COLOR);
            notePaint.setColor(noteColor);
            noteNumberColor = a.getColor(R.styleable.GuitarChordView_noteNumberColor, WHITE);
            noteNumberPaint.setColor(noteNumberColor);
            barLineColor = a.getColor(R.styleable.GuitarChordView_barLineColor, DEFAULT_COLOR);
            barLinePaint.setColor(barLineColor);
            mutedText = a.getString(R.styleable.GuitarChordView_mutedText);
            mutedText = (mutedText == null) ? MUTED_TEXT : mutedText;
            openStringText = a.getString(R.styleable.GuitarChordView_openStringText);
            openStringText = (openStringText == null) ? OPEN_STRING_TEXT : openStringText;
            stringCount = a.getInt(R.styleable.GuitarChordView_stringAmount, 6);
            editable = a.getBoolean(R.styleable.GuitarChordView_editable, false);
            showFingerNumbers = a.getBoolean(R.styleable.GuitarChordView_showFingerNumbers, true);
            showFretNumbers = a.getBoolean(R.styleable.GuitarChordView_showFretNumbers, true);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            a.recycle();
        }
    }
}

From source file:de.tlabs.ssr.g1.client.SourcesView.java

private void init() {
    // make this view focusable
    setFocusable(true);/*w ww. j  a  v  a2  s  .  co m*/

    // init fields
    viewportTransformation = new Matrix();
    newViewportTransformation = new Matrix();
    inverseViewportTransformation = new Matrix();

    selectionOffset = new float[2];
    touchPoint = new float[2];

    buffer = ByteBuffer.allocate(1024);

    scalingInterpolator = new TimedInterpolator();
    scalingInterpolator.setDuration(800);
    translationXInterpolator = new TimedInterpolator();
    translationXInterpolator.setDuration(800);
    translationYInterpolator = new TimedInterpolator();
    translationYInterpolator.setDuration(800);
    rotationInterpolator = new TimedInterpolator();
    rotationInterpolator.setDuration(800);
    centerRotationInterpolator = new TimedInterpolator();
    centerRotationInterpolator.setDuration(800);

    currentOrientation = getContext().getResources().getConfiguration().orientation;
    setOrientationFlag(true);

    if (SourcesView.paint == null) {
        SourcesView.paint = new Paint();
        SourcesView.paint.setAntiAlias(false);
        SourcesView.paint.setStrokeWidth(0);
        SourcesView.paint.setTextAlign(Paint.Align.CENTER);
        SourcesView.paint.setTextSize(9.0f);
    }

    // set up orientation event listener
    orientationEventListener = new OrientationEventListener(getContext(), SensorManager.SENSOR_DELAY_NORMAL) {
        @Override
        public void onOrientationChanged(int orientation) {
            if ((orientation >= 80 && orientation <= 100) || (orientation >= 260 && orientation <= 280)) { // landscape
                setOrientation(Configuration.ORIENTATION_LANDSCAPE);
            } else if ((orientation >= 350 || orientation <= 10)
                    || (orientation >= 170 && orientation <= 190)) { // portrait
                setOrientation(Configuration.ORIENTATION_PORTRAIT);
            }
        }
    };
    if (!GlobalData.orientationTrackingEnabled) // orientation tracking and screen rotation tracking don't go together
        orientationEventListener.enable();

    // set up gesture detector
    gestureDetector = new GestureDetector(getContext(), this);
    gestureDetector.setIsLongpressEnabled(false);
    gestureDetector.setOnDoubleTapListener(this);

    // init viewport transformation matrix
    recalculateViewportTransformation();
}

From source file:me.littlecheesecake.listviewwidget.HorizontalListLayout.java

public HorizontalListLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mEdgeGlowLeft = new EdgeEffectCompat(context);
    mEdgeGlowRight = new EdgeEffectCompat(context);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    bindGestureDetector();//from www. ja v  a2s . c  o  m
    initView();
    retrieveXmlConfiguration(context, attrs);
    setWillNotDraw(false);

    // If the OS version is high enough then set the friction on the fling tracker */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION);
    }
}

From source file:me.tb.player.SkeletonActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the Google API Client with access to Plus and Games
    mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
            .addApi(Games.API).addScope(Games.SCOPE_GAMES).build();

    initFragments();// w w  w.  j  a  v a 2  s . c  o  m

    dbAdapter = new DBAdapter(this);

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().hide();

    rules = new RulesForStealingWords();

    gestureScanner = new GestureDetector(this, new MyGestureListener());

    tb_tiles = (Button) findViewById(R.id.toolbar_tiles);

    Button tb_pass = (Button) findViewById(R.id.toolbar_pass);
    tb_pass.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            messageAtPass("Are you sure you want to pass?\n\nThis action will end your turn.");
        }
    });

    Button tb_shuffle = (Button) findViewById(R.id.toolbar_shuffle);
    tb_shuffle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            messageAtShuffle("Are you sure you want to shuffle the tiles?\n\nThis action will end your turn.");
        }
    });
}

From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripView.java

public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    final LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.suggestions_strip, this);

    mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip);
    mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key);
    mAddToDictionaryStrip = (ViewGroup) findViewById(R.id.add_to_dictionary_strip);
    mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
    mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mAddToDictionaryStrip,
            mImportantNoticeStrip);/*  w  w w .  j  a  va  2  s .  c om*/

    for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
        final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
        word.setOnClickListener(this);
        word.setOnLongClickListener(this);
        mWordViews.add(word);
        final View divider = inflater.inflate(R.layout.suggestion_divider, null);
        mDividerViews.add(divider);
        final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
        info.setTextColor(Color.WHITE);
        info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP);
        mDebugInfoViews.add(info);
    }

    mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews,
            mDebugInfoViews);

    mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
    mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer
            .findViewById(R.id.more_suggestions_view);
    mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);

    final Resources res = context.getResources();
    mMoreSuggestionsModalTolerance = res
            .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance);
    mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener);

    final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle,
            R.style.SuggestionStripView);
    final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey);
    keyboardAttr.recycle();
    mVoiceKey.setImageDrawable(iconVoice);
    mVoiceKey.setOnClickListener(this);
}

From source file:uk.co.senab.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView, PdfiumCore pdfiumCore, PdfDocument pdfDocument, int pageIndex,
        float pageScale, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    this.pdfiumCore = pdfiumCore;
    this.pdfDocument = pdfDocument;
    this.pageIndex = pageIndex;

    pdfiumCore.openPage(pdfDocument, pageIndex);
    originalBitmapSize.set((int) (pageScale * pdfiumCore.getPageWidthPoint(pdfDocument, pageIndex)),
            (int) (pageScale * pdfiumCore.getPageHeightPoint(pdfDocument, pageIndex)));

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;/*w  ww  .  ja  va2 s  .  co m*/
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    // Finally, update the UI so that we're zoomable

    setZoomable(zoomable);
}

From source file:org.torproject.android.Orbot.java

private void doLayout() {
    setContentView(R.layout.layout_main);

    mViewMain = findViewById(R.id.viewMain);
    lblStatus = (TextView) findViewById(R.id.lblStatus);
    lblStatus.setOnLongClickListener(this);
    imgStatus = (ImageProgressView) findViewById(R.id.imgStatus);
    imgStatus.setOnLongClickListener(this);
    imgStatus.setOnTouchListener(this);

    lblStatus.setText("Initializing the application...");

    downloadText = (TextView) findViewById(R.id.trafficDown);
    uploadText = (TextView) findViewById(R.id.trafficUp);
    mTxtOrbotLog = (TextView) findViewById(R.id.orbotLog);

    mDrawer = ((SlidingDrawer) findViewById(R.id.SlidingDrawer));
    Button slideButton = (Button) findViewById(R.id.slideButton);
    if (slideButton != null) {
        slideButton.setOnTouchListener(new OnTouchListener() {

            @Override/* w  w w .j  a va2s. c  o  m*/
            public boolean onTouch(View v, MotionEvent event) {

                if (event.equals(MotionEvent.ACTION_DOWN)) {
                    mDrawerOpen = !mDrawerOpen;
                    mTxtOrbotLog.setEnabled(mDrawerOpen);
                }
                return false;
            }

        });
    }

    ScrollingMovementMethod smm = new ScrollingMovementMethod();

    mTxtOrbotLog.setMovementMethod(smm);
    mTxtOrbotLog.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setText(mTxtOrbotLog.getText());
            Toast.makeText(Orbot.this, "LOG COPIED TO CLIPBOARD", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    downloadText.setText(formatCount(0) + " / " + formatTotal(0));
    uploadText.setText(formatCount(0) + " / " + formatTotal(0));

    // Gesture detection
    mGestureDetector = new GestureDetector(this, new MyGestureDetector());

}

From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java

/** Called when the activity is first created. */
@Override/*from w w w. ja  v  a  2s.c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Restore preferences
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.read_book);
    setupConstants();

    this.uiHandler = new Handler();

    HandlerThread bgThread = new HandlerThread("background");
    bgThread.start();
    this.backgroundHandler = new Handler(bgThread.getLooper());

    this.waitDialog = new ProgressDialog(this);
    this.waitDialog.setOwnerActivity(this);
    this.waitDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            // This just consumes all key events and does nothing.
            return true;
        }
    });

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    this.gestureDetector = new GestureDetector(this, new NavGestureDetector(bookView, this, metrics));
    //      this.gestureDetector = new GestureDetector(new NavGestureDetector(
    //bookView, this, metrics));

    this.gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };

    this.progressBar.setFocusable(true);
    this.progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        private int seekValue;

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            bookView.navigateToPercentage(this.seekValue);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                seekValue = progress;
                percentageField.setText(progress + "% ");
            }
        }
    });

    this.viewSwitcher.setOnTouchListener(gestureListener);
    bookView.setOnTouchListener(gestureListener);

    bookView.addListener(this);
    bookView.setSpanner(getInjector().getInstance(HtmlSpanner.class));
    //      this.bookView.setSpanner(new HtmlSpanner());

    this.oldBrightness = config.isBrightnessControlEnabled();
    this.oldStripWhiteSpace = config.isStripWhiteSpaceEnabled();
    this.oldFontName = config.getFontFamily().getName();

    registerForContextMenu(bookView);

    String file = getIntent().getStringExtra("file_name");
    if (file == null && getIntent().getData() != null) {
        file = getIntent().getData().getPath();
    }

    if (file == null) {
        file = config.getLastOpenedFile();
    }

    updateFromPrefs();
    updateFileName(savedInstanceState, file);

    if ("".equals(fileName)) {

        //         Intent intent = new Intent(this, LibraryActivity.class);
        //         startActivity(intent);
        //         finish();
        //         return;
        //         Util.toast(this, "Launch library activity. Empty file name");

    } else {

        /**         if (savedInstanceState == null && config.isSyncEnabled()) {
                    new DownloadProgressTask().execute();
                 } else {**/
        bookView.restore();
        //         }
    }

}

From source file:com.fa.imaged.activity.DetailActivityV2.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = new InstagramApp(getBaseContext(), ApplicationData.CLIENT_ID, ApplicationData.CLIENT_SECRET,
            ApplicationData.CALLBACK_URL);
    // Get Theme Info
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    selectedTheme = prefs.getString("theme_color", "0");
    selectedThemeInt = Integer.parseInt(selectedTheme);
    themePrimaryColors = getResources().getStringArray(R.array.themeColorsPrimary);
    themePrimaryDarkColors = getResources().getStringArray(R.array.themeColorsPrimaryDark);

    headerHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_max_height);
    minHeaderHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_height);
    toolbarTitleLeftMargin = getResources().getDimensionPixelSize(R.dimen.toolbar_left_margin);

    detailImageLoaderv2 = (InstagramImage) getIntent().getSerializableExtra("EXTRA_DATA");

    detailVideoV2 = (VideoView) findViewById(R.id.post_video);
    detailImageV2 = (ImageView) findViewById(R.id.post_image);
    ViewCompat.setTransitionName(detailImageV2, EXTRA_IMAGE);
    ViewCompat.setTransitionName(detailVideoV2, EXTRA_IMAGE);

    detailScrollView = (ObservableScrollView) findViewById(R.id.detail_scrollview);
    detailUserInfo = (RelativeLayout) findViewById(R.id.detail_userinfo);
    detailShare = (LinearLayout) findViewById(R.id.detail_share);
    detailComments = (LinearLayout) findViewById(R.id.detail_comments);
    detailLike = (LinearLayout) findViewById(R.id.detail_like);

    detailFullName = (TextView) findViewById(R.id.detail_fullname);
    detailUserName = (TextView) findViewById(R.id.detail_username);
    detailDate = (TextView) findViewById(R.id.detail_date);
    detailCaption = (TextView) findViewById(R.id.detail_postcaption);

    detailLikeStatus = (ImageView) findViewById(R.id.detail_likeStatus);
    detailLikeCounts = (TextView) findViewById(R.id.detail_likeCounts);
    detailCommentCounts = (TextView) findViewById(R.id.detail_commentCounts);

    detailProfilePic = (ImageView) findViewById(R.id.detail_user_pic);

    detailvBgLike = (View) findViewById(R.id.vBgLike);
    detailivLike = (ImageView) findViewById(R.id.ivLike);

    Picasso.with(this).load(detailImageLoaderv2.profile_picture).transform(new PicassoRound())
            .into(detailProfilePic);//from ww w . java 2 s . c o  m

    detailFullName.setText(detailImageLoaderv2.full_name);
    detailUserName.setText(detailImageLoaderv2.username + ", ");
    detailDate.setText(detailImageLoaderv2.taken_at);

    if (detailImageLoaderv2.user_has_liked) {
        Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
        myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
        detailLikeStatus.setImageDrawable(myIcon);
    }

    if (detailImageLoaderv2.caption != null) {
        detailCaption.setText(detailImageLoaderv2.caption);
    } else {
        detailCaption.setVisibility(View.GONE);
    }
    detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
    detailCommentCounts.setText(String.valueOf(detailImageLoaderv2.comment_count));

    detailImageV2.setOnTouchListener(new OnTouchListener() {
        private GestureDetector gestureDetector = new GestureDetector(DetailActivityV2.this,
                new GestureDetector.SimpleOnGestureListener() {
                    boolean isTouchFirst = true;

                    @Override
                    public boolean onDoubleTap(MotionEvent eV) {
                        animatePhotoLike();
                        if (!detailImageLoaderv2.user_has_liked) {
                            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0);
                            liker.execute();
                            try {
                                detailImageLoaderv2 = liker.get();
                            } catch (InterruptedException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (ExecutionException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            if (detailImageLoaderv2.user_has_liked) {
                                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                                myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
                                detailLikeStatus.setImageDrawable(myIcon);
                            }
                            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
                        }
                        return super.onDoubleTap(eV);
                    }

                    // implement here other callback methods like onFling, onScroll as necessary
                    @Override
                    public boolean onSingleTapConfirmed(MotionEvent e) {
                        if (isTouchFirst) {
                            isTouchFirst = false;

                            getToolbar().animate().translationY(-getToolbar().getBottom()).alpha(0)
                                    .setDuration(320).setInterpolator(new DecelerateInterpolator());

                        } else {
                            isTouchFirst = true;
                            getToolbar().animate().translationY(0).alpha(1).setDuration(400)
                                    .setInterpolator(new DecelerateInterpolator());

                            //mSystemUiHider.show();
                            Log.d("Here isTouch is false", ">");

                        }
                        return true;
                    }
                });

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            gestureDetector.onTouchEvent(event);
            return true;
        }
    });
    detailShare.setOnClickListener(this);
    detailLike.setOnClickListener(this);
    detailProfilePic.setOnClickListener(this);
    detailScrollView.getViewTreeObserver()
            .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {

                @Override
                public void onScrollChanged() {

                    int scroll = detailScrollView.getScrollY();
                    saveInitialScroll(scroll);
                    /*
                    if(detailUserInfo != null){
                       if (getAlpha(-scroll - getToolbar().getHeight()) >= 1.0f) {
                          detailUserInfo.setTranslationY(-detailUserInfo.getHeight() + getToolbar().getHeight());
                       }
                       else {
                          detailUserInfo.setTranslationY(-scroll - detailUserInfo.getHeight());
                       }
                    }
                    */
                    findViewById(R.id.detail_image_container)
                            .setTranslationY(Math.max(0, detailScrollView.getScrollY() + minHeaderTranslation));

                    float offset = 1 - Math.max((float) (-minHeaderTranslation - detailScrollView.getScrollY())
                            / -minHeaderTranslation, 0f);

                    // Now that we have this ratio, we only have to apply translations, scales,
                    // alpha, etc. to the header views

                    // For instance, this will move the toolbar title & subtitle on the X axis 
                    // from its original position when the ListView will be completely scrolled
                    // down, to the Toolbar title position when it will be scrolled up.
                    //detailFullName.setTranslationX(toolbarTitleLeftMargin * offset);
                    //detailUserName.setTranslationX(toolbarTitleLeftMargin * offset);
                    //detailProfilePic.animate().alpha(1.0f * offset).translationX(-toolbarTitleLeftMargin * offset);
                }
            });
    commentsAdapter = new CommentsAdapter(this, detailImageLoaderv2.comment_list);
    if (detailImageLoaderv2.comment_count > 8) {
        Button load_more_button = new Button(this);
        load_more_button.setText(getResources().getString(R.string.load_old_comments));
        load_more_button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), getResources().getString(R.string.coming_soon),
                        Toast.LENGTH_SHORT).show();

            }
        });
        detailComments.addView(load_more_button, 0);
    }
    for (int i = 0; i < commentsAdapter.getCount(); i++) {

        View item = commentsAdapter.getView(i, null, detailComments);

        detailComments.addView(item);
    }
}

From source file:com.pseudosurface.levels.template.SimulatorActivity.java

public MyGLSurfaceView(Context context, SimulatorActivity simulation) {
    super(context);

    gestureDetector = new GestureDetector(context, new GestureListener());

    this.simulation = simulation;

    // Create an OpenGL ES 2.0 context.
    setEGLContextClientVersion(2);/*w  ww  .  j  av a  2  s. c  om*/

    // Set the Renderer for drawing on the GLSurfaceView
    mRenderer = simulation.getRenderer();

    setRenderer(mRenderer);

    setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}