Example usage for android.view GestureDetector onTouchEvent

List of usage examples for android.view GestureDetector onTouchEvent

Introduction

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

Prototype

public boolean onTouchEvent(MotionEvent ev) 

Source Link

Document

Analyzes the given motion event and if applicable triggers the appropriate callbacks on the OnGestureListener supplied.

Usage

From source file:com.gcssloop.diycode.activity.MainActivity.java

private void initMenu(ViewHolder holder) {
    Toolbar toolbar = holder.get(R.id.toolbar);
    toolbar.setLogo(R.mipmap.logo_actionbar);
    toolbar.setTitle("");
    DrawerLayout drawer = holder.get(R.id.drawer_layout);
    setSupportActionBar(toolbar);/*www  .j  a va  2s.c om*/
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // ? 666
    final GestureDetector detector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            quickToTop(); // 
            return super.onDoubleTap(e);
        }
    });

    toolbar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            detector.onTouchEvent(event);
            return false;
        }
    });

    toolbar.setOnClickListener(this);

    holder.setOnClickListener(this, R.id.fab);

    loadMenuData();
}

From source file:me.jreilly.JamesTweet.Dashboard.DashActivity.java

/**
 * Initializes the navigation drawer and its contents
 *//*from ww w .  j av  a  2  s . c om*/
public void initDrawer() {
    //Find the view id
    mDrawerView = (RecyclerView) findViewById(R.id.left_drawer);
    //Drawer size is fixed
    mDrawerView.setHasFixedSize(true);
    //Add List Dividers
    mDrawerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));

    //Initialize the Nav Adapter to populate the drawer
    mAdapter = new NavAdapter(navItems, this, mUsername, mprofileUrl);
    mActivity = this;
    mDrawerView.setAdapter(mAdapter);

    //Detect swipe to open navigation drawer
    final GestureDetector mGestureDetector = new GestureDetector(DashActivity.this,
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    return true;
                }
            });

    //Detect Item CLicks and respond accordingly
    mDrawerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {

        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            View child = rv.findChildViewUnder(e.getX(), e.getY());

            if (child != null && mGestureDetector.onTouchEvent(e)) {

                if (rv.getChildPosition(child) == 0) {
                    swapToProfile();
                } else if (navItems[rv.getChildPosition(child) - 1].equals("Timeline")) {
                    swapToTimeline();
                } else if (navItems[rv.getChildPosition(child) - 1].equals("Mentions")) {
                    mDrawer.closeDrawers();
                    getSupportFragmentManager().beginTransaction()
                            .replace(R.id.content_frame, new MentionsFragment()).commit();
                } else if (navItems[rv.getChildPosition(child) - 1].equals("Favorites")) {
                    mDrawer.closeDrawers();
                    getSupportFragmentManager().beginTransaction()
                            .replace(R.id.content_frame, new FavoritesFragment()).commit();
                } else if (navItems[rv.getChildPosition(child) - 1].equals("Settings")) {
                    Intent intent = new Intent(mActivity, SettingsActivity.class);
                    startActivity(intent);
                }
                return true;
            }
            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent e) {

        }
    });

    mLayoutManager = new LinearLayoutManager(this);
    mDrawerView.setLayoutManager(mLayoutManager);

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, this.toolbar, R.string.openDrawer,
            R.string.closeDrawer) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }
    };

    mDrawer.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

}

