Tuesday 29 November 2011

gridview.java


package com.LijslGallery;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class LijslGalleryActivity extends Activity {
String[] str;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dest);

GridView g = (GridView) findViewById(R.id.dhaval);
g.setAdapter(new ImageAdapter(this));

}

public class ImageAdapter extends BaseAdapter {
public ImageAdapter(Context c) {
mContext = c;
}

public int getCount() {
return mThumbIds.length;
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

// string array

public View getView(int position, View convertView, ViewGroup parent) {

View v;
if (convertView == null) {
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon, null);

ImageView iv = (ImageView) v.findViewById(R.id.icon_image);
iv.setImageResource(mThumbIds[position]);
} else {
v = convertView;
}
return v;

}

@SuppressWarnings("unused")
private Context mContext;

private Integer[] mThumbIds = {

R.drawable.calendar, R.drawable.clubs, R.drawable.fandd,
R.drawable.gallery, R.drawable.links, R.drawable.mylijsl,
R.drawable.latesth, R.drawable.sponsors, R.drawable.register,
R.drawable.news, R.drawable.tryouts,R.drawable.programs

};

}

}





///////////////////////////////icon.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"

android:gravity="center_horizontal">
<ImageView android:id="@+id/icon_image" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>

</LinearLayout>





gridview=>arranging 4*3 images


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainlayout"
android:background="#ffffffff" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/screen_label" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="lijsl"
android:gravity="center" android:textColor="#ffffffff"
android:background="#808080ff" android:textStyle="bold">
</TextView>
<GridView android:id="@+id/dhaval" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:verticalSpacing="14.5dp"
android:horizontalSpacing="4.5dp" android:columnWidth="65dp"
android:numColumns="auto_fit" android:stretchMode="columnWidth"
android:gravity="center" android:paddingTop="40dp">
<!-- using verticalspacing,horizontal spacing,coloumnwidth properites we
can arrange images in gridview -->

</GridView>
</LinearLayout>

========================>honeycomb

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainlayout"
android:background="#ffffffff" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/screen_label" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="lijsl"
android:gravity="center" android:textColor="#ffffffff"
android:background="#808080ff" android:textStyle="bold">
</TextView>
<GridView android:id="@+id/dhaval" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:verticalSpacing="20dp"
android:horizontalSpacing="20dp" android:columnWidth="160dp"
android:numColumns="auto_fit" android:stretchMode="columnWidth"
android:gravity="center" android:paddingTop="40dp">
<!-- using verticalspacing,horizontal spacing,coloumnwidth properites we
can arrange images in gridview -->

</GridView>
</LinearLayout>








 ==========================>galaxy tab

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainlayout"
android:background="#ffffffff" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/screen_label" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="lijsl"
android:gravity="center" android:textColor="#ffffffff"
android:background="#808080ff" android:textStyle="bold">
</TextView>
<GridView android:id="@+id/dhaval" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:columnWidth="80dp"
android:numColumns="auto_fit" android:stretchMode="columnWidth"
android:gravity="center" android:paddingTop="40dp">
<!-- using verticalspacing,horizontal spacing,coloumnwidth properites we
can arrange images in gridview -->

</GridView>
</LinearLayout>




















Wednesday 23 November 2011

map view to view longitude lattitude in map using google map api (key is not required)


//to view the map,key is not required
package com.MapActivity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class MapActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);//default main.xml
        double SLatitude = 1.234;
double SLongitude = 1.34;

final Intent intent = new Intent(Intent.ACTION_VIEW,
/** Using the web based turn by turn directions url. */
Uri.parse("http://maps.google.com/maps?" + "saddr="
+ SLatitude + "," + SLongitude + "&daddr="
+ 2.34 + "," + 3.45 + ""));

intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
    }
}
manifest:=>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MapActivity" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-library android:name="com.google.android.maps" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MapActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
</manifest>

Saturday 5 November 2011

show-hide news


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();
}

}