Android Open Source - PinchToClose Main Activity






From Project

Back to project page PinchToClose.

License

The source code is released under:

Apache License

If you think the Android project PinchToClose listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package lt.marius.pinchtoclosedemo.testui;
/*  w ww.  j a  va  2 s  . c o  m*/
import lt.marius.pinchtoclose.MultiFingerGestureDetector;
import lt.marius.pinchtoclose.PinchToClose;
import lt.marius.pinchtoclose.PinchToClose.CustomFinishCallback;
import lt.marius.pinchtoclose.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity extends Activity {

  MultiFingerGestureDetector detector;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.activity_main);
    
    ToggleButton button = (ToggleButton)findViewById(R.id.toggleButton1);
    button.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        PinchToClose.init(MainActivity.this, false, new CustomFinishCallback() {
          
          @Override
          public void finish(Activity activity) {
            Toast t = Toast.makeText(getApplicationContext(), "Activity closed", Toast.LENGTH_SHORT);
            t.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 20);
            t.show();
          }
        },
        isChecked);
      }
    });
    
    //must be called after setContentView()
//    PinchToClose.init(this); // shorthand version

    //More extensive version
    PinchToClose.init(this, false, new CustomFinishCallback() {
      
      @Override
      public void finish(Activity activity) {
        Toast t = Toast.makeText(getApplicationContext(), "Activity closed", Toast.LENGTH_SHORT);
        t.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 20);
        t.show();
      }
    });
    
    
    
    TextView tv = (TextView) findViewById(R.id.textUrl);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setText(Html.fromHtml("<a href=\"https://github.com/marnore/PinchToClose\">Get it on GitHub"));
  }
  
  
}




Java Source Code List

lt.marius.pinchtoclose.CloseDecoratorLayout.java
lt.marius.pinchtoclose.MultiFingerAreaListener.java
lt.marius.pinchtoclose.MultiFingerGestureDetector.java
lt.marius.pinchtoclose.MultiFingerGestureListener.java
lt.marius.pinchtoclose.PinchToClose.java
lt.marius.pinchtoclose.algo.AreaAlgorithm.java
lt.marius.pinchtoclose.algo.DelaunayArea.java
lt.marius.pinchtoclose.algo.TriangleArea.java
lt.marius.pinchtoclose.algo.Visualizable.java
lt.marius.pinchtoclosedemo.testui.MainActivity.java