String ReadRaw(int id)
{
try
{
InputStream raw = getResources().openRawResource(id);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
i = raw.read();
while (i != -1)
{
byteArrayOutputStream.write(i);
i = raw.read();
}
raw.close();
return byteArrayOutputStream.toString();
}
catch (IOException e)
{
e.printStackTrace();
return "";
}
}
Wednesday, March 30, 2011
Store DB Links
http://www.screaming-penguin.com/node/7742
http://android.bigresource.com/Android-Want-Database-to-save-retrieve-names-in-phone-application-haK6YhJIr.html
main.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
"http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="wrap_content"
android:text="@string/hello" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="" />
DataHelper.java
package com.ram.sampleDB;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
public class DataHelper {
private static final String DATABASE_NAME = "example.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "table1";
private Context context;
private SQLiteDatabase db;
private SQLiteStatement insertStmt;
private static final String INSERT = "insert into "
+ TABLE_NAME + "(name) values (?)";
public DataHelper(sampleDB sampleDB) {
// TODO Auto-generated constructor stub
this.context = sampleDB;
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
this.insertStmt = this.db.compileStatement(INSERT);
}
public void deleteAll() {
// TODO Auto-generated method stub
this.db.delete(TABLE_NAME, null, null);
}
public long insert(String name) {
// TODO Auto-generated method stub
this.insertStmt.bindString(1, name);
return this.insertStmt.executeInsert();
}
public List selectAll() {
// TODO Auto-generated method stub
List list = new ArrayList();
Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name" },
null, null, null, null, "name desc");
if (cursor.moveToFirst()) {
do {
list.add(cursor.getString(0));
} while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return list;
}
private static class OpenHelper extends SQLiteOpenHelper {
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name TEXT)");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Example", "Upgrading database, this will drop tables and recreate.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
}
sampleDB.java
package com.ram.sampleDB;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class sampleDB extends Activity {
/** Called when the activity is first created. */
private TextView output;
private DataHelper dh;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.output = (TextView) this.findViewById(R.id.out_text);
this.dh = new DataHelper(this);
this.dh.deleteAll();
this.dh.insert("Porky Pig");
this.dh.insert("Foghorn Leghorn");
this.dh.insert("Yosemite Sam");
List names = this.dh.selectAll();
StringBuilder sb = new StringBuilder();
sb.append("Names in database:\n");
for (String name : names) {
sb.append(name + "\n");
}
Log.d("EXAMPLE", "names size - " + names.size());
this.output.setText(sb.toString());
}
}
http://android.bigresource.com/Android-Want-Database-to-save-retrieve-names-in-phone-application-haK6YhJIr.html
main.xml
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:text="@string/hello" />
android:layout_height="wrap_content"
android:text="" />
DataHelper.java
package com.ram.sampleDB;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
public class DataHelper {
private static final String DATABASE_NAME = "example.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "table1";
private Context context;
private SQLiteDatabase db;
private SQLiteStatement insertStmt;
private static final String INSERT = "insert into "
+ TABLE_NAME + "(name) values (?)";
public DataHelper(sampleDB sampleDB) {
// TODO Auto-generated constructor stub
this.context = sampleDB;
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
this.insertStmt = this.db.compileStatement(INSERT);
}
public void deleteAll() {
// TODO Auto-generated method stub
this.db.delete(TABLE_NAME, null, null);
}
public long insert(String name) {
// TODO Auto-generated method stub
this.insertStmt.bindString(1, name);
return this.insertStmt.executeInsert();
}
public List
// TODO Auto-generated method stub
List
Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name" },
null, null, null, null, "name desc");
if (cursor.moveToFirst()) {
do {
list.add(cursor.getString(0));
} while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return list;
}
private static class OpenHelper extends SQLiteOpenHelper {
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name TEXT)");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Example", "Upgrading database, this will drop tables and recreate.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
}
sampleDB.java
package com.ram.sampleDB;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class sampleDB extends Activity {
/** Called when the activity is first created. */
private TextView output;
private DataHelper dh;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.output = (TextView) this.findViewById(R.id.out_text);
this.dh = new DataHelper(this);
this.dh.deleteAll();
this.dh.insert("Porky Pig");
this.dh.insert("Foghorn Leghorn");
this.dh.insert("Yosemite Sam");
List
StringBuilder sb = new StringBuilder();
sb.append("Names in database:\n");
for (String name : names) {
sb.append(name + "\n");
}
Log.d("EXAMPLE", "names size - " + names.size());
this.output.setText(sb.toString());
}
}
Saturday, March 19, 2011
Android Links
http://www.ndtv.com/convergence/ndtv/rssfeedback.aspx
http://www.google.com/language_tools
http://maxood-android-corner.blogspot.com/2011/03/tutorial-using-google-translate-api-in.html
http://android-er.blogspot.com/2009/10/multi-language-translate.html
http://stackoverflow.com/questions/4979078/google-translator-in-android
http://stackoverflow.com/questions/2325547/how-to-have-a-translation-service-in-android-app
http://www.google.com/language_tools
http://maxood-android-corner.blogspot.com/2011/03/tutorial-using-google-translate-api-in.html
http://android-er.blogspot.com/2009/10/multi-language-translate.html
http://stackoverflow.com/questions/4979078/google-translator-in-android
http://stackoverflow.com/questions/2325547/how-to-have-a-translation-service-in-android-app
Thursday, March 10, 2011
USING CANVAS TO ROTATE BALL
package in.ram.JungleMayhem;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
public class JungleMayhem extends Activity {
//private Bitmap bg;
private DrawOval dw;
int x = 30;
int y = 230;
//private boolean start = true;
private boolean running = true;
private boolean direction = true;
private boolean direction1;
private boolean direction2;
private boolean direction3;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bg1480x320);
//Bitmap bg= Bitmap.createScaledBitmap(mBitmap, 240, 320, true);
//int pic_width = mBitmap.getWidth();
//int pic_height = mBitmap.getHeight();
//ImageView img = new ImageView(this);
//img.setImageBitmap(bg);
//setContentView(img);
dw = new DrawOval(this);
setContentView(dw,new ViewGroup.LayoutParams(240,400));
(new Thread(new Animationloop())).start();
}
public void updatePhysics() {
if(direction == true) {
if(x<= 130) {
x+=1;
y-=1;
}else if(x==131){
direction = false;
direction1=true;
}
}
if(direction1==true){
if(x<=230){
x+=1;
y+=1;
}else if(x==231){
direction1=false;
direction2=true;
}
}
if(direction2==true){
if(x>=131){
x-=1;
y+=1;
}else if(x==130){
direction2=false;
direction3=true;
}
}
if(direction3==true){
if(x>=30){
x-=1;
y-=1;
}else if(x==29){
direction3=false;
direction=true;
x = 30;
y = 230;
}
}
}
class DrawOval extends View {
//Canvas c;
//private ShapeDrawable shp;
private Bitmap bg = BitmapFactory.decodeResource(getResources(),R.drawable.bg2480x320);
private Bitmap bg1= Bitmap.createScaledBitmap(bg, 240, 320, true);
private Bitmap p1 = BitmapFactory.decodeResource(getResources(),R.drawable.egg);
private Bitmap egg = Bitmap.createScaledBitmap(p1, 10, 10, true);
private Bitmap pl1 =BitmapFactory.decodeResource(getResources(),R.drawable.egg1);
private Bitmap pl2 =BitmapFactory.decodeResource(getResources(),R.drawable.egg2);
private Bitmap pl11 = Bitmap.createScaledBitmap(pl1, 45,45, true);
private Bitmap pl22 = Bitmap.createScaledBitmap(pl2, 45,45, true);
public DrawOval(Context context) {
super(context);
}
//shp = new ShapeDrawable(new OvalShape());
//shp.getPaint().setColor(0xff74AC23);
//shp.setBounds(0, 0, 480, 360);
protected synchronized void onDraw(Canvas canvas) {
canvas.drawBitmap(bg1, new Rect(0,0,240,400), new Rect(0,0,240,400), new Paint());
canvas.drawBitmap(pl11,25,150,new Paint());
canvas.drawBitmap(pl22,165,150,new Paint());
canvas.drawBitmap(egg,200,200,new Paint());
canvas.drawBitmap(egg,x,y,new Paint());
//canvas.drawBitmap(p1, new Rect(0,0,100,100), new Rect(0,0,100,100), new Paint());
//canvas.drawColor(Color.BLUE);
//shp.draw(canvas);
invalidate();
}
}
class Animationloop implements Runnable {
@Override
public void run() {
while(true) {
while(running) {
try {
Thread.sleep(10);
}catch(InterruptedException e) {
System.out.println("-------InterruptedException-----"+e);
}
//dw.postInvalidate();
updatePhysics();
}
}
}
}
}
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
public class JungleMayhem extends Activity {
//private Bitmap bg;
private DrawOval dw;
int x = 30;
int y = 230;
//private boolean start = true;
private boolean running = true;
private boolean direction = true;
private boolean direction1;
private boolean direction2;
private boolean direction3;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bg1480x320);
//Bitmap bg= Bitmap.createScaledBitmap(mBitmap, 240, 320, true);
//int pic_width = mBitmap.getWidth();
//int pic_height = mBitmap.getHeight();
//ImageView img = new ImageView(this);
//img.setImageBitmap(bg);
//setContentView(img);
dw = new DrawOval(this);
setContentView(dw,new ViewGroup.LayoutParams(240,400));
(new Thread(new Animationloop())).start();
}
public void updatePhysics() {
if(direction == true) {
if(x<= 130) {
x+=1;
y-=1;
}else if(x==131){
direction = false;
direction1=true;
}
}
if(direction1==true){
if(x<=230){
x+=1;
y+=1;
}else if(x==231){
direction1=false;
direction2=true;
}
}
if(direction2==true){
if(x>=131){
x-=1;
y+=1;
}else if(x==130){
direction2=false;
direction3=true;
}
}
if(direction3==true){
if(x>=30){
x-=1;
y-=1;
}else if(x==29){
direction3=false;
direction=true;
x = 30;
y = 230;
}
}
}
class DrawOval extends View {
//Canvas c;
//private ShapeDrawable shp;
private Bitmap bg = BitmapFactory.decodeResource(getResources(),R.drawable.bg2480x320);
private Bitmap bg1= Bitmap.createScaledBitmap(bg, 240, 320, true);
private Bitmap p1 = BitmapFactory.decodeResource(getResources(),R.drawable.egg);
private Bitmap egg = Bitmap.createScaledBitmap(p1, 10, 10, true);
private Bitmap pl1 =BitmapFactory.decodeResource(getResources(),R.drawable.egg1);
private Bitmap pl2 =BitmapFactory.decodeResource(getResources(),R.drawable.egg2);
private Bitmap pl11 = Bitmap.createScaledBitmap(pl1, 45,45, true);
private Bitmap pl22 = Bitmap.createScaledBitmap(pl2, 45,45, true);
public DrawOval(Context context) {
super(context);
}
//shp = new ShapeDrawable(new OvalShape());
//shp.getPaint().setColor(0xff74AC23);
//shp.setBounds(0, 0, 480, 360);
protected synchronized void onDraw(Canvas canvas) {
canvas.drawBitmap(bg1, new Rect(0,0,240,400), new Rect(0,0,240,400), new Paint());
canvas.drawBitmap(pl11,25,150,new Paint());
canvas.drawBitmap(pl22,165,150,new Paint());
canvas.drawBitmap(egg,200,200,new Paint());
canvas.drawBitmap(egg,x,y,new Paint());
//canvas.drawBitmap(p1, new Rect(0,0,100,100), new Rect(0,0,100,100), new Paint());
//canvas.drawColor(Color.BLUE);
//shp.draw(canvas);
invalidate();
}
}
class Animationloop implements Runnable {
@Override
public void run() {
while(true) {
while(running) {
try {
Thread.sleep(10);
}catch(InterruptedException e) {
System.out.println("-------InterruptedException-----"+e);
}
//dw.postInvalidate();
updatePhysics();
}
}
}
}
}
Ondraw/canvas method
package in.ram.JungleMayhem;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
public class JungleMayhem extends Activity {
//private Bitmap bg;
private DrawOval dw;
int x = 0;
int y = 100;
//private boolean start = true;
private boolean running = true;
private boolean direction = true;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bg1480x320);
//Bitmap bg= Bitmap.createScaledBitmap(mBitmap, 240, 320, true);
//int pic_width = mBitmap.getWidth();
//int pic_height = mBitmap.getHeight();
//ImageView img = new ImageView(this);
//img.setImageBitmap(bg);
//setContentView(img);
dw = new DrawOval(this);
setContentView(dw,new ViewGroup.LayoutParams(240,320));
(new Thread(new Animationloop())).start();
}
public void updatePhysics() {
if(direction == true) {
if(x<= 80) {
x+=1;
y-=1;
}
else if(x>80 && x<=100) {
y-=0;
x+=1;
}
else if(x>=100) {
y+=1;
x+=1;
}
}
if(x==200){
direction = false;
}
if(direction == false) {
//running = false;
if(x>=100) {
x-=1;
y-=1;
}
else if(x<=100 && x>=80) {
y-=0;
x-=1;
}
else if(x<=80) {
y+=1;
x-=1;
}
if(x == 50) {
direction = true;
}
}
}
class DrawOval extends View {
//Canvas c;
//private ShapeDrawable shp;
private Bitmap bg = BitmapFactory.decodeResource(getResources(),R.drawable.bg2480x320);
private Bitmap bg1= Bitmap.createScaledBitmap(bg, 240, 320, true);
private Bitmap p1 = BitmapFactory.decodeResource(getResources(),R.drawable.egg);
private Bitmap egg = Bitmap.createScaledBitmap(p1, 10, 10, true);
private Bitmap pl1 =BitmapFactory.decodeResource(getResources(),R.drawable.egg1);
private Bitmap pl2 =BitmapFactory.decodeResource(getResources(),R.drawable.egg2);
private Bitmap pl11 = Bitmap.createScaledBitmap(pl1, 45,45, true);
private Bitmap pl22 = Bitmap.createScaledBitmap(pl2, 45,45, true);
public DrawOval(Context context) {
super(context);
//shp = new ShapeDrawable(new OvalShape());
//shp.getPaint().setColor(0xff74AC23);
//shp.setBounds(0, 0, 480, 360);
}
protected synchronized void onDraw(Canvas canvas) {
canvas.drawBitmap(bg1, new Rect(0,0,240,320), new Rect(0,0,240,320), new Paint());
canvas.drawBitmap(pl11,25,150,new Paint());
canvas.drawBitmap(pl22,165,150,new Paint());
//canvas.drawBitmap(egg,200,200,new Paint());
canvas.drawBitmap(egg,x,y,new Paint());
//canvas.drawBitmap(p1, new Rect(0,0,100,100), new Rect(0,0,100,100), new Paint());
//canvas.drawColor(Color.BLUE);
//shp.draw(canvas);
invalidate();
}
}
class Animationloop implements Runnable {
@Override
public void run() {
while(true) {
while(running) {
try {
Thread.sleep(10);
}catch(InterruptedException e) {
System.out.println("-------InterruptedException-----"+e);
}
//dw.postInvalidate();
updatePhysics();
}
}
}
}
}
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
public class JungleMayhem extends Activity {
//private Bitmap bg;
private DrawOval dw;
int x = 0;
int y = 100;
//private boolean start = true;
private boolean running = true;
private boolean direction = true;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bg1480x320);
//Bitmap bg= Bitmap.createScaledBitmap(mBitmap, 240, 320, true);
//int pic_width = mBitmap.getWidth();
//int pic_height = mBitmap.getHeight();
//ImageView img = new ImageView(this);
//img.setImageBitmap(bg);
//setContentView(img);
dw = new DrawOval(this);
setContentView(dw,new ViewGroup.LayoutParams(240,320));
(new Thread(new Animationloop())).start();
}
public void updatePhysics() {
if(direction == true) {
if(x<= 80) {
x+=1;
y-=1;
}
else if(x>80 && x<=100) {
y-=0;
x+=1;
}
else if(x>=100) {
y+=1;
x+=1;
}
}
if(x==200){
direction = false;
}
if(direction == false) {
//running = false;
if(x>=100) {
x-=1;
y-=1;
}
else if(x<=100 && x>=80) {
y-=0;
x-=1;
}
else if(x<=80) {
y+=1;
x-=1;
}
if(x == 50) {
direction = true;
}
}
}
class DrawOval extends View {
//Canvas c;
//private ShapeDrawable shp;
private Bitmap bg = BitmapFactory.decodeResource(getResources(),R.drawable.bg2480x320);
private Bitmap bg1= Bitmap.createScaledBitmap(bg, 240, 320, true);
private Bitmap p1 = BitmapFactory.decodeResource(getResources(),R.drawable.egg);
private Bitmap egg = Bitmap.createScaledBitmap(p1, 10, 10, true);
private Bitmap pl1 =BitmapFactory.decodeResource(getResources(),R.drawable.egg1);
private Bitmap pl2 =BitmapFactory.decodeResource(getResources(),R.drawable.egg2);
private Bitmap pl11 = Bitmap.createScaledBitmap(pl1, 45,45, true);
private Bitmap pl22 = Bitmap.createScaledBitmap(pl2, 45,45, true);
public DrawOval(Context context) {
super(context);
//shp = new ShapeDrawable(new OvalShape());
//shp.getPaint().setColor(0xff74AC23);
//shp.setBounds(0, 0, 480, 360);
}
protected synchronized void onDraw(Canvas canvas) {
canvas.drawBitmap(bg1, new Rect(0,0,240,320), new Rect(0,0,240,320), new Paint());
canvas.drawBitmap(pl11,25,150,new Paint());
canvas.drawBitmap(pl22,165,150,new Paint());
//canvas.drawBitmap(egg,200,200,new Paint());
canvas.drawBitmap(egg,x,y,new Paint());
//canvas.drawBitmap(p1, new Rect(0,0,100,100), new Rect(0,0,100,100), new Paint());
//canvas.drawColor(Color.BLUE);
//shp.draw(canvas);
invalidate();
}
}
class Animationloop implements Runnable {
@Override
public void run() {
while(true) {
while(running) {
try {
Thread.sleep(10);
}catch(InterruptedException e) {
System.out.println("-------InterruptedException-----"+e);
}
//dw.postInvalidate();
updatePhysics();
}
}
}
}
}
Wednesday, March 9, 2011
Android Record/play
http://www.hascode.com/2010/05/sensor-fun-creating-a-simple-audio-recorderplayer/
Android Links
http://www.droidnova.com/2d-sprite-animation-in-android,471.html
http://www.deitel.com/ResourceCenters/Programming/Android/Animation/tabid/3554/Default.aspx
http://www.hascode.com/2010/05/sensor-fun-location-based-services-and-gps-for-android
/http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/
http://developerlife.com/tutorials/?p=343
http://www.deitel.com/ResourceCenters/Programming/Android/Animation/tabid/3554/Default.aspx
http://www.hascode.com/2010/05/sensor-fun-location-based-services-and-gps-for-android
/http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/
http://developerlife.com/tutorials/?p=343
Sunday, March 6, 2011
All Type Parser
Parser:1
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
public class Team {
private String teamname="";
private String teamflag="";
private String innings="";
List nodeList = new ArrayList();
public String getinnings(){
return innings;
}
public String getteamname(){
return teamname;
}
public String getteamflag(){
return teamflag;
}
public void setinnings(String innings){
this.innings=innings;
}
public void setteamflag(String teamflag){
this.teamflag=teamflag;
}
public void setteamname(String teamname){
this.teamname=teamname;
}
public List getNodeList(){
return nodeList;
}
public void setNode(node node){
this.nodeList.add(node);
}
public class node{
private String name="";
private String url="";
private String image="";
private String thum="";
public void setname(String name){
this.name=name;
}
public void seturl(String url){
this.url=url;
}
public String getname(){
return name;
}
public String geturl(){
return url;
}
public void setimage(String image){
this.image=image;
}
public String getimage(){
return image;
}
public String getthum(){
return thum;
}
public void setthum(String thum){
this.thum=thum;
}
}
}
parser:1
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import com.ram.parser.Team.node;
import android.util.Log;
import android.util.Xml;
public class live_battingXMLParser extends BaseFeedParser {
ParserCallback callback;
public live_battingXMLParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List messages = null;
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
int eventType = parser.getEventType();
Team currentMessage = null;
node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList();
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("team")){
currentMessage = new Team();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("teamname")){
currentMessage.setteamname(parser.nextText());
}else if (name.equalsIgnoreCase("inning")){
currentMessage.setinnings(parser.nextText());
}
}if (name.equalsIgnoreCase("node")){
currentNode = currentMessage.new node();
}else if (currentNode != null){
if (name.equalsIgnoreCase("name")){
currentNode.setname(parser.nextText());
}else if(name.equalsIgnoreCase("url")){
currentNode.seturl(parser.nextText());
}else if(name.equalsIgnoreCase("matchid")){
currentNode.setimage(parser.nextText());
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("node") && currentNode != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("team") && currentMessage != null){
messages.add(currentMessage);
}
else if(name.equalsIgnoreCase("xml")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishLive(messages);
keepGoing = false;
}
}
}.start();
}
@Override
public List parse() {
// TODO Auto-generated method stub
return null;
}
}
paser:3
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import com.ram.parser.Team.node;
import android.util.Log;
import android.util.Xml;
public class thum_PhotoParser extends BaseFeedParser {
ParserCallback callback;
public thum_PhotoParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List messages = null;
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
System.out.println("Parser Data--------------\n------"+parser.getText());
int eventType = parser.getEventType();
Team currentMessage = null;
node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList();
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("flipbooks")){
currentMessage = new Team();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("flipbook")){
currentMessage.setinnings(parser.getAttributeValue(0));
currentMessage.setteamname(parser.getAttributeValue(1));
}
}
{
if (name.equalsIgnoreCase("flip")){
currentNode = currentMessage.new node();
}else if (currentNode != null){
if (name.equalsIgnoreCase("caption")){
currentNode.setthum(parser.nextText());
}else if (name.equalsIgnoreCase("image")){
currentNode.setname(parser.getAttributeValue(0));
currentNode.seturl(parser.getAttributeValue(1));
}
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("flip") && currentNode != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("flipbook") && currentMessage != null){
messages.add(currentMessage);
}else if(name.equalsIgnoreCase("content")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishLive(messages);
keepGoing = false;
}
}
}.start();
}
@Override
public List parse() {
// TODO Auto-generated method stub
return null;
}
}
Parser:4
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import android.util.Log;
import android.util.Xml;
public class SplashScreenXmlParser extends BaseFeedParser {
ParserCallback callback;
String[] head;
public SplashScreenXmlParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List messages = null;
List newsMessage=null;
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
System.out.println("Parser Data--------------\n------"+parser.getText());
int eventType = parser.getEventType();
head=new String[3];
splash currentMessage = null;
message currentNewsNode=null;
com.ram.parser.splash.node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList();
newsMessage=new ArrayList();
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("livematch_score")){
currentMessage = new splash();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("teams")){
currentMessage.setteams(parser.nextText());
}else if (name.equalsIgnoreCase("status")){
currentMessage.setstatus(parser.nextText());
}else if (name.equalsIgnoreCase("clickurl")){
currentMessage.setclickurl(parser.nextText());
}else if (name.equalsIgnoreCase("smallteams")){
currentMessage.setsmallteam(parser.nextText());
}
}
if (name.equalsIgnoreCase("inng")){
currentNode = currentMessage.new node();
} else if (currentNode != null){
if (name.equalsIgnoreCase("type")){
currentNode.settype(parser.nextText());
}else if(name.equalsIgnoreCase("team")){
currentNode.setteam(parser.nextText());
}else if(name.equalsIgnoreCase("score")){
currentNode.setscore(parser.nextText());
}else if(name.equalsIgnoreCase("overs")){
currentNode.setovers(parser.nextText());
}else if(name.equalsIgnoreCase("wickets")){
currentNode.setwicket(parser.nextText());
}
}
if (name.equalsIgnoreCase("node")){
currentNewsNode = new message();
}else if (currentNewsNode != null){
if(name.equalsIgnoreCase("thumbnail")){
currentNewsNode.setthumbnail(parser.nextText());
}else if(name.equalsIgnoreCase("headline")){
currentNewsNode.setheadline(parser.nextText());
}else if(name.equalsIgnoreCase("story_id")){
currentNewsNode.setcontain_id(parser.nextText());
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("inng") && currentMessage != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("livematch_score") && currentMessage != null){
messages.add(currentMessage);
}else if (name.equalsIgnoreCase("node") && currentNewsNode != null){
newsMessage.add(currentNewsNode);
}else if(name.equalsIgnoreCase("xml")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishSplesh(messages, newsMessage);
keepGoing = false;
}
}
}.start();
}
@Override
public List parse() {
// TODO Auto-generated method stub
return null;
}
}
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
public class Team {
private String teamname="";
private String teamflag="";
private String innings="";
List
public String getinnings(){
return innings;
}
public String getteamname(){
return teamname;
}
public String getteamflag(){
return teamflag;
}
public void setinnings(String innings){
this.innings=innings;
}
public void setteamflag(String teamflag){
this.teamflag=teamflag;
}
public void setteamname(String teamname){
this.teamname=teamname;
}
public List
return nodeList;
}
public void setNode(node node){
this.nodeList.add(node);
}
public class node{
private String name="";
private String url="";
private String image="";
private String thum="";
public void setname(String name){
this.name=name;
}
public void seturl(String url){
this.url=url;
}
public String getname(){
return name;
}
public String geturl(){
return url;
}
public void setimage(String image){
this.image=image;
}
public String getimage(){
return image;
}
public String getthum(){
return thum;
}
public void setthum(String thum){
this.thum=thum;
}
}
}
parser:1
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import com.ram.parser.Team.node;
import android.util.Log;
import android.util.Xml;
public class live_battingXMLParser extends BaseFeedParser {
ParserCallback callback;
public live_battingXMLParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
int eventType = parser.getEventType();
Team currentMessage = null;
node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("team")){
currentMessage = new Team();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("teamname")){
currentMessage.setteamname(parser.nextText());
}else if (name.equalsIgnoreCase("inning")){
currentMessage.setinnings(parser.nextText());
}
}if (name.equalsIgnoreCase("node")){
currentNode = currentMessage.new node();
}else if (currentNode != null){
if (name.equalsIgnoreCase("name")){
currentNode.setname(parser.nextText());
}else if(name.equalsIgnoreCase("url")){
currentNode.seturl(parser.nextText());
}else if(name.equalsIgnoreCase("matchid")){
currentNode.setimage(parser.nextText());
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("node") && currentNode != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("team") && currentMessage != null){
messages.add(currentMessage);
}
else if(name.equalsIgnoreCase("xml")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishLive(messages);
keepGoing = false;
}
}
}.start();
}
@Override
public List
// TODO Auto-generated method stub
return null;
}
}
paser:3
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import com.ram.parser.Team.node;
import android.util.Log;
import android.util.Xml;
public class thum_PhotoParser extends BaseFeedParser {
ParserCallback callback;
public thum_PhotoParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
System.out.println("Parser Data--------------\n------"+parser.getText());
int eventType = parser.getEventType();
Team currentMessage = null;
node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("flipbooks")){
currentMessage = new Team();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("flipbook")){
currentMessage.setinnings(parser.getAttributeValue(0));
currentMessage.setteamname(parser.getAttributeValue(1));
}
}
{
if (name.equalsIgnoreCase("flip")){
currentNode = currentMessage.new node();
}else if (currentNode != null){
if (name.equalsIgnoreCase("caption")){
currentNode.setthum(parser.nextText());
}else if (name.equalsIgnoreCase("image")){
currentNode.setname(parser.getAttributeValue(0));
currentNode.seturl(parser.getAttributeValue(1));
}
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("flip") && currentNode != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("flipbook") && currentMessage != null){
messages.add(currentMessage);
}else if(name.equalsIgnoreCase("content")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishLive(messages);
keepGoing = false;
}
}
}.start();
}
@Override
public List
// TODO Auto-generated method stub
return null;
}
}
Parser:4
package com.ram.parser;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import android.util.Log;
import android.util.Xml;
public class SplashScreenXmlParser extends BaseFeedParser {
ParserCallback callback;
String[] head;
public SplashScreenXmlParser(String feedUrl) {
super(feedUrl);
}
public void parse(final ParserCallback callback) {
this.callback = callback;
new Thread(){
@Override
public void run(){
boolean keepGoing = true;
while(keepGoing){
List
List
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(getInputStream(), null);
System.out.println("Parser Data--------------\n------"+parser.getText());
int eventType = parser.getEventType();
head=new String[3];
splash currentMessage = null;
message currentNewsNode=null;
com.ram.parser.splash.node currentNode = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList
newsMessage=new ArrayList
break;
case XmlPullParser.START_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("livematch_score")){
currentMessage = new splash();
} else if (currentMessage != null){
if (name.equalsIgnoreCase("teams")){
currentMessage.setteams(parser.nextText());
}else if (name.equalsIgnoreCase("status")){
currentMessage.setstatus(parser.nextText());
}else if (name.equalsIgnoreCase("clickurl")){
currentMessage.setclickurl(parser.nextText());
}else if (name.equalsIgnoreCase("smallteams")){
currentMessage.setsmallteam(parser.nextText());
}
}
if (name.equalsIgnoreCase("inng")){
currentNode = currentMessage.new node();
} else if (currentNode != null){
if (name.equalsIgnoreCase("type")){
currentNode.settype(parser.nextText());
}else if(name.equalsIgnoreCase("team")){
currentNode.setteam(parser.nextText());
}else if(name.equalsIgnoreCase("score")){
currentNode.setscore(parser.nextText());
}else if(name.equalsIgnoreCase("overs")){
currentNode.setovers(parser.nextText());
}else if(name.equalsIgnoreCase("wickets")){
currentNode.setwicket(parser.nextText());
}
}
if (name.equalsIgnoreCase("node")){
currentNewsNode = new message();
}else if (currentNewsNode != null){
if(name.equalsIgnoreCase("thumbnail")){
currentNewsNode.setthumbnail(parser.nextText());
}else if(name.equalsIgnoreCase("headline")){
currentNewsNode.setheadline(parser.nextText());
}else if(name.equalsIgnoreCase("story_id")){
currentNewsNode.setcontain_id(parser.nextText());
}
}
break;
case XmlPullParser.END_TAG:
name = parser.getName();
if (name.equalsIgnoreCase("inng") && currentMessage != null){
currentMessage.setNode(currentNode);
}else if (name.equalsIgnoreCase("livematch_score") && currentMessage != null){
messages.add(currentMessage);
}else if (name.equalsIgnoreCase("node") && currentNewsNode != null){
newsMessage.add(currentNewsNode);
}else if(name.equalsIgnoreCase("xml")){
done = true;
}
break;
}
eventType = parser.next();
}
} catch (Exception e) {
Log.e("Error Mian PullFeedParser", e.getMessage(), e);
//throw new RuntimeException(e);
}
//return messages;
System.out.println("Pass ctrl 2 Main");
callback.parseDidFinishSplesh(messages, newsMessage);
keepGoing = false;
}
}
}.start();
}
@Override
public List
// TODO Auto-generated method stub
return null;
}
}
Subscribe to:
Posts (Atom)