From source file:com.drmidnight.materialtest.MainActivity.java

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

    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);//from  w  ww  . j a v a  2 s  .  c  om

    mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View

    mRecyclerView.setHasFixedSize(true); // Letting the system know that the list objects are of fixed size

    mAdapter = new MyAdapter(TITLES, ICONS, TITLES2, ICONS2, TITLES3, ICONS3, SUBTITLES, NAME, EMAIL, PROFILE,
            this); // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
    // And passing the titles,icons,header view name, header view email,
    // and header view profile picture

    mRecyclerView.setAdapter(mAdapter); // Setting the adapter to RecyclerView

    final GestureDetector mGestureDetector = new GestureDetector(MainActivity.this,
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    return true;
                }

            });

    mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
            View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());

            if (child != null && mGestureDetector.onTouchEvent(motionEvent)) {
                //Drawer.closeDrawers();
                Toast.makeText(MainActivity.this,
                        "The Item Clicked is: " + recyclerView.getChildPosition(child), Toast.LENGTH_SHORT)
                        .show();

                switch (recyclerView.getChildPosition(child)) {
                case 0:
                    //This is the header
                    break;
                case 1:
                    Drawer.closeDrawers();
                    break;
                case 2:
                    Drawer.closeDrawers();
                    Intent diningintent = new Intent(MainActivity.this, DiningActivity.class);
                    startActivity(diningintent);
                    break;
                case 3:
                    Drawer.closeDrawers();
                    break;
                case 4:
                    Drawer.closeDrawers();
                    break;
                case 5:
                    Drawer.closeDrawers();
                    break;
                case 6:
                    //This is a line
                    break;
                case 7:
                    //This is a subtitle
                    break;
                case 8:
                    Drawer.closeDrawers();
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://my.ucsc.edu/psp/ep9prd/?cmd=login&languageCd=ENG"));
                    if (browserIntent.resolveActivity(getPackageManager()) != null) {
                        startActivity(browserIntent);
                    }
                    break;
                case 9:
                    Drawer.closeDrawers();
                    Intent browserIntent2 = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://ecommons.ucsc.edu/portal/login"));
                    if (browserIntent2.resolveActivity(getPackageManager()) != null) {
                        startActivity(browserIntent2);
                    }
                    break;
                case 10:
                    Drawer.closeDrawers();
                    Intent browserIntent3 = new Intent(android.content.Intent.ACTION_VIEW,
                            Uri.parse("https://piazza.com/class"));
                    if (browserIntent3.resolveActivity(getPackageManager()) != null) {
                        startActivity(browserIntent3);
                    }
                    break;
                case 12:
                    Drawer.closeDrawers();
                    break;
                case 13:
                    Drawer.closeDrawers();
                    break;
                case 14:
                    Drawer.closeDrawers();
                    break;
                default:
                    break;
                }

                return true;

            }

            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {

        }
    });

    mLayoutManager = new LinearLayoutManager(this); // Creating a layout Manager

    mRecyclerView.setLayoutManager(mLayoutManager); // Setting the layout Manager

    Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout); // Drawer object Assigned to the view
    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // code here will execute once the drawer is opened( As I dont want anything happened whe drawer is
            // open I am not going to put anything here)
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            // Code here will execute once drawer is closed
        }

    }; // Drawer Toggle Object Made
    Drawer.setDrawerListener(mDrawerToggle); // Drawer Listener set to the Drawer toggle
    mDrawerToggle.syncState(); // Finally we set the drawer toggle sync State

}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

private View.OnTouchListener getOnTouchListener(final XYPlot plot) {
    final GestureDetector gestureDetector = getOneFingerGestureDetector(plot);
    final ScaleGestureDetector scaleGestureDetector = getTwoFingerGestureDetector(plot);
    return new View.OnTouchListener() {
        @Override// w  ww. j a  v a  2s  .  c  o m
        public boolean onTouch(View view, MotionEvent motionEvent) {
            boolean returnMe;
            returnMe = scaleGestureDetector.onTouchEvent(motionEvent);
            returnMe |= gestureDetector.onTouchEvent(motionEvent);
            returnMe |= view.onTouchEvent(motionEvent);
            return returnMe;
        }
    };
}

From source file:nl.hnogames.domoticz.MainActivity.java

/**
 * Adds the items to the drawer and registers a click listener on the items
 *///w w w . j  a v a  2 s  .  co  m
private void addDrawerItems() {
    String[] drawerActions = mSharedPrefs.getNavigationActions();
    fragments = mSharedPrefs.getNavigationFragments();
    int ICONS[] = mSharedPrefs.getNavigationIcons();

    String NAME = getString(R.string.app_name_domoticz);
    String WEBSITE = getString(R.string.domoticz_url);
    int PROFILE = R.drawable.ic_launcher;

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView);
    mRecyclerView.setHasFixedSize(true); // Letting the system know that the list objects are of fixed size

    mAdapter = new NavigationAdapter(drawerActions, ICONS, NAME, WEBSITE, PROFILE, this); // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
    mRecyclerView.setAdapter(mAdapter);

    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager); // Setting the layout Manager

    final GestureDetector mGestureDetector = new GestureDetector(MainActivity.this,
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    return true;
                }
            });

    mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
            View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());

            if (child != null && mGestureDetector.onTouchEvent(motionEvent)) {
                try {
                    searchViewAction.setQuery("", false);
                    searchViewAction.clearFocus();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                try {
                    FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
                    //tx.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
                    tx.replace(R.id.main, Fragment.instantiate(MainActivity.this,
                            fragments[recyclerView.getChildPosition(child) - 1]));
                    tx.commitAllowingStateLoss();
                    addFragmentStack(fragments[recyclerView.getChildPosition(child) - 1]);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                invalidateOptionsMenu();
                mDrawer.closeDrawer(GravityCompat.START);

                return true;
            }

            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });

    setupDrawer();
}

