I am trying to make my first live wallpaper. Everything was good while i was testing my app on my own mobile phone (Xperia Arc). But after running the app on G2 mini, Galaxy note 10 n8000 and Galaxy note 3, I found that nothing works.
On G2 mini the background doesn't even load, but in both notes the OnOffsetChanged
listener doesn't do it's job.
This is the drawing part and offset listener of my project, if any other methods is needed, tell me to add.
private void drawItems(Canvas c) {
c.save();
// item 12
c.drawBitmap(item12Bitmap,item12Left,item12Top,null);
// item 0
c.drawBitmap(item0Bitmap,item0Left,item0Top,null);
// item 1
item1Left = nextLeftGenerator(item1Left,item1NextLeft);
c.drawBitmap(item1Bitmap,item1Left,item1Top,null);
// item 2
item2Left = nextLeftGenerator(item2Left,item2NextLeft);
c.drawBitmap(item2Bitmap,item2Left,item2Top,null);
// item 3
item3Left = nextLeftGenerator(item3Left,item3NextLeft);
c.drawBitmap(item3Bitmap,item3Left,item3Top,null);
// item 4
item4Left = nextLeftGenerator(item4Left,item4NextLeft);
c.drawBitmap(item4Bitmap,item4Left,item4Top,null);
// item 5
item5Left = nextLeftGenerator(item5Left,item5NextLeft);
c.drawBitmap(item5Bitmap,item5Left,item5Top,null);
// item 6
item6Left = nextLeftGenerator(item6Left,item6NextLeft);
c.drawBitmap(item6Bitmap,item6Left,item6Top,null);
// item 7
item7Left = nextLeftGenerator(item7Left,item7NextLeft);
c.drawBitmap(item7Bitmap,item7Left,item7Top,null);
// item 8
item8Left = nextLeftGenerator(item8Left,item8NextLeft);
c.drawBitmap(item8Bitmap,item8Left,item8Top,null);
// item 9
item9Left = nextLeftGenerator(item9Left,item9NextLeft);
c.drawBitmap(item9Bitmap,item9Left,item9Top,null);
// item 10
item10Left = nextLeftGenerator(item10Left,item10NextLeft);
c.drawBitmap(item10Bitmap,item10Left,item10Top,null);
// item 11
item11Left = nextLeftGenerator(item11Left,item11NextLeft);
c.drawBitmap(item11Bitmap,item11Left,item11Top,null);
c.restore();
}
and the offset listener :
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xStep,
float yStep, int xPixels, int yPixels) {
Float diffrence;
if (firstOffset == null){
firstOffset = xOffset;
diffrence = 0.0f;
}
else {
diffrence = firstOffset - xOffset;
}
item1NextLeft = item1FirstPlace+Math.round(diffrence*drawHere.width()*1f);
item2NextLeft = item2FirstPlace-Math.round(diffrence*drawHere.width()*0.9f);
item3NextLeft = item3FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
item4NextLeft = item4FirstPlace-Math.round(diffrence*drawHere.width()*0.8f);
item5NextLeft = item5FirstPlace+Math.round(diffrence*drawHere.width()*0.7f);
item6NextLeft = item6FirstPlace-Math.round(diffrence*drawHere.width()*1f);
item7NextLeft = item7FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
item8NextLeft = item8FirstPlace-Math.round(diffrence*drawHere.width()*0.7f);
item9NextLeft = item9FirstPlace+Math.round(diffrence*drawHere.width()*0.6f);
item10NextLeft = item10FirstPlace-Math.round(diffrence*drawHere.width()*0.8f);
item11NextLeft = item11FirstPlace+Math.round(diffrence*drawHere.width()*0.5f);
//drawFrame();
//Toast.makeText(getApplicationContext(),"Offset Changed!!! xOffset : " + xOffset + "yOffset : " + yOffset + "xStep : " + xStep + "yStep : " + yStep + "xPixels : " + xPixels + "yPixels : " + yPixels ,Toast.LENGTH_SHORT).show();
//System.out.println("Offset Changed!!! xOffset : " + xOffset + "yOffset : " + yOffset + "xStep : " + xStep + "yStep : " + yStep + "xPixels : " + xPixels + "yPixels : " + yPixels );
}