From 4d41372159344d9324eb9d6e884eb0657d3a897a Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Sat, 7 May 2011 09:28:40 +0200 Subject: [PATCH] Refactored code --- .../src/es/ugr/swad/swadroid/SWADMain.java | 17 +++--- .../ugr/swad/swadroid/model/Notification.java | 54 ------------------- .../modules/notifications/Notifications.java | 3 +- .../NotificationsCursorAdapter.java | 1 + 4 files changed, 11 insertions(+), 64 deletions(-) diff --git a/SWADroid/src/es/ugr/swad/swadroid/SWADMain.java b/SWADroid/src/es/ugr/swad/swadroid/SWADMain.java index cdcfa5fe..ffa597e8 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/SWADMain.java +++ b/SWADroid/src/es/ugr/swad/swadroid/SWADMain.java @@ -38,7 +38,6 @@ import android.view.View; import android.widget.ExpandableListView; import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; import es.ugr.swad.swadroid.model.DataBaseHelper; import es.ugr.swad.swadroid.modules.notifications.Notifications; import es.ugr.swad.swadroid.modules.tests.Tests; @@ -175,10 +174,10 @@ public class SWADMain extends ExpandableListActivity { startActivityForResult(activity, Global.NOTIFICATIONS_REQUEST_CODE); } else if(keyword.equals(getString(R.string.testsModuleLabel))) { - /*activity = new Intent(getBaseContext(), Tests.class); - startActivityForResult(activity, Global.TESTS_REQUEST_CODE);*/ - Toast.makeText(this, keyword + " aún no implementado", Toast.LENGTH_LONG) - .show(); + activity = new Intent(getBaseContext(), Tests.class); + startActivityForResult(activity, Global.TESTS_REQUEST_CODE); + /*Toast.makeText(this, keyword + " aún no implementado", Toast.LENGTH_LONG) + .show();*/ } return true; @@ -198,7 +197,7 @@ public class SWADMain extends ExpandableListActivity { */ private void createMainMenu() { - // Construct Expandable List + //Construct Expandable List final ArrayList> headerData = new ArrayList>(); final HashMap messages = new HashMap(); @@ -278,13 +277,15 @@ public class SWADMain extends ExpandableListActivity { SecureConnection.initSecureConnection(); //Check if this is the first run after an install or upgrade - //If this is the first run, show configuration dialog - //If this is an upgrade, show upgrade dialog lastVersion = prefs.getLastVersion(); currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; + + //If this is the first run, show configuration dialog if(lastVersion == 0) { showConfigurationDialog(); prefs.setLastVersion(currentVersion); + + //If this is an upgrade, show upgrade dialog } else if(lastVersion < 12) { dbHelper.emptyTable(Global.DB_TABLE_NOTIFICATIONS); prefs.setLastVersion(currentVersion); diff --git a/SWADroid/src/es/ugr/swad/swadroid/model/Notification.java b/SWADroid/src/es/ugr/swad/swadroid/model/Notification.java index b4aea74f..289e4c81 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/model/Notification.java +++ b/SWADroid/src/es/ugr/swad/swadroid/model/Notification.java @@ -282,60 +282,6 @@ public class Notification extends Model { return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - Notification other = (Notification) obj; - if (content == null) { - if (other.content != null) - return false; - } else if (!content.equals(other.content)) - return false; - if (eventTime != other.eventTime) - return false; - if (eventType == null) { - if (other.eventType != null) - return false; - } else if (!eventType.equals(other.eventType)) - return false; - if (location == null) { - if (other.location != null) - return false; - } else if (!location.equals(other.location)) - return false; - if (status != other.status) - return false; - if (summary == null) { - if (other.summary != null) - return false; - } else if (!summary.equals(other.summary)) - return false; - if (userFirstName == null) { - if (other.userFirstName != null) - return false; - } else if (!userFirstName.equals(other.userFirstName)) - return false; - if (userSurname1 == null) { - if (other.userSurname1 != null) - return false; - } else if (!userSurname1.equals(other.userSurname1)) - return false; - if (userSurname2 == null) { - if (other.userSurname2 != null) - return false; - } else if (!userSurname2.equals(other.userSurname2)) - return false; - return true; - } - /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java index dea8940c..f7d2f3ce 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java +++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java @@ -186,8 +186,7 @@ public class Notifications extends Module { } //Request finalized without errors - if(isDebuggable) - Log.i(Global.NOTIFICATIONS_TAG, "Retrieved " + csSize + " notifications"); + Log.i(Global.NOTIFICATIONS_TAG, "Retrieved " + csSize + " notifications"); //Clear old notifications to control database size dbHelper.clearOldNotifications(SIZE_LIMIT); diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java index 446a235c..b4b45956 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java +++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java @@ -54,6 +54,7 @@ public class NotificationsCursorAdapter extends CursorAdapter { String[] dateContent; Date d; + view.setScrollContainer(false); TextView eventType = (TextView) view.findViewById(R.id.eventType); TextView eventDate = (TextView) view.findViewById(R.id.eventDate); TextView eventTime = (TextView) view.findViewById(R.id.eventTime);