1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
|
public class ItemEcran extends Activity{
Document doc;
String urlMoreDetails;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ecran_item);
ImageView lcg = (ImageView)findViewById(R.id.lcg);
ImageView lfb = (ImageView)findViewById(R.id.lfb);
ImageView lnv = (ImageView)findViewById(R.id.lnv);
ImageView lpa = (ImageView)findViewById(R.id.lpa);
AfficherBandeau(lcg, lfb, lnv, lpa);
afficherBreadCrumb();
TextView txtTitle = (TextView)findViewById(R.id.txtTitleItem);
TextView txtDate = (TextView)findViewById(R.id.txtDateItem);
txtDate.setTextColor(Color.rgb(135,154,29));
ImageView imgViewDeco = (ImageView)findViewById(R.id.imgViewItemDecoEcran);
ImageView imgSeparator = (ImageView)findViewById(R.id.imgSeparator);
WebView txtContent = (WebView)findViewById(R.id.webViewContentItem);
imgSeparator.setImageResource(R.drawable.item_separator);
String urlD;
try {
urlD = Main.urlPrefix + Main.itemDecorationImageUrl;
URL aURL = new URL(urlD);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
imgViewDeco.setImageBitmap(bm);
} catch (IOException e) {
imgViewDeco.setImageResource(R.drawable.icon);
Log.e("DEBUGTAG", "Remtoe Image Exception", e);
}
txtTitle.setText(Main.el.getAttribute("title"));
String strPubDate = Main.el.getAttribute("pubDate");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date d = sdf.parse(strPubDate.substring(0,10));
txtDate.setText("Publié le " + DateFormat.format("dd/MM/yyyy", d));
} catch (ParseException e) {
e.printStackTrace();
}
try{
NodeList nodes = Main.el.getElementsByTagName("content");
Node n = nodes.item(0);
Element el = (Element) n;
NodeList nodesContent =
((Node) el).getChildNodes();
String content = ((Node) nodesContent.item(0)).getNodeValue();
txtContent.loadData(URLEncoder.encode("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><body><div><p>" + content + "</p></div></body></html>","utf-8").replaceAll("\\+"," "), "text/html", "utf-8");
}catch(Exception e){
URL myURLr;
try {
myURLr = new URL("http://pass-age-mobile.fr.chloro.info/protocolM/xmlcontentdata.aspx?itemid="+Main.el.getAttribute("id"));
DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
DocumentBuilder constructeur = fabrique.newDocumentBuilder();
doc = constructeur.parse(myURLr.openStream());
} catch (Exception e1) {
e1.printStackTrace();
}
try{
Element ei = doc.getDocumentElement();
NodeList nodes = ei.getElementsByTagName("content");
Node n = nodes.item(0);
Element el = (Element) n;
NodeList nodesContent =
((Node) el).getChildNodes();
String content = ((Node) nodesContent.item(0)).getNodeValue();
txtContent.loadData(URLEncoder.encode("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><body><div><p>" + content + "</p></div></body></html>","utf-8").replaceAll("\\+"," "), "text/html", "utf-8");
}catch(Exception eie){}
}
}
public void AfficherBandeau(ImageView lcg,ImageView lfb,ImageView lnv,ImageView lpa){
lcg.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
WebEcran.urlHeader = "http://www.bas-rhin.fr/accueil";
Intent i = new Intent(ItemEcran.this, WebEcran.class);
startActivity(i);
}
});
lfb.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
WebEcran.urlHeader = "http://www.facebook.com/pass-age";
Intent i = new Intent(ItemEcran.this, WebEcran.class);
startActivity(i);
}
});
/*lnv.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:0800747800"));
startActivity(callIntent);
}
});*/
lpa.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent i = new Intent(ItemEcran.this, Credits.class);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.add(1, 1, Menu.NONE, Main.strMenu);
menuItem.setIntent(new Intent(this, Main.class));
menuItem.setIcon(R.drawable.ic_menu_revert);
Element el = (Element) Main.el.getParentNode();
if(el.getAttribute("geolocalisation").equals("yes")){
MenuItem menuItem2 = menu.add(1, 1, Menu.NONE, "Localiser");
menuItem2.setIntent(new Intent(this, MapEcran.class));
menuItem2.setIcon(R.drawable.ic_menu_mapmode);
}
if(Main.el.getAttribute("detailsUrl").length()>0){
WebEcran.urlHeader = Main.traiterUrl(Main.el.getAttribute("detailsUrl"));
MenuItem menuItem3 = menu.add(1, 1, Menu.NONE, "Plus de détails");
menuItem3.setIntent(new Intent(this, WebEcran.class));
menuItem3.setIcon(R.drawable.ic_menu_info_details);
}
/*if(Main.el.hasAttribute("phone")){
MenuItem menuItem4 = menu.add(1, 3, Menu.NONE, "Téléphoner");
menuItem4.setIcon(android.R.drawable.ic_menu_call);
}
if(Main.el.hasAttribute("email")){
MenuItem menuItem4 = menu.add(1, 4, Menu.NONE, "Email");
menuItem4.setIcon(android.R.drawable.ic_menu_send);
}*/
if(Main.el.hasAttribute("webSite")){
WebEcran.urlHeader = Main.traiterUrl(Main.el.getAttribute("webSite"));
MenuItem menuItem4 = menu.add(1, 5, Menu.NONE, "Site");
menuItem4.setIntent(new Intent(this, WebEcran.class));
menuItem4.setIcon(android.R.drawable.ic_menu_set_as);
}
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 3:
try{
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+Main.el.getAttribute("phone")));
startActivity(callIntent);
}catch(Exception e){
}
break;
case 4:
String[] mailto = { Main.el.getAttribute("email")};
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
sendIntent.setType("message/rfc822");
ItemEcran.this.startActivity(Intent.createChooser(sendIntent, "Envoie d'un e-mail :"));
return true;
}
return false;
}
public void appelWebEcran(){
Intent i = new Intent(ItemEcran.this, WebEcran.class);
startActivity(i);
}
public void afficherBreadCrumb(){
Main.breadCrumbElement.clear();
Main.breadCrumbString.clear();
try{
Element bCEl = Main.el;
do{
String bCStr = bCEl.getAttribute("title");
Main.breadCrumbElement.put(bCStr, bCEl);
Main.breadCrumbString.add(0,bCStr);
bCEl = (Element)bCEl.getParentNode();
}while(bCEl.getParentNode()!=null);
}catch(Exception e){
}
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter(this, R.layout.element_breadcrumb, Main.breadCrumbString));
g.setBackgroundResource(R.drawable.bc_background);
g.setSelection(Main.breadCrumbString.size()-1);
g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int i, long id) {
String key = Main.breadCrumbString.get(i);
Main.el = Main.breadCrumbElement.get(key);
if(Main.el.getTagName().equals("list")){
String str = Main.el.getAttribute("listType").toLowerCase();
if (str.equals("menu")){
appelMenu();
}else if (str.equals("summary")){
appelSummary();
}
else if (str.equals("videosummary")){
appelVideoSummary();
}
}
else if(Main.el.getTagName().equals("item")){
appelItem();
}
else if(Main.el.getTagName().equals("application")){
AgendaEcran.urlData = Main.el.getAttribute("applicationData");
Intent in = new Intent(ItemEcran.this, AgendaEcran.class);
startActivity(in);
}
}
});
}
public void appelMenu(){
Intent i = new Intent(ItemEcran.this, MenuEcran.class);
startActivity(i);
}
public void appelSummary(){
Intent i = new Intent(ItemEcran.this, SummaryEcran.class);
startActivity(i);
}
public void appelItem(){
Intent i = new Intent(ItemEcran.this, ItemEcran.class);
startActivity(i);
}
public void appelVideoSummary(){
Intent i = new Intent(ItemEcran.this, VideoSummaryEcran.class);
startActivity(i);
}
protected void sendEmail(String[] mailTo) {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, mailTo);
sendIntent.setType("message/rfc822");
ItemEcran.this.startActivity(Intent.createChooser(sendIntent, "Email"));
}
} |
Partager