Commit 8102ea02 authored by v.tarantik's avatar v.tarantik Committed by Matyáš Latner

Nasazeni sipky, zatim nefunkcni pro Nexus 7

Conflicts:
	.gitignore
	src/main/java/cz/nic/tablexia/newusers/fragment/AnimationNewUserFragment.java
parent ca26c21b
......@@ -12,4 +12,4 @@
# Project target.
target=android-19
android.library.reference.1=libraries/AndEngine-1.0.0-SNAPSHOT
android.library.reference.1=../AndEngine/AndEngine-GLES2-AnchorCenter
<?xml version="1.0" encoding="utf-8"?>
<!--
Tablexia
Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="60" android:duration="1000"
android:interpolator="@android:anim/linear_interpolator" />
......@@ -40,6 +40,17 @@
android:layout_centerInParent="true"
android:src="@drawable/newuseranim_newspaper"
android:visibility="gone" />
<cz.nic.tablexia.widget.RatioPositionSizeImageView
android:id="@+id/arrow_newspaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_newspaper"
android:visibility="visible"
custom:displayRatioType="height"
custom:displaySizeRatio="0.15"
custom:xPositionRatio="0.08"
custom:yPositionRatio="0.45" />
<RelativeLayout
android:id="@+id/newuseranim_newspaper_open1_image"
......
......@@ -26,6 +26,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
......@@ -37,6 +38,7 @@ import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
......@@ -80,6 +82,7 @@ public class AnimationNewUserFragment extends Fragment implements OnTouchListene
private RatioPositionSizeImageView knock1;
private RatioPositionSizeImageView knock2;
private RatioPositionSizeImageView knock3;
private RatioPositionSizeImageView arrowNewspaper;
private RatioPositionTextView topicBeard;
private RatioPositionTextView topicBalloon;
......@@ -90,6 +93,9 @@ public class AnimationNewUserFragment extends Fragment implements OnTouchListene
private float displayRatio;
private Handler handler = new Handler();
private Runnable runnable;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
pageLayout = (ViewGroup) inflater.inflate(NEWUSER_LAYOUT_BALCONY_ID, null);
......@@ -123,6 +129,36 @@ public class AnimationNewUserFragment extends Fragment implements OnTouchListene
topicSwimwear = (RatioPositionTextView) pageLayout.findViewById(R.id.newuseranim_bubble_swimsuit);
topicDetective = (RatioPositionTextView) pageLayout.findViewById(R.id.newuseranim_bubble_detective);
handler.removeCallbacks(runnable);
arrowNewspaper = (RatioPositionSizeImageView) pageLayout.findViewById(R.id.arrow_newspaper);
final Animation slideOn = AnimationUtils.loadAnimation(getActivity(), R.animator.slide_on);
slideOn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d("ANIMATION STARTED");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Log.d("ANIMATION END");
handler.postDelayed(runnable = new Runnable() {
@Override
public void run() {
arrowNewspaper.startAnimation(slideOn);
}
}, 1500);
}
});
arrowNewspaper.startAnimation(slideOn);
newspaperColorBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.newuseranim_newspaper_opened_colormap);
newspaperOpenOne.setOnTouchListener(new OnTouchListener() {
......@@ -309,70 +345,73 @@ public class AnimationNewUserFragment extends Fragment implements OnTouchListene
double ratioX = (double) backgroundBitmap.getWidth() / displaySize.x;
double ratioY = (double) backgroundBitmap.getHeight() / displaySize.y;
if (((event.getX() * ratioX) < backgroundBitmap.getWidth()) && ((event.getY() * ratioY) < backgroundBitmap.getHeight())) {
int pixel = backgroundBitmap.getPixel((int) (event.getX() * ratioX), (int) (event.getY() * ratioY));
if (Color.alpha(pixel) != 255) {
Log.d("ALPHA", Integer.toString(Color.alpha(pixel)));
if (!newspaperRotated) {
newspaperView.setVisibility(View.VISIBLE);
newspaper.setVisibility(View.VISIBLE);
newspaperView.setBackgroundResource((getResources().getIdentifier("newuseranim_balcony_blur", "drawable", "cz.nic.tablexia")));
AnimationSet animationSet = new AnimationSet(true);
Animation nPAnim = new ScaleAnimation(0.01f, 2, 0.01f, 2, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
nPAnim.setDuration(500);
Animation ani = new RotateAnimation(0, /* from degree */
360, /* to degree */
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ani.setDuration(100);
ani.setFillAfter(false);
ani.setRepeatCount(10);
ani.setRepeatMode(Animation.RESTART);
animationSet.addAnimation(nPAnim);
animationSet.addAnimation(ani);
animationSet.setInterpolator(new LinearInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// nic
}
@Override
public void onAnimationRepeat(Animation animation) {
// nic
}
@Override
public void onAnimationEnd(Animation animation) {
// Set the content view to 0% opacity but visible, so that it is visible
// (but fully transparent) during the animation.
newspaperOpenOne.setAlpha(0f);
newspaperOpenOne.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
newspaperOpenOne.animate().alpha(1f).setDuration(1000).setListener(null);
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)
newspaper.animate().alpha(0f).setDuration(1000).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
newspaper.setVisibility(View.GONE);
}
});
}
});
newspaper.startAnimation(animationSet);
newspaperRotated = true;
}
}
}
Log.d("TOUCH", event.getX() + ", " + event.getY());
int pixel = backgroundBitmap.getPixel((int) (event.getX() * ratioX), (int) (event.getY() * ratioY));
if (Color.alpha(pixel) != 255) {
handler.removeCallbacks(runnable);
arrowNewspaper.setVisibility(View.GONE);
Log.d("ALPHA", Integer.toString(Color.alpha(pixel)));
if (!newspaperRotated) {
newspaperView.setVisibility(View.VISIBLE);
newspaper.setVisibility(View.VISIBLE);
newspaperView.setBackgroundResource((getResources().getIdentifier("newuser_balcony_blur", "drawable", "cz.nic.tablexia")));
AnimationSet animationSet = new AnimationSet(true);
Animation nPAnim = new ScaleAnimation(0.01f, 2, 0.01f, 2, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
nPAnim.setDuration(500);
Animation ani = new RotateAnimation(0, /* from degree */
360, /* to degree */
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ani.setDuration(100);
ani.setFillAfter(false);
ani.setRepeatCount(10);
ani.setRepeatMode(Animation.RESTART);
animationSet.addAnimation(nPAnim);
animationSet.addAnimation(ani);
animationSet.setInterpolator(new LinearInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// nic
}
@Override
public void onAnimationRepeat(Animation animation) {
// nic
}
@Override
public void onAnimationEnd(Animation animation) {
// Set the content view to 0% opacity but visible, so that it is visible
// (but fully transparent) during the animation.
newspaperOpenOne.setAlpha(0f);
newspaperOpenOne.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
newspaperOpenOne.animate().alpha(1f).setDuration(1000).setListener(null);
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)
newspaper.animate().alpha(0f).setDuration(1000).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
newspaper.setVisibility(View.GONE);
}
});
}
});
newspaper.startAnimation(animationSet);
newspaperRotated = true;
}
}
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment