onDraw method not called in my application - android

i am developing an application, in that onDraw() is called. i am using the following logic.
so, please guide where i did the mistake.
MainActivity
public class Hello extends Activity implements SensorListener
{
private MyView myView;
private SensorManager sensorManager;
public void onAccuracyChanged(int paramInt1, int paramInt2)
{
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
Log.e("hello", "hello");
this.myView = new MyView(this);
setContentView(this.myView);
this.sensorManager = ((SensorManager)getSystemService("sensor"));
this.myView.setTheme(2);
}
protected void onResume()
{
super.onResume();
this.sensorManager.registerListener(this, 3, 0);
}
public void onSensorChanged(int paramInt, float[] paramArrayOfFloat)
{
switch (paramInt)
{
default:
case 1:
case 2:
}
this.myView.resetTama();
do
{
do
return;
while (Math.abs(paramArrayOfFloat[2]) <= 50.0F);
}
while (Math.abs(paramArrayOfFloat[0]) <= 15.0F);
}
public void onWindowFocusChanged(boolean paramBoolean)
{
super.onWindowFocusChanged(paramBoolean);
if (paramBoolean)
this.myView.init();
}
}
MyView class
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import java.lang.reflect.Array;
public class MyView extends RelativeLayout
{
private final int FP = -1;
private final int WC = -2;
public boolean disableApplication = false;
private int imgType = 1;
public boolean isBlack = false;
boolean isInitialized;
private Bitmap myBitmap;
private Paint myPaint = new Paint();
private int[] numbers;
private Tama[] oyatamaArray;
private Tama[][] tamaArray;
public MyView(Context paramContext)
{
super(paramContext);
Log.e("MyView", "MyView");
setFocusable(true);
setBackgroundResource(R.drawable.haikei);
setWillNotDraw(false);
this.myBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.tama);
this.numbers = new int[6];
for (int i = 0; i<numbers.length; i++)
{
if (i >= this.numbers.length)
{
loadChangeThemeButton(paramContext);
new TextView(paramContext).setBackgroundResource(R.drawable.bar);
return;
}
this.numbers[i] = 0;
}
}
private void changeBackgroundImage()
{
int i = 1 + this.imgType;
this.imgType = i;
if (i > 3)
this.imgType = 1;
setTheme(this.imgType);
}
private void loadChangeThemeButton(Context paramContext)
{
ImageButton localImageButton = new ImageButton(paramContext);
localImageButton.setBackgroundResource(R.drawable.themebutton);
RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
localLayoutParams.addRule(9);
localLayoutParams.addRule(12);
localLayoutParams.setMargins(0, 0, 30, 30);
addView(localImageButton, localLayoutParams);
localImageButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
MyView.this.changeBackgroundImage();
}
});
}
private Bitmap returnNumberImg(Resources paramResources, int paramInt)
{
switch (paramInt)
{
default:
return BitmapFactory.decodeResource(paramResources, R.drawable.n0);
case 1:
return BitmapFactory.decodeResource(paramResources, R.drawable.n1);
case 2:
return BitmapFactory.decodeResource(paramResources, R.drawable.n2);
case 3:
return BitmapFactory.decodeResource(paramResources, R.drawable.n3);
case 4:
return BitmapFactory.decodeResource(paramResources, R.drawable.n4);
case 5:
return BitmapFactory.decodeResource(paramResources, R.drawable.n5);
case 6:
return BitmapFactory.decodeResource(paramResources, R.drawable.n6);
case 7:
return BitmapFactory.decodeResource(paramResources, R.drawable.n7);
case 8:
return BitmapFactory.decodeResource(paramResources, R.drawable.n8);
case 9:
}
return BitmapFactory.decodeResource(paramResources, R.drawable.n9);
}
private void settingTamasTouchX(int paramInt1, int paramInt2)
{
int i = 0;
if (i >= this.oyatamaArray.length);
int k;
for (int j = 0; ; j++)
{
if (j >= this.tamaArray.length)
{
return;
}
k = 0;
if (k < this.tamaArray[j].length)
{
if (this.tamaArray[j][k].checkArea(paramInt1, paramInt2));
for (this.tamaArray[j][k].touchX = paramInt1; ; this.tamaArray[j][k].touchX = 0)
{
k++;
break;
}
// break label90;
}
}
}
public void init()
{
int i = getHeight() / 7;
int[] arrayOfInt = new int[6];
int j = 5;
if (j < 0)
this.oyatamaArray = new Tama[6];
int m;
int i1 = 0;
for (int k = 0; ; k++)
{
if (k >= this.oyatamaArray.length)
{
this.tamaArray = ((Tama[][])Array.newInstance(Tama.class, new int[] { 6, 4 }));
m = 0;
if (m < this.tamaArray.length)
{
for (int n = 0; ; n++)
{
if (n >= this.tamaArray[m].length)
{
m++;
break;
}
this.tamaArray[m][n] = new Tama(40 + n * 37, arrayOfInt[m] - 32, n + m * 10);
}
// break label154;
}
i1 = 0;
if (i1 < this.tamaArray.length)
{
for (int i2 = 0; ; i2++)
{
if (i2 >= this.tamaArray[i1].length)
{
i1++;
break;
}
if (i2 != this.tamaArray[i1].length - 1)
this.tamaArray[i1][i2].ueTama = this.tamaArray[i1][(i2 + 1)];
if (i2 == 0)
continue;
this.tamaArray[i1][i2].shitaTama = this.tamaArray[i1][(i2 - 1)];
}
// break label222;
}
this.isInitialized = true;
return;
}
this.oyatamaArray[k] = new Tama(279, arrayOfInt[k] - 32, k);
this.oyatamaArray[k].isOya = true;
}
}
#Override
protected void dispatchDraw(Canvas canvas){
super.dispatchDraw(canvas);
Log.e("......this.........","drawing");
}
#Override
protected void onDraw(Canvas paramCanvas)
{
super.onDraw(paramCanvas);
Log.e("This on draw","....yes");
if (!this.isInitialized)
init();
int i = 0;
Resources localResources;
int m;
while (true)
{
int j;
if (i >= this.oyatamaArray.length)
{
j = 0;
if (j >= this.tamaArray.length)
{
localResources = getContext().getResources();
m = 0;
if (m < 7)
break;
return;
}
}
else
{
paramCanvas.drawBitmap(this.myBitmap, this.oyatamaArray[i].getX(), this.oyatamaArray[i].getY(), this.myPaint);
i++;
continue;
}
for (int k = 0; ; k++)
{
if (k >= this.tamaArray[j].length)
{
j++;
break;
}
paramCanvas.drawBitmap(this.myBitmap, this.tamaArray[j][k].getX(), this.tamaArray[j][k].getY(), this.myPaint);
}
}
if (this.numbers.length <= m)
{
for (Bitmap localBitmap = BitmapFactory.decodeResource(localResources, 2130837523); ; localBitmap = returnNumberImg(localResources, this.numbers[m]))
{
paramCanvas.drawBitmap(localBitmap, 8.0F, getHeight() / 2 + m * 18, this.myPaint);
m++;
break;
}
}
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
int i = (int)paramMotionEvent.getX();
int j = (int)paramMotionEvent.getY();
if ((paramMotionEvent.getAction() == 0) && (i >= 0) && (i <= 40) && (410 <= j) && (j <= 430))
changeBackgroundImage();
if (paramMotionEvent.getAction() == 0)
settingTamasTouchX(i, j);
if (1 == paramMotionEvent.getAction())
settingTamasTouchX(0, 0);
int k;
int m = 0;
if (2 == paramMotionEvent.getAction())
{
k = 0;
if (k >= this.oyatamaArray.length)
{
m = 0;
if (m < this.tamaArray.length)
{
for (int n = 0; ; n++)
{
if (n >= this.tamaArray[m].length)
{
m++;
break;
}
this.tamaArray[m][n].checkAndSetArea(i, j);
if (!this.tamaArray[m][n].isUp)
continue;
int[] arrayOfInt = this.numbers;
arrayOfInt[m] = (1 + arrayOfInt[m]);
}
// break label164;
}
invalidate();
}
}
else
{
return true;
}
this.oyatamaArray[k].checkAndSetArea(i, j);
if (this.oyatamaArray[k].isUp)
this.numbers[k] = 5;
while (true)
{
k++;
break;
}
// label164:
return disableApplication;
}
public void resetTama()
{
int j;
for (int i = 0; ; i++)
{
if (i >= this.oyatamaArray.length)
{
j = 0;
if (j < this.tamaArray.length)
break;
invalidate();
return;
}
this.oyatamaArray[i].moveX(this.oyatamaArray[i].startX);
this.oyatamaArray[i].isUp = false;
this.numbers[i] = 0;
}
for (int k = 0; ; k++)
{
if (k >= this.tamaArray[j].length)
{
j++;
break;
}
this.tamaArray[j][k].moveX(this.tamaArray[j][k].startX);
this.tamaArray[j][k].isUp = false;
}
}
public void sensorChange(float[] paramArrayOfFloat)
{
int i = 0;
if (paramArrayOfFloat[2] < -50.0F)
i = 0 - 3;
int k;
while (true)
{
int j = 0;
if (j >= this.oyatamaArray.length)
{
k = 0;
if (k < this.tamaArray.length)
break;
if (i != 0)
invalidate();
return;
}
else
{
this.oyatamaArray[j].moveX(i + this.oyatamaArray[j].getX());
if (this.oyatamaArray[j].isUp)
this.numbers[j] = 5;
while (true)
{
j++;
break;
}
}
}
for (int m = 0; ; m++)
{
if (m >= this.tamaArray[k].length)
{
k++;
break;
}
this.tamaArray[k][m].moveX(i + this.tamaArray[k][m].getX());
if (!this.tamaArray[k][m].isUp)
continue;
int[] arrayOfInt = this.numbers;
arrayOfInt[k] = (1 + arrayOfInt[k]);
}
}
public void setTheme(int paramInt)
{
Resources localResources = getContext().getResources();
if (paramInt == 1)
{
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama);
setBackgroundResource(R.drawable.haikei);
}
while (true)
{
invalidate();
// return;
if (paramInt == 2)
{
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama2);
setBackgroundResource(2130837510);
continue;
}
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama3);
setBackgroundResource(2130837510);
}
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="#id/FrameLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

Try the below it works
To the question posted before edit.
If you're extending a ViewGroup you should override dispatchDraw() instead of onDraw().
Discussion on the topic #
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/oLccWfszuUo
public class Hello extends Activity {
private MyView myView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
Log.e("hello", "hello");
this.myView = new MyView(this);
setContentView(this.myView);
}
public class MyView extends RelativeLayout
{
private Paint myPaint = new Paint();
private int[] numbers;
public MyView(Context paramContext)
{
super(paramContext);
Log.e("MyView", "MyView");
setFocusable(true);
setBackgroundResource(R.drawable.ic_launcher);
}
#Override
protected void dispatchDraw(Canvas canvas){
super.dispatchDraw(canvas);
Log.i("...............","drawing");
}
}
}
protected void dispatchDraw (Canvas canvas)
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
Parameters
canvas the canvas on which to draw the view
If you Override onDraw inthe constructor call setWillNotDraw(false) then it should work.
http://developer.android.com/reference/android/view/View.html#setWillNotDraw(boolean)
public MyView(Context paramContext)
{
super(paramContext);
Log.e("MyView", "MyView");
setFocusable(true);
setBackgroundResource(R.drawable.ic_launcher);
setWillNotDraw(false);
}

Related

Exit to a different Activity when game loop ends?

I want my game to exit and go to a separate Activity when the user collides. For example, I want it to go back to my main menu. I've tried adding a Button, new intent method etc and these don't work. I can't find the answer anywhere and i'm not knowledgeable enough to do this as I'm learning. I've trawled the internet but nothing has really helped. Any advice would be awesome. My idea was to change the newgame() method to exit the game?
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.util.ArrayList;
import java.util.Random;
public class GamePanel extends SurfaceView implements SurfaceHolder.Callback {
private Threading threading;
private BackgroundImage bg;
public static final int WIDTH = 856;
public static final int HEIGHT = 480;
public static final int MovementSpeed = -8;
private Player player;
private ArrayList<BorderTop> borderTop;
private ArrayList<BorderBottom> borderBottom;
private ArrayList<Smokepuff> smoke;
private ArrayList<Missile> missiles;
private int MaximumBorderHeight;
private int MinimumBorderHeight;
private boolean topDown = true;
private boolean botDown = true;
private int progressDifficulty = 20;
private Random rand = new Random();
private boolean newGameCreated;
private long smokeStartTime;
private long missileStartTime;
public GamePanel(Context context) {
super(context);
getHolder().addCallback(this);
setFocusable(true);
}
#Override
public void surfaceCreated(SurfaceHolder holder) {
bg = new BackgroundImage(BitmapFactory.decodeResource(getResources(), R.drawable.grassbg1));
player = new Player(BitmapFactory.decodeResource(getResources(), R.drawable.smallcatfinal), 40, 44, 1);
borderTop = new ArrayList<BorderTop>();
borderBottom = new ArrayList<BorderBottom>();
smoke = new ArrayList<Smokepuff>();
missiles = new ArrayList<Missile>();
smokeStartTime= System.nanoTime();
missileStartTime = System.nanoTime();
threading = new Threading(getHolder(), this);
threading.setRunning(true);
threading.start();
}
#Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
int counter = 0;
while (retry && counter < 1000) {
counter++;
try {
threading.setRunning(false);
threading.join();
retry = false;
threading = null;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
#Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (!player.getPlaying()) {
player.setPlaying(true);
player.setUp(true);
}else{
player.setUp(true);
}
return true;
}
if (event.getAction() == MotionEvent.ACTION_UP) {
player.setUp(false);
return true;
}
return super.onTouchEvent(event);
}
public void update() {
if (player.getPlaying()) {
bg.update();
player.update();
MaximumBorderHeight = 30 + player.getScore() / progressDifficulty;
if (MaximumBorderHeight > HEIGHT / 4) MaximumBorderHeight = HEIGHT / 4;
MinimumBorderHeight = 5 + player.getScore() / progressDifficulty;
//check bottom border collision
for (int i = 0; i < borderBottom.size(); i++) {
if (collision(borderBottom.get(i), player))
player.setPlaying(false);
}
//check top border collision
for (int i = 0; i < borderTop.size(); i++) {
if (collision(borderTop.get(i), player))
player.setPlaying(false);
}
this.updateTop();
this.updateBottom();
long missileElapsed = (System.nanoTime() - missileStartTime) / 1000000;
if (missileElapsed > (2000 - player.getScore() / 4)) {
//first missile always goes down the middle
if (missiles.size() == 0) {
missiles.add(new Missile(BitmapFactory.decodeResource(getResources(), R.drawable.
missile), WIDTH + 10, HEIGHT / 2, 45, 15, player.getScore(), 13));
} else {
missiles.add(new Missile(BitmapFactory.decodeResource(getResources(), R.drawable.missile),
WIDTH + 10, (int) (rand.nextDouble() * (HEIGHT - (MaximumBorderHeight * 2)) + MaximumBorderHeight), 45, 15, player.getScore(), 13));
}
//reset timer
missileStartTime = System.nanoTime();
}
//loop through every missile and check collision and remove
for (int i = 0; i < missiles.size(); i++) {
//update missile
missiles.get(i).update();
if (collision(missiles.get(i), player)) {
missiles.remove(i);
player.setPlaying(false);
break;
}
//remove missile if it is way off the screen
if (missiles.get(i).getX() < -100) {
missiles.remove(i);
break;
}
}
long elapsed = (System.nanoTime() - smokeStartTime) / 1000000;
if (elapsed > 120) {
smoke.add(new Smokepuff(player.getX(), player.getY() + 10));
smokeStartTime = System.nanoTime();
}
for (int i = 0; i < smoke.size(); i++) {
smoke.get(i).update();
if (smoke.get(i).getX() < -10) {
smoke.remove(i);
}
}
} else {
newGameCreated = false;
if (!newGameCreated) {
newGame();
}
}
public boolean collision (GameObject a, GameObject b)
{
if (Rect.intersects(a.getRectangle(), b.getRectangle())) {
return true;
}
return false;
}
#Override
public void draw(Canvas canvas) {
super.draw(canvas);
final float ScaleX = (float) getWidth() / WIDTH*1.f;
final float ScaleY = (float) getHeight() / HEIGHT*1.f;
if (canvas != null) {
final int savedState = canvas.save();
canvas.scale(ScaleX, ScaleY);
bg.draw(canvas);
player.draw(canvas);
for(Smokepuff sp: smoke)
{
sp.draw(canvas);
}
//draw missiles
for(Missile m: missiles)
{
m.draw(canvas);
}
for(BorderTop bt: borderTop)
{
bt.draw(canvas);
}
for(BorderBottom bb: borderBottom)
{
bb.draw(canvas);
}
canvas.restoreToCount(savedState);
}
}
public void updateBottom() {
if (player.getScore() % 40 == 0) {
borderBottom.add(new BorderBottom(BitmapFactory.decodeResource(getResources(), R.drawable.brick),
borderBottom.get(borderBottom.size() - 1).getX() + 20, (int) ((rand.nextDouble()
* MaximumBorderHeight) + (HEIGHT - MaximumBorderHeight))));
}
//update bottom border
for (int i = 0; i < borderBottom.size(); i++) {
borderBottom.get(i).update();
//if border is moving off screen, remove it and add a corresponding new one
if (borderBottom.get(i).getX() < -20) {
borderBottom.remove(i);
//determine if border will be moving up or down
if (borderBottom.get(borderBottom.size() - 1).getY() <= HEIGHT - MaximumBorderHeight) {
botDown = true;
}
if (borderBottom.get(borderBottom.size() - 1).getY() >= HEIGHT - MinimumBorderHeight) {
botDown = false;
}
if (botDown) {
borderBottom.add(new BorderBottom(BitmapFactory.decodeResource(getResources(),R.drawable.brick
), borderBottom.get(borderBottom.size() - 1).getX() + 20, borderBottom.get(borderBottom.size() - 1
).getY() + 1));
} else {
borderBottom.add(new BorderBottom(BitmapFactory.decodeResource(getResources(), R.drawable.brick
), borderBottom.get(borderBottom.size() - 1).getX() + 20, borderBottom.get(borderBottom.size() - 1
).getY() - 1));
}
}
}
}
public void updateTop()
{
if (player.getScore() % 50 == 0) {
borderTop.add(new BorderTop(BitmapFactory.decodeResource(getResources(), R.drawable.brick), borderTop.get(borderTop.size() - 1).getX() + 20, 0, (int) ((rand.nextDouble() * (MaximumBorderHeight)) + 1)));
}
for (int i = 0; i < borderTop.size(); i++) {
borderTop.get(i).update();
if (borderTop.get(i).getX() < -20) {
borderTop.remove(i);
if (borderTop.get(borderTop.size() - 1).getHeight() >= MaximumBorderHeight) {
topDown = false;
}
if (borderTop.get(borderTop.size() - 1).getHeight() <= MinimumBorderHeight) {
topDown = true;
}
if (topDown) {
borderTop.add(new BorderTop(BitmapFactory.decodeResource(getResources(), R.drawable.brick), borderTop.get(borderTop.size() - 1).getX() + 20, 0, borderTop.get(borderTop.size() - 1).getHeight() + 1));
} else {
borderTop.add(new BorderTop(BitmapFactory.decodeResource(getResources(), R.drawable.brick), borderTop.get(borderTop.size() - 1).getX() + 20, 0, borderTop.get(borderTop.size() - 1).getHeight() - 1));
}
}
}
}
public void newGame() {
borderBottom.clear();
borderTop.clear();
missiles.clear();
smoke.clear();
MinimumBorderHeight = 5;
MaximumBorderHeight = 30;
player.resetDY();
player.resetScore();
player.setY(HEIGHT/2);
//create initial borders
//initial top border
for(int i = 0; i*20<WIDTH+40;i++)
{
// first top border create
if(i==0)
{borderTop.add(new BorderTop(BitmapFactory.decodeResource(getResources(),R.drawable.brick
),i*20,0, 10));
}
else
{
borderTop.add(new BorderTop(BitmapFactory.decodeResource(getResources(),R.drawable.brick
),i*20,0, borderTop.get(i-1).getHeight()+1));
}
}
//initial bottom border
for(int i = 0; i*20<WIDTH+40; i++)
{
//first border ever created
if(i==0)
{
borderBottom.add(new BorderBottom(BitmapFactory.decodeResource(getResources(),R.drawable.brick)
,i*20,HEIGHT - MinimumBorderHeight));
}
//adding borders until the initial screen is filed
else
{
borderBottom.add(new BorderBottom(BitmapFactory.decodeResource(getResources(), R.drawable.brick),
i * 20, borderBottom.get(i - 1).getY() - 1));
}
}
newGameCreated = true;
}
}