From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

private void addTabDoubleTapListener(final int position, View tab) {
    final GestureDetector gd = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
        @Override/*from   ww  w. j av  a 2s.  co  m*/
        public boolean onDoubleTap(MotionEvent e) {
            if (onTabDoubleTapListener != null)
                onTabDoubleTapListener.onCurrentTabDoubleTap(position);

            return true;
        }
    });

    tab.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gd.onTouchEvent(event);
        }
    });
}

From source file:com.example.android.immersive.ImmersiveDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.immersive_drawer_activity);
    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.fullscreen_content);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);//  w  ww . jav  a2  s.c  om
        configureDrawer(toolbar);
        getSupportActionBar().setTitle("");
    }
    mDecorView = getWindow().getDecorView();
    mDecorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int flags) {
            boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
            controlsView.animate().alpha(visible ? 1 : 0).translationY(visible ? 0 : controlsView.getHeight());
            if (getSupportActionBar() == null) {
                return;
            }
            if (visible) {
                getSupportActionBar().show();
            } else {
                getSupportActionBar().hide();
            }
        }
    });
    contentView.setClickable(true);
    final GestureDetector clickDetector = new GestureDetector(this,
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    if (!USE_FULLSCREEN) {
                        return true;
                    }
                    boolean visible = (mDecorView.getSystemUiVisibility()
                            & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
                    if (visible) {
                        hideSystemUI();
                    } else {
                        showSystemUI();
                    }
                    return true;
                }
            });
    contentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return clickDetector.onTouchEvent(motionEvent);
        }
    });
}

From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail);
    getWindow().getDecorView().setBackgroundResource(
            PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "light").equals("dark")
                    ? R.color.darkColorTransparent
                    : R.color.lightColorTransparent);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Locate the main ImageView and TextView
    mImageView = (ImageView) findViewById(R.id.imageView);
    final TextView mTextView = (TextView) findViewById(R.id.textView);

    mSectionNumber = getIntent().getIntExtra(SECTION_NUMBER, 0);
    registerForContextMenu(mImageView);// w  w  w  . jav  a 2  s . com
    mImageView.setLongClickable(false);

    // Enable some additional newer visibility and ActionBar features
    // to create a more immersive photo viewing experience
    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        // Set home as up
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar and TextView as the visibility changes
        mImageView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                    if (mSectionNumber == 1) {
                        mTextView.animate().translationY(mTextView.getHeight())
                                .setListener(new AnimatorListenerAdapter() {
                                    @Override
                                    public void onAnimationEnd(Animator animation) {
                                        mTextView.setVisibility(View.GONE);
                                    }
                                });
                    }
                } else {
                    actionBar.show();
                    if (mSectionNumber == 1) {
                        mTextView.animate().translationY(0).setListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationStart(Animator animation) {
                                mTextView.setVisibility(View.VISIBLE);
                            }
                        });
                    }
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    GestureListener.init(this, mImageView);
    ScaleGestureListener.init(mImageView);

    // Use the ImageWorker to load the image into the ImageView
    // (so a single cache can be used over all pages in the ViewPager)
    // based on the extra passed in to this activity
    int position = getIntent().getIntExtra(POSITION, 0);
    switch (mSectionNumber) {
    case 0:
        GalleryWorker.loadImage(position, mImageView);
        break;
    case 1:
        FotkiWorker.loadImage(position, mImageView);
        mTextView.setText(getResources().getString(R.string.detail_text, FotkiWorker.getAuthor(),
                new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()).format(FotkiWorker.getPublished())));
        break;
    case 2:
        ResourcesWorker.loadImage(position, mImageView);
        break;
    }
    setTitle(ImageWorker.getTitle());

    // First we create the GestureListener that will include all our callbacks.
    // Then we create the GestureDetector, which takes that listener as an argument.
    GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener();
    final GestureDetector gd = new GestureDetector(this, gestureListener);

    ScaleGestureDetector.SimpleOnScaleGestureListener scaleGestureListener = new ScaleGestureListener();
    final ScaleGestureDetector sgd = new ScaleGestureDetector(this, scaleGestureListener);

    /* For the view where gestures will occur, we create an onTouchListener that sends
     * all motion events to the gesture detectors.  When the gesture detectors
     * actually detects an event, it will use the callbacks we created in the
     * SimpleOnGestureListener and SimpleOnScaleGestureListener to alert our application.
    */

    findViewById(R.id.frameLayout).setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            gd.onTouchEvent(motionEvent);
            sgd.onTouchEvent(motionEvent);
            return true;
        }
    });
}

From source file:org.strongswan.android.ui.fragment.ImcStateFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.imc_state_fragment, container, false);

    mButton = (LinearLayout) view.findViewById(R.id.imc_state_button);
    mButton.setOnClickListener(new OnClickListener() {
        @Override/*from ww w  . j a  v  a2 s. c  o  m*/
        public void onClick(View v) {
            Intent intent;
            if (mService != null && !mService.getRemediationInstructions().isEmpty()) {
                intent = new Intent(getActivity(), RemediationInstructionsActivity.class);
                intent.putParcelableArrayListExtra(
                        RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS,
                        new ArrayList<RemediationInstruction>(mService.getRemediationInstructions()));
            } else {
                intent = new Intent(getActivity(), LogActivity.class);
            }
            startActivity(intent);
        }
    });
    final GestureDetector gestures = new GestureDetector(getActivity(),
            new GestureDetector.SimpleOnGestureListener() {
                /* a better value would be getScaledTouchExplorationTapSlop() but that is hidden */
                private final int mMinDistance = ViewConfiguration.get(getActivity()).getScaledTouchSlop() * 4;

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (Math.abs(e1.getX() - e2
                            .getX()) >= mMinDistance) { /* only if the user swiped a minimum horizontal distance */
                        if (mService != null) {
                            mService.setImcState(ImcState.UNKNOWN);
                        }
                        return true;
                    }
                    return false;
                }
            });
    mButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestures.onTouchEvent(event);
        }
    });

    mStateView = (TextView) view.findViewById(R.id.imc_state);
    mAction = (TextView) view.findViewById(R.id.action);

    return view;
}

From source file:life.knowledge4.videotrimmer.K4LVideoTrimmer.java

private void setUpListeners() {
    mListeners = new ArrayList<>();
    mListeners.add(new OnProgressVideoListener() {
        @Override/*from ww  w  . j av  a  2s . c o  m*/
        public void updateProgress(int time, int max, float scale) {
            updateVideoProgress(time);
        }
    });
    mListeners.add(mVideoProgressIndicator);

    findViewById(R.id.btCancel).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            onCancelClicked();
        }
    });

    findViewById(R.id.btSave).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            onSaveClicked();
        }
    });

    final GestureDetector gestureDetector = new GestureDetector(getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    onClickVideoPlayPause();
                    return true;
                }
            });

    mVideoView.setOnErrorListener(new OnErrorListener() {
        @Override
        public boolean onError() {
            if (mOnTrimVideoListener != null)
                mOnTrimVideoListener.onError("Something went wrong");
            return false;
        }
    });

    mVideoView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, @NonNull MotionEvent event) {
            gestureDetector.onTouchEvent(event);
            return true;
        }
    });

    mRangeSeekBarView.addOnRangeSeekBarListener(new OnRangeSeekBarListener() {
        @Override
        public void onCreate(RangeSeekBarView rangeSeekBarView, int index, float value) {
            // Do nothing
        }

        @Override
        public void onSeek(RangeSeekBarView rangeSeekBarView, int index, float value) {
            onSeekThumbs(index, value);
        }

        @Override
        public void onSeekStart(RangeSeekBarView rangeSeekBarView, int index, float value) {
            // Do nothing
        }

        @Override
        public void onSeekStop(RangeSeekBarView rangeSeekBarView, int index, float value) {
            onStopSeekThumbs();
        }
    });
    mRangeSeekBarView.addOnRangeSeekBarListener(mVideoProgressIndicator);

    mHolderTopView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            onPlayerIndicatorSeekChanged(progress, fromUser);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            onPlayerIndicatorSeekStart();
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            onPlayerIndicatorSeekStop(seekBar);
        }
    });

    mVideoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared() {
            onVideoPrepared();
        }
    });

    mVideoView.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion() {
            onVideoCompleted();
        }
    });
}