mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
2012-06-20 Santiago Munin <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/API.java: New class, it will provide all API calls. * src/pandroid_event_viewer/pandorafms/EventList.java: Loading more events on scroll down. * src/pandroid_event_viewer/pandorafms/Core.java: Added HTTPS connections. * src/pandroid_event_viewer/pandorafms/Options.java: Added self-signed certificates check. * src/pandroid_event_viewer/pandorafms/NaiveTrustManager.java: HTTPS through self-signed websites. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Added ListAdapter to get events asynctask as a parameter. * res/layout/list_view_layout.xml: Little UI changes. * res/layout/item_list_event_layout.xml: Little UI changes. * res/values/strings.xml: Added new entries. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6612 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e197350df4
commit
d9552510b5
@ -1,3 +1,15 @@
|
|||||||
|
2012-06-20 Santiago Munín <burning1@gmail.com>
|
||||||
|
|
||||||
|
* src/pandroid_event_viewer/pandorafms/API.java: New class, it will provide all API calls.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Loading more events on scroll down.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Core.java: Added HTTPS connections.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Options.java: Added self-signed certificates check.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/NaiveTrustManager.java: HTTPS through self-signed websites.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Added ListAdapter to get events asynctask as a parameter.
|
||||||
|
* res/layout/list_view_layout.xml: Little UI changes.
|
||||||
|
* res/layout/item_list_event_layout.xml: Little UI changes.
|
||||||
|
* res/values/strings.xml: Added new entries.
|
||||||
|
|
||||||
2012-06-11 Santiago Munín <burning1@gmail.com>
|
2012-06-11 Santiago Munín <burning1@gmail.com>
|
||||||
|
|
||||||
* src/pandroid_event_viewer/pandorafms/Core.java,
|
* src/pandroid_event_viewer/pandorafms/Core.java,
|
||||||
|
@ -62,12 +62,12 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
<!-- <Button
|
||||||
android:id="@+id/button_load_more_events"
|
android:id="@+id/button_load_more_events"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/load_more_events_button_str"
|
android:text="@string/load_more_events_button_str"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" /> -->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/loading_more_events"
|
android:id="@+id/loading_more_events"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
>
|
>
|
||||||
<LinearLayout
|
<!-- <LinearLayout
|
||||||
android:id="@+id/loading_layout"
|
android:id="@+id/loading_layout"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout> -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/empty_list_layout"
|
android:id="@+id/empty_list_layout"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -117,5 +117,7 @@
|
|||||||
<string name="creating_incident">Creating new incident…</string>
|
<string name="creating_incident">Creating new incident…</string>
|
||||||
<string name="create_incident">Create incident</string>
|
<string name="create_incident">Create incident</string>
|
||||||
<string name="create_incident_group_error">There was an error creating the incident: unrecognized event group. Please, contact administrator.</string>
|
<string name="create_incident_group_error">There was an error creating the incident: unrecognized event group. Please, contact administrator.</string>
|
||||||
|
<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>
|
||||||
</resources>
|
</resources>
|
@ -87,7 +87,7 @@ public class API {
|
|||||||
parameters.add(new BasicNameValuePair("op2", "test"));
|
parameters.add(new BasicNameValuePair("op2", "test"));
|
||||||
String return_api = Core.httpGet(context, parameters);
|
String return_api = Core.httpGet(context, parameters);
|
||||||
// TODO wait version
|
// TODO wait version
|
||||||
if (return_api.equals("OK\n")) {
|
if (return_api.contains("OK")) {
|
||||||
return "4.0.2";
|
return "4.0.2";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
@ -96,4 +96,21 @@ public class API {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get events from pandora console.
|
||||||
|
*
|
||||||
|
* @param newEvents
|
||||||
|
*/
|
||||||
|
public static String getEvents(Context context, String other) {
|
||||||
|
// Get total count.
|
||||||
|
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||||
|
parameters.add(new BasicNameValuePair("op", "get"));
|
||||||
|
parameters.add(new BasicNameValuePair("op2", "events"));
|
||||||
|
parameters.add(new BasicNameValuePair("other_mode",
|
||||||
|
"url_encode_separator_|"));
|
||||||
|
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||||
|
parameters.add(new BasicNameValuePair("other", other));
|
||||||
|
return Core.httpGet(context, parameters);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,14 +20,27 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import javax.net.ssl.KeyManager;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
@ -59,6 +72,8 @@ import android.widget.TextView;
|
|||||||
public class Core {
|
public class Core {
|
||||||
private static String TAG = "Core";
|
private static String TAG = "Core";
|
||||||
private static Map<String, Bitmap> imgCache = new HashMap<String, Bitmap>();
|
private static Map<String, Bitmap> imgCache = new HashMap<String, Bitmap>();
|
||||||
|
// Don't use this variable, just call getSocketFactory
|
||||||
|
private static SSLSocketFactory sslSocketFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from the input stream and returns a string.
|
* Reads from the input stream and returns a string.
|
||||||
@ -266,7 +281,8 @@ public class Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts params to string.
|
* Converts params to string.
|
||||||
|
*
|
||||||
* @param params
|
* @param params
|
||||||
* @return All params in a single string.
|
* @return All params in a single string.
|
||||||
*/
|
*/
|
||||||
@ -305,6 +321,10 @@ public class Core {
|
|||||||
parameters.add(new BasicNameValuePair("user", user));
|
parameters.add(new BasicNameValuePair("user", user));
|
||||||
parameters.add(new BasicNameValuePair("pass", password));
|
parameters.add(new BasicNameValuePair("pass", password));
|
||||||
parameters.addAll(additionalParameters);
|
parameters.addAll(additionalParameters);
|
||||||
|
if (url.contains("https")) {
|
||||||
|
// Secure connection
|
||||||
|
return Core.httpsGet(url, parameters);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
UrlEncodedFormEntity entity;
|
UrlEncodedFormEntity entity;
|
||||||
@ -343,16 +363,30 @@ public class Core {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
myFileUrl = new URL(fileUrl);
|
myFileUrl = new URL(fileUrl);
|
||||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
if (fileUrl.contains("https")) {
|
||||||
.openConnection();
|
HttpsURLConnection con = (HttpsURLConnection) new URL(fileUrl)
|
||||||
conn.setDoInput(true);
|
.openConnection();
|
||||||
conn.connect();
|
con.setHostnameVerifier(new HostnameVerifier() {
|
||||||
InputStream is = conn.getInputStream();
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
Bitmap img = BitmapFactory.decodeStream(is);
|
return true;
|
||||||
imgCache.put(fileUrl, img);
|
}
|
||||||
return img;
|
});
|
||||||
|
con.setSSLSocketFactory(getSocketFactory());
|
||||||
|
Bitmap img = BitmapFactory.decodeStream(con.getInputStream());
|
||||||
|
imgCache.put(fileUrl, img);
|
||||||
|
return img;
|
||||||
|
} else {
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||||
|
.openConnection();
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.connect();
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
Bitmap img = BitmapFactory.decodeStream(is);
|
||||||
|
imgCache.put(fileUrl, img);
|
||||||
|
return img;
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Downloading image: error");
|
Log.e(TAG, "Downloading image "+fileUrl+": error");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -398,4 +432,92 @@ public class Core {
|
|||||||
image.setBounds(0, 0, size, size);
|
image.setBounds(0, 0, size, size);
|
||||||
view.setCompoundDrawables(image, null, null, null);
|
view.setCompoundDrawables(image, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds out if the given url has a CA signed certificate.
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isValidCertificate(URL url) {
|
||||||
|
|
||||||
|
HttpsURLConnection con;
|
||||||
|
try {
|
||||||
|
con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.connect();
|
||||||
|
con.disconnect();
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String httpsGet(String url,
|
||||||
|
List<NameValuePair> additionalParameters) {
|
||||||
|
String result = "";
|
||||||
|
try {
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) new URL(url)
|
||||||
|
.openConnection();
|
||||||
|
con.setHostnameVerifier(new HostnameVerifier() {
|
||||||
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
con.setSSLSocketFactory(getSocketFactory());
|
||||||
|
con.setDoOutput(true);
|
||||||
|
String postData = "";
|
||||||
|
boolean first = true;
|
||||||
|
for (NameValuePair nameValuePair : additionalParameters) {
|
||||||
|
postData = first ? postData : postData + "&";
|
||||||
|
first = false;
|
||||||
|
postData += URLEncoder.encode(nameValuePair.getName()) + "="
|
||||||
|
+ URLEncoder.encode(nameValuePair.getValue());
|
||||||
|
}
|
||||||
|
if (postData.length() > 0) {
|
||||||
|
OutputStreamWriter wr = new OutputStreamWriter(
|
||||||
|
con.getOutputStream());
|
||||||
|
wr.write(postData);
|
||||||
|
wr.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
InputStream inputStream;
|
||||||
|
inputStream = con.getInputStream();
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(
|
||||||
|
new InputStreamReader(inputStream));
|
||||||
|
String temp;
|
||||||
|
while ((temp = bufferedReader.readLine()) != null) {
|
||||||
|
Log.d("CONTENT", temp);
|
||||||
|
result += temp+"\n";
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a SSL Factory instance that accepts all server certificates.
|
||||||
|
*
|
||||||
|
* @return An SSL-specific socket factory.
|
||||||
|
**/
|
||||||
|
private static final SSLSocketFactory getSocketFactory() {
|
||||||
|
if (sslSocketFactory == null) {
|
||||||
|
try {
|
||||||
|
TrustManager[] tm = new TrustManager[] { new NaiveTrustManager() };
|
||||||
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
|
context.init(new KeyManager[0], tm, new SecureRandom());
|
||||||
|
|
||||||
|
sslSocketFactory = (SSLSocketFactory) context
|
||||||
|
.getSocketFactory();
|
||||||
|
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
Log.e("No SSL algorithm support: " + e.getMessage(),
|
||||||
|
e.toString());
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
Log.e("Exception when setting up the Naive key management.",
|
||||||
|
e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sslSocketFactory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import android.graphics.Color;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@ -38,11 +39,12 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AbsListView;
|
||||||
|
import android.widget.AbsListView.OnScrollListener;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +57,7 @@ public class EventList extends ListActivity {
|
|||||||
private ListView lv;
|
private ListView lv;
|
||||||
private MyAdapter la;
|
private MyAdapter la;
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
|
private boolean moreEvents;
|
||||||
|
|
||||||
private BroadcastReceiver onBroadcast;
|
private BroadcastReceiver onBroadcast;
|
||||||
|
|
||||||
@ -68,13 +71,40 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.list_view_layout);
|
setContentView(R.layout.list_view_layout);
|
||||||
|
|
||||||
this.toggleLoadingLayout();
|
//this.toggleLoadingLayout();
|
||||||
|
moreEvents = true;
|
||||||
lv = (ListView) findViewById(android.R.id.list);
|
lv = (ListView) findViewById(android.R.id.list);
|
||||||
|
|
||||||
la = new MyAdapter(getBaseContext(), object);
|
la = new MyAdapter(getBaseContext(), object);
|
||||||
|
this.object.adapter = la;
|
||||||
lv.setAdapter(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() {
|
onBroadcast = new BroadcastReceiver() {
|
||||||
|
|
||||||
@ -82,37 +112,26 @@ public class EventList extends ListActivity {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
int load_more = intent.getIntExtra("load_more", 0);
|
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) {
|
if (load_more == 1) {
|
||||||
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
/* LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
layout.setVisibility(LinearLayout.GONE);*/
|
||||||
la.showLoadingEvents = false;
|
la.showLoadingEvents = false;
|
||||||
} else {
|
} else {
|
||||||
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
/*LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
layout.setVisibility(LinearLayout.GONE);*/
|
||||||
|
|
||||||
if (((int) object.count_events) == 0) {
|
if (((int) object.count_events) == 0) {
|
||||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
LinearLayout layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
layout.setVisibility(LinearLayout.VISIBLE);
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
la.notifyDataSetChanged();
|
la.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||||
|
|
||||||
this.toggleLoadingLayout();
|
//this.toggleLoadingLayout();
|
||||||
|
|
||||||
if (this.object.show_popup_info) {
|
if (this.object.show_popup_info) {
|
||||||
this.object.show_popup_info = false;
|
this.object.show_popup_info = false;
|
||||||
@ -126,7 +145,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
if (this.object.showOptionsFirstTime) {
|
if (this.object.showOptionsFirstTime) {
|
||||||
this.object.loadInProgress = true;
|
this.object.loadInProgress = true;
|
||||||
toggleLoadingLayout();
|
// toggleLoadingLayout();
|
||||||
|
|
||||||
this.object.showOptionsFirstTime = false;
|
this.object.showOptionsFirstTime = false;
|
||||||
this.object.executeBackgroundGetEvents();
|
this.object.executeBackgroundGetEvents();
|
||||||
@ -138,7 +157,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||||
|
|
||||||
this.toggleLoadingLayout();
|
//this.toggleLoadingLayout();
|
||||||
|
|
||||||
if (!this.object.loadInProgress) {
|
if (!this.object.loadInProgress) {
|
||||||
if (((int) object.count_events) == 0) {
|
if (((int) object.count_events) == 0) {
|
||||||
@ -170,7 +189,7 @@ public class EventList extends ListActivity {
|
|||||||
this.object.loadInProgress = true;
|
this.object.loadInProgress = true;
|
||||||
this.object.getNewListEvents = true;
|
this.object.getNewListEvents = true;
|
||||||
this.object.eventList = new ArrayList<EventListItem>();
|
this.object.eventList = new ArrayList<EventListItem>();
|
||||||
this.toggleLoadingLayout();
|
// this.toggleLoadingLayout();
|
||||||
this.object.executeBackgroundGetEvents();
|
this.object.executeBackgroundGetEvents();
|
||||||
break;
|
break;
|
||||||
case R.id.about_button_menu_options:
|
case R.id.about_button_menu_options:
|
||||||
@ -185,7 +204,7 @@ public class EventList extends ListActivity {
|
|||||||
/**
|
/**
|
||||||
* Shows loading information.
|
* Shows loading information.
|
||||||
*/
|
*/
|
||||||
private void toggleLoadingLayout() {
|
/*private void toggleLoadingLayout() {
|
||||||
LinearLayout layout;
|
LinearLayout layout;
|
||||||
|
|
||||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
@ -198,7 +217,7 @@ public class EventList extends ListActivity {
|
|||||||
} else {
|
} else {
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private String getImageGroupUrl(String group_icon) {
|
private String getImageGroupUrl(String group_icon) {
|
||||||
SharedPreferences preferences = getApplicationContext()
|
SharedPreferences preferences = getApplicationContext()
|
||||||
@ -244,7 +263,12 @@ public class EventList extends ListActivity {
|
|||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
|
|
||||||
EventListItem item = this.object.eventList.get(position);
|
EventListItem item;
|
||||||
|
try {
|
||||||
|
item = this.object.eventList.get(position);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
item.opened = !item.opened;
|
item.opened = !item.opened;
|
||||||
this.object.eventList.set(position, item);
|
this.object.eventList.set(position, item);
|
||||||
@ -258,8 +282,7 @@ public class EventList extends ListActivity {
|
|||||||
*/
|
*/
|
||||||
private void loadMoreEvents() {
|
private void loadMoreEvents() {
|
||||||
la.showLoadingEvents = true;
|
la.showLoadingEvents = true;
|
||||||
la.notifyDataSetChanged();
|
object.offset += object.pagination;
|
||||||
|
|
||||||
object.executeBackgroundGetEvents();
|
object.executeBackgroundGetEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,49 +327,83 @@ public class EventList extends ListActivity {
|
|||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.item_list_event_layout, null);
|
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 the end of the list.
|
||||||
if (this.object.eventList.size() == position) {
|
if (this.object.eventList.size() == position) {
|
||||||
// Show button to get more events
|
if (object.newEvents) {
|
||||||
if ((!object.loadInProgress) && (object.count_events != 0)) {
|
Log.d("loading", "true");
|
||||||
if (showLoadingEvents) {
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
LinearLayout layout = (LinearLayout) view
|
if (convertView != null) {
|
||||||
.findViewById(R.id.loading_more_events);
|
convertView.setClickable(false);
|
||||||
layout.setVisibility(LinearLayout.VISIBLE);
|
}
|
||||||
|
} else {
|
||||||
RelativeLayout layout2 = (RelativeLayout) view
|
Log.d("loading", "false");
|
||||||
.findViewById(R.id.content_event_item);
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
layout2.setVisibility(RelativeLayout.GONE);
|
if (convertView != null) {
|
||||||
|
convertView.setClickable(false);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 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 {
|
} else {
|
||||||
final EventListItem item = this.object.eventList.get(position);
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
switch (item.criticity) {
|
switch (item.criticity) {
|
||||||
|
|
||||||
@ -543,7 +600,7 @@ public class EventList extends ListActivity {
|
|||||||
itemLinearLayout.addView(viewEventExtended);
|
itemLinearLayout.addView(viewEventExtended);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.notifyDataSetChanged();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +675,12 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
EventListItem item = this.object.eventList.get(mPosition);
|
EventListItem item;
|
||||||
|
try {
|
||||||
|
item = this.object.eventList.get(mPosition);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
item.opened = !item.opened;
|
item.opened = !item.opened;
|
||||||
this.object.eventList.set(mPosition, item);
|
this.object.eventList.set(mPosition, item);
|
||||||
la.notifyDataSetChanged();
|
la.notifyDataSetChanged();
|
||||||
|
@ -74,7 +74,7 @@ public class IncidentList extends ListActivity {
|
|||||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
|
|
||||||
layout = (LinearLayout) findViewById(R.id.loading_layout);
|
// layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
|
|
||||||
if (loadInProgress) {
|
if (loadInProgress) {
|
||||||
layout.setVisibility(LinearLayout.VISIBLE);
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Trust Manager is "naive" because it trusts everyone.
|
||||||
|
**/
|
||||||
|
public class NaiveTrustManager implements X509TrustManager
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Doesn't throw an exception, so this is how it approves a certificate.
|
||||||
|
* @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], String)
|
||||||
|
**/
|
||||||
|
public void checkClientTrusted ( X509Certificate[] cert, String authType )
|
||||||
|
throws CertificateException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Doesn't throw an exception, so this is how it approves a certificate.
|
||||||
|
* @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String)
|
||||||
|
**/
|
||||||
|
public void checkServerTrusted ( X509Certificate[] cert, String authType )
|
||||||
|
throws CertificateException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
|
||||||
|
**/
|
||||||
|
public X509Certificate[] getAcceptedIssuers ()
|
||||||
|
{
|
||||||
|
return null; // I've seen someone return new X509Certificate[ 0 ];
|
||||||
|
}
|
||||||
|
}
|
@ -16,8 +16,13 @@ GNU General Public License for more details.
|
|||||||
*/
|
*/
|
||||||
package pandroid_event_viewer.pandorafms;
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.media.Ringtone;
|
import android.media.Ringtone;
|
||||||
@ -129,7 +134,7 @@ public class Options extends Activity {
|
|||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
|
||||||
getString(R.string.select_sound));
|
getString(R.string.select_sound));
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT,
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT,
|
||||||
false);
|
true);
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT,
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT,
|
||||||
false);
|
false);
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
|
||||||
@ -160,6 +165,48 @@ public class Options extends Activity {
|
|||||||
* Saves all options
|
* Saves all options
|
||||||
*/
|
*/
|
||||||
private void save_options() {
|
private void save_options() {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
writeChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeChanges() {
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
this.getString(R.string.const_string_preferences),
|
this.getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
@ -171,7 +218,6 @@ public class Options extends Activity {
|
|||||||
if (url.charAt(url.length() - 1) == '/') {
|
if (url.charAt(url.length() - 1) == '/') {
|
||||||
url = url.substring(0, url.length() - 1);
|
url = url.substring(0, url.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
editorPreferences.putString("url", url);
|
editorPreferences.putString("url", url);
|
||||||
// MainActivity uses this to know if it has to check tags and groups
|
// MainActivity uses this to know if it has to check tags and groups
|
||||||
// again
|
// again
|
||||||
|
@ -23,9 +23,6 @@ import java.util.Date;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.http.NameValuePair;
|
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -34,6 +31,7 @@ import android.content.res.Configuration;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -44,11 +42,13 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
|
|
||||||
// Data aplication
|
// Data aplication
|
||||||
public ArrayList<EventListItem> eventList;
|
public ArrayList<EventListItem> eventList;
|
||||||
|
public BaseAdapter adapter;
|
||||||
public long count_events;
|
public long count_events;
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
public boolean loadInProgress;
|
public boolean loadInProgress;
|
||||||
public boolean getNewListEvents;
|
public boolean getNewListEvents;
|
||||||
|
public boolean newEvents;
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
public boolean show_popup_info;
|
public boolean show_popup_info;
|
||||||
@ -283,20 +283,11 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
/**
|
/**
|
||||||
* Get events from pandora console.
|
* Get events from pandora console.
|
||||||
*
|
*
|
||||||
* @param newEvents
|
|
||||||
*/
|
*/
|
||||||
private void getEvents(boolean newEvents) {
|
private void getEvents() {
|
||||||
// Get total count.
|
// Get total count.
|
||||||
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
String return_api = API.getEvents(getApplicationContext(),
|
||||||
parameters.add(new BasicNameValuePair("op", "get"));
|
serializeParams2Api(true));
|
||||||
parameters.add(new BasicNameValuePair("op2", "events"));
|
|
||||||
parameters.add(new BasicNameValuePair("other_mode",
|
|
||||||
"url_encode_separator_|"));
|
|
||||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
|
||||||
parameters.add(new BasicNameValuePair("other",
|
|
||||||
serializeParams2Api(true)));
|
|
||||||
String return_api = Core.httpGet(getApplicationContext(), parameters);
|
|
||||||
Log.i(TAG + " getEvents", return_api);
|
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
try {
|
try {
|
||||||
this.count_events = new Long(return_api).longValue();
|
this.count_events = new Long(return_api).longValue();
|
||||||
@ -310,16 +301,9 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the list of events.
|
// Get the list of events.
|
||||||
parameters = new ArrayList<NameValuePair>();
|
return_api = API.getEvents(getApplicationContext(),
|
||||||
parameters.add(new BasicNameValuePair("op", "get"));
|
serializeParams2Api(false));
|
||||||
parameters.add(new BasicNameValuePair("op2", "events"));
|
Log.d(TAG, "List of events: " + return_api);
|
||||||
parameters.add(new BasicNameValuePair("other_mode",
|
|
||||||
"url_encode_separator_|"));
|
|
||||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
|
||||||
parameters.add(new BasicNameValuePair("other",
|
|
||||||
serializeParams2Api(false)));
|
|
||||||
return_api = Core.httpGet(getApplicationContext(), parameters);
|
|
||||||
|
|
||||||
Pattern pattern = Pattern
|
Pattern pattern = Pattern
|
||||||
.compile("Unable to process XML data file '(.*)'");
|
.compile("Unable to process XML data file '(.*)'");
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
@ -346,8 +330,10 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
Log.i(TAG + " getEvents - return_api", return_api);
|
Log.i(TAG + " getEvents - return_api", return_api);
|
||||||
|
|
||||||
String[] lines = return_api.split("\n");
|
String[] lines = return_api.split("\n");
|
||||||
|
newEvents = true;
|
||||||
if (return_api.length() == 0) {
|
if (return_api.length() == 0) {
|
||||||
|
Log.d("WORKS?", "NEWEVENTS = FALSE");
|
||||||
|
newEvents = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +410,7 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
* Executes the async task of getting events.
|
* Executes the async task of getting events.
|
||||||
*/
|
*/
|
||||||
public void executeBackgroundGetEvents() {
|
public void executeBackgroundGetEvents() {
|
||||||
new GetEventsAsyncTask().execute();
|
new GetEventsAsyncTask(adapter).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -435,14 +421,16 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
*/
|
*/
|
||||||
public class GetEventsAsyncTask extends AsyncTask<Void, Void, Void> {
|
public class GetEventsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private BaseAdapter adapter;
|
||||||
|
|
||||||
|
public GetEventsAsyncTask(BaseAdapter adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
Log.i(TAG + " GetEventsAsyncTask", "doInBackground");
|
Log.i(TAG + " GetEventsAsyncTask", "doInBackground");
|
||||||
if (getNewListEvents) {
|
getEvents();
|
||||||
getEvents(true);
|
|
||||||
} else {
|
|
||||||
getEvents(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -460,7 +448,9 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
i.putExtra("load_more", 1);
|
i.putExtra("load_more", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
getApplicationContext().sendBroadcast(i);
|
getApplicationContext().sendBroadcast(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user