]> iEval git - unical.git/commitdiff
Clean up previous commit
authorMarius Gavrilescu <marius@ieval.ro>
Tue, 18 Jun 2013 14:04:18 +0000 (17:04 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Tue, 18 Jun 2013 14:04:18 +0000 (17:04 +0300)
.pmd
src/ro/ieval/unical/AlarmReceiverActivity.java
src/ro/ieval/unical/Utils.java

diff --git a/.pmd b/.pmd
index 6a82507be493841d7d23f918bfef691f7a735dc0..7edda501d680929ac28f9520d65452bbd7092453 100644 (file)
--- a/.pmd
+++ b/.pmd
             <name>AvoidMultipleUnaryOperators</name>
             <ruleset>Basic Rules</ruleset>
         </rule>
-        <rule>
-            <name>AvoidPrintStackTrace</name>
-            <ruleset>Java Logging Rules</ruleset>
-        </rule>
         <rule>
             <name>AvoidProtectedFieldInFinalClass</name>
             <ruleset>Design Rules</ruleset>
index 8f5fca016d9a16950d45a57e980d1d5dd530dec9..d96a5af9ef00de588248ef88dbe84c378d1b59a4 100644 (file)
@@ -20,15 +20,16 @@ public class AlarmReceiverActivity extends Activity {
        private MediaPlayer mMediaPlayer;
        
        @Override
-       public void onCreate(Bundle savedInstanceState) {
+       public void onCreate(final Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                this.requestWindowFeature(Window.FEATURE_NO_TITLE);
                this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
                setContentView(R.layout.alarm);
                
-               Button stopAlarm = (Button) findViewById(R.id.stopAlarm);
+               final Button stopAlarm = (Button) findViewById(R.id.stopAlarm);
         stopAlarm.setOnTouchListener(new OnTouchListener() {
-            public boolean onTouch(View arg0, MotionEvent arg1) {
+            @Override
+                       public boolean onTouch(final View arg0, final MotionEvent arg1) {
                 mMediaPlayer.stop();
                 finish();
                 return false;
@@ -38,7 +39,7 @@ public class AlarmReceiverActivity extends Activity {
         playSound(this, getAlarmUri());
     }
  
-    private void playSound(Context context, Uri alert) {
+    private void playSound(final Context context, final Uri alert) {
         mMediaPlayer = new MediaPlayer();
         try {
             mMediaPlayer.setDataSource(context, alert);
@@ -50,23 +51,17 @@ public class AlarmReceiverActivity extends Activity {
                 mMediaPlayer.start();
             }
         } catch (IOException e) {
-            System.out.println("OOPS");
+               e.printStackTrace();
         }
     }
-    //Get an alarm sound. Try for an alarm. If none set, try notification, 
-    //Otherwise, ringtone.
-    private Uri getAlarmUri() {
-        Uri alert = RingtoneManager
-                .getDefaultUri(RingtoneManager.TYPE_ALARM);
-        if (alert == null) {
-            alert = RingtoneManager
-                    .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
-            if (alert == null) {
-                alert = RingtoneManager
-                        .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
-            }
-        }
+
+    private static Uri getAlarmUri() {
+        Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
+        if (alert == null)
+            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+        if (alert == null) 
+            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
+           
         return alert;
     }
 }
index 73e27371de292d33837d689faeae123f975e37fe..df57cda73262ff9f5ac6d13aeb1492cf786b9b0f 100644 (file)
@@ -3,7 +3,6 @@ package ro.ieval.unical;
 import java.util.GregorianCalendar;
 import java.util.Locale;
 
-import android.app.Activity;
 import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.content.Context;
@@ -27,10 +26,9 @@ final class Utils {
                return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month, day);
        }
        
-       public static void setAlarm(GregorianCalendar cal,Context context) {
-               Intent in = new Intent(context,AlarmReceiverActivity.class);
-               PendingIntent pi = PendingIntent.getActivity(context, 1234, in, PendingIntent.FLAG_CANCEL_CURRENT);
-               AlarmManager am = (AlarmManager)context.getSystemService(Activity.ALARM_SERVICE);
+       public static void setAlarm(final GregorianCalendar cal, final Context context) {
+               final PendingIntent pi = PendingIntent.getActivity(context, 1234, new Intent(context, AlarmReceiverActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
+               final AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
                am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pi);
        }
 }
This page took 0.036108 seconds and 4 git commands to generate.