How to stop rotation when reaching that particular point in Rotatory Dialer android

Here is my source code.
/*
* This code is a modification of the Android LunarLander example.
*/
package net.simplifiedcoding.detectoutgoingcalls.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import net.simplifiedcoding.detectoutgoingcalls.R;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* View that draws, takes keystrokes, etc. for a simple LunarLander game.
* <p/>
* Has a mode which RUNNING, PAUSED, etc. draw() renders the
* ship, and does an invalidate() to prompt another draw() as soon as possible
* by the system.
*/
public class RotaryDialerView extends View {
private float rotorAngle = 0F;
private final Drawable rotorDrawable;
private final int r1 = 50;
private final int r2 = 160;
private double lastFi;
private int startN;
public MediaPlayer mPlayer;
private int width;
private int height;
private boolean soundRotating;
android.media.MediaPlayer.OnCompletionListener soundListener;
private boolean playSound;
MainActivity activity = new MainActivity();
public RotaryDialerView(Context context) {
this(context, null);
soundListener = new android.media.MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mediaplayer) {
stop();
}
};
}
public RotaryDialerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public RotaryDialerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
playSound = false;
startN = -1;
soundRotating = false;
rotorDrawable = context.getResources().getDrawable(R.drawable.dialer);
}
#Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int availableWidth = getRight() - getLeft();
int availableHeight = getBottom() - getTop();
int x = availableWidth / 2;
int y = availableHeight / 2;
canvas.save();
rotorDrawable.setBounds(0, 0, rotorDrawable.getIntrinsicWidth(),
rotorDrawable.getIntrinsicHeight());
if (rotorAngle != 0) {
canvas.rotate(rotorAngle, x, y);
}
rotorDrawable.draw(canvas);
canvas.restore();
}
protected void onMeasure(int i, int j) {
height = android.view.View.MeasureSpec.getSize(j);
width = android.view.View.MeasureSpec.getSize(i);
setMeasuredDimension(width, height);
}
#Override
public boolean onTouchEvent(MotionEvent event) {
final float x0 = width / 2;
final float y0 = height / 2;
float x1 = event.getX();
float y1 = event.getY();
float x = x0 - x1;
float y = y0 - y1;
double r = Math.sqrt(x * x + y * y);
double sinfi = y / r;
double fi = Math.toDegrees(Math.asin(sinfi));
if (x1 > x0 && y0 > y1) {
fi = 180D - fi;
} else if (x1 > x0 && y1 > y0) {
fi = 180D - fi;
} else if (x0 > x1 && y1 > y0) {
fi += 360D;
}
boolean isComplete = false;
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Log.e("MotionEvent.ACTION_MOVE", "" + MotionEvent.ACTION_MOVE);
if (r > r1 && r < r2) {
if (!soundRotating) {
soundRotating = true;
playSound(startN);
}
final float angle2 = rotorAngle % 360;
int number2 = Math.round(angle2 - 20) / 30;
rotorAngle += Math.abs(fi - lastFi) + 0.25f;
rotorAngle %= 360F;
lastFi = fi;
if (startN >= 10 && !isComplete) {
isComplete = true;
}
// if (number2 < startN || startN == 0 && !isComplete) {
invalidate();
//}
return false;
}
case MotionEvent.ACTION_DOWN:
// playMusic();
// mPlayer2.pause();
calculateStartN(rotorAngle);
rotorAngle = 0F;
lastFi = fi;
return true;
// }
//return false;
case MotionEvent.ACTION_UP:
//mPlayer2.pause();
soundRotating = false;
final float angle = rotorAngle % 360;
int number = Math.round(angle - 20) / 30;
playSound_2(number);
final float fl22 = Math.round(angle - 20) - number * 30;
Log.e("angle", "" + fl22);
if (number > 0) {
if (number == 10) {
number = 0;
}
// if (fl2 < 8.0 && fl2 > 4.0) {
fireDialListenerEvent(number);
//return true;
//}
}
rotorAngle = 0F;
post(new Runnable() {
public void run() {
float fromDegrees = angle;
Animation anim = new RotateAnimation(fromDegrees, 0, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F);
anim.setInterpolator(AnimationUtils.loadInterpolator(getContext(), android.R.anim.decelerate_interpolator));
anim.setAnimationListener(animListener);
anim.setDuration((long) (angle * 5F));
startAnimation(anim);
// playSound();
// angle = 00;//x0;
}
});
startN = -1;
isComplete = false;
return true;
default:
break;
}
return super.onTouchEvent(event);
}
public interface DialListener {
void onDial(int number);
}
private final List<DialListener> dialListeners = new ArrayList<DialListener>();
public void addDialListener(DialListener listener) {
dialListeners.add(listener);
}
public void removeDialListener(DialListener listener) {
dialListeners.remove(listener);
}
private void fireDialListenerEvent(int number) {
for (DialListener listener : dialListeners) {
listener.onDial(number);
Log.e("position ", "Reached");
}
}
private android.view.animation.Animation.AnimationListener animListener = new android.view.animation.Animation.AnimationListener() {
public void onAnimationEnd(Animation animation) {
activity.stopVibrate();
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
};
public void playSound(int n) {
try {
Log.e("n value is", "" + n);
boolean mStartPlaying = true;
if (mStartPlaying == true) {
mPlayer = new MediaPlayer();
Uri uri = Uri.parse("android.resource://net.simplifiedcoding.detectoutgoingcalls/" + activity.SOUNDS_R[n]);
mPlayer.setOnCompletionListener(soundListener);
mPlayer.setDataSource(getContext(), uri);
mPlayer.prepare();
mPlayer.setLooping(false);
mPlayer.start();
} else {
// stopPlaying();
//rePlay.setText("Replay");
mPlayer.stop();
mPlayer.release();
mPlayer = null;
}
mStartPlaying = !mStartPlaying;
} catch (IOException e) {
Log.e("ERR", "prepare() failed");
}
}
public void playSound_2(int n) {
try {
boolean mStartPlaying = true;
if (mStartPlaying == true) {
mPlayer = new MediaPlayer();
Uri uri = Uri.parse("android.resource://net.simplifiedcoding.detectoutgoingcalls/" + activity.SOUNDS_S[n]);
mPlayer.setOnCompletionListener(soundListener);
mPlayer.setDataSource(getContext(), uri);
mPlayer.prepare();
mPlayer.setLooping(false);
mPlayer.start();
} else {
// stopPlaying();
//rePlay.setText("Replay");
mPlayer.stop();
mPlayer.release();
mPlayer = null;
}
mStartPlaying = !mStartPlaying;
} catch (IOException e) {
Log.e("ERR", "prepare() failed");
}
}
public void stop() {
try {
mPlayer.release();
mPlayer.stop();
return;
}
// Misplaced declaration of an exception variable
catch (Exception mediaplayer) {
return;
}
}
private void calculateStartN(double d) {
if (d >= 0.0D && d < 30D) {
startN = 5;
} else {
if (d >= 30D && d < 60D) {
startN = 4;
return;
}
if (d >= 60D && d < 90D) {
startN = 3;
return;
}
if (d >= 90D && d < 120D) {
startN = 2;
return;
}
if (d >= 120D && d <= 150D) {
startN = 1;
return;
}
if (d >= 210D && d < 240D) {
startN = 0;
return;
}
if (d >= 240D && d < 270D) {
startN = 9;
return;
}
if (d >= 270D && d < 300D) {
startN = 8;
return;
}
if (d >= 300D && d < 330D) {
startN = 7;
return;
}
if (d >= 330D && d <= 360D) {
startN = 6;
return;
}
}
}
}
The problem is when i rotate the dialer number it is not stooped when it reach the point.it rotate contentiously with out end.
here is the sample source code
http://www.ssaurel.com/blog/how-to-create-a-rotary-dialer-application-for-android/
every thing is perfect but the only issue is rotation is not stoped when it reach the end

