Skip to content

Commit

Permalink
Trecias
Browse files Browse the repository at this point in the history
  • Loading branch information
laurynas committed Nov 12, 2011
1 parent c2cb92e commit 0f676d2
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 20 deletions.
Binary file added bin/res/drawable/c10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/res/drawable/c9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# project structure.

# Project target.
target=android-7
target=android-10
12 changes: 12 additions & 0 deletions res/anim/grow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="1.5"
android:fromYScale="1.0"
android:toYScale="1.5"
android:duration="150"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fillAfter="true">
</scale>
22 changes: 16 additions & 6 deletions res/layout/trecias.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallerylayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<lt.appcamp.appcamp16.ui.CoverFlow
xmlns:android="http://schemas.android.com/apk/res/android"
Expand All @@ -12,5 +12,15 @@
android:layout_height="wrap_content"
/>

</LinearLayout>
<ImageView
android:id="@+id/preview"
android:background="#0000"
android:scaleType="fitXY"
android:layout_alignTop="@+id/overview"
android:layout_alignBottom="@+id/overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

</RelativeLayout>

89 changes: 76 additions & 13 deletions src/lt/appcamp/appcamp16/Trecias.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

public class Trecias extends Activity
{
Expand All @@ -25,22 +26,84 @@ public void onCreate(Bundle savedInstanceState) {

CoverFlow coverFlow = (CoverFlow) findViewById(R.id.gallery);

PhotoAdapter coverImageAdapter = new PhotoAdapter(this);
coverFlow.setAdapter(coverImageAdapter);
// PhotoAdapter coverImageAdapter = new PhotoAdapter(this);
// coverFlow.setAdapter(coverImageAdapter);
ImageAdapter imageAdapter = new ImageAdapter(this);
coverFlow.setAdapter(imageAdapter);

coverFlow.setSpacing(-25);
coverFlow.setSelection(4, true);
coverFlow.setAnimationDuration(1000);

coverFlow.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {

Toast.makeText(Trecias.this, "" + position, Toast.LENGTH_SHORT).show();

}
});
coverFlow.setOnItemClickListener(new ClickListener(this));
}

public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;

private Integer[] mImageIds = {
R.drawable.k1,
R.drawable.k2,
R.drawable.k3,
R.drawable.k4,
R.drawable.k5,
R.drawable.k6
};

public ImageAdapter(Context c) {
mContext = c;
TypedArray attr = mContext.obtainStyledAttributes(R.styleable.ProductsGallery);
mGalleryItemBackground = attr.getResourceId(
R.styleable.ProductsGallery_android_galleryItemBackground, 0);
attr.recycle();
}

public int getCount() {
return mImageIds.length;
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);

imageView.setImageResource(mImageIds[position]);
imageView.setLayoutParams(new Gallery.LayoutParams(200, 150));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
// imageView.setBackgroundResource(mGalleryItemBackground);

return imageView;
}
}

private class ClickListener implements AdapterView.OnItemClickListener {

private Animation grow = null;
private View lastView = null;

public ClickListener(Context c) {
grow = AnimationUtils.loadAnimation(c, R.anim.grow);
}

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

// Shrink the view that was zoomed
try { if (null != lastView) lastView.clearAnimation();
} catch (Exception clear) { }

// Zoom the new selected view
try { v.startAnimation(grow); } catch (Exception animate) {}

// Set the last view so we can clear the animation
lastView = v;
}

}
}

0 comments on commit 0f676d2

Please sign in to comment.