package com.LIJSL.News;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.LIJSL.BaseFeedParser;
import com.LIJSL.Internet_Check;
import com.LIJSL.Ksoap;
import com.LIJSL.Main;
import com.LIJSL.NewsWebView;
import com.LIJSL.R;
import com.LIJSL.ScreenConfg;
public class Linews extends Activity {
private SoapObject Soapresponse;
// News variable
String[] HeaderName, Type, Description, Url, FileName, PublishDate,
NewsImageName;
String[] NewsId;
// screen size check
private boolean checkofmedium;
private boolean checkoflarge;
private boolean checkofNormal;
// coaching variable
String[] NewsCoaching, HeaderNameofCoaching, TypeofCoaching,
DescriptionofCoaching, UrlofCoaching, FileNameofEvent,
PublishDateofCoaching, CoachImageNameOfCoaching;
// Event Variable
String[] NewsEvent, HeaderNameEvent, DescriptionofEvent, UrlofEvent,
FileNameofCoaching, PublishDateofEvent, NewsImageNameofEvent;
// String[] IsCurrent;
Button nwsUp, nwsDown, socnws, coaching, evnt;
ListView nwslist, coachlist, eventlist, socnwslist;
final ArrayList<HashMap<String, String>> list1 = new ArrayList<HashMap<String, String>>();
final ArrayList<HashMap<String, String>> list2 = new ArrayList<HashMap<String, String>>();
final ArrayList<HashMap<String, String>> list3 = new ArrayList<HashMap<String, String>>();
final ArrayList<HashMap<String, String>> list4 = new ArrayList<HashMap<String, String>>();
ListView customList1, customList2, customList3, customList4;
SimpleAdapter adapter1, adapter2, adapter3, adapter4;
HashMap<String, String> temp4 = new HashMap<String, String>();
String stringValueq = null, stringValue = "done";
int total_News;
int total_Coaching;
int total_Events;
int width, height;
ProgressDialog dialog;
int count11, count00, count111, count000;
// SharedPreferences.Editor editor;
SharedPreferences myPrefs;
private Dialog alertDialog;
private List<com.LIJSL.Message> messages;
String[] title, date, link;
// Back Button
private Button back;
private TextView top_text;
// Screen Orientation Variable
int screenOrientation;
private boolean checkCoaching = false;
private boolean checkEvent = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.linews);
myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
top_text = (TextView) findViewById(R.id.top_text);
top_text.setText("NEWS");
checkofmedium = ScreenConfg.checkScreenSize(getWindowManager());
checkoflarge = ScreenConfg.checkScreenSize_10(getWindowManager());
checkofNormal = ScreenConfg.checkScreenSize_Normal(getWindowManager());
// if (checkofmedium) {
// Log.v("log_tag", "Screen 1");
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// } else if (checkoflarge) {
// // Log.v("log_tag", "Screen 2");
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// } else
if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
screenOrientation = getScreenOrientation();
back = (Button) findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(Linews.this, Main.class);
startActivity(i);
finish();
}
});
dialog = ProgressDialog.show(this, "", "Loading Data ...Please Wait",
true);
nwsUp = (Button) findViewById(R.id.btn_lijslnews);
nwsDown = (Button) findViewById(R.id.btn_nwsdown);
socnws = (Button) findViewById(R.id.btn_soccernews);
coaching = (Button) findViewById(R.id.btn_coaching);
evnt = (Button) findViewById(R.id.btn_event);
adapter1 = new SimpleAdapter(this, list1, R.layout.customlijsl,
new String[] { "text1", "text2" }, new int[] { R.id.text1,
R.id.text2 });
if (Internet_Check.checkInternetConnection(getApplicationContext())) {
checkUpdate.start();
} else {
Alert_dialog();
dialog.dismiss();
}
customList1 = (ListView) findViewById(R.id.list_lnews);
customList2 = (ListView) findViewById(R.id.list_lcoachnews);
customList3 = (ListView) findViewById(R.id.list_leventnews);
customList4 = (ListView) findViewById(R.id.list_lsocnews);
nwsUp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
nwsDown.setVisibility(View.VISIBLE);
coaching.setVisibility(View.VISIBLE);
evnt.setVisibility(View.VISIBLE);
customList1.setVisibility(View.VISIBLE);
if (screenOrientation == 1) {
if (checkofmedium) {
socnws.setBackgroundResource(R.drawable.lsoccernws_240);
nwsUp.setBackgroundResource(R.drawable.lnwsactiveup_240);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_240);
coaching.setBackgroundResource(R.drawable.lcoach_240);
evnt.setBackgroundResource(R.drawable.levent_240);
} else if (checkoflarge) {
socnws.setBackgroundResource(R.drawable.soccernews_160_port);
nwsUp.setBackgroundResource(R.drawable.lijslnewsact_up_160_port);
nwsDown.setBackgroundResource(R.drawable.lijslnewsact_down_160_port);
coaching.setBackgroundResource(R.drawable.coaching_160_port);
evnt.setBackgroundResource(R.drawable.event_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
socnws.setBackgroundResource(R.drawable.lsoccernws);
nwsUp.setBackgroundResource(R.drawable.lnwsactiveup);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown);
coaching.setBackgroundResource(R.drawable.lcoach);
evnt.setBackgroundResource(R.drawable.levent);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
socnws.setBackgroundResource(R.drawable.soccernews_240_land);
nwsUp.setBackgroundResource(R.drawable.lijslnewsact_240_land);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_240_land);
coaching.setBackgroundResource(R.drawable.lcoach_240_land);
evnt.setBackgroundResource(R.drawable.levent_240_land);
} else if (checkoflarge) {
socnws.setBackgroundResource(R.drawable.lsoccernws_160);
nwsUp.setBackgroundResource(R.drawable.lnwsactiveup_160);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_160);
coaching.setBackgroundResource(R.drawable.lcoach_160);
evnt.setBackgroundResource(R.drawable.levent_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
socnws.setBackgroundResource(R.drawable.lsoccernws);
nwsUp.setBackgroundResource(R.drawable.lnwsactiveup);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown);
coaching.setBackgroundResource(R.drawable.lcoach);
evnt.setBackgroundResource(R.drawable.levent);
}
}
customList3.setVisibility(View.INVISIBLE);
customList2.setVisibility(View.INVISIBLE);
customList4.setVisibility(View.INVISIBLE);
top_text.setText("NEWS");
}
});
nwsDown.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
list1.clear();
if (screenOrientation == 1) {
if (checkofmedium) {
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_240);
coaching.setBackgroundResource(R.drawable.lcoach_240);
evnt.setBackgroundResource(R.drawable.levent_240);
} else if (checkoflarge) {
nwsDown.setBackgroundResource(R.drawable.lijslnewsact_down_160_port);
coaching.setBackgroundResource(R.drawable.coaching_160_port);
evnt.setBackgroundResource(R.drawable.event_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown);
coaching.setBackgroundResource(R.drawable.lcoach);
evnt.setBackgroundResource(R.drawable.levent);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_240_land);
coaching.setBackgroundResource(R.drawable.lcoach_240_land);
evnt.setBackgroundResource(R.drawable.levent_240_land);
} else if (checkoflarge) {
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown_160);
coaching.setBackgroundResource(R.drawable.lcoach_160);
evnt.setBackgroundResource(R.drawable.levent_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nwsDown.setBackgroundResource(R.drawable.lnewsactivedown);
coaching.setBackgroundResource(R.drawable.lcoach);
evnt.setBackgroundResource(R.drawable.levent);
}
}
customList1.setVisibility(View.VISIBLE);
customList2.setVisibility(View.INVISIBLE);
customList3.setVisibility(View.INVISIBLE);
populateList1();
adapter1 = new SimpleAdapter(Linews.this, list1,
R.layout.customlijsl,
new String[] { "text1", "text2" }, new int[] {
R.id.text1, R.id.text2 });
customList1.setAdapter(adapter1);
top_text.setText("NEWS");
}
});
coaching.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
list2.clear();
if (checkCoaching) {
populateList2();
adapter2 = new SimpleAdapter(Linews.this, list2,
R.layout.customcoachingview, new String[] {
"header", "publish" }, new int[] {
R.id.text1, R.id.text2 });
customList2.setAdapter(adapter2);
} else {
dialog = ProgressDialog.show(Linews.this, "",
"Loading Data ...Please Wait", true);
CoachingCheck.start();
checkCoaching = true;
}
if (screenOrientation == 1) {
if (checkofmedium) {
coaching.setBackgroundResource(R.drawable.lcoachactive_240);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_240);
evnt.setBackgroundResource(R.drawable.levent_240);
} else if (checkoflarge) {
coaching.setBackgroundResource(R.drawable.coachingact_down_160_port);
nwsDown.setBackgroundResource(R.drawable.lijslnews_down_160_port);
evnt.setBackgroundResource(R.drawable.event_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
coaching.setBackgroundResource(R.drawable.lcoachactive);
nwsDown.setBackgroundResource(R.drawable.lnewsdown);
evnt.setBackgroundResource(R.drawable.levent);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
coaching.setBackgroundResource(R.drawable.lcoachactive_240_land);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_240_land);
evnt.setBackgroundResource(R.drawable.levent_240_land);
} else if (checkoflarge) {
coaching.setBackgroundResource(R.drawable.lcoachactive_160);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_160);
evnt.setBackgroundResource(R.drawable.levent_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
coaching.setBackgroundResource(R.drawable.lcoachactive);
nwsDown.setBackgroundResource(R.drawable.lnewsdown);
evnt.setBackgroundResource(R.drawable.levent);
}
}
customList1.setVisibility(View.INVISIBLE);
customList2.setVisibility(View.VISIBLE);
customList3.setVisibility(View.INVISIBLE);
top_text.setText("NEWS");
}
});
evnt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
list3.clear();
if (checkEvent) {
populateList3();
adapter3 = new SimpleAdapter(Linews.this, list3,
R.layout.customevents, new String[] {
"headerEvent", "publishEvent" }, new int[] {
R.id.text1, R.id.text2 });
customList3.setAdapter(adapter3);
} else {
dialog = ProgressDialog.show(Linews.this, "",
"Loading Data ...Please Wait", true);
checkEventUpdate.start();
checkEvent = true;
}
if (screenOrientation == 1) {
if (checkofmedium) {
evnt.setBackgroundResource(R.drawable.leventactive_240);
coaching.setBackgroundResource(R.drawable.lcoach_240);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_240);
} else if (checkoflarge) {
evnt.setBackgroundResource(R.drawable.eventact_down_160_port);
coaching.setBackgroundResource(R.drawable.coaching_160_port);
nwsDown.setBackgroundResource(R.drawable.lijslnews_down_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
evnt.setBackgroundResource(R.drawable.leventactive);
coaching.setBackgroundResource(R.drawable.lcoach);
nwsDown.setBackgroundResource(R.drawable.lnewsdown);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
evnt.setBackgroundResource(R.drawable.leventactive_240_land);
coaching.setBackgroundResource(R.drawable.lcoach_240_land);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_240_land);
} else if (checkoflarge) {
evnt.setBackgroundResource(R.drawable.leventactive_160);
coaching.setBackgroundResource(R.drawable.lcoach_160);
nwsDown.setBackgroundResource(R.drawable.lnewsdown_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
evnt.setBackgroundResource(R.drawable.leventactive);
coaching.setBackgroundResource(R.drawable.lcoach);
nwsDown.setBackgroundResource(R.drawable.lnewsdown);
}
}
customList1.setVisibility(View.INVISIBLE);
customList2.setVisibility(View.INVISIBLE);
customList3.setVisibility(View.VISIBLE);
top_text.setText("NEWS");
}
});
socnws.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
list4.clear();
// list1.clear();
// list2.clear();
// list3.clear();
nwsDown.setVisibility(View.INVISIBLE);
coaching.setVisibility(View.INVISIBLE);
evnt.setVisibility(View.INVISIBLE);
if (screenOrientation == 1) {
if (checkofmedium) {
nwsUp.setBackgroundResource(R.drawable.lnwsup_240);
socnws.setBackgroundResource(R.drawable.lsoccernwsact_240);
} else if (checkoflarge) {
nwsUp.setBackgroundResource(R.drawable.lijslnews_up_160_port);
socnws.setBackgroundResource(R.drawable.soccernewsact_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nwsUp.setBackgroundResource(R.drawable.lnwsup);
socnws.setBackgroundResource(R.drawable.lsoccernwsact);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
nwsUp.setBackgroundResource(R.drawable.lijslnews_240_land);
socnws.setBackgroundResource(R.drawable.lijslsoccernews_240_land);
} else if (checkoflarge) {
nwsUp.setBackgroundResource(R.drawable.lnwsup_160);
socnws.setBackgroundResource(R.drawable.lsoccernwsact_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nwsUp.setBackgroundResource(R.drawable.lnwsup);
socnws.setBackgroundResource(R.drawable.lsoccernwsact);
}
}
customList1.setVisibility(View.INVISIBLE);
customList2.setVisibility(View.INVISIBLE);
customList3.setVisibility(View.INVISIBLE);
customList4.setVisibility(View.VISIBLE);
soccernews();
adapter4 = new SimpleAdapter(Linews.this, list4,
R.layout.customevents,
new String[] { "Title", "Date" }, new int[] {
R.id.text1, R.id.text2 });
customList4.setAdapter(adapter4);
top_text.setText("NEWS");
}
});
customList1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent l = new Intent(Linews.this, NewsWebView.class);
l.putExtra("headername", HeaderName[arg2]);
l.putExtra("publishdate", PublishDate[arg2]);
l.putExtra("filename", FileName[arg2]);
l.putExtra("url", Url[arg2]);
l.putExtra("description", Description[arg2]);
l.putExtra("top_header", "NEWS");
startActivity(l);
}
});
customList2.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent l = new Intent(Linews.this, NewsWebView.class);
l.putExtra("headername", HeaderNameofCoaching[arg2]);
l.putExtra("publishdate", PublishDateofCoaching[arg2]);
l.putExtra("filename", FileNameofCoaching[arg2]);
l.putExtra("url", UrlofCoaching[arg2]);
l.putExtra("description", DescriptionofCoaching[arg2]);
l.putExtra("top_header", "COACHING");
startActivity(l);
}
});
customList3.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent l = new Intent(Linews.this, NewsWebView.class);
l.putExtra("headername", HeaderNameEvent[arg2]);
l.putExtra("publishdate", PublishDateofEvent[arg2]);
l.putExtra("filename", FileNameofEvent[arg2]);
l.putExtra("url", UrlofEvent[arg2]);
l.putExtra("description", DescriptionofEvent[arg2]);
l.putExtra("top_header", "EVENT");
startActivity(l);
}
});
customList4.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent l = new Intent(Linews.this, NewsWebView.class);
l.putExtra("headername", title[arg2]);
l.putExtra("publishdate", date[arg2]);
l.putExtra("filename", "");
l.putExtra("url", link[arg2]);
l.putExtra("description", "");
l.putExtra("top_header", "SOCCER NEWS");
startActivity(l);
}
});
}
@Override
protected void onStop() {
super.onStop();
if (dialog != null) {
dialog.dismiss();
}
}
Thread checkUpdate = new Thread() {
public void run() {
Soapresponse = Ksoap.CallService("GetFeatureNews", 0, null);
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);
if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
NewsId = new String[Table.getPropertyCount()];
HeaderName = new String[Table
.getPropertyCount()];
Type = new String[Table.getPropertyCount()];
Description = new String[Table
.getPropertyCount()];
Url = new String[Table.getPropertyCount()];
FileName = new String[Table.getPropertyCount()];
PublishDate = new String[Table
.getPropertyCount()];
NewsImageName = new String[Table
.getPropertyCount()];
// IsCurrent = new
// String[Table.getPropertyCount()];
// String temp="";
total_News = Table.getPropertyCount();
myPrefs = getApplicationContext()
.getSharedPreferences("myPrefs",
MODE_WORLD_READABLE);
// editor.putString("data2",
// SP_PastWinners);
// editor = myPrefs.edit();
// editor.putInt("data11", total_data);
for (int i = 0; i < total_News; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
NewsId[i] = row.getProperty("NewsId")
.toString();
HeaderName[i] = row.getProperty(
"HeaderName").toString();
Type[i] = row.getProperty("Type")
.toString();
Description[i] = row.getProperty(
"Description").toString();
Url[i] = row.getProperty("Url").toString();
FileName[i] = row.getProperty("FileName")
.toString();
PublishDate[i] = row.getProperty(
"PublishDate").toString();
NewsImageName[i] = row.getProperty(
"NewsImageName").toString();
}
}
}
}
}
} catch (NullPointerException f) {
} catch (ClassCastException d) {
}
handler.sendEmptyMessage(0);
}
};
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
// if (Soapresponse == null) {
// Alert_dialog();
// } else {
populateList1();
try {
customList1.setAdapter(adapter1);
dialog.dismiss();
} catch (NullPointerException f) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
} catch (ClassCastException d) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
}
// }
}
};
// Now Coaching Functionality
Thread CoachingCheck = new Thread() {
public void run() {
// private void ff() {
PropertyInfo total_property[] = null;
SoapObject Soapresponse = Ksoap.CallService("GetCoachingNews", 0,
total_property);
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);
if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
NewsCoaching = new String[Table
.getPropertyCount()];
HeaderNameofCoaching = new String[Table
.getPropertyCount()];
TypeofCoaching = new String[Table
.getPropertyCount()];
DescriptionofCoaching = new String[Table
.getPropertyCount()];
UrlofCoaching = new String[Table
.getPropertyCount()];
FileNameofCoaching = new String[Table
.getPropertyCount()];
PublishDateofCoaching = new String[Table
.getPropertyCount()];
CoachImageNameOfCoaching = new String[Table
.getPropertyCount()];
// IsCurrent = new
// String[Table.getPropertyCount()];
// String temp="";
total_Coaching = Table.getPropertyCount();
myPrefs = getApplicationContext()
.getSharedPreferences("myPrefs",
MODE_WORLD_READABLE);
// editor.putString("data2", SP_PastWinners);
// editor = myPrefs.edit();
// editor.putInt("data11", total_data);
for (int i = 0; i < total_Coaching; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
NewsCoaching[i] = row.getProperty(
"NewsId").toString();
HeaderNameofCoaching[i] = row
.getProperty("HeaderName")
.toString();
TypeofCoaching[i] = row.getProperty(
"Type").toString();
DescriptionofCoaching[i] = row
.getProperty("Description")
.toString();
UrlofCoaching[i] = row.getProperty(
"Url").toString();
FileNameofCoaching[i] = row
.getProperty("FileName")
.toString();
PublishDateofCoaching[i] = row
.getProperty("PublishDate")
.toString();
CoachImageNameOfCoaching[i] = row
.getProperty("CoachImageName")
.toString();
} catch (NullPointerException e) {
}
}
}
}
}
}
} catch (NullPointerException f) {
} catch (ClassCastException d) {
}
Coachinghandler.sendEmptyMessage(0);
}
};
final Handler Coachinghandler = new Handler() {
public void handleMessage(Message msg) {
try {
dialog.dismiss();
populateList2();
adapter2 = new SimpleAdapter(Linews.this, list2,
R.layout.customcoachingview, new String[] { "header",
"publish" },
new int[] { R.id.text1, R.id.text2 });
customList2.setAdapter(adapter2);
// checkEventUpdate.start();
} catch (NullPointerException f) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
}
}
};
// Now Event Functionality
Thread checkEventUpdate = new Thread() {
public void run() {
PropertyInfo total_property[] = null;
SoapObject Soapresponse = Ksoap.CallService("GetEventList", 0,
total_property);
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);
if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
NewsEvent = new String[Table.getPropertyCount()];
HeaderNameEvent = new String[Table
.getPropertyCount()];
// TypeofEvent = new String[Table
// .getPropertyCount()];
DescriptionofEvent = new String[Table
.getPropertyCount()];
UrlofEvent = new String[Table
.getPropertyCount()];
FileNameofEvent = new String[Table
.getPropertyCount()];
PublishDateofEvent = new String[Table
.getPropertyCount()];
// NewsImageNameofEvent = new String[Table
// .getPropertyCount()];
// IsCurrent = new
// String[Table.getPropertyCount()];
// String temp="";
total_Events = Table.getPropertyCount();
myPrefs = getApplicationContext()
.getSharedPreferences("myPrefs",
MODE_WORLD_READABLE);
for (int i = 0; i < total_Events; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
NewsEvent[i] = row
.getProperty("NewsId")
.toString();
HeaderNameEvent[i] = row.getProperty(
"HeaderName").toString();
// TypeofEvent[i] = row
// .getProperty("Type").toString();
DescriptionofEvent[i] = row
.getProperty("Description")
.toString();
UrlofEvent[i] = row.getProperty("Url")
.toString();
FileNameofEvent[i] = row.getProperty(
"FileName").toString();
PublishDateofEvent[i] = row
.getProperty("PublishDate")
.toString();
// NewsImageNameofEvent[i] = row
// .getProperty("NewsImageName")
// .toString();
} catch (NullPointerException e) {
}
}
}
}
}
}
} catch (NullPointerException f) {
} catch (ClassCastException d) {
}
Eventhandler.sendEmptyMessage(0);
}
};
final Handler Eventhandler = new Handler() {
public void handleMessage(Message msg) {
try {
populateList3();
adapter3 = new SimpleAdapter(Linews.this, list3,
R.layout.customevents, new String[] { "headerEvent",
"publishEvent" }, new int[] { R.id.text1,
R.id.text2 });
customList3.setAdapter(adapter3);
dialog.dismiss();
// soccernews();
} catch (NullPointerException f) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
}
}
};
private void soccernews() {
dialog = ProgressDialog.show(this, "", "Loading Data ...Please Wait",
true);
BaseFeedParser parser = new BaseFeedParser();
messages = parser.parse();
title = new String[messages.size()];
link = new String[messages.size()];
date = new String[messages.size()];
int i = 0;
for (com.LIJSL.Message message : messages) {
HashMap<String, String> temp4 = new HashMap<String, String>();
title[i] = message.getTitle();
link[i] = message.getLink().toString();
date[i] = message.getDate();
i++;
temp4.put("Title", message.getTitle());
temp4.put("Date", message.getDate());
list4.add(temp4);
}
dialog.dismiss();
}
private void populateList1() {
for (int i = 0; i < total_News; i++) {
HashMap<String, String> temp = new HashMap<String, String>();
temp.put("text1", HeaderName[i]);
temp.put("text2", PublishDate[i]);
list1.add(temp);
}
}
private void Alert_dialog() {
// Create the dialog box
AlertDialog.Builder alertbox = new AlertDialog.Builder(Linews.this);
alertbox.setTitle("Connection Error");
// Set the message to display
alertbox.setMessage("Please Check your internet connection");
// Set a positive/yes button and create a listener
alertbox.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// Click listener
public void onClick(DialogInterface arg0, int arg1) {
Intent i = new Intent(Linews.this, Main.class);
startActivity(i);
finish();
}
});
// display box
alertbox.show();
}
private void populateList2() {
for (int i = 0; i < total_Coaching; i++) {
HashMap<String, String> temp = new HashMap<String, String>();
temp.put("header", HeaderNameofCoaching[i]);
temp.put("publish", PublishDateofCoaching[i]);
list2.add(temp);
}
}
private void populateList3() {
for (int i = 0; i < total_Events; i++) {
HashMap<String, String> temp = new HashMap<String, String>();
temp.put("headerEvent", HeaderNameEvent[i]);
temp.put("publishEvent", PublishDateofEvent[i]);
list3.add(temp);
}
}
// Check Orientation For Landscape And portrait Mode.
public int getScreenOrientation() {
Display getOrient = getWindowManager().getDefaultDisplay();
int orientation = Configuration.ORIENTATION_UNDEFINED;
if (getOrient.getWidth() == getOrient.getHeight()) {
orientation = Configuration.ORIENTATION_SQUARE;
} else {
if (getOrient.getWidth() < getOrient.getHeight()) {
orientation = Configuration.ORIENTATION_PORTRAIT;
} else {
orientation = Configuration.ORIENTATION_LANDSCAPE;
}
}
return orientation;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
onBackPressed();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed() {
// do something on back.
Intent i = new Intent(Linews.this, Main.class);
startActivity(i);
finish();
}
}