Trying to Call an Activity from a Surface View (via onTouch)

I've been trying to call an activity from a surface view via On Touch. However, with the code I've constructed (and I've tried all possible trials and errors, I'm a novice programmer fyi), I keep clicking on the surface view and nothing happens.
I badly need some help guys, this is a school project :3
Thanks!
package com.projtimesequencesrc;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class SurfaceViewer extends View implements OnTouchListener {
private Context svc;
float x, y;
Bitmap bgd, main;
Bitmap dialog;
Rect dialogsrc, dialogdst;
//dog
Bitmap dog;
Rect dogsrc, dogdst;
Paint p;
//Molly
Bitmap molly;
Rect mollysrc, mollydst;
//Molly2
Bitmap youngstar;
Rect youngstarsrc, youngstardst;
//Bear
Bitmap bear;
Rect bearsrc, beardst;
Thread tbear, tdbear;
Runnable rbear, dbear;
//man1
Bitmap man1;
Rect mansrc, mandst;
// Main Character
Rect bgdst, charsrc, chardst;
Thread tstory, tdstory;
Runnable rstory, dstory;
protected void onDraw (Canvas c) {
super.onDraw(c);
bgdst.right=getWidth();
bgdst.bottom=getHeight();
c.drawBitmap(bgd, null, bgdst, p);
c.drawBitmap(main, charsrc,chardst, p);
c.drawBitmap(dog, dogsrc, dogdst, p);
c.drawBitmap(bear, bearsrc, beardst, p);
c.drawBitmap(man1, mansrc, mandst, p);
c.drawBitmap(dialog, dialogsrc, dialogdst, p);
c.drawBitmap(molly, mollysrc,mollydst, p);
c.drawBitmap(youngstar, youngstarsrc, youngstardst, p);
invalidate();
}
void sqyoungstar2() {
int count = 0;
while (true) {
youngstarsrc.left += 64;
youngstarsrc.right += 64;
if (youngstarsrc.left > (64*6)) {
youngstarsrc.left = 0;
youngstarsrc.right = 64;
}
SystemClock.sleep(200);
count++;
if (count > 38) {
break;
}
}
}
void sqyoungstar1() {
youngstarsrc.left = 0;
youngstarsrc.right = 64;
youngstarsrc.top = 64*2;
youngstarsrc.bottom = 64*3;
youngstardst.left = 280;
youngstardst.right = 330;
youngstardst.top = 200;
youngstardst.bottom = 250;
sqyoungstar2();
}
void seq4() {
// Main Character
charsrc.left = 0;
charsrc.right = 64;
charsrc.top = (64*9);
charsrc.bottom = (64*10);
mansrc.left = 0;
mansrc.right = 64;
mansrc.top = (64*9);
mansrc.bottom = (64*10);
int count = 0;
while (true) {
charsrc.left += 64;
charsrc.right += 64;
if (charsrc.left > (64*8)) {
charsrc.left = 0;
charsrc.right = 64;
}
chardst.offset(-5, 0);
SystemClock.sleep(100);
count++;
if (count > 38) {
break;
}
}
SystemClock.sleep(1000);
}
void seq3() {
// Main Character
charsrc.left = 0;
charsrc.top = (64*11);
charsrc.right= 64;
charsrc.bottom = (64*12);
SystemClock.sleep(3000);
seq4();
}
void seq2() {
// Main Character
int count = 0;
while (true) {
charsrc.left += 64;
charsrc.right += 64;
if (charsrc.left > (64 * 6)) {
charsrc.left = 0;
charsrc.right = 64;
}
chardst.offset(5, 0);
SystemClock.sleep(100);
count++;
if (count > 38) {
break;
}
}
seq3();
}
void sequence1() {
// main character
dialogsrc.left = 0;
dialogsrc.right = 536;
dialogsrc.top = 0;
dialogsrc.bottom = 120;
dialogdst.left = 100;
dialogdst.right = 736;
dialogdst.top = 50;
dialogdst.bottom = 170;
charsrc.left = 0;
charsrc.top = (64*11);
charsrc.right= 64;
charsrc.bottom = (64*12);
chardst.left = 192;
chardst.top = 255;
chardst.right= 256;
chardst.bottom = 315;
mansrc.left = 0;
mansrc.right = 64;
mansrc.top = (64*3);
mansrc.bottom = (64*4);
mandst.left = 150;
mandst.right = 214;
mandst.top = 255;
mandst.bottom = 315;
SystemClock.sleep(2000);
seq2();
}
void sqdog4() {
dogsrc.left = 0;
dogsrc.right = 80;
dogsrc.top = 0;
dogsrc.bottom = 80;
SystemClock.sleep(2000);
}
void sqdog3() {
dogsrc.left = 80;
dogsrc.right = 80*2;
dogsrc.top = 80;
dogsrc.bottom = 80*2;
SystemClock.sleep(2000);
sqdog4();
}
void sqdog2() {
int count = 0;
while (true) {
dogsrc.left +=80;
dogsrc.right +=80;
if (dogsrc.left > (80*2)) {
dogsrc.left = 0;
dogsrc.right = 80;
}
SystemClock.sleep(100);
count++;
if (count > 28) {
break;
}
}
SystemClock.sleep(5000);
// insert sequence
sqdog3();
}
void sqdog1() {
dogsrc.left = 0;
dogsrc.right = 80;
dogsrc.top = 0;
dogsrc.bottom = 80;
dogdst.left = 470;
dogdst.right = 535;
dogdst.top = 280;
dogdst.bottom = 315;
sqdog2();
}
void sqbear2() {
int count = 0;
while (true) {
bearsrc.left+= 56;
bearsrc.right+=56;
if (bearsrc.left > 56) {
bearsrc.left = 0;
bearsrc.right = 56;
}
SystemClock.sleep(100);
count++;
if (count > 14) {
break;
}
}
SystemClock.sleep(2000);
}
void sqbear1() {
bearsrc.left = 0;
bearsrc.right = 56;
bearsrc.top = (56*4);
bearsrc.bottom = (56*5);
beardst.left = 600;
beardst.right = 656;
beardst.top = 260;
beardst.bottom = 316;
sqbear2();
}
public SurfaceViewer(Context context, AttributeSet attrs) {
super(context, attrs);
bgdst = new Rect();
charsrc = new Rect();
chardst = new Rect();
dogsrc = new Rect();
dogdst = new Rect();
bearsrc = new Rect();
beardst = new Rect();
dialogsrc = new Rect();
dialogdst = new Rect();
mansrc = new Rect();
mandst = new Rect();
mollysrc = new Rect();
mollydst = new Rect();
youngstarsrc = new Rect();
youngstardst = new Rect();
// TODO Auto-generated constructor stub
main = BitmapFactory.decodeResource(getResources(),
R.drawable.moviemysterycharacter);
bgd = BitmapFactory.decodeResource(getResources(),
R.drawable.background);
dog = BitmapFactory.decodeResource(getResources(),
R.drawable.dog);
bear = BitmapFactory.decodeResource(getResources(),
R.drawable.differentbears);
man1 = BitmapFactory.decodeResource(getResources(), R.drawable.man1);
dialog = BitmapFactory.decodeResource(getResources(), R.drawable.dialog1);
molly = BitmapFactory.decodeResource(getResources(), R.drawable.auntmollu);
youngstar = BitmapFactory.decodeResource(getResources(), R.drawable.auntmollu);
p = new Paint();
rstory = new Runnable() {
public void run() {
while(true) {
sequence1();
}
}
};
tstory = new Thread(rstory);
tstory.start();
dstory = new Runnable() {
public void run() {
while(true) {
sqdog1();
}
}
};
tdstory = new Thread(dstory);
tdstory.start();
dbear = new Runnable() {
public void run() {
while(true) {
sqbear1();
}
}
};
tbear = new Thread(dbear);
tbear.start();
dbear = new Runnable() {
public void run() {
while (true) {
sqyoungstar1();
}
}
};
tbear = new Thread(dbear);
tbear.start();
}
#Override
public boolean onTouch(View v, MotionEvent me) {
// TODO Auto-generated method stub
Intent i = new Intent(svc, SecondAct.class);
switch (me.getAction()) {
case MotionEvent.ACTION_DOWN:
svc.startActivity(i);
break;
case MotionEvent.ACTION_UP:
svc.startActivity(i);
break;
}
return true;
}
}
Try to use getContext() instead of svc.

View not displayed in my application

I Am developing android abacus application, in that i need to develope the user interface like the following and i am using the following logic. It compiles and executes without exceptions but the view is not visible.
So, please guide me how develope this.
**MainActivity**
public class Hello extends Activity implements SensorListener
{
private MyView myView;
private SensorManager sensorManager;
public void onAccuracyChanged(int paramInt1, int paramInt2)
{
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
Log.e("hello", "hello");
this.myView = new MyView(this);
setContentView(this.myView);
Log.e("hello", "hello after constructor");
this.sensorManager = ((SensorManager)getSystemService("sensor"));
this.myView.setTheme(2);
}
protected void onResume()
{
super.onResume();
this.sensorManager.registerListener(this, 3, 0);
}
public void onSensorChanged(int paramInt, float[] paramArrayOfFloat)
{
switch (paramInt)
{
default:
case 1:
case 2:
}
this.myView.resetTama();
do
{
do
return;
while (Math.abs(paramArrayOfFloat[2]) <= 50.0F);
}
while (Math.abs(paramArrayOfFloat[0]) <= 15.0F);
}
public void onWindowFocusChanged(boolean paramBoolean)
{
super.onWindowFocusChanged(paramBoolean);
if (paramBoolean)
this.myView.init();
}
}
**MyView class**
public class MyView extends RelativeLayout
{
private final int FP = -1;
private final int WC = -2;
public boolean disableApplication = false;
private int imgType = 1;
public boolean isBlack = false;
boolean isInitialized;
private Bitmap myBitmap;
private Paint myPaint = new Paint();
private int[] numbers;
private Tama[] oyatamaArray;
private Tama[][] tamaArray;
public MyView(Context paramContext)
{
super(paramContext);
Log.e("MyView", "MyView");
setFocusable(true);
setBackgroundResource(R.drawable.haikei);
this.myBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.tama);
this.numbers = new int[6];
//for displaying numbers
for (int i = 0; i<numbers.length; i++)
{
if (i >= this.numbers.length)
{
loadChangeThemeButton(paramContext);
new TextView(paramContext).setBackgroundResource(R.drawable.bar);
return;
}
this.numbers[i] = 0;
}
}
private void changeBackgroundImage()
{
int i = 1 + this.imgType;
this.imgType = i;
if (i > 3)
this.imgType = 1;
setTheme(this.imgType);
}
private void loadChangeThemeButton(Context paramContext)
{
ImageButton localImageButton = new ImageButton(paramContext);
localImageButton.setBackgroundResource(R.drawable.themebutton);
RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
localLayoutParams.addRule(9);
localLayoutParams.addRule(12);
localLayoutParams.setMargins(0, 0, 30, 30);
addView(localImageButton, localLayoutParams);
localImageButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
MyView.this.changeBackgroundImage();
}
});
}
private Bitmap returnNumberImg(Resources paramResources, int paramInt)
{
switch (paramInt)
{
default:
return BitmapFactory.decodeResource(paramResources, R.drawable.n0);
case 1:
return BitmapFactory.decodeResource(paramResources, R.drawable.n1);
case 2:
return BitmapFactory.decodeResource(paramResources, R.drawable.n2);
case 3:
return BitmapFactory.decodeResource(paramResources, R.drawable.n3);
case 4:
return BitmapFactory.decodeResource(paramResources, R.drawable.n4);
case 5:
return BitmapFactory.decodeResource(paramResources, R.drawable.n5);
case 6:
return BitmapFactory.decodeResource(paramResources, R.drawable.n6);
case 7:
return BitmapFactory.decodeResource(paramResources, R.drawable.n7);
case 8:
return BitmapFactory.decodeResource(paramResources, R.drawable.n8);
case 9:
}
return BitmapFactory.decodeResource(paramResources, R.drawable.n9);
}
private void settingTamasTouchX(int paramInt1, int paramInt2)
{
int i = 0;
if (i >= this.oyatamaArray.length);
int k;
for (int j = 0; ; j++)
{
if (j >= this.tamaArray.length)
{
return;
}
k = 0;
if (k < this.tamaArray[j].length)
{
if (this.tamaArray[j][k].checkArea(paramInt1, paramInt2));
for (this.tamaArray[j][k].touchX = paramInt1; ; this.tamaArray[j][k].touchX = 0)
{
k++;
break;
}
// break label90;
}
}
}
public void init()
{
int i = getHeight() / 7;
int[] arrayOfInt = new int[6];
int j = 5;
//if (j < 0){
this.oyatamaArray = new Tama[6];
//}
int m;
int i1 = 0;
for (int k = 0; ; k++)
{
if (k >= this.oyatamaArray.length)
{
this.tamaArray = ((Tama[][])Array.newInstance(Tama.class, new int[] { 6, 4 }));
m = 0;
if (m < this.tamaArray.length)
{
for (int n = 0; ; n++)
{
if (n >= this.tamaArray[m].length)
{
m++;
break;
}
this.tamaArray[m][n] = new Tama(40 + n * 37, arrayOfInt[m] - 32, n + m * 10);
}
// break label154;
}
i1 = 0;
if (i1 < this.tamaArray.length)
{
for (int i2 = 0; ; i2++)
{
if (i2 >= this.tamaArray[i1].length)
{
i1++;
break;
}
if (i2 != this.tamaArray[i1].length - 1)
this.tamaArray[i1][i2].ueTama = this.tamaArray[i1][(i2 + 1)];
if (i2 == 0)
continue;
this.tamaArray[i1][i2].shitaTama = this.tamaArray[i1][(i2 - 1)];
}
// break label222;
}
this.isInitialized = true;
return;
}
this.oyatamaArray[k] = new Tama(279, arrayOfInt[k] - 32, k);
this.oyatamaArray[k].isOya = true;
}
}
#Override
protected void onDraw(Canvas paramCanvas)
{
Log.e("this is",".........onDraw");
if (!this.isInitialized)
init();
int i = 0;
Resources localResources;
int m;
while (true)
{
int j;
if (i >= this.oyatamaArray.length)
{
j = 0;
if (j >= this.tamaArray.length)
{
localResources = getContext().getResources();
m = 0;
if (m < 7)
break;
return;
}
}
else
{
paramCanvas.drawBitmap(this.myBitmap, this.oyatamaArray[i].getX(), this.oyatamaArray[i].getY(), this.myPaint);
i++;
continue;
}
for (int k = 0; ; k++)
{
if (k >= this.tamaArray[j].length)
{
j++;
break;
}
paramCanvas.drawBitmap(this.myBitmap, this.tamaArray[j][k].getX(), this.tamaArray[j][k].getY(), this.myPaint);
}
}
if (this.numbers.length <= m)
{
for (Bitmap localBitmap = BitmapFactory.decodeResource(localResources, R.drawable.space); ; localBitmap = returnNumberImg(localResources, this.numbers[m]))
{
paramCanvas.drawBitmap(localBitmap, 8.0F, getHeight() / 2 + m * 18, this.myPaint);
m++;
break;
}
}
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
int i = (int)paramMotionEvent.getX();
int j = (int)paramMotionEvent.getY();
if ((paramMotionEvent.getAction() == 0) && (i >= 0) && (i <= 40) && (410 <= j) && (j <= 430))
changeBackgroundImage();
if (paramMotionEvent.getAction() == 0)
settingTamasTouchX(i, j);
if (1 == paramMotionEvent.getAction())
settingTamasTouchX(0, 0);
int k;
int m = 0;
if (2 == paramMotionEvent.getAction())
{
k = 0;
if (k >= this.oyatamaArray.length)
{
m = 0;
if (m < this.tamaArray.length)
{
for (int n = 0; ; n++)
{
if (n >= this.tamaArray[m].length)
{
m++;
break;
}
this.tamaArray[m][n].checkAndSetArea(i, j);
if (!this.tamaArray[m][n].isUp)
continue;
int[] arrayOfInt = this.numbers;
arrayOfInt[m] = (1 + arrayOfInt[m]);
}
// break label164;
}
invalidate();
}
}
else
{
return true;
}
this.oyatamaArray[k].checkAndSetArea(i, j);
if (this.oyatamaArray[k].isUp)
this.numbers[k] = 5;
while (true)
{
k++;
break;
}
// label164:
return disableApplication;
}
public void resetTama()
{
int j;
for (int i = 0; ; i++)
{
if (i >= this.oyatamaArray.length)
{
j = 0;
if (j < this.tamaArray.length)
break;
invalidate();
return;
}
this.oyatamaArray[i].moveX(this.oyatamaArray[i].startX);
this.oyatamaArray[i].isUp = false;
this.numbers[i] = 0;
}
for (int k = 0; ; k++)
{
if (k >= this.tamaArray[j].length)
{
j++;
break;
}
this.tamaArray[j][k].moveX(this.tamaArray[j][k].startX);
this.tamaArray[j][k].isUp = false;
}
}
public void sensorChange(float[] paramArrayOfFloat)
{
int i = 0;
if (paramArrayOfFloat[2] < -50.0F)
i = 0 - 3;
int k;
while (true)
{
int j = 0;
if (j >= this.oyatamaArray.length)
{
k = 0;
if (k < this.tamaArray.length)
break;
if (i != 0)
invalidate();
return;
}
else
{
this.oyatamaArray[j].moveX(i + this.oyatamaArray[j].getX());
if (this.oyatamaArray[j].isUp)
this.numbers[j] = 5;
while (true)
{
j++;
break;
}
}
}
for (int m = 0; ; m++)
{
if (m >= this.tamaArray[k].length)
{
k++;
break;
}
this.tamaArray[k][m].moveX(i + this.tamaArray[k][m].getX());
if (!this.tamaArray[k][m].isUp)
continue;
int[] arrayOfInt = this.numbers;
arrayOfInt[k] = (1 + arrayOfInt[k]);
}
}
public void setTheme(int paramInt)
{
Resources localResources = getContext().getResources();
if (paramInt == 1)
{
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama);
setBackgroundResource(R.drawable.haikei);
}
while (true)
{
invalidate();
// return;
if (paramInt == 2)
{
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama2);
setBackgroundResource(R.drawable.haikei1);
continue;
}
this.myBitmap = BitmapFactory.decodeResource(localResources, R.drawable.tama3);
setBackgroundResource(R.drawable.haikei1);
}
}
}
Try this (instead of the setContentView )
this.myView = new MyView(this);
this.myView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
this.addContentView(myView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));

why jd-gui lost some info when decompile a .class file?

I have decompiled a class by jd-gui below, but I am unable to understand how the "linearLayout" is being initialized and why linearLayout.startAnimation(animationset) should be invoked, the LockScreen member "linearLayout" is not referred to any instance.
Can anybody tell me how this work? Is it possible for jd-gui lose something while decompilin a .class file ?
the decompiled file below:
// Referenced classes of package com.android.internal.policy.impl:
// KeyguardScreen, KeyguardStatusViewManager, DrawWaterWave, KeyguardUpdateMonitor,
// KeyguardScreenCallback
class LockScreen extends RelativeLayout
implements KeyguardScreen
{
class MultiWaveViewMethods
implements com.android.internal.widget.multiwaveview.MultiWaveView.OnTriggerListener, UnlockWidgetCommonMethods
{
private boolean mCameraDisabled;
private final MultiWaveView mMultiWaveView;
final LockScreen this$0;
public View getView()
{
return mMultiWaveView;
}
public void onGrabbed(View view, int i)
{
}
public void onGrabbedStateChange(View view, int i)
{
if (i != 0)
mCallback.pokeWakelock();
}
public void onReleased(View view, int i)
{
}
public void onTrigger(View view, int i)
{
if (i != 0 && i != 1) goto _L2; else goto _L1
_L1:
mCallback.goToUnlockScreen();
_L4:
return;
_L2:
if (i == 2 || i == 3)
if (!mCameraDisabled)
{
Intent intent = new Intent("android.intent.action.CAMERA_BUTTON", null);
mContext.sendOrderedBroadcast(intent, null);
mCallback.goToUnlockScreen();
} else
{
toggleRingMode();
mUnlockWidgetMethods.updateResources();
mCallback.pokeWakelock();
}
if (true) goto _L4; else goto _L3
_L3:
}
public void ping()
{
mMultiWaveView.ping();
}
public void reset(boolean flag)
{
mMultiWaveView.reset(flag);
}
public void updateResources()
{
int i;
if (mCameraDisabled)
{
if (mSilentMode)
i = 0x107000b;
else
i = 0x107000e;
} else
{
i = 0x1070010;
}
mMultiWaveView.setTargetResources(i);
}
MultiWaveViewMethods(MultiWaveView multiwaveview)
{
boolean flag = true;
this$0 = LockScreen.this;
super();
mMultiWaveView = multiwaveview;
if (mLockPatternUtils.getDevicePolicyManager().getCameraDisabled(null))
{
Log.v("LockScreen", "Camera disabled by Device Policy");
mCameraDisabled = flag;
} else
{
if (mMultiWaveView.getTargetResourceId() == 0x1070010)
flag = false;
mCameraDisabled = flag;
}
}
}
class SlidingTabMethods
implements com.android.internal.widget.SlidingTab.OnTriggerListener, UnlockWidgetCommonMethods
{
private final SlidingTab mSlidingTab;
final LockScreen this$0;
public View getView()
{
return mSlidingTab;
}
public void onGrabbedStateChange(View view, int i)
{
if (i == 2)
{
mSilentMode = isSilentMode();
SlidingTab slidingtab = mSlidingTab;
int j;
if (mSilentMode)
j = 0x104030b;
else
j = 0x104030c;
slidingtab.setRightHintText(j);
}
if (i != 0)
mCallback.pokeWakelock();
}
public void onTrigger(View view, int i)
{
if (i != 1) goto _L2; else goto _L1
_L1:
mCallback.goToUnlockScreen();
_L4:
return;
_L2:
if (i == 2)
{
toggleRingMode();
mCallback.pokeWakelock();
}
if (true) goto _L4; else goto _L3
_L3:
}
public void ping()
{
}
public void reset(boolean flag)
{
mSlidingTab.reset(flag);
}
public void updateResources()
{
int i = 1;
SlidingTab slidingtab;
int j;
int k;
int l;
int i1;
if (!mSilentMode || mAudioManager.getRingerMode() != i)
i = 0;
slidingtab = mSlidingTab;
if (mSilentMode)
{
if (i != 0)
j = 0x10802cc;
else
j = 0x10802c9;
} else
{
j = 0x10802ca;
}
if (mSilentMode)
k = 0x1080398;
else
k = 0x1080395;
if (mSilentMode)
l = 0x1080381;
else
l = 0x1080380;
if (mSilentMode)
i1 = 0x1080394;
else
i1 = 0x1080393;
slidingtab.setRightTabResources(j, k, l, i1);
}
SlidingTabMethods(SlidingTab slidingtab)
{
this$0 = LockScreen.this;
super();
mSlidingTab = slidingtab;
}
}
private static interface UnlockWidgetCommonMethods
{
public abstract View getView();
public abstract void ping();
public abstract void reset(boolean flag);
public abstract void updateResources();
}
class WaveViewMethods
implements com.android.internal.widget.WaveView.OnTriggerListener, UnlockWidgetCommonMethods
{
private final WaveView mWaveView;
final LockScreen this$0;
public View getView()
{
return mWaveView;
}
public void onGrabbedStateChange(View view, int i)
{
if (i == 10)
mCallback.pokeWakelock(30000);
}
public void onTrigger(View view, int i)
{
Log.i("LockScreen", (new StringBuilder()).append("onTrigger, whichHandle=").append(i).toString());
if (i == 10)
{
Log.i("LockScreen", "onTrigger, requestUnlockScreen");
requestUnlockScreen();
}
}
public void ping()
{
}
public void reset(boolean flag)
{
mWaveView.reset();
}
public void updateResources()
{
}
WaveViewMethods(WaveView waveview)
{
this$0 = LockScreen.this;
super();
mWaveView = waveview;
}
}
private static final boolean DBG = true;
private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
static final String LOCKSCREEN_WALLPAPER = "lockScreenWallpaper";
static final File LOCKSCREEN_WALLPAPER_DIR;
static final File LOCKSCREEN_WALLPAPER_FILE;
private static final int MASTER_STREAM_TYPE = 3;
private static final int ON_RESUME_PING_DELAY = 500;
private static final int STAY_ON_WHILE_GRABBED_TIMEOUT = 30000;
private static final String TAG = "LockScreen";
private static final int WAIT_FOR_ANIMATION_TIMEOUT;
Bitmap BitmapLock;
Bitmap BitmapLockin;
Bitmap BitmapLockout;
final float MAX_LOCK_VOLUME = 0.2F;
final float MIN_LOCK_VOLUME = 0.05F;
int circleinwidth;
int circlewidth;
private ImageView imageCircle;
private LinearLayout linearLayout;
private LinearLayout linearLayout2;
private int locationBrower[];
private int locationCall[];
private int locationCamera[];
private boolean mAnimate;
private AudioManager mAudioManager;
private ImageView mBrower;
private boolean mBrowerPress;
private ImageView mCall;
private boolean mCallPress;
private KeyguardScreenCallback mCallback;
private ImageView mCamera;
private boolean mCameraPress;
private RelativeLayout mChildView;
private Context mContext;
private int mCreationOrientation;
private boolean mDMLock;
private boolean mEnableMenuKeyInLockScreen;
private float mFirstMotionX;
private float mFirstMotionY;
private HDMINative mHDMI;
private int mKeyboardHidden;
private float mLastMotionX;
private float mLastMotionY;
private LockPatternUtils mLockPatternUtils;
private int mLockSoundId;
private int mLockSoundStreamId;
private SoundPool mLockSounds;
private TextView mLockString;
private int mMasterStreamMaxVolume;
private float mMotionDeltaX;
private float mMotionDeltaY;
private int mMoveFirst;
private boolean mMoveFirst2;
private final Runnable mOnResumePing = new Runnable() {
final LockScreen this$0;
public void run()
{
if (mDMLock)
mUnlockWidgetMethods.ping();
}
{
this$0 = LockScreen.this;
super();
}
};
Paint mPaintin;
Paint mPaintout;
private boolean mScreenOn;
private boolean mSilentMode;
private KeyguardStatusViewManager mStatusViewManager;
private boolean mTouching;
private boolean mUnlock;
private int mUnlockSoundId;
private View mUnlockWidget;
private UnlockWidgetCommonMethods mUnlockWidgetMethods;
private KeyguardUpdateMonitor mUpdateMonitor;
private final WallpaperManager mWallpaperManager;
private float mYVelocity;
DrawWaterWave m_DrawWaterWave;
LockScreen(Context context, Configuration configuration, LockPatternUtils lockpatternutils, KeyguardUpdateMonitor keyguardupdatemonitor, KeyguardScreenCallback keyguardscreencallback)
{
super(context);
mHDMI = new HDMINative();
BitmapLockin = null;
BitmapLockout = null;
BitmapLock = null;
circleinwidth = 75;
circlewidth = 180;
mMoveFirst = 0;
mMoveFirst2 = false;
mPaintin = null;
mPaintout = null;
mTouching = false;
mAnimate = false;
mUnlock = false;
mScreenOn = false;
mDMLock = false;
mContext = null;
mCallPress = false;
mBrowerPress = false;
mCameraPress = false;
locationCall = new int[2];
locationBrower = new int[2];
locationCamera = new int[2];
mContext = context;
mLockPatternUtils = lockpatternutils;
mUpdateMonitor = keyguardupdatemonitor;
mCallback = keyguardscreencallback;
mEnableMenuKeyInLockScreen = shouldEnableMenuKey();
mWallpaperManager = WallpaperManager.getInstance(context);
mCreationOrientation = configuration.orientation;
mKeyboardHidden = configuration.hardKeyboardHidden;
LayoutInflater layoutinflater = LayoutInflater.from(context);
Log.v("LockScreen", (new StringBuilder()).append("Creation orientation = ").append(mCreationOrientation).toString());
Log.i("LockScreen", "we will initialize the LockScreen single portrait layout");
layoutinflater.inflate(0x109005a, this, true);
mChildView = (RelativeLayout)findViewById(0x10202b4);
setBackDrawable();
mStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor, mLockPatternUtils, mCallback, false);
setFocusable(true);
setFocusableInTouchMode(true);
setDescendantFocusability(0x60000);
mAudioManager = (AudioManager)mContext.getSystemService("audio");
mSilentMode = isSilentMode();
m_DrawWaterWave = new DrawWaterWave(context);
if (mDMLock)
{
mUnlockWidget = findViewById(0x102029b);
android.content.ContentResolver contentresolver;
String s;
StringBuilder stringbuilder;
if (mUnlockWidget instanceof SlidingTab)
{
SlidingTab slidingtab = (SlidingTab)mUnlockWidget;
slidingtab.setHoldAfterTrigger(true, false);
slidingtab.setLeftHintText(0x104030a);
slidingtab.setLeftTabResources(0x10802cb, 0x1080396, 0x1080377, 0x108038a);
SlidingTabMethods slidingtabmethods = new SlidingTabMethods(slidingtab);
slidingtab.setOnTriggerListener(slidingtabmethods);
mUnlockWidgetMethods = slidingtabmethods;
} else
if (mUnlockWidget instanceof WaveView)
{
WaveView waveview = (WaveView)mUnlockWidget;
WaveViewMethods waveviewmethods = new WaveViewMethods(waveview);
waveview.setOnTriggerListener(waveviewmethods);
mUnlockWidgetMethods = waveviewmethods;
} else
if (mUnlockWidget instanceof MultiWaveView)
{
MultiWaveView multiwaveview = (MultiWaveView)mUnlockWidget;
MultiWaveViewMethods multiwaveviewmethods = new MultiWaveViewMethods(multiwaveview);
multiwaveview.setOnTriggerListener(multiwaveviewmethods);
mUnlockWidgetMethods = multiwaveviewmethods;
} else
{
throw new IllegalStateException((new StringBuilder()).append("Unrecognized unlock widget: ").append(mUnlockWidget).toString());
}
mUnlockWidgetMethods.updateResources();
}
BitmapLockin = ((BitmapDrawable)(BitmapDrawable)getResources().getDrawable(0x1080617)).getBitmap();
BitmapLockout = ((BitmapDrawable)(BitmapDrawable)getResources().getDrawable(0x1080619)).getBitmap();
BitmapLock = ((BitmapDrawable)(BitmapDrawable)getResources().getDrawable(0x1080618)).getBitmap();
imageCircle = (ImageView)findViewById(0x10202c7);
mCall = (ImageView)findViewById(0x10202c0);
mBrower = (ImageView)findViewById(0x10202c1);
mCamera = (ImageView)findViewById(0x10202c2);
mLockString = (TextView)findViewById(0x10202bd);
mPaintin = new Paint();
mPaintout = new Paint();
contentresolver = mContext.getContentResolver();
mLockSounds = new SoundPool(1, 1, 0);
s = android.provider.Settings.System.getString(contentresolver, "lock_sound");
if (s != null)
mLockSoundId = mLockSounds.load(s, 1);
if (s == null || mLockSoundId == 0)
Log.d("LockScreen", (new StringBuilder()).append("failed to load sound from ").append(s).toString());
if ("/system/media/audio/ui/Effect_Tick.ogg" != null)
mUnlockSoundId = mLockSounds.load("/system/media/audio/ui/Effect_Tick.ogg", 1);
if ("/system/media/audio/ui/Effect_Tick.ogg" == null || mUnlockSoundId == 0)
Log.d("LockScreen", (new StringBuilder()).append("failed to load sound from ").append("/system/media/audio/ui/Effect_Tick.ogg").toString());
if (mUpdateMonitor.DM_IsLocked() && mDMLock)
{
Log.i("LockScreen", "we should hide unlock widget");
mUnlockWidget.setVisibility(4);
}
if (mDMLock)
{
stringbuilder = (new StringBuilder()).append("*** LockScreen accel is ");
String s1;
if (mUnlockWidget.isHardwareAccelerated())
s1 = "on";
else
s1 = "off";
Log.v("LockScreen", stringbuilder.append(s1).toString());
}
}
private boolean isScreenOn()
{
PowerManager powermanager = (PowerManager)mContext.getSystemService("power");
boolean flag = false;
if (powermanager != null)
{
flag = powermanager.isScreenOn();
Log.d("LockScreen", (new StringBuilder()).append("screenOn:").append(flag).toString());
}
return flag;
}
private boolean isSilentMode()
{
boolean flag;
if (mAudioManager.getRingerMode() != 2)
flag = true;
else
flag = false;
return flag;
}
private void playSounds(boolean flag)
{
if (android.provider.Settings.System.getInt(mContext.getContentResolver(), "lockscreen_sounds_enabled", 1) != 1) goto _L2; else goto _L1
_L1:
int i;
if (flag)
i = mLockSoundId;
else
i = mUnlockSoundId;
mLockSounds.stop(mLockSoundStreamId);
if (mAudioManager != null) goto _L4; else goto _L3
_L3:
mAudioManager = (AudioManager)mContext.getSystemService("audio");
if (mAudioManager != null) goto _L5; else goto _L2
_L2:
return;
_L5:
mMasterStreamMaxVolume = mAudioManager.getStreamMaxVolume(3);
_L4:
int j = mAudioManager.getStreamVolume(3);
if (j != 0)
{
float f = 0.05F + 0.15F * ((float)j / (float)mMasterStreamMaxVolume);
Log.d("LockScreen", (new StringBuilder()).append("playSounds").append(i).toString());
mLockSoundStreamId = mLockSounds.play(i, f, f, 1, 0, 1.0F);
}
if (true) goto _L2; else goto _L6
_L6:
}
private void requestUnlockScreen()
{
postDelayed(new Runnable() {
final LockScreen this$0;
public void run()
{
mCallback.goToUnlockScreen();
}
{
this$0 = LockScreen.this;
super();
}
}, 0L);
}
private void setBackDrawable()
{
}
private boolean shouldEnableMenuKey()
{
boolean flag = getResources().getBoolean(0x111001a);
boolean flag1 = ActivityManager.isRunningInTestHarness();
boolean flag2 = (new File("/data/local/enable_menu_key")).exists();
boolean flag3;
if (!flag || flag1 || flag2)
flag3 = true;
else
flag3 = false;
return flag3;
}
private void toggleRingMode()
{
int i = 1;
boolean flag;
if (!mSilentMode)
flag = i;
else
flag = false;
mSilentMode = flag;
if (mSilentMode)
{
int j;
AudioManager audiomanager;
if (android.provider.Settings.System.getInt(mContext.getContentResolver(), "vibrate_in_silent", i) == i)
j = i;
else
j = 0;
audiomanager = mAudioManager;
if (j == 0)
i = 0;
audiomanager.setRingerMode(i);
} else
{
mAudioManager.setRingerMode(2);
}
}
public void cleanUp()
{
mUpdateMonitor.removeCallback(this);
mLockPatternUtils = null;
mUpdateMonitor = null;
mCallback = null;
}
protected void dispatchDraw(Canvas canvas)
{
if ((mTouching || mMoveFirst != 0) && !mDMLock)
{
super.dispatchDraw(canvas);
canvas.save();
canvas.translate(0.0F, 0.0F);
if (mMotionDeltaX * mMotionDeltaX + mMotionDeltaY * mMotionDeltaY > (float)(circleinwidth * circleinwidth))
{
float f = mMotionDeltaX * mMotionDeltaX + mMotionDeltaY * mMotionDeltaY;
float f1 = (0 + (0 + circlewidth)) * (0 + (0 + circlewidth));
float f2 = (255F * f) / f1;
if (f2 >= 255F)
f2 = 255F;
mPaintin.setAlpha((int)(255F - f2));
} else
{
mPaintin.setAlpha(255);
}
canvas.drawBitmap(BitmapLockin, mFirstMotionX - (float)circlewidth, mFirstMotionY - (float)circlewidth, mPaintin);
canvas.drawBitmap(BitmapLock, mFirstMotionX - 25F, mFirstMotionY - 25F, null);
canvas.restore();
invalidate();
if (mMoveFirst == 1)
mMoveFirst = 2;
if (isScreenOn())
mCallback.pokeWakelock();
else
Log.i("LockScreen", "dispatch, screenoff");
} else
{
setBackDrawable();
super.dispatchDraw(canvas);
}
}
public boolean needsInput()
{
return false;
}
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
updateConfiguration();
}
public void onClick2(View view)
{
if (view.getId() != 0x10202c0) goto _L2; else goto _L1
_L1:
mCallPress = true;
mBrowerPress = false;
mCameraPress = false;
mCall.setVisibility(0);
mBrower.setVisibility(4);
mCamera.setVisibility(4);
_L4:
return;
_L2:
if (view.getId() == 0x10202c1)
{
mCallPress = false;
mBrowerPress = true;
mCameraPress = false;
mCall.setVisibility(4);
mBrower.setVisibility(0);
mCamera.setVisibility(4);
} else
if (view.getId() == 0x10202c2)
{
mCallPress = false;
mBrowerPress = false;
mCameraPress = true;
mCall.setVisibility(4);
mBrower.setVisibility(4);
mCamera.setVisibility(0);
}
if (true) goto _L4; else goto _L3
_L3:
}
protected void onConfigurationChanged(Configuration configuration)
{
super.onConfigurationChanged(configuration);
updateConfiguration();
}
public boolean onKeyDown(int i, KeyEvent keyevent)
{
if (i == 82 && mEnableMenuKeyInLockScreen)
mCallback.goToUnlockScreen();
return false;
}
public void onPause()
{
mScreenOn = false;
mTouching = false;
mStatusViewManager.onPause();
setBackDrawable();
if (mDMLock)
mUnlockWidgetMethods.reset(false);
mHDMI.hdmiPortraitEnable(false);
}
public void onPhoneStateChanged(String s)
{
}
public void onResume()
{
mAnimate = false;
mTouching = false;
mMotionDeltaY = 0.0F;
mStatusViewManager.onResume();
postDelayed(mOnResumePing, 500L);
mHDMI.hdmiPortraitEnable(true);
mScreenOn = isScreenOn();
setBackDrawable();
}
public void onRingerModeChanged(int i)
{
boolean flag;
if (2 != i)
flag = true;
else
flag = false;
if (flag != mSilentMode)
{
mSilentMode = flag;
if (mDMLock)
mUnlockWidgetMethods.updateResources();
}
}
public boolean onTouchEvent(MotionEvent motionevent)
{
if (mScreenOn && !mDMLock) goto _L2; else goto _L1
_L1:
boolean flag;
Log.w("LockScreen", " ** Lock Screen is off or animation is running **");
flag = false;
_L8:
return flag;
_L2:
int i;
int j;
int k;
int l;
int i1;
int j1;
int k1;
int l1;
int i2;
i = motionevent.getAction();
j = (int)motionevent.getX();
mUnlock = false;
k = (int)motionevent.getY();
l = mCall.getWidth();
i1 = mCall.getHeight();
j1 = mBrower.getWidth();
k1 = mBrower.getHeight();
l1 = mCamera.getWidth();
i2 = mCamera.getHeight();
mCall.getLocationInWindow(locationCall);
mBrower.getLocationInWindow(locationBrower);
mCamera.getLocationInWindow(locationCamera);
i & 0xff;
JVM INSTR tableswitch 0 2: default 172
// 0 193
// 1 834
// 2 662;
goto _L3 _L4 _L5 _L6
_L5:
break MISSING_BLOCK_LABEL_834;
_L3:
break; /* Loop/switch isn't completed */
_L4:
break; /* Loop/switch isn't completed */
_L9:
if (mUnlock)
mCallback.goToUnlockScreen();
flag = true;
if (true) goto _L8; else goto _L7
_L7:
if (!mAnimate)
{
if (k > locationCall[1] && k < i1 + locationCall[1] && j > locationCall[0] && j < l + locationCall[0])
{
mCallPress = true;
mBrowerPress = false;
mCameraPress = false;
mCall.setVisibility(0);
mBrower.setVisibility(4);
mCamera.setVisibility(4);
mLockString.setText(0x10404db);
} else
if (k > locationBrower[1] && k < k1 + locationBrower[1] && j > locationBrower[0] && j < j1 + locationBrower[0])
{
mCallPress = false;
mBrowerPress = true;
mCameraPress = false;
mCall.setVisibility(4);
mBrower.setVisibility(0);
mCamera.setVisibility(4);
mLockString.setText(0x10404db);
} else
if (k > locationCamera[1] && k < i2 + locationCamera[1] && j > locationCamera[0] && j < l1 + locationCamera[0])
{
mCallPress = false;
mBrowerPress = false;
mCameraPress = true;
mCall.setVisibility(4);
mBrower.setVisibility(4);
mCamera.setVisibility(0);
mLockString.setText(0x10404db);
} else
{
onWallpaperTap(motionevent);
}
playSounds(true);
mFirstMotionX = j;
mFirstMotionY = k;
mMoveFirst2 = true;
m_DrawWaterWave.DropStone(j, k, 10, 50);
if (mMoveFirst == 10)
{
mMoveFirst = 1;
AnimationSet animationset = new AnimationSet(false);
b8 b8_1 = new b8(mFirstMotionX - (float)circlewidth, mFirstMotionY - (float)circlewidth, linearLayout, linearLayout2);
b8_1.initialize(circlewidth, circlewidth, 0, 0);
animationset.addAnimation(b8_1);
linearLayout.startAnimation(animationset);
android.view.animation.Animation.AnimationListener animationlistener = new android.view.animation.Animation.AnimationListener() {
final LockScreen this$0;
public void onAnimationEnd(Animation animation)
{
if (mTouching)
linearLayout2.setVisibility(0);
linearLayout.clearAnimation();
linearLayout.setVisibility(4);
}
public void onAnimationRepeat(Animation animation)
{
}
public void onAnimationStart(Animation animation)
{
}
{
this$0 = LockScreen.this;
super();
}
};
b8_1.setAnimationListener(animationlistener);
}
}
goto _L9
_L6:
if (!mAnimate)
{
mTouching = true;
mMotionDeltaY = (float)k - mFirstMotionY;
mMotionDeltaX = (float)j - mFirstMotionX;
if ((mMotionDeltaX % 3F == 0.0F || mMotionDeltaY % 3F == 0.0F) && mFirstMotionY < 750F)
onWallpaperTap(motionevent);
if (mMoveFirst2 && (mMotionDeltaX >= 20F || mMotionDeltaY >= 20F || mMotionDeltaX <= -20F || mMotionDeltaY <= -20F) && mFirstMotionY < 750F)
mMoveFirst2 = false;
if (mMotionDeltaY <= 0.0F);
m_DrawWaterWave.DropStone(j, k, 10, 50);
}
goto _L9
if (!mAnimate)
{
onWallpaperTap(motionevent);
float f = mMotionDeltaX;
float f1 = mMotionDeltaY;
mTouching = false;
mMotionDeltaY = 0.0F;
mMotionDeltaX = 0.0F;
mMoveFirst = 0;
if ((mCallPress || mBrowerPress || mCameraPress) && k < 700 && mFirstMotionY > 750F)
{
Intent intent = new Intent();
if (mCallPress)
{
intent.setClassName("com.android.contacts", "com.android.contacts.DialtactsActivity");
intent.setAction("android.intent.action.DIAL");
} else
if (mBrowerPress)
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
else
if (mCameraPress)
intent.setClassName("com.android.camera", "com.android.camera.Camera");
intent.setFlags(0x10000000);
mCallback.goToUnlockScreen();
mContext.startActivity(intent);
mUnlock = false;
} else
if (f * f + f1 * f1 > (float)(circlewidth * circlewidth))
{
mUnlock = true;
} else
{
mCall.setVisibility(0);
mBrower.setVisibility(0);
mCamera.setVisibility(0);
mLockString.setText(0x10404a0);
mUnlock = false;
}
imageCircle.setVisibility(8);
}
goto _L9
}
protected void onWallpaperTap(MotionEvent motionevent)
{
motionevent.findPointerIndex(motionevent.getPointerId(0));
Log.d("SlideButton", (new StringBuilder()).append("eee ").append(motionevent).toString());
mWallpaperManager.sendWallpaperTouch(getWindowToken(), motionevent);
}
protected void onWallpaperTapSecondary(MotionEvent motionevent)
{
int i = motionevent.findPointerIndex(motionevent.getPointerId(0));
mWallpaperManager.sendWallpaperCommand(getWindowToken(), "android.wallpaper.secondaryTap", 0 + (int)motionevent.getX(i), 0 + (int)motionevent.getY(i), 0, null);
}
void updateConfiguration()
{
int i;
Configuration configuration;
i = 1;
configuration = getResources().getConfiguration();
if (configuration.orientation == mCreationOrientation) goto _L2; else goto _L1
_L1:
mCallback.recreateMe(configuration);
_L4:
return;
_L2:
if (configuration.hardKeyboardHidden != mKeyboardHidden)
{
mKeyboardHidden = configuration.hardKeyboardHidden;
if (mKeyboardHidden != i)
i = 0;
if (mUpdateMonitor.isKeyguardBypassEnabled() && i != 0)
mCallback.goToUnlockScreen();
}
if (true) goto _L4; else goto _L3
_L3:
}
static
{
LOCKSCREEN_WALLPAPER_DIR = new File("/data/data/com.android.settings/mtk");
LOCKSCREEN_WALLPAPER_FILE = new File(LOCKSCREEN_WALLPAPER_DIR, "lockScreenWallpaper");
}
/*
static boolean access$002(LockScreen lockscreen, boolean flag)
{
lockscreen.mSilentMode = flag;
return flag;
}
*/
enter code here
}
A good rule of thumb is that these decompilers only generate something that resembles java code. There are often syntax/compilation problems, and there's no guarantee that the semantics match that of the original class.
If you want a lossless representation, it's better to use a disassembler to view the bytecode. For dex files, you can use baksmali, dexdump or dedexer.

Categories

Resources