Skip to content

Commit

Permalink
Readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpolites committed Feb 20, 2012
1 parent a3fcdcf commit 8193f64
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
43 changes: 38 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ Features:
3. Double tap reset
4. Configurable zoom boundaries (min/max)

NOT Implemented (and may never be :/):
Limitations:

1. Fling
2. Rotation
3. Pan and Zoom together
1. Does not support Fling
2. Does not support Rotation
3. Does not support Pan and Zoom together
4. Only supports Bitmap objects and image resources (i.e. does not support setting a Drawable that is not a bitmap/png/jpg)
5. Does not support multiple images on screen

Usage
-----

Configured as View in layout.xml
================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
code::

<com.polites.android.GestureImageView
Expand All @@ -30,3 +32,34 @@ code::
gesture-image:min-scale="0.1"
gesture-image:max-scale="10.0"
android:src="@drawable/image"/>
Configured Programmatically
~~~~~~~~~~~~~~~~~~~~~~~~~~~
code::

import com.polites.android.GestureImageView;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout.LayoutParams;

public class SampleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

GestureImageView view = new GestureImageView(this);
view.setImageResource(R.drawable.image);
view.setLayoutParams(params);

ViewGroup layout = (ViewGroup) findViewById(R.id.layout);

layout.addView(view);
}
}

2 changes: 1 addition & 1 deletion example/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<com.polites.android.GestureImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
gesture-image:min-scale="0.1"
gesture-image:max-scale="10.0"
Expand Down
15 changes: 14 additions & 1 deletion example/src/com/polites/android/example/SampleActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package com.polites.android.example;

import com.polites.android.GestureImageView;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout.LayoutParams;

public class SampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

GestureImageView view = new GestureImageView(this);
view.setImageResource(R.drawable.image);
view.setLayoutParams(params);

ViewGroup layout = (ViewGroup) findViewById(R.id.layout);

layout.addView(view);
}
}
8 changes: 4 additions & 4 deletions main/src/com/polites/android/GestureImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
setupCanvas(w, h, getResources().getConfiguration().orientation);
}

protected void setupCanvas(int measuredWidth, int measuredHeight, int orientation) {

if(bitmap != null) {
if(bitmap != null && !layout) {

int imageWidth = this.bitmap.getWidth();
int imageHeight = this.bitmap.getHeight();
Expand Down Expand Up @@ -118,8 +118,8 @@ protected void setupCanvas(int measuredWidth, int measuredHeight, int orientatio
scaleAdjust = startingScale;
}

this.centerX = (float)measuredWidth / 2.0f;
this.centerY = (float)measuredHeight / 2.0f;
this.centerX = (float)measuredWidth / 2.0f;
this.centerY = (float)measuredHeight / 2.0f;

x = centerX;
y = centerY;
Expand Down

0 comments on commit 8193f64

Please sign in to comment.