1
0
Fork 0
forked from len0rd/rockbox

Code style changes in the java part (whitespaces and braces) to match Rockbox coding style.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28065 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-09-12 19:56:13 +00:00
parent 54c838d2ae
commit 282adacb54
5 changed files with 549 additions and 528 deletions

View file

@ -29,7 +29,8 @@ import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
public class RockboxActivity extends Activity {
public class RockboxActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
@ -52,7 +53,8 @@ public class RockboxActivity extends Activity {
* This thread waits for the fb to become ready */
new Thread(new Runnable()
{
public void run() {
public void run()
{
try {
while (RockboxService.fb == null)
Thread.sleep(250);
@ -95,19 +97,22 @@ public class RockboxActivity extends Activity {
* which is nice
*/
@Override
protected void onPause() {
protected void onPause()
{
super.onPause();
RockboxService.fb.suspend();
}
@Override
protected void onStop() {
protected void onStop()
{
super.onStop();
RockboxService.fb.suspend();
}
@Override
protected void onDestroy() {
protected void onDestroy()
{
super.onDestroy();
RockboxService.fb.suspend();
}

View file

@ -68,7 +68,6 @@ public class RockboxFramebuffer extends View
{
/* can't copy a partial buffer */
btm.copyPixelsFromBuffer(native_buf);
postInvalidate(x, y, x+w, y+h);
}

View file

@ -59,12 +59,14 @@ public class RockboxPCM extends AudioTrack
l = new PCMListener(buf_len);
}
int bytes2frames(int bytes) {
private int bytes2frames(int bytes)
{
/* 1 sample is 2 bytes, 2 samples are 1 frame */
return (bytes/4);
}
int frames2bytes(int frames) {
private int frames2bytes(int frames)
{
/* 1 frame is 2 samples, 1 sample is 2 bytes */
return (frames*4);
}
@ -125,18 +127,21 @@ public class RockboxPCM extends AudioTrack
public native void pcmSamplesToByteArray(byte[] dest);
private class PCMListener implements OnPlaybackPositionUpdateListener {
int max_len;
int refill_mark;
byte[] buf;
public PCMListener(int len) {
private class PCMListener implements OnPlaybackPositionUpdateListener
{
private int max_len;
private int refill_mark;
private byte[] buf;
public PCMListener(int len)
{
max_len = len;
/* refill to 100% when reached the 25% */
buf = new byte[max_len*3/4];
refill_mark = max_len - buf.length;
}
@Override
public void onMarkerReached(AudioTrack track) {
public void onMarkerReached(AudioTrack track)
{
/* push new data to the hardware */
RockboxPCM pcm = (RockboxPCM)track;
int result = -1;
@ -149,7 +154,8 @@ public class RockboxPCM extends AudioTrack
case AudioTrack.PLAYSTATE_PLAYING:
case AudioTrack.PLAYSTATE_PAUSED:
/* refill at 25% no matter of how many bytes we've written */
if (setNotificationMarkerPosition(bytes2frames(refill_mark)) != AudioTrack.SUCCESS)
if (setNotificationMarkerPosition(bytes2frames(refill_mark))
!= AudioTrack.SUCCESS)
LOG("Error in onMarkerReached: Could not set notification marker");
else /* recharge */
setPlaybackPositionUpdateListener(this, h);
@ -167,8 +173,8 @@ public class RockboxPCM extends AudioTrack
}
@Override
public void onPeriodicNotification(AudioTrack track) {
// TODO Auto-generated method stub
public void onPeriodicNotification(AudioTrack track)
{
}
}
}

View file

@ -65,16 +65,20 @@ public class RockboxService extends Service
private IntentFilter itf;
private BroadcastReceiver batt_monitor;
private int battery_level;
@Override
public void onCreate()
{
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
try {
try
{
mStartForeground = getClass().getMethod("startForeground",
mStartForegroundSignature);
mStopForeground = getClass().getMethod("stopForeground",
mStopForegroundSignature);
} catch (NoSuchMethodException e) {
}
catch (NoSuchMethodException e)
{
/* Running on an older platform: fall back to old API */
mStartForeground = mStopForeground = null;
}
@ -131,7 +135,8 @@ public class RockboxService extends Service
ZipFile zipfile = new ZipFile(file);
Enumeration<? extends ZipEntry> e = zipfile.entries();
File folder;
while(e.hasMoreElements()) {
while(e.hasMoreElements())
{
entry = (ZipEntry) e.nextElement();
LOG("Extracting: " +entry);
if (entry.isDirectory())
@ -140,7 +145,7 @@ public class RockboxService extends Service
LOG("mkdir "+ entry);
try {
folder.mkdirs();
} catch (SecurityException ex){
} catch (SecurityException ex) {
LOG(ex.getMessage());
}
continue;
@ -154,9 +159,8 @@ public class RockboxService extends Service
folder.mkdirs();
FileOutputStream fos = new FileOutputStream(entry.getName());
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = is.read(data, 0, BUFFER)) != -1) {
while ((count = is.read(data, 0, BUFFER)) != -1)
dest.write(data, 0, count);
}
dest.flush();
dest.close();
is.close();
@ -185,7 +189,8 @@ public class RockboxService extends Service
private native void main();
@Override
public IBinder onBind(Intent intent) {
public IBinder onBind(Intent intent)
{
// TODO Auto-generated method stub
return null;
}
@ -207,8 +212,10 @@ public class RockboxService extends Service
/* we get literally spammed with battery statuses
* if we don't delay the re-attaching
*/
TimerTask tk = new TimerTask() {
public void run() {
TimerTask tk = new TimerTask()
{
public void run()
{
registerReceiver(batt_monitor, itf);
}
};
@ -327,7 +334,8 @@ public class RockboxService extends Service
}
@Override
public void onDestroy() {
public void onDestroy()
{
super.onDestroy();
/* Make sure our notification is gone. */
stopForegroundCompat(R.string.notification);

View file

@ -45,12 +45,14 @@ public class RockboxTimer extends Timer
}
@Override
public void run() {
public void run()
{
timerTask();
int state = tm.getCallState();
if (state != last_state)
{
switch (state) {
switch (state)
{
case TelephonyManager.CALL_STATE_IDLE:
postCallHungUp();
break;
@ -69,7 +71,7 @@ public class RockboxTimer extends Timer
public RockboxTimer(RockboxService instance, long period_inverval_in_ms)
{
super("tick timer", false);
super("tick timer");
task = new RockboxTimerTask(instance, this);
schedule(task, 0, period_inverval_in_ms);
interval = period_inverval_in_ms;
@ -85,7 +87,8 @@ public class RockboxTimer extends Timer
/* methods called from native, keep them simple */
public void java_wait_for_interrupt()
{
synchronized(this) {
synchronized(this)
{
try {
this.wait();
} catch (InterruptedException e) {