2012-06-21 Santiago Munin <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/EventList.java: Restored to the previous version. * src/pandroid_event_viewer/pandorafms/Core.java: Added a line which checks if the connection is secure. * src/pandroid_event_viewer/pandorafms/Options.java: Made some changes in certificate checking. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Now, if there are any problem parsing data received from server. * res/layout/list_view_layout.xml: Restored to the previous version. * res/layout/item_list_event_layout.xml: Restored to the previous version. * res/values/strings.xml: Added new entries. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6665 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f16cf3cd5a
commit
6f73b31102
|
@ -1,3 +1,12 @@
|
|||
2012-06-21 Santiago Munín <burning1@gmail.com>
|
||||
* src/pandroid_event_viewer/pandorafms/EventList.java: Restored to the previous version.
|
||||
* src/pandroid_event_viewer/pandorafms/Core.java: Added a line which checks if the connection is secure.
|
||||
* src/pandroid_event_viewer/pandorafms/Options.java: Made some changes in certificate checking.
|
||||
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Now, if there are any problem parsing data received from server.
|
||||
* res/layout/list_view_layout.xml: Restored to the previous version.
|
||||
* res/layout/item_list_event_layout.xml: Restored to the previous version.
|
||||
* res/values/strings.xml: Added new entries.
|
||||
|
||||
2012-06-20 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/API.java: New class, it will provide all API calls.
|
||||
|
|
|
@ -62,12 +62,12 @@
|
|||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- <Button
|
||||
<Button
|
||||
android:id="@+id/button_load_more_events"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/load_more_events_button_str"
|
||||
android:visibility="gone" /> -->
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_more_events"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<!-- <LinearLayout
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_layout"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -39,7 +39,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
</LinearLayout> -->
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/empty_list_layout"
|
||||
android:orientation="horizontal"
|
||||
|
|
|
@ -120,4 +120,5 @@
|
|||
<string name="url_not_valid">Incorrect url. Please, insert a valid url</string>
|
||||
<string name="certificate_not_valid">This server has a certificate not signed by a CA, do you trust it?</string>
|
||||
<string name="options_not_saved">Options not saved.</string>
|
||||
<string name="notification_error_parsing">There was an error retrieving data from server.</string>
|
||||
</resources>
|
|
@ -321,7 +321,7 @@ public class Core {
|
|||
parameters.add(new BasicNameValuePair("user", user));
|
||||
parameters.add(new BasicNameValuePair("pass", password));
|
||||
parameters.addAll(additionalParameters);
|
||||
if (url.contains("https")) {
|
||||
if (url.toLowerCase().contains("https")) {
|
||||
// Secure connection
|
||||
return Core.httpsGet(url, parameters);
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ public class Core {
|
|||
|
||||
try {
|
||||
myFileUrl = new URL(fileUrl);
|
||||
if (fileUrl.contains("https")) {
|
||||
if (fileUrl.toLowerCase().contains("https")) {
|
||||
HttpsURLConnection con = (HttpsURLConnection) new URL(fileUrl)
|
||||
.openConnection();
|
||||
con.setHostnameVerifier(new HostnameVerifier() {
|
||||
|
|
|
@ -31,7 +31,6 @@ import android.graphics.Color;
|
|||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -39,12 +38,11 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +55,6 @@ public class EventList extends ListActivity {
|
|||
private ListView lv;
|
||||
private MyAdapter la;
|
||||
private PandroidEventviewerActivity object;
|
||||
private boolean moreEvents;
|
||||
|
||||
private BroadcastReceiver onBroadcast;
|
||||
|
||||
|
@ -71,40 +68,13 @@ public class EventList extends ListActivity {
|
|||
|
||||
setContentView(R.layout.list_view_layout);
|
||||
|
||||
//this.toggleLoadingLayout();
|
||||
moreEvents = true;
|
||||
this.toggleLoadingLayout();
|
||||
|
||||
lv = (ListView) findViewById(android.R.id.list);
|
||||
|
||||
la = new MyAdapter(getBaseContext(), object);
|
||||
this.object.adapter = la;
|
||||
|
||||
lv.setAdapter(la);
|
||||
lv.setOnScrollListener(new OnScrollListener() {
|
||||
private int priorFirst = -1;
|
||||
|
||||
@Override
|
||||
public void onScroll(final AbsListView view, final int first,
|
||||
final int visible, final int total) {
|
||||
// detect if last item is visible
|
||||
if (visible < total && (first + visible == total)) {
|
||||
// see if we have more results
|
||||
if (first != priorFirst) {
|
||||
priorFirst = first;
|
||||
Log.d("EventList", "Loading smthing");
|
||||
if (((long) object.eventList.size()) < object.count_events) {
|
||||
loadMoreEvents();
|
||||
// moreEvents = true;
|
||||
} /*
|
||||
* else { Log.d("eventList", "moreEvents FALSE");
|
||||
* moreEvents = false; }
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
}
|
||||
});
|
||||
|
||||
onBroadcast = new BroadcastReceiver() {
|
||||
|
||||
|
@ -112,26 +82,37 @@ public class EventList extends ListActivity {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
int load_more = intent.getIntExtra("load_more", 0);
|
||||
|
||||
Button button = (Button) findViewById(R.id.button_load_more_events);
|
||||
|
||||
if (object.eventList.size() == 0) {
|
||||
button.setVisibility(Button.GONE);
|
||||
} else if (((long) object.eventList.size()) >= object.count_events) {
|
||||
button.setVisibility(Button.GONE);
|
||||
} else {
|
||||
button.setVisibility(Button.VISIBLE);
|
||||
}
|
||||
|
||||
if (load_more == 1) {
|
||||
/* LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||
layout.setVisibility(LinearLayout.GONE);*/
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||
layout.setVisibility(LinearLayout.GONE);
|
||||
la.showLoadingEvents = false;
|
||||
} else {
|
||||
/*LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||
layout.setVisibility(LinearLayout.GONE);*/
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||
layout.setVisibility(LinearLayout.GONE);
|
||||
|
||||
if (((int) object.count_events) == 0) {
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||
layout.setVisibility(LinearLayout.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
la.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||
|
||||
//this.toggleLoadingLayout();
|
||||
this.toggleLoadingLayout();
|
||||
|
||||
if (this.object.show_popup_info) {
|
||||
this.object.show_popup_info = false;
|
||||
|
@ -145,7 +126,7 @@ public class EventList extends ListActivity {
|
|||
|
||||
if (this.object.showOptionsFirstTime) {
|
||||
this.object.loadInProgress = true;
|
||||
// toggleLoadingLayout();
|
||||
toggleLoadingLayout();
|
||||
|
||||
this.object.showOptionsFirstTime = false;
|
||||
this.object.executeBackgroundGetEvents();
|
||||
|
@ -157,7 +138,7 @@ public class EventList extends ListActivity {
|
|||
|
||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||
|
||||
//this.toggleLoadingLayout();
|
||||
this.toggleLoadingLayout();
|
||||
|
||||
if (!this.object.loadInProgress) {
|
||||
if (((int) object.count_events) == 0) {
|
||||
|
@ -189,7 +170,7 @@ public class EventList extends ListActivity {
|
|||
this.object.loadInProgress = true;
|
||||
this.object.getNewListEvents = true;
|
||||
this.object.eventList = new ArrayList<EventListItem>();
|
||||
// this.toggleLoadingLayout();
|
||||
this.toggleLoadingLayout();
|
||||
this.object.executeBackgroundGetEvents();
|
||||
break;
|
||||
case R.id.about_button_menu_options:
|
||||
|
@ -204,7 +185,7 @@ public class EventList extends ListActivity {
|
|||
/**
|
||||
* Shows loading information.
|
||||
*/
|
||||
/*private void toggleLoadingLayout() {
|
||||
private void toggleLoadingLayout() {
|
||||
LinearLayout layout;
|
||||
|
||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||
|
@ -217,7 +198,7 @@ public class EventList extends ListActivity {
|
|||
} else {
|
||||
layout.setVisibility(LinearLayout.GONE);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private String getImageGroupUrl(String group_icon) {
|
||||
SharedPreferences preferences = getApplicationContext()
|
||||
|
@ -263,12 +244,7 @@ public class EventList extends ListActivity {
|
|||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
super.onListItemClick(l, v, position, id);
|
||||
|
||||
EventListItem item;
|
||||
try {
|
||||
item = this.object.eventList.get(position);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
EventListItem item = this.object.eventList.get(position);
|
||||
|
||||
item.opened = !item.opened;
|
||||
this.object.eventList.set(position, item);
|
||||
|
@ -282,7 +258,8 @@ public class EventList extends ListActivity {
|
|||
*/
|
||||
private void loadMoreEvents() {
|
||||
la.showLoadingEvents = true;
|
||||
object.offset += object.pagination;
|
||||
la.notifyDataSetChanged();
|
||||
|
||||
object.executeBackgroundGetEvents();
|
||||
}
|
||||
|
||||
|
@ -327,83 +304,49 @@ public class EventList extends ListActivity {
|
|||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.item_list_event_layout, null);
|
||||
|
||||
LinearLayout layout = (LinearLayout) view
|
||||
.findViewById(R.id.loading_more_events);
|
||||
// layout.setVisibility(LinearLayout.GONE);*/
|
||||
// If the end of the list.
|
||||
if (this.object.eventList.size() == position) {
|
||||
if (object.newEvents) {
|
||||
Log.d("loading", "true");
|
||||
layout.setVisibility(LinearLayout.VISIBLE);
|
||||
if (convertView != null) {
|
||||
convertView.setClickable(false);
|
||||
}
|
||||
} else {
|
||||
Log.d("loading", "false");
|
||||
layout.setVisibility(LinearLayout.GONE);
|
||||
if (convertView != null) {
|
||||
convertView.setClickable(false);
|
||||
}
|
||||
}
|
||||
this.notifyDataSetChanged();
|
||||
// if (showLoadingEvents) {
|
||||
/*
|
||||
* layout = (LinearLayout) view
|
||||
* .findViewById(R.id.loading_more_events);
|
||||
* layout.setVisibility(LinearLayout.VISIBLE);
|
||||
*/
|
||||
// }// else {
|
||||
/*
|
||||
* LinearLayout layout = (LinearLayout) view
|
||||
* .findViewById(R.id.loading_more_events);
|
||||
* layout.setVisibility(LinearLayout.GONE);
|
||||
*/
|
||||
// }
|
||||
// Show button to get more events
|
||||
if ((!object.loadInProgress) && (object.count_events != 0)) {
|
||||
if (showLoadingEvents) {
|
||||
LinearLayout layout = (LinearLayout) view
|
||||
.findViewById(R.id.loading_more_events);
|
||||
layout.setVisibility(LinearLayout.VISIBLE);
|
||||
|
||||
RelativeLayout layout2 = (RelativeLayout) view
|
||||
.findViewById(R.id.content_event_item);
|
||||
layout2.setVisibility(RelativeLayout.GONE);
|
||||
|
||||
Button button = (Button) view
|
||||
.findViewById(R.id.button_load_more_events);
|
||||
button.setVisibility(Button.GONE);
|
||||
} else {
|
||||
Button button = (Button) view
|
||||
.findViewById(R.id.button_load_more_events);
|
||||
|
||||
if (object.eventList.size() == 0) {
|
||||
button.setVisibility(Button.GONE);
|
||||
} else if (((long) object.eventList.size()) >= object.count_events) {
|
||||
button.setVisibility(Button.GONE);
|
||||
} else {
|
||||
button.setVisibility(Button.VISIBLE);
|
||||
}
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
object.offset += object.pagination;
|
||||
loadMoreEvents();
|
||||
}
|
||||
});
|
||||
|
||||
RelativeLayout content_event_item = (RelativeLayout) view
|
||||
.findViewById(R.id.content_event_item);
|
||||
content_event_item.setVisibility(RelativeLayout.GONE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Log.d("error", "crash2"); LinearLayout layout =
|
||||
* (LinearLayout) view .findViewById(R.id.loading_more_events);
|
||||
* layout.setVisibility(LinearLayout.VISIBLE);
|
||||
*
|
||||
* RelativeLayout layout2 = (RelativeLayout) view
|
||||
* .findViewById(R.id.content_event_item);
|
||||
* layout2.setVisibility(RelativeLayout.GONE);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Button button = (Button) view
|
||||
* .findViewById(R.id.button_load_more_events);
|
||||
* button.setVisibility(Button.GONE);
|
||||
*/
|
||||
// } else {
|
||||
/*
|
||||
* Log.d("error", "crash1"); LinearLayout layout =
|
||||
* (LinearLayout) view .findViewById(R.id.loading_more_events);
|
||||
* layout.setVisibility(LinearLayout.GONE);
|
||||
*/
|
||||
|
||||
/*
|
||||
* RelativeLayout content_event_item = (RelativeLayout) view
|
||||
* .findViewById(R.id.content_event_item);
|
||||
* content_event_item.setVisibility(RelativeLayout.GONE);
|
||||
*/
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
/*
|
||||
* LinearLayout layout = (LinearLayout) view
|
||||
* .findViewById(R.id.loading_more_events);
|
||||
* layout.setVisibility(LinearLayout.GONE);
|
||||
*/
|
||||
final EventListItem item;
|
||||
try {
|
||||
item = this.object.eventList.get(position);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return view;
|
||||
}
|
||||
final EventListItem item = this.object.eventList.get(position);
|
||||
|
||||
switch (item.criticity) {
|
||||
|
||||
|
@ -577,6 +520,7 @@ public class EventList extends ListActivity {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO
|
||||
Intent intent = new Intent(
|
||||
getBaseContext(),
|
||||
CreateIncidentActivity.class);
|
||||
|
@ -600,7 +544,7 @@ public class EventList extends ListActivity {
|
|||
itemLinearLayout.addView(viewEventExtended);
|
||||
}
|
||||
}
|
||||
this.notifyDataSetChanged();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -675,12 +619,7 @@ public class EventList extends ListActivity {
|
|||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
EventListItem item;
|
||||
try {
|
||||
item = this.object.eventList.get(mPosition);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
EventListItem item = this.object.eventList.get(mPosition);
|
||||
item.opened = !item.opened;
|
||||
this.object.eventList.set(mPosition, item);
|
||||
la.notifyDataSetChanged();
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.net.URL;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -56,13 +57,15 @@ public class Options extends Activity {
|
|||
private String password;
|
||||
private int refreshTimeKey;
|
||||
private TextView connectionStatus;
|
||||
private ProgressDialog retrievingCertificate;
|
||||
private Context context;
|
||||
|
||||
private PandroidEventviewerActivity object;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.context = this;
|
||||
Intent i = getIntent();
|
||||
|
||||
setContentView(R.layout.options);
|
||||
|
@ -168,34 +171,10 @@ public class Options extends Activity {
|
|||
String url = ((EditText) findViewById(R.id.url)).getText().toString();
|
||||
if (url.contains("https")) {
|
||||
try {
|
||||
if (!Core.isValidCertificate(new URL(url))) {
|
||||
// Displays confirmation dialog
|
||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
Toast.makeText(getApplicationContext(),
|
||||
R.string.options_not_saved,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
writeChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(
|
||||
getString(R.string.certificate_not_valid))
|
||||
.setPositiveButton(getString(android.R.string.yes),
|
||||
dialogClickListener)
|
||||
.setNegativeButton(getString(android.R.string.no),
|
||||
dialogClickListener).show();
|
||||
} else {
|
||||
writeChanges();
|
||||
}
|
||||
retrievingCertificate = ProgressDialog.show(this, "",
|
||||
"Loading...", true);
|
||||
new CheckCertificateAsyncTask()
|
||||
.execute(new URL[] { new URL(url) });
|
||||
} catch (MalformedURLException e) {
|
||||
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
@ -333,4 +312,45 @@ public class Options extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CheckCertificateAsyncTask extends
|
||||
AsyncTask<URL, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(URL... arg0) {
|
||||
return Core.isValidCertificate(arg0[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
retrievingCertificate.dismiss();
|
||||
if (!result) {
|
||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
Toast.makeText(getApplicationContext(),
|
||||
R.string.options_not_saved,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
writeChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
context);
|
||||
builder.setMessage(getString(R.string.certificate_not_valid))
|
||||
.setPositiveButton(getString(android.R.string.yes),
|
||||
dialogClickListener)
|
||||
.setNegativeButton(getString(android.R.string.no),
|
||||
dialogClickListener).show();
|
||||
} else {
|
||||
writeChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,11 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -38,6 +42,7 @@ import android.widget.Toast;
|
|||
public class PandroidEventviewerActivity extends TabActivity implements
|
||||
Serializable {
|
||||
private static String TAG = "PandroidEventviewerActivity";
|
||||
private static final int PROBLEM_NOTIFICATION_ID = 1;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Data aplication
|
||||
|
@ -346,61 +351,65 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
event.event = getApplication().getString(
|
||||
R.string.unknown_event_str);
|
||||
} else {
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
} else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
} else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
event.id_user = items[2];
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
} else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
} else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
event.timestamp = items[5];
|
||||
event.event = items[6];
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
} else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
event.event_type = items[8];
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
} else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
} else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
} else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
event.user_comment = items[12];
|
||||
event.tags = items[13];
|
||||
event.agent_name = items[16];
|
||||
event.group_name = items[17];
|
||||
event.group_icon = items[18];
|
||||
event.description_event = items[19];
|
||||
event.description_image = items[20];
|
||||
event.criticity_name = items[21];
|
||||
event.criticity_image = items[22];
|
||||
try {
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
} else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
} else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
event.id_user = items[2];
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
} else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
} else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
event.timestamp = items[5];
|
||||
event.event = items[6];
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
} else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
event.event_type = items[8];
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
} else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
} else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
} else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
event.user_comment = items[12];
|
||||
event.tags = items[13];
|
||||
event.agent_name = items[16];
|
||||
event.group_name = items[17];
|
||||
event.group_icon = items[18];
|
||||
event.description_event = items[19];
|
||||
event.description_image = items[20];
|
||||
event.criticity_name = items[21];
|
||||
event.criticity_image = items[22];
|
||||
|
||||
event.opened = false;
|
||||
event.opened = false;
|
||||
} catch (NumberFormatException nfe) {
|
||||
launchProblemParsingNotification();
|
||||
}
|
||||
}
|
||||
this.eventList.add(event);
|
||||
}
|
||||
|
@ -410,7 +419,11 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
* Executes the async task of getting events.
|
||||
*/
|
||||
public void executeBackgroundGetEvents() {
|
||||
new GetEventsAsyncTask(adapter).execute();
|
||||
if (adapter != null) {
|
||||
new GetEventsAsyncTask(adapter).execute();
|
||||
} else {
|
||||
new GetEventsAsyncTask(null).execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -448,9 +461,34 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
i.putExtra("load_more", 1);
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
// adapter.notifyDataSetChanged();
|
||||
getApplicationContext().sendBroadcast(i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the user when there is a problem retrieving server's data.
|
||||
*/
|
||||
private void launchProblemParsingNotification() {
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||
int icon = R.drawable.pandorafms_logo;
|
||||
String tickerText = getString(R.string.notification_error_parsing);
|
||||
String title = getString(R.string.pandroid_event_viewer_str);
|
||||
|
||||
long when = System.currentTimeMillis();
|
||||
|
||||
Notification notification = new Notification(icon, tickerText, when);
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
|
||||
Context context = getApplicationContext();
|
||||
Intent notificationIntent = new Intent(this, Options.class);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
|
||||
notificationIntent, 0);
|
||||
|
||||
notification.setLatestEventInfo(context, title, tickerText,
|
||||
contentIntent);
|
||||
mNotificationManager.notify(PROBLEM_NOTIFICATION_ID, notification);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue