mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
2012-06-01 Santiago Munin <burnin1@gmail.com>
* src/pandroid_event_viewer/pandorafms/Core.java: Added image setting methods. * src/pandroid_event_viewer/pandorafms/EventList.java: Removed image setting methods. * res/layout/item_list_event_layout.xml: Removed not needed ImageViews. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6401 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ff7d71c5b3
commit
75ebce15a2
@ -1,3 +1,8 @@
|
|||||||
|
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Core.java: Added image setting methods.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Removed image setting methods.
|
||||||
|
* res/layout/item_list_event_layout.xml: Removed not needed ImageViews.
|
||||||
|
|
||||||
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
||||||
* src/pandroid_event_viewer/pandorafms/EventList.java: Now Agent's link points to mobile console.
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Now Agent's link points to mobile console.
|
||||||
|
|
||||||
|
@ -14,104 +14,80 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
-->
|
-->
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:id="@+id/item_linear_layout"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:id="@+id/item_linear_layout"
|
android:paddingBottom="5dp"
|
||||||
>
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/content_event_item"
|
android:id="@+id/content_event_item"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1" >
|
||||||
>
|
|
||||||
<ImageView
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:id="@+id/img_severity_colapse_item"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:padding="5px"
|
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/event_name"
|
android:id="@+id/event_name"
|
||||||
|
|
||||||
android:layout_toRightOf="@id/img_severity_colapse_item"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
android:textColor="#000"
|
android:textColor="#000"
|
||||||
android:textColorHighlight="#000"
|
android:textColorHighlight="#000" />
|
||||||
/>
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_below="@id/event_name"
|
android:layout_below="@id/event_name"
|
||||||
>
|
android:orientation="horizontal" >
|
||||||
<ImageView
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:id="@+id/img_group_colapse_item"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:padding="5px"
|
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/agent_name"
|
android:id="@+id/agent_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:layout_weight="1"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
android:textColor="#000"
|
android:textColor="#000"
|
||||||
android:textColorHighlight="#000"
|
android:textColorHighlight="#000"
|
||||||
android:layout_weight="1"
|
android:textStyle="bold" />
|
||||||
/>
|
|
||||||
<ImageView
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:id="@+id/img_validate_colapse_item"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:padding="5px"
|
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/timestamp"
|
android:id="@+id/timestamp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
android:textColor="#000"
|
android:textColor="#000"
|
||||||
android:textColorHighlight="#000"
|
android:textColorHighlight="#000"
|
||||||
android:layout_weight="0"
|
android:textSize="10sp" />
|
||||||
android:textSize="10sp"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_load_more_events"
|
android:id="@+id/button_load_more_events"
|
||||||
android:text="@string/load_more_events_button_str"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:text="@string/load_more_events_button_str"
|
||||||
/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/loading_more_events"
|
android:id="@+id/loading_more_events"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:visibility="gone" >
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
>
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
style="?android:attr/progressBarStyleSmall"
|
style="?android:attr/progressBarStyleSmall"
|
||||||
android:paddingRight="10dip"
|
android:layout_width="wrap_content"
|
||||||
/>
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="10dip" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="#ffffff"
|
|
||||||
android:text="@string/loading_label_str"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:text="@string/loading_label_str"
|
||||||
/>
|
android:textColor="#ffffff"
|
||||||
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,9 +20,13 @@ 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.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
@ -38,7 +42,12 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides basic functions to manage services and some received
|
* This class provides basic functions to manage services and some received
|
||||||
@ -49,6 +58,7 @@ import android.util.Log;
|
|||||||
*/
|
*/
|
||||||
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>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from the input stream and returns a string.
|
* Reads from the input stream and returns a string.
|
||||||
@ -273,8 +283,11 @@ public class Core {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs an http get petition.
|
* Performs an http get petition.
|
||||||
* @param context Application context.
|
*
|
||||||
* @param additionalParameters Petition additional parameters
|
* @param context
|
||||||
|
* Application context.
|
||||||
|
* @param additionalParameters
|
||||||
|
* Petition additional parameters
|
||||||
* @return Petition result.
|
* @return Petition result.
|
||||||
*/
|
*/
|
||||||
public static String httpGet(Context context,
|
public static String httpGet(Context context,
|
||||||
@ -313,4 +326,76 @@ public class Core {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads an image
|
||||||
|
*
|
||||||
|
* @param fileUrl
|
||||||
|
* Image's url.
|
||||||
|
* @return A bitmap of that image.
|
||||||
|
*/
|
||||||
|
public static Bitmap downloadImage(String fileUrl) {
|
||||||
|
if (imgCache.containsKey(fileUrl)) {
|
||||||
|
Log.i(TAG, "Fetched from cache: " + fileUrl);
|
||||||
|
return imgCache.get(fileUrl);
|
||||||
|
}
|
||||||
|
Log.i(TAG, "Downloading image: " + fileUrl);
|
||||||
|
URL myFileUrl = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
myFileUrl = new URL(fileUrl);
|
||||||
|
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) {
|
||||||
|
Log.e(TAG, "Downloading image: error");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts the image to the left of theTextView.
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
* TextView.
|
||||||
|
* @param image
|
||||||
|
* Bitmap.
|
||||||
|
*/
|
||||||
|
public static void setTextViewLeftImage(TextView view, Bitmap image) {
|
||||||
|
Drawable d = new BitmapDrawable(image);
|
||||||
|
setTextViewLeftImage(view, d, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts the image to the left of theTextView.
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
* TextView.
|
||||||
|
* @param url
|
||||||
|
* Image's url.
|
||||||
|
*/
|
||||||
|
public static void setTextViewLeftImage(TextView view, String url) {
|
||||||
|
Drawable d = new BitmapDrawable(Core.downloadImage(url));
|
||||||
|
setTextViewLeftImage(view, d, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts the image to the left of theTextView.
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
* TextView.
|
||||||
|
* @param image
|
||||||
|
* Image.
|
||||||
|
* @param size Image size
|
||||||
|
*/
|
||||||
|
public static void setTextViewLeftImage(TextView view, Drawable image,
|
||||||
|
int size) {
|
||||||
|
image.setBounds(0, 0, size, size);
|
||||||
|
view.setCompoundDrawables(image, null, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,7 @@ GNU General Public License for more details.
|
|||||||
*/
|
*/
|
||||||
package pandroid_event_viewer.pandorafms;
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
@ -32,14 +27,10 @@ import android.content.IntentFilter;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
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;
|
||||||
@ -49,7 +40,6 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
@ -62,24 +52,16 @@ import android.widget.TextView;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EventList extends ListActivity {
|
public class EventList extends ListActivity {
|
||||||
private static String TAG = "EventList";
|
|
||||||
private ListView lv;
|
private ListView lv;
|
||||||
private MyAdapter la;
|
private MyAdapter la;
|
||||||
|
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
|
|
||||||
// private HashMap<Integer, Boolean> openedItem;
|
|
||||||
private HashMap<String, Bitmap> imgGroups;
|
|
||||||
private HashMap<String, Bitmap> imgType;
|
|
||||||
private BroadcastReceiver onBroadcast;
|
private BroadcastReceiver onBroadcast;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
this.imgGroups = new HashMap<String, Bitmap>();
|
|
||||||
this.imgType = new HashMap<String, Bitmap>();
|
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
this.object = (PandroidEventviewerActivity) i
|
this.object = (PandroidEventviewerActivity) i
|
||||||
.getSerializableExtra("object");
|
.getSerializableExtra("object");
|
||||||
@ -218,43 +200,33 @@ public class EventList extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Downloads an image
|
|
||||||
*
|
|
||||||
* @param fileUrl
|
|
||||||
* @return A bitmap of that image
|
|
||||||
*/
|
|
||||||
private Bitmap downloadImage(String fileUrl) {
|
|
||||||
Log.i(TAG, "Downloading image: " + fileUrl);
|
|
||||||
URL myFileUrl = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
myFileUrl = new URL(fileUrl);
|
|
||||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
|
||||||
.openConnection();
|
|
||||||
conn.setDoInput(true);
|
|
||||||
conn.connect();
|
|
||||||
InputStream is = conn.getInputStream();
|
|
||||||
return BitmapFactory.decodeStream(is);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Downloading image: error");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the group image on event list.
|
* Sets the group image on event list.
|
||||||
* @param view Parent view.
|
*
|
||||||
* @param group_icon Group icon.
|
* @param view
|
||||||
* @param id Group's ImageView id.
|
* Parent view.
|
||||||
|
* @param group_icon
|
||||||
|
* Group icon.
|
||||||
|
* @param id
|
||||||
|
* Group's ImageView id.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* private void setImageGroup(View view, String group_icon, int id) {
|
||||||
|
* ImageView imgview = (ImageView) view.findViewById(id); Bitmap img;
|
||||||
|
*
|
||||||
|
* SharedPreferences preferences = getApplicationContext()
|
||||||
|
* .getSharedPreferences( getApplicationContext().getString(
|
||||||
|
* R.string.const_string_preferences), Activity.MODE_PRIVATE);
|
||||||
|
*
|
||||||
|
* String url = preferences.getString("url", "");
|
||||||
|
*
|
||||||
|
* img = Core.downloadImage(url + "/images/groups_small/" + group_icon +
|
||||||
|
* ".png");
|
||||||
|
*
|
||||||
|
* if (img != null) { imgview.setImageBitmap(img); } }
|
||||||
*/
|
*/
|
||||||
private void setImageGroup(View view, String group_icon, int id) {
|
|
||||||
ImageView imgview = (ImageView) view.findViewById(id);
|
|
||||||
Bitmap img;
|
|
||||||
|
|
||||||
if (this.imgGroups.containsKey(group_icon)) {
|
private String getImageGroupUrl(String group_icon) {
|
||||||
img = this.imgGroups.get(group_icon);
|
|
||||||
} else {
|
|
||||||
SharedPreferences preferences = getApplicationContext()
|
SharedPreferences preferences = getApplicationContext()
|
||||||
.getSharedPreferences(
|
.getSharedPreferences(
|
||||||
getApplicationContext().getString(
|
getApplicationContext().getString(
|
||||||
@ -262,85 +234,23 @@ public class EventList extends ListActivity {
|
|||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
|
|
||||||
String url = preferences.getString("url", "");
|
String url = preferences.getString("url", "");
|
||||||
|
return url + "/images/groups_small/" + group_icon + ".png";
|
||||||
img = this.downloadImage(url + "/images/groups_small/" + group_icon
|
|
||||||
+ ".png");
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
this.imgGroups.put(group_icon, img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
imgview.setImageBitmap(img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets type's image on event list.
|
|
||||||
* @param view
|
|
||||||
* @param url
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
private void setImageType(View view, String url, int id) {
|
|
||||||
ImageView imgview = (ImageView) view.findViewById(id);
|
|
||||||
Bitmap img = null;
|
|
||||||
|
|
||||||
if (this.imgType.containsKey(url)) {
|
|
||||||
img = this.imgType.get(url);
|
|
||||||
} else {
|
|
||||||
img = this.downloadImage(url);
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
this.imgType.put(url, img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
imgview.setImageBitmap(img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets an image to the left of a TextView.
|
|
||||||
* @param view Parent view.
|
|
||||||
* @param url Image uri.
|
|
||||||
* @param id TextView's id;
|
|
||||||
*/
|
|
||||||
private void setTextViewImage(View view, String url, int id) {
|
|
||||||
TextView tview = (TextView) view.findViewById(id);
|
|
||||||
Bitmap img = null;
|
|
||||||
|
|
||||||
if (this.imgType.containsKey(url)) {
|
|
||||||
img = this.imgType.get(url);
|
|
||||||
} else {
|
|
||||||
img = this.downloadImage(url);
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
this.imgType.put(url, img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
Drawable d = new BitmapDrawable(img);
|
|
||||||
d.setBounds(0, 0, 16, 16);
|
|
||||||
tview.setCompoundDrawables(d, null, null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an image to the left of group's TextView.
|
* Sets an image to the left of group's TextView.
|
||||||
* @param view Parent view.
|
*
|
||||||
* @param group_icon Icon name.
|
* @param view
|
||||||
* @param id Group's TextView id;
|
* Parent view.
|
||||||
|
* @param group_icon
|
||||||
|
* Icon name.
|
||||||
|
* @param id
|
||||||
|
* Group's TextView id;
|
||||||
*/
|
*/
|
||||||
private void setTextViewGroupImage(View view, String group_icon, int id) {
|
private void setTextViewGroupImage(View view, String group_icon, int id) {
|
||||||
TextView tview = (TextView) view.findViewById(id);
|
TextView tview = (TextView) view.findViewById(id);
|
||||||
Bitmap img = null;
|
Bitmap img = null;
|
||||||
|
|
||||||
if (this.imgGroups.containsKey(group_icon)) {
|
|
||||||
img = this.imgGroups.get(group_icon);
|
|
||||||
} else {
|
|
||||||
SharedPreferences preferences = getApplicationContext()
|
SharedPreferences preferences = getApplicationContext()
|
||||||
.getSharedPreferences(
|
.getSharedPreferences(
|
||||||
getApplicationContext().getString(
|
getApplicationContext().getString(
|
||||||
@ -348,18 +258,11 @@ public class EventList extends ListActivity {
|
|||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
|
|
||||||
String url = preferences.getString("url", "");
|
String url = preferences.getString("url", "");
|
||||||
|
img = Core.downloadImage(url + "/images/groups_small/" + group_icon
|
||||||
img = this.downloadImage(url + "/images/groups_small/" + group_icon
|
|
||||||
+ ".png");
|
+ ".png");
|
||||||
|
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
this.imgGroups.put(group_icon, img);
|
Core.setTextViewLeftImage(tview, img);
|
||||||
}
|
|
||||||
}
|
|
||||||
if (img != null) {
|
|
||||||
Drawable d = new BitmapDrawable(img);
|
|
||||||
d.setBounds(0, 0, 16, 16);
|
|
||||||
tview.setCompoundDrawables(d, null, null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,18 +413,21 @@ public class EventList extends ListActivity {
|
|||||||
timestamp.setText(item.timestamp);
|
timestamp.setText(item.timestamp);
|
||||||
|
|
||||||
if (item.criticity_image.length() != 0)
|
if (item.criticity_image.length() != 0)
|
||||||
setImageType(view, item.criticity_image,
|
Core.setTextViewLeftImage(
|
||||||
R.id.img_severity_colapse_item);
|
(TextView) view.findViewById(R.id.event_name),
|
||||||
if (item.group_icon.length() != 0)
|
Core.downloadImage(item.criticity_image));
|
||||||
setImageGroup(view, item.group_icon,
|
|
||||||
R.id.img_group_colapse_item);
|
if (item.group_icon.length() != 0)
|
||||||
|
Core.setTextViewLeftImage(
|
||||||
|
(TextView) view.findViewById(R.id.agent_name),
|
||||||
|
getImageGroupUrl(item.group_icon));
|
||||||
|
|
||||||
ImageView imgValidate = (ImageView) view
|
|
||||||
.findViewById(R.id.img_validate_colapse_item);
|
|
||||||
if (item.status == 1) {
|
if (item.status == 1) {
|
||||||
imgValidate.setImageResource(R.drawable.tick);
|
Core.setTextViewLeftImage(timestamp, getResources()
|
||||||
|
.getDrawable(R.drawable.tick), 24);
|
||||||
} else {
|
} else {
|
||||||
imgValidate.setImageResource(R.drawable.tick_off);
|
Core.setTextViewLeftImage(timestamp, getResources()
|
||||||
|
.getDrawable(R.drawable.tick_off), 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show extended info
|
// Show extended info
|
||||||
@ -581,20 +487,21 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
.findViewById(R.id.agent_text);
|
.findViewById(R.id.agent_text);
|
||||||
text.setText(Html
|
text.setText(Html.fromHtml("<a href='"
|
||||||
.fromHtml("<a href='"
|
|
||||||
+ this.object.url
|
+ this.object.url
|
||||||
+ "/mobile/index.php?page=agent&id="
|
+ "/mobile/index.php?page=agent&id="
|
||||||
+ item.id_agent
|
+ item.id_agent + " &autologin=1&user="
|
||||||
+" &autologin=1&user="+this.object.user+"&password="+ this.object.password
|
+ this.object.user + "&password="
|
||||||
+"'>"
|
+ this.object.password + "'>" + item.agent_name
|
||||||
+ item.agent_name + "</a>"));
|
+ "</a>"));
|
||||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.description_image.length() != 0)
|
if (item.description_image.length() != 0)
|
||||||
setTextViewImage(viewEventExtended,
|
Core.setTextViewLeftImage((TextView) viewEventExtended
|
||||||
item.description_image, R.id.type_text);
|
.findViewById(R.id.type_text),
|
||||||
|
item.description_image);
|
||||||
|
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
.findViewById(R.id.type_text);
|
.findViewById(R.id.type_text);
|
||||||
text.setText(eventType2Text(item.event_type));
|
text.setText(eventType2Text(item.event_type));
|
||||||
@ -605,8 +512,10 @@ public class EventList extends ListActivity {
|
|||||||
text.setText(item.criticity_name);
|
text.setText(item.criticity_name);
|
||||||
|
|
||||||
if (item.criticity_image.length() != 0)
|
if (item.criticity_image.length() != 0)
|
||||||
setTextViewImage(viewEventExtended,
|
Core.setTextViewLeftImage(
|
||||||
item.criticity_image, R.id.severity_text);
|
(TextView) viewEventExtended
|
||||||
|
.findViewById(R.id.severity_text),
|
||||||
|
item.criticity_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the open and close the extended info event row
|
// Set the open and close the extended info event row
|
||||||
|
Loading…
x
Reference in New Issue
Block a user