2012-05-17 Santiago Munín <burning1@gmail.com>
* Core.java: Changed methods to static. * Main.java, PandroidEventviewerService.java, Core.java, Options.java, EventList.java PandroidEventviewerActivity.java: Instances of "Core" removed. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6319 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b579a9cd69
commit
b7336682e6
|
@ -1,3 +1,14 @@
|
|||
2012-05-17 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* Core.java: Changed methods to static.
|
||||
|
||||
* Main.java,
|
||||
PandroidEventviewerService.java,
|
||||
Core.java, Options.java,
|
||||
EventList.java
|
||||
PandroidEventviewerActivity.java: Instances of "Core" removed.
|
||||
|
||||
|
||||
2012-05-12 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* Licenses and javadoc comments added to all files, refactorized code.
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -33,28 +32,17 @@ import android.content.Intent;
|
|||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class Core implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7071445033114548174L;
|
||||
public Intent intent_service;
|
||||
|
||||
public Core() {
|
||||
intent_service = null;
|
||||
}
|
||||
public class Core {
|
||||
|
||||
/**
|
||||
* Starts PandroidEventviewerService.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void startServiceEventWatcher(Context context) {
|
||||
if (intent_service == null) {
|
||||
public static void startServiceEventWatcher(Context context) {
|
||||
|
||||
intent_service = new Intent(context,
|
||||
PandroidEventviewerService.class);
|
||||
}
|
||||
|
||||
context.startService(intent_service);
|
||||
context.startService(new Intent(context,
|
||||
PandroidEventviewerService.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,14 +50,10 @@ public class Core implements Serializable {
|
|||
*
|
||||
* @param context
|
||||
*/
|
||||
public void stopServiceEventWatcher(Context context) {
|
||||
if (intent_service == null) {
|
||||
public static void stopServiceEventWatcher(Context context) {
|
||||
|
||||
intent_service = new Intent(context,
|
||||
PandroidEventviewerService.class);
|
||||
}
|
||||
|
||||
context.stopService(this.intent_service);
|
||||
context.stopService(new Intent(context,
|
||||
PandroidEventviewerService.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +92,7 @@ public class Core implements Serializable {
|
|||
* @param arrayKey
|
||||
* @return Time in milliseconds.
|
||||
*/
|
||||
public long convertMaxTimeOldEventValuesToTimestamp(long time, int arrayKey) {
|
||||
public static long convertMaxTimeOldEventValuesToTimestamp(long time, int arrayKey) {
|
||||
long return_var = 0;
|
||||
|
||||
if (time == 0) {
|
||||
|
|
|
@ -184,10 +184,7 @@ public class EventList extends ListActivity {
|
|||
Intent i;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.options_button_menu_options:
|
||||
i = new Intent(this, Options.class);
|
||||
i.putExtra("core", this.core);
|
||||
|
||||
startActivity(i);
|
||||
startActivity(new Intent(this, Options.class));
|
||||
break;
|
||||
case R.id.refresh_button_menu_options:
|
||||
this.object.loadInProgress = true;
|
||||
|
@ -330,7 +327,6 @@ public class EventList extends ListActivity {
|
|||
la.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// TODO removed a View v argument, check
|
||||
/**
|
||||
* Loads more events.
|
||||
*
|
||||
|
@ -352,7 +348,6 @@ public class EventList extends ListActivity {
|
|||
private class MyAdapter extends BaseAdapter {
|
||||
private Context mContext;
|
||||
public PandroidEventviewerActivity object;
|
||||
public Core core;
|
||||
|
||||
public boolean showLoadingEvents;
|
||||
|
||||
|
@ -361,8 +356,6 @@ public class EventList extends ListActivity {
|
|||
mContext = c;
|
||||
|
||||
this.object = object;
|
||||
this.core = core;
|
||||
|
||||
showLoadingEvents = false;
|
||||
}
|
||||
|
||||
|
@ -571,7 +564,6 @@ public class EventList extends ListActivity {
|
|||
} else if (item.status != 1) {
|
||||
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
||||
clickListener.id_event = item.id_event;
|
||||
clickListener.core = this.core;
|
||||
button.setOnClickListener(clickListener);
|
||||
|
||||
text = (TextView) viewEventExtended
|
||||
|
@ -679,14 +671,12 @@ public class EventList extends ListActivity {
|
|||
*/
|
||||
private class OnClickListenerButtonValidate implements OnClickListener {
|
||||
public int id_event;
|
||||
public Core core;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(getApplicationContext(),
|
||||
PopupValidationEvent.class);
|
||||
i.putExtra("id_event", id_event);
|
||||
i.putExtra("core", this.core);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ public class Main extends Activity {
|
|||
private PandroidEventviewerActivity object;
|
||||
private HashMap<Integer, String> pandoraGroups;
|
||||
private Spinner comboSeverity;
|
||||
private Core core;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -69,7 +68,6 @@ public class Main extends Activity {
|
|||
Intent i = getIntent();
|
||||
this.object = (PandroidEventviewerActivity) i
|
||||
.getSerializableExtra("object");
|
||||
this.core = (Core) i.getSerializableExtra("core");
|
||||
|
||||
this.pandoraGroups = new HashMap<Integer, String>();
|
||||
|
||||
|
@ -280,10 +278,7 @@ public class Main extends Activity {
|
|||
Intent i;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.options_button_menu_options:
|
||||
i = new Intent(this, Options.class);
|
||||
i.putExtra("core", new Core());
|
||||
|
||||
startActivity(i);
|
||||
startActivity(new Intent(this, Options.class));
|
||||
break;
|
||||
case R.id.about_button_menu_options:
|
||||
i = new Intent(this, About.class);
|
||||
|
@ -307,7 +302,7 @@ public class Main extends Activity {
|
|||
Spinner combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
timeKey = combo.getSelectedItemPosition();
|
||||
|
||||
this.object.timestamp = this.core
|
||||
this.object.timestamp = Core
|
||||
.convertMaxTimeOldEventValuesToTimestamp(0, timeKey);
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
|
@ -402,8 +397,8 @@ public class Main extends Activity {
|
|||
editorPreferences.putInt("filterLastTime", filterLastTime);
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
Core.stopServiceEventWatcher(getApplicationContext());
|
||||
Core.startServiceEventWatcher(getApplicationContext());
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
this.getString(R.string.filter_update_succesful_str),
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.media.RingtoneManager;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -51,7 +52,6 @@ public class Options extends Activity {
|
|||
private int refreshTimeKey;
|
||||
private TextView connectionStatus;
|
||||
|
||||
private Core core;
|
||||
private PandroidEventviewerActivity object;
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,6 @@ public class Options extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.core = (Core) i.getSerializableExtra("core");
|
||||
|
||||
setContentView(R.layout.options);
|
||||
connectionStatus = (TextView) findViewById(R.id.check_connection_status);
|
||||
|
@ -132,7 +131,9 @@ public class Options extends Activity {
|
|||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT,
|
||||
false);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT,
|
||||
true);
|
||||
false);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
|
||||
Settings.System.DEFAULT_NOTIFICATION_URI);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
|
||||
RingtoneManager.TYPE_NOTIFICATION);
|
||||
startActivityForResult(intent, RINGTONE_PICK_CODE);
|
||||
|
@ -189,10 +190,6 @@ public class Options extends Activity {
|
|||
Context context = this.getApplicationContext();
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
if (this.core != null) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
Log.i(TAG, "Settings saved");
|
||||
Toast toast = Toast.makeText(context,
|
||||
this.getString(R.string.config_update_succesful_str),
|
||||
|
|
|
@ -73,8 +73,6 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
public String eventSearch;
|
||||
public int filterLastTime;
|
||||
|
||||
private Core core;
|
||||
|
||||
public boolean showOptionsFirstTime;
|
||||
public boolean showTabListFirstTime;
|
||||
|
||||
|
@ -95,18 +93,10 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
|
||||
this.loadInProgress = false;
|
||||
|
||||
this.core = new Core();
|
||||
|
||||
// Check if the preferences is setted, if not show the option activity.
|
||||
if ((user.length() == 0) && (password.length() == 0)
|
||||
&& (url.length() == 0)) {
|
||||
|
||||
Intent i = new Intent(this, Options.class);
|
||||
// i.putExtra("object", this);
|
||||
i.putExtra("core", this.core);
|
||||
|
||||
startActivity(i);
|
||||
|
||||
startActivity(new Intent(this, Options.class));
|
||||
this.showOptionsFirstTime = true;
|
||||
} else {
|
||||
this.loadInProgress = true;
|
||||
|
@ -122,7 +112,7 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
this.status = preferences.getInt("filterStatus", 3);
|
||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||
this.filterLastTime = preferences.getInt("filterLastTime", 6);
|
||||
this.timestamp = this.core.convertMaxTimeOldEventValuesToTimestamp(0,
|
||||
this.timestamp = Core.convertMaxTimeOldEventValuesToTimestamp(0,
|
||||
this.filterLastTime);
|
||||
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
|
@ -130,12 +120,12 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
|
||||
if (!this.showOptionsFirstTime) {
|
||||
// Start the background service for the notifications
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
Core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
|
||||
Intent i_main = new Intent(this, Main.class);
|
||||
i_main.putExtra("object", this);
|
||||
i_main.putExtra("core", this.core);
|
||||
// TODO corei_main.putExtra("core", this.core);
|
||||
|
||||
tabHost.addTab(tabHost
|
||||
.newTabSpec(
|
||||
|
|
|
@ -38,7 +38,6 @@ public class PandroidEventviewerService extends Service {
|
|||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue