Skip to content

Intercept onBackPressed

JingYeoh edited this page Dec 18, 2017 · 1 revision

Fragment remove operation from the stack in this library is worked by onBackPressed method,but sometimes we nedd intercept this method to do something.This library provides api for this.

How to intercept?

Add a public method onRiggerBackPressed with no parameter.

@Puppet
public class TestFragment extent Fragment{
  public void onRiggerBackPressed(){
    //Rigger.getRigger(this).onBackPressed();
    //if you nedd intercept onBackPressed method,do not write the above code.
  }
}

If your class contains onRiggerBackPressed method,then this method will be called as the host Activity#onBackPressed is calling.If you need use the default operation of library, add Rigger.getRigger(this).onBackPressed() to the method.