Monday 31 October 2011

splash2.xml


<?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost">

<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/bottombar" android:layout_height="wrap_content">
<LinearLayout android:id="@+id/layouttab"
android:layout_centerHorizontal="true" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">


<TabWidget android:id="@android:id/tabs"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="wrap_content">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_weight="1" android:layout_height="fill_parent"
android:layout_width="wrap_content"></FrameLayout>
</TabWidget>


</LinearLayout>


<RelativeLayout android:id="@+id/mainscreen"
android:background="@drawable/secondimage" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="90dp" android:text="shop"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/b1" />
<Button android:layout_width="90dp" android:text="our specials"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/b2" />
<Button android:layout_width="90dp" android:text="printers"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/b3" />
<Button android:layout_width="90dp" android:text="copiers"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/b4" />
<Button android:layout_width="90dp" android:text="cash register"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/b5" />


</RelativeLayout>


</RelativeLayout>






</TabHost>

MainScreen.java =>dynamically adjusting height,width of widget


package com.OfficeDepot;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;

public class MainScreen extends TabActivity implements OnClickListener {

protected boolean _active = true;
protected int _splashTime = 3000;
static TabHost tabHost;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash2);

RelativeLayout main = (RelativeLayout) findViewById(R.id.mainscreen);
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();
LayoutParams l = main.getLayoutParams();

l.width = width;
if (height == 320) {
l.height = (int) (height * 0.75);
} else {
l.height = (int) (height * 0.80);
}
main.setLayoutParams(l);

main.setOnClickListener(this);
RelativeLayout.LayoutParams layout1 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if (height == 800) {
layout1.height = 110;
layout1.width = 100;
layout1.setMargins(205, 95, 0, 0);

} else if (height == 854) {
layout1.height = 125;
layout1.width = 110;
layout1.setMargins(205, 95, 0, 0);

} else if (height == 432) {
layout1.width = 53;
layout1.height = 65;
layout1.setMargins(100, 45, 0, 0);
} else if (height == 400) {
layout1.width = 53;
layout1.height = 65;
layout1.setMargins(100, 40, 0, 0);
}

else {
layout1.width = 50;
layout1.height = 50;
layout1.setMargins(100, 30, 0, 0);

}
RelativeLayout.LayoutParams layout2 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if (height == 800) {
layout2.height = 110;
layout2.width = 100;
layout2.setMargins(30, 200, 0, 0);

} else if (height == 854) {
layout2.height = 125;
layout2.width = 110;
layout2.setMargins(30, 210, 0, 0);

}

else if (height == 432) {
layout2.width = 53;
layout2.height = 65;
layout2.setMargins(15, 106, 0, 0);
} else if (height == 400) {
layout2.width = 53;
layout2.height = 65;
layout2.setMargins(15, 100, 0, 0);
} else {
layout2.width = 50;
layout2.height = 50;
layout2.setMargins(15, 65, 0, 0);

}
RelativeLayout.LayoutParams layout3 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if (height == 800) {
layout3.height = 110;
layout3.width = 100;
layout3.setMargins(350, 210, 0, 0);

} else if (height == 854) {
layout3.height = 125;
layout3.width = 110;
layout3.setMargins(350, 220, 0, 0);

} else if (height == 432) {
layout3.width = 53;
layout3.height = 65;
layout3.setMargins(170, 113, 0, 0);
} else if (height == 400) {
layout3.width = 53;
layout3.height = 65;
layout3.setMargins(170, 107, 0, 0);
} else {
layout3.width = 50;
layout3.height = 50;
layout3.setMargins(170, 80, 0, 0);

}
RelativeLayout.LayoutParams layout4 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if (height == 800) {
layout4.height = 110;
layout4.width = 100;
layout4.setMargins(65, 425, 0, 0);

} else if (height == 854) {
layout4.height = 125;
layout4.width = 110;
layout4.setMargins(65, 450, 0, 0);

} else if (height == 432) {
layout4.width = 53;
layout4.height = 63;
layout4.setMargins(35, 226, 0, 0);
} else if (height == 400) {
layout4.width = 53;
layout4.height = 63;
layout4.setMargins(35, 210, 0, 0);
} else {
layout4.width = 50;
layout4.height = 50;
layout4.setMargins(35, 160, 0, 0);

}
RelativeLayout.LayoutParams layout5 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if (height == 800) {
layout5.height = 110;
layout5.width = 100;
layout5.setMargins(300, 435, 0, 0);

} else if (height == 854) {
layout5.height = 125;
layout5.width = 110;
layout5.setMargins(300, 460, 0, 0);

} else if (height == 432) {
layout5.width = 53;
layout5.height = 63;
layout5.setMargins(151, 232, 0, 0);

} else if (height == 400) {
layout5.width = 53;
layout5.height = 63;
layout5.setMargins(151, 218, 0, 0);

} else {
layout5.width = 50;
layout5.height = 50;
layout5.setMargins(155, 160, 0, 0);

}

final Button shop = (Button) this.findViewById(R.id.b1);
final Button specials = (Button) this.findViewById(R.id.b2);
final Button printers = (Button) this.findViewById(R.id.b3);
final Button copiers = (Button) this.findViewById(R.id.b4);
final Button cashregister = (Button) this.findViewById(R.id.b5);
final RelativeLayout mainscreen = (RelativeLayout) this
.findViewById(R.id.mainscreen);
mainscreen.removeAllViews();
mainscreen.addView(shop, layout1);
mainscreen.addView(specials, layout2);
mainscreen.addView(printers, layout3);
mainscreen.addView(copiers, layout4);
mainscreen.addView(cashregister, layout5);

shop.setOnClickListener(this);
specials.setOnClickListener(this);
printers.setOnClickListener(this);
copiers.setOnClickListener(this);
cashregister.setOnClickListener(this);
tabHost = getTabHost();

LayoutInflater.from(this).inflate(R.layout.tabs1,
tabHost.getTabContentView(), true);

tabHost.addTab(tabHost
.newTabSpec("tab1")
.setIndicator("tab1",
getResources().getDrawable(R.drawable.settings))
.setContent(R.id.view1));
tabHost.addTab(tabHost
.newTabSpec("tab3")
.setIndicator("tab2",
getResources().getDrawable(R.drawable.mainimage))
.setContent(R.id.view2));
tabHost.addTab(tabHost
.newTabSpec("tab3")
.setIndicator("tab3",
getResources().getDrawable(R.drawable.wishlist))
.setContent(R.id.view3));
tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("tab4")
.setContent(R.id.view3));
tabHost.getTabWidget().getChildAt(4).setVisibility(4);

getTabWidget().getChildAt(1).setOnClickListener(
new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent;
if (flag.counter_islogin == 0) {
intent = new Intent(MainScreen.this,
LoginActivity.class);
} else {
intent = new Intent(MainScreen.this,
LogoutActivity.class);
}
flag.count_login = 0;

flag.flag_mainscreen = true;
MainScreen.this.finish();
startActivity(intent);
}
});
getTabWidget().getChildAt(3).setOnClickListener(
new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent;
if ((flag.flag_wishlistdelete == false)
|| (LoginActivity.flag_login == false)
|| (flag.counter_islogin == 0)) {
intent = new Intent(MainScreen.this,
wishlistActivity.class);
} else {
intent = new Intent(MainScreen.this,
wishlistdeleteActivity.class);
}
flag.count_wishlist = 0;
flag.flag_mainscreen_wish = true;
MainScreen.this.finish();
startActivity(intent);
}
});

}

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if (arg0.getId() == R.id.b1) {
Intent intent = new Intent(MainScreen.this,
MainCategoryActivity.class);
flag.maincatfromwebservice = 1;
startActivity(intent);
} else if (arg0.getId() == R.id.b2) {
Intent m = new Intent(MainScreen.this, SubCategoriesActivity.class);
flag.subcatfromwebservice = 1;
m.putExtra("CategoryID", "1424");
m.putExtra("Name", "Specials");
m.putExtra("MappedParentCategoryID", "0");
startActivity(m);
} else if (arg0.getId() == R.id.b3) {
Intent m = new Intent(MainScreen.this, SubCategoriesActivity.class);
flag.subcatfromwebservice = 1;
m.putExtra("CategoryID", "1420");
m.putExtra("Name", "Printers");
m.putExtra("MappedParentCategoryID", "0");
startActivity(m);
} else if (arg0.getId() == R.id.b4) {
Intent m = new Intent(MainScreen.this, SubCategoriesActivity.class);
flag.subcatfromwebservice = 1;
m.putExtra("CategoryID", "1406");
m.putExtra("Name", "Copiers");
m.putExtra("MappedParentCategoryID", "0");
startActivity(m);
} else if (arg0.getId() == R.id.b5) {
Intent m = new Intent(MainScreen.this, SubCategoriesActivity.class);
flag.subcatfromwebservice = 1;
m.putExtra("CategoryID", "1403");
m.putExtra("Name", "Cash Registers");
m.putExtra("MappedParentCategoryID", "0");
startActivity(m);
}

}

}

flag.java


package com.OfficeDepot;

public class flag {

public static boolean flag_mainscreen = false, flag_maincategory = false,
flag_subcategories = false, flag_product = false,
flag_productdetail = false;

public static boolean flag_mainscreen_wish = false,
flag_maincategory_wish = false, flag_subcategories_wish = false,
flag_product_wish = false, flag_productdetail_wish = false;
public static int count_login = 0, count_wishlist = 0, counter_islogin = 0;
public static int product_add_delete = 1,
maincatfromwebservice = 1, subcatfromwebservice = 1,
productfromwebservice = 1, productdetailfromwebservice = 1;

public static boolean flag_wishlistdelete = false;
public static int flag_dialog=1;

}

Sunday 30 October 2011

deletewishlist.xml


<?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:gravity="center" android:id="@+id/topbar"
android:layout_height="wrap_content" android:layout_gravity="center"
android:background="@drawable/mainheading">
<Button android:layout_width="wrap_content" android:text="done"
android:background="@drawable/icon" android:layout_height="wrap_content"
android:layout_margin="5dip" android:id="@+id/done" />
<TextView android:layout_width="fill_parent" android:id="@+id/top_text"
android:textStyle="bold" android:textSize="17sp" android:gravity="center"
android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/back" android:text="Wishlist" />
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/bottombar" android:layout_height="wrap_content">
<LinearLayout android:id="@+id/layouttab"
android:layout_centerHorizontal="true" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">

<!-- Button android:id="@+id/btn1" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="btn1" /> <Button android:id="@+id/btn2"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="btn2" /> <Button android:id="@+id/btn3" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="btn3" / -->
<TabWidget android:id="@android:id/tabs"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="wrap_content">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_weight="1" android:layout_height="fill_parent"
android:layout_width="wrap_content"></FrameLayout>
</TabWidget>
</LinearLayout>
<ListView android:layout_width="fill_parent"
android:focusable="false" android:fadingEdge="none"
android:layout_below="@id/topbar" android:id="@+id/wishlist"
android:layout_height="wrap_content"></ListView>

</RelativeLayout>
</LinearLayout>
</TabHost>

customwishdelete.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainlayout"
android:layout_weight="1" android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:layout_width="wrap_content" android:background="@drawable/icon"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/show_delete" android:layout_gravity="center_vertical"
android:gravity="center_vertical" />
<LinearLayout android:id="@+id/sublayout"
android:orientation="horizontal" android:layout_width="200dp"
android:layout_height="wrap_content">
<ImageView android:id="@+id/productimage"
android:layout_width="105dp" android:layout_height="105dp">
</ImageView>
<LinearLayout android:id="@+id/textlayout"
android:layout_gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="10dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:id="@+id/productname" android:singleLine="true"
android:gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</TextView>
<LinearLayout android:id="@+id/bottomlayout"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/price" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="left"
android:gravity="left">
</TextView>
<TextView android:id="@+id/quantity" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginLeft="30dp">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Button android:layout_width="wrap_content" android:background="@drawable/icon"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/delete" android:visibility="invisible"
android:gravity="center_vertical" android:layout_gravity="center_vertical" />
</LinearLayout>

registration.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/linearlayout_top"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="fill_parent"
android:gravity="center" android:id="@+id/topbar"
android:layout_height="wrap_content" android:layout_gravity="center"
android:background="@drawable/mainheading">
<Button android:layout_width="wrap_content" android:background="@drawable/back"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/back" />
<TextView android:layout_width="fill_parent" android:text="Registration"
android:id="@+id/top_text" android:textStyle="bold" android:textSize="20sp"
android:gravity="center" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_alignBottom="@+id/back" />
</RelativeLayout>

<LinearLayout android:id="@+id/LinearLayout_data"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">



<LinearLayout android:id="@+id/linearlayout_firstname"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_firstname" android:textSize="14sp"
android:layout_width="125dp" android:layout_height="wrap_content"
android:text="First Name:">
</TextView>
<EditText android:id="@+id/edit_firstname" android:singleLine="true"
android:layout_marginRight="10dip" android:layout_marginLeft="15dp"
android:layout_width="fill_parent" android:layout_height="45dp"
android:text="" android:textSize="14sp">
</EditText>
</LinearLayout>

<LinearLayout android:id="@+id/linearlayout_lastname"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_lastname" android:textSize="14sp"
android:layout_width="125dp" android:layout_height="wrap_content"
android:text="Last Name:">
</TextView>
<EditText android:id="@+id/edit_lastname" android:singleLine="true"
android:layout_marginRight="10dip" android:layout_marginLeft="15dp"
android:layout_width="fill_parent" android:layout_height="45dp"
android:text="" android:textSize="14sp">
</EditText>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_email"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_email" android:textSize="14sp"
android:layout_width="125dp" android:layout_height="wrap_content"
android:text="Email:">
</TextView>
<EditText android:id="@+id/edit_email" android:singleLine="true"
android:layout_marginRight="10dip" android:layout_marginLeft="15dp"
android:layout_width="fill_parent" android:layout_height="45dp"
android:text="" android:textSize="14sp">
</EditText>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_phone"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_phone" android:textSize="14sp"
android:layout_width="125dp" android:layout_height="wrap_content"
android:text="Phone:">
</TextView>
<EditText android:id="@+id/edit_phone" android:phoneNumber="true"
android:layout_marginRight="10dip" android:layout_marginLeft="15dp"
android:layout_width="fill_parent" android:layout_height="45dp"
android:text="" android:textSize="14sp" android:singleLine="true">
</EditText>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_password"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_password" android:textSize="14sp"
android:layout_width="125dp" android:layout_height="wrap_content"
android:text="Password:">
</TextView>
<EditText android:id="@+id/edit_password" android:password="true"
android:layout_marginRight="10dip" android:layout_marginLeft="15dp"
android:layout_width="fill_parent" android:layout_height="45dp"
android:text="" android:textSize="14sp" android:singleLine="true">
</EditText>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_confirmpassword"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="45dp">
<TextView android:id="@+id/text_confirmpassword"
android:textSize="14sp" android:layout_width="125dp"
android:layout_height="wrap_content" android:text="Confirm Password:">
</TextView>
<EditText android:id="@+id/edit_confirmpassword" android:singleLine="true"
android:password="true" android:layout_marginRight="10dip"
android:layout_marginLeft="15dp" android:layout_width="fill_parent"
android:layout_height="45dp" android:text="" android:textSize="14sp">
</EditText>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_button"
android:gravity="center" android:layout_gravity="center"
android:layout_width="fill_parent" android:layout_height="45dp">
<Button android:id="@+id/send" android:layout_width="85dp"
android:layout_marginLeft="20dp" android:layout_height="wrap_content"
android:text="" android:layout_gravity="center" android:background="@drawable/finish">
</Button>
</LinearLayout>
</LinearLayout>

</LinearLayout>

RegistrationActivity.java for registration which uses file validate.java


package com.OfficeDepot;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegistrationActivity extends Activity {

EditText password, firstname, lastname, email, phone, confirm_password;
int[] flag;

private Button finish;

// Back Button

private Button back;
private TextView top_text;
AlertDialog alertDialog;
@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.registration);

top_text = (TextView) findViewById(R.id.top_text);
top_text.setText("Registration");

back = (Button) findViewById(R.id.back);

confirm_password = (EditText) findViewById(R.id.edit_confirmpassword);
password = (EditText) findViewById(R.id.edit_password);
firstname = (EditText) findViewById(R.id.edit_firstname);
lastname = (EditText) findViewById(R.id.edit_lastname);
email = (EditText) findViewById(R.id.edit_email);
phone = (EditText) findViewById(R.id.edit_phone);

finish = (Button) findViewById(R.id.send);

flag = new int[6];
for (int i = 0; i < 6; i++) {
flag[i] = 0;
}
alertDialog = new AlertDialog.Builder(
RegistrationActivity.this).create();
alertDialog.setTitle("");

finish.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

if (Validate.Check_Lengh(firstname)) {

alertDialog.setMessage("Enter FirstName.");
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {

// here you can add functions

}
});
alertDialog.show();
} else {
flag[0] = 1;
if (Validate.Check_Lengh(lastname)) {

alertDialog.setMessage("Enter LastName.");
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {

// here you can add
// functions

}
});
alertDialog.show();
} else {
flag[1] = 1;
if (Validate.Check_Lengh(email)) {

alertDialog.setMessage("Enter Email.");
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here you can
// add functions

}
});
alertDialog.show();
} else {
if (Validate.checkEmail(email) == false) {
alertDialog.setMessage("Enter Valid Email.");
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();

} else {
Log.v("log_tag", "Else not proper");
flag[2] = 1;
if (Validate.Check_Lengh(phone)) {

alertDialog.setMessage("Enter Phone.");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();
} else {
if (phone.getText().toString().length() != 10) {

alertDialog
.setMessage("Enter Valid Phone.");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();
} else {

if (phone.getText().toString()
.contains("-")
|| phone.getText().toString()
.contains("+")
|| phone.getText().toString()
.contains("*")
|| phone.getText().toString()
.contains("#")
|| phone.getText().toString()
.contains("/")) {

alertDialog
.setMessage("Enter Valid Phone.");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();
} else {
flag[3] = 1;
if (Validate.Check_Lengh(password)) {

//
alertDialog
.setMessage("Enter Password");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

}
});
alertDialog.show();

}

else {

if (password.getText()
.toString().length() < 6) {
alertDialog
.setMessage("Password must be 6 characters long");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();

}

else {
flag[4] = 1;
if (Validate
.Check_Lengh(confirm_password)) {

alertDialog
.setMessage("Enter Password again to confirm");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

}
});
alertDialog.show();

} else {

if (confirm_password
.getText()
.toString()
.length() < 6) {
alertDialog
.setMessage("Password must be 6 characters long");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();
} else if (!(confirm_password
.getText()
.toString()
.equals(password
.getText()
.toString()))) {
alertDialog
.setMessage("Enter the Same Password Again ");
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();

} else {
flag[5] = 1;

}
}
}
}
}
}
}
}
}
}
}
if (flag[5] == 1) {
Log.e("log_tag", "All Data Final");
doRegistration();

}

}

});

}

public void doRegistration() {

PropertyInfo p[] = new PropertyInfo[7];
p[0] = new PropertyInfo();

p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("FirstName");
p[0].setValue(firstname.getText().toString());

p[1] = new PropertyInfo();

p[1].type = PropertyInfo.STRING_CLASS;
p[1].setName("LastName");
p[1].setValue(lastname.getText().toString());

p[2] = new PropertyInfo();

p[2].type = PropertyInfo.STRING_CLASS;
p[2].setName("Email");
p[2].setValue(email.getText().toString());

p[3] = new PropertyInfo();

p[3].type = PropertyInfo.STRING_CLASS;
p[3].setName("Phone");
p[3].setValue(phone.getText().toString());

p[4] = new PropertyInfo();

p[4].type = PropertyInfo.STRING_CLASS;
p[4].setName("Password");
p[4].setValue(password.getText().toString());

p[5] = new PropertyInfo();

p[5].type = PropertyInfo.STRING_CLASS;
p[5].setName("StoreID");
p[5].setValue(15);
p[6] = new PropertyInfo();

p[6].type = PropertyInfo.INTEGER_CLASS;
p[6].setName("Mode");
p[6].setValue(1);

SoapObject Soapresponse = Ksoap
.CallService("Iphone_Registration", 7, p);

// if (Soapresponse != null) {
// SoapObject Soapresult = (SoapObject) Soapresponse.getProperty(0);
// if (Soapresult != null) {
// Dataset = (SoapObject) Soapresult.getProperty(1);
// if (Dataset != null) {
// Table = (SoapObject) Dataset.getProperty(0);
// }
// }
String result = Soapresponse.getProperty("Iphone_RegistrationResult").toString();

//Log.e("soap result", Soapresponse.toString());
alertDialog
.setMessage(""+result);
alertDialog
.setButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {

// here
// you
// can
// add
// functions

}
});
alertDialog.show();

}

}

Validate.java for E-mail validation


package com.OfficeDepot;

import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.util.Log;
import android.widget.EditText;

public class Validate {

public static boolean Check_Lengh(EditText editText) {

boolean validated = false;

String text = editText.getText().toString().trim();

if (text.length() == 0) {
editText.setText(text);
validated = true;
}

return validated;
}

public static boolean isEqual(EditText edittext1, EditText edittext2) {

boolean validated = false;

String text1 = edittext1.getText().toString().trim();
String text2 = edittext2.getText().toString().trim();

if (text1.equalsIgnoreCase(text2)) {
validated = true;
}

return validated;
}

public static boolean checkEmail(EditText inputMail) {
boolean validated;

Pattern p = Pattern.compile(".+@.+\\.[a-z]+");

Matcher m = p.matcher(inputMail.getText());

boolean matchFound = m.matches();

StringTokenizer st = new StringTokenizer(inputMail.toString(), ".");
String lastToken = null;
while (st.hasMoreTokens()) {
lastToken = st.nextToken();
}

if (matchFound && lastToken.length() >= 2
&& inputMail.length() - 1 != lastToken.length()) {

// validate the country code
validated = true;
} else
validated = false;

Log.v("log_tag", "on " + validated);

return validated;
}

}

wishlistdeleteActivity.java for displaying data using handler


package com.OfficeDepot;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import org.apache.http.util.ByteArrayBuffer;
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.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TextView;

public class wishlistdeleteActivity extends TabActivity {
/** Called when the activity is first created. */

ProgressDialog dialog;

String[] Quantity, Price, ProductName, ImageName;
Bitmap[] bmp;
ByteArrayBuffer baf;
int index = 0;
int total_data;
static TabHost tabHost;

ListView wishlist;
String CategoryID, ProductID, MappedParentCategoryID, Name, result;

String[] ProductID_wishlist;
String ProductID_final;
AlertDialog alertDialog;
int count;
SharedPreferences.Editor editor;
public static final String PREFS_COUNT = "MyPrefsFile";
public ImageLoader1 imageLoader;
private static LayoutInflater inflater = null;
String[] Image_Path;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

alertDialog = new AlertDialog.Builder(wishlistdeleteActivity.this)
.create();
alertDialog.setTitle("");
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.deletewishlist);
flag.flag_wishlistdelete = true;

Bundle extras = getIntent().getExtras();
if (extras != null) {
// CategoryID = extras.getString("CategoryID");
// ProductID = extras.getString("ProductID");
// MappedParentCategoryID =
// extras.getString("MappedParentCategoryID");
CategoryID = extras.getString("CategoryID");
ProductID = extras.getString("ProductID");
MappedParentCategoryID = extras.getString("MappedParentCategoryID");
Name = extras.getString("Name");

}
flag.flag_wishlistdelete = true;
wishlist = (ListView) findViewById(R.id.wishlist);
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();
LayoutParams l = wishlist.getLayoutParams();

l.height = (int) (height * 0.75);
wishlist.setLayoutParams(l);

Resources res = getResources();
/** Add tabSpec to the TabHost to display. */

tabHost = getTabHost();

LayoutInflater.from(this).inflate(R.layout.tabs1,
tabHost.getTabContentView(), true);

tabHost.addTab(tabHost
.newTabSpec("tab1")
.setIndicator("tab1",
getResources().getDrawable(R.drawable.settings))
.setContent(R.id.view1));
tabHost.addTab(tabHost
.newTabSpec("tab3")
.setIndicator("tab2",
getResources().getDrawable(R.drawable.mainimage))
.setContent(R.id.view2));
tabHost.addTab(tabHost
.newTabSpec("tab3")
.setIndicator("tab3",
getResources().getDrawable(R.drawable.wishlist))
.setContent(R.id.view3));
tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("tab4")
.setContent(R.id.view3));
tabHost.getTabWidget().getChildAt(4).setVisibility(4);
getTabWidget().getChildAt(2).setOnClickListener(
new View.OnClickListener() {

@Override
public void onClick(View v) {
//

if (flag.flag_mainscreen_wish == true) {
Intent intent = new Intent(
wishlistdeleteActivity.this,
MainScreen.class);
flag.flag_mainscreen_wish = false;
startActivity(intent);
} else if (flag.flag_maincategory_wish == true) {
Intent intent = new Intent(
wishlistdeleteActivity.this,
MainCategoryActivity.class);

flag.flag_maincategory_wish = false;
startActivity(intent);
} else if (flag.flag_subcategories_wish == true) {
Intent intent = new Intent(
wishlistdeleteActivity.this,
SubCategoriesActivity.class);
flag.flag_subcategories_wish = false;
intent.putExtra("CategoryID", CategoryID);
intent.putExtra("Name", Name);
intent.putExtra("MappedParentCategoryID",
MappedParentCategoryID);
startActivity(intent);

} else if (flag.flag_product_wish == true) {
Intent intent = new Intent(
wishlistdeleteActivity.this, Product.class);
flag.flag_product_wish = false;
intent.putExtra("CategoryID", CategoryID);
intent.putExtra("MappedParentCategoryID",
MappedParentCategoryID);
intent.putExtra("Name", Name);
startActivity(intent);

} else if (flag.flag_productdetail_wish == true) {

Intent intent = new Intent(
wishlistdeleteActivity.this,
ProductDetailActivity.class);
flag.flag_productdetail_wish = false;
intent.putExtra("ProductID", ProductID);
intent.putExtra("CategoryID", CategoryID);
intent.putExtra("MappedParentCategoryID",
MappedParentCategoryID);
startActivity(intent);

} else {
Intent intent = new Intent(
wishlistdeleteActivity.this,
MainScreen.class);
flag.flag_mainscreen = false;
startActivity(intent);
}
}
});
getTabWidget().getChildAt(1).setOnClickListener(
new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent;
if (flag.counter_islogin == 0) {
intent = new Intent(wishlistdeleteActivity.this,
LoginActivity.class);
} else {
intent = new Intent(wishlistdeleteActivity.this,
LogoutActivity.class);
}
if (flag.count_wishlist == 0) {
flag.flag_mainscreen = true;
flag.flag_mainscreen_wish = false;
} else if (flag.count_wishlist == 1) {
flag.flag_maincategory = true;
flag.flag_maincategory_wish = false;
} else if (flag.count_wishlist == 2) {
flag.flag_subcategories = true;
flag.flag_subcategories_wish = false;
} else if (flag.count_wishlist == 3) {
flag.flag_product = true;
flag.flag_product_wish = false;
} else if (flag.count_wishlist == 4) {
flag.flag_productdetail = true;
flag.flag_productdetail_wish = false;
}
intent.putExtra("CategoryID", CategoryID);

intent.putExtra("Name", Name);
intent.putExtra("MappedParentCategoryID",
MappedParentCategoryID);
intent.putExtra("ProductID", ProductID);
startActivity(intent);
}
});
final Button doneButton = (Button) this.findViewById(R.id.done);
doneButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {

Intent m = new Intent(wishlistdeleteActivity.this,
wishlistActivity.class);

m.putExtra("ProductID", ProductID);
m.putExtra("CategoryID", CategoryID);
m.putExtra("MappedParentCategoryID", MappedParentCategoryID);
startActivity(m);

}
});

dialog = ProgressDialog.show(this, "", "Loading Data ...Please Wait",
true);

if (flag.product_add_delete == 1) {

startLongRunningOperation();
} else if (flag.product_add_delete == 0) {
startOperationFromPreferences();
} else if (flag.product_add_delete == 2) {
if ((((Dialog) dialog).isShowing())) {
dialog.dismiss();
flag.flag_dialog = 1;
}
}
}

protected void startOperationFromPreferences() {
Thread preferences = new Thread() {
public void run() {
SharedPreferences myPrefs = getSharedPreferences(PREFS_COUNT, 0);
total_data = myPrefs.getInt("total_data", 0);
count = total_data;
Quantity = new String[total_data];
Price = new String[total_data];
ProductName = new String[total_data];
ImageName = new String[total_data];
ProductID_wishlist = new String[total_data];
bmp = new Bitmap[total_data];
for (int i = 0; i < total_data; i++) {
Quantity[i] = myPrefs.getString("Quantity" + i, " ");
Price[i] = myPrefs.getString("Price" + i, " ");
ImageName[i] = myPrefs.getString("ImageName" + i, " ");
ProductName[i] = myPrefs.getString("ProductName" + i, " ");
ProductID_wishlist[i] = myPrefs.getString(
"ProductID_wishlist" + i, " ");
}
// Toast.makeText(getApplicationContext(), "" + total_data,
// 2000).show();

// convert();
mHandler.post(mUpdateResults);
}
// checkUpdate();
};
preferences.start();
}

final Handler mHandler = new Handler();

// Create runnable for posting
final Runnable mUpdateResults = new Runnable() {
public void run() {
handler.sendEmptyMessage(0);
}
};

// public void checkUpdate() {
protected void startLongRunningOperation() {

Thread display_wishlist = new Thread() {
public void run() {
flag.product_add_delete = 0;

PropertyInfo p[] = new PropertyInfo[2];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.INTEGER_CLASS;
p[0].setName("CustomerID");
p[0].setValue(LoginActivity.CustomerID);
p[1] = new PropertyInfo();
p[1].type = PropertyInfo.INTEGER_CLASS;
p[1].setName("StoreID");
p[1].setValue(15);
SoapObject Soapresponse = Ksoap.CallService(
"GetWishListByCustomerID", 2, p);

// Log.e("soap response delete wishlist",
// Soapresponse.toString());
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);
// Log.e("data", "" + Soapresult.toString());
if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);

if (Table != null) {
Quantity = new String[Table
.getPropertyCount()];
Price = new String[Table.getPropertyCount()];
ProductName = new String[Table
.getPropertyCount()];
ImageName = new String[Table
.getPropertyCount()];
ProductID_wishlist = new String[Table
.getPropertyCount()];
total_data = Table.getPropertyCount();
Log.e("total_data delete activity", ""
+ total_data);
bmp = new Bitmap[total_data];
// if (total_data <= 1) {
count = total_data;

// }
SharedPreferences myPrefs = getSharedPreferences(
PREFS_COUNT, 0);
editor = myPrefs.edit();
editor.putInt("total_data", total_data);
for (int i = 0; i < total_data; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {

Quantity[i] = row.getProperty(
"Quantity").toString();

Price[i] = row.getProperty("Price")
.toString();

ImageName[i] = row.getProperty(
"ImageName").toString();
Log.e(" ImageName", ImageName[i]);
ProductName[i] = row.getProperty(
"ProductName").toString();
ProductID_wishlist[i] = row
.getProperty("ProductID")
.toString();
Log.e("productid",
ProductID_wishlist[i]);
editor.putString("Quantity" + i,
Quantity[i]);

editor.putString("Price" + i,
Price[i]);
editor.putString("ImageName" + i,
ImageName[i]);
editor.putString("ProductName" + i,
ProductName[i]);
editor.putString(
"ProductID_wishlist" + i,
ProductID_wishlist[i]);

} catch (NullPointerException e) {
if (dialog.isShowing()) {
dialog.dismiss();
flag.flag_dialog = 1;
}
}
}
editor.commit();
// convert();
// handler.sendEmptyMessage(0);

}
}
}
}
} catch (NullPointerException f) {
if (dialog.isShowing()) {
dialog.dismiss();
flag.flag_dialog = 1;
}
} catch (ClassCastException d) {
if (dialog.isShowing()) {
dialog.dismiss();
flag.flag_dialog = 1;
}

} catch (ArrayIndexOutOfBoundsException g) {
if (dialog.isShowing()) {
dialog.dismiss();
flag.flag_dialog = 1;
}
}
mHandler.post(mUpdateResults);
}
};
display_wishlist.start();
}

// public void convert() {
// try {
// for (int i = 0; i < total_data; i++) {
//
// URL updateURL = new URL(
//
// "http://www.officemachinedepot.com/images/letterfolders/product/icon/"
// + ImageName[i]);
// URLConnection conn = updateURL.openConnection();
// InputStream is = conn.getInputStream();
// BufferedInputStream bis = new BufferedInputStream(is);
// baf = new ByteArrayBuffer(50);
//
// int current = 0;
// while ((current = bis.read()) != -1) {
// baf.append((byte) current);
// }
// bmp[i] = BitmapFactory.decodeByteArray(baf.toByteArray(), 0,
// baf.length());
// }
// } catch (Exception e) {
// }
// }

final Handler handler = new Handler() {
public void handleMessage(Message msg) {
// wishlist.setAdapter(new ImageAdapter(getApplicationContext()));
Image_Path = new String[total_data];
for (int i = 0; i < total_data; i++) {
Image_Path[i] = "http://www.officemachinedepot.com/images/letterfolders/product/icon/"
+ ImageName[i];
}
wishlist.setAdapter(new ImageAdapter(wishlistdeleteActivity.this,
Image_Path));

try {
Thread.sleep(6 * 1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if ((dialog.isShowing())) {
dialog.dismiss();
flag.flag_dialog = 1;
}

}
};

private class ImageAdapter extends BaseAdapter {
public final String ImageLoader = null;
private Activity activity;
private String[] data;

public ImageAdapter(Activity a, String[] d) {
activity = a;
data = d;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

imageLoader = new ImageLoader1(activity.getApplicationContext());
}

public class ViewHolder {
public ImageView iv;
public TextView name;
public TextView price;
public TextView quantity;

}

public ImageAdapter(Context c) {
mContext = c;
}

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

public Object getItem(int position) {

return position;
}

public long getItemId(int position) {

return position;
}

public View getView(final int position, View convertView,
ViewGroup parent) {
ViewHolder holder;
View v = convertView;

if (convertView == null) {
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.customwishdelete, null, true);
holder = new ViewHolder();
holder.name = (TextView) v.findViewById(R.id.productname);

holder.price = (TextView) v.findViewById(R.id.price);

holder.quantity = (TextView) v.findViewById(R.id.quantity);

holder.iv = (ImageView) v.findViewById(R.id.productimage);

v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
holder.name.setText(ProductName[position]);
holder.price.setText(Price[position]);
holder.quantity.setText(Quantity[position]);
// holder.iv.setImageBitmap(bmp[position]);
holder.iv.setTag(data[position]);
imageLoader.DisplayImage(data[position], activity, holder.iv);

Button show_delete = (Button) v.findViewById(R.id.show_delete);
final Button delete = (Button) v.findViewById(R.id.delete);
show_delete.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
delete.setVisibility(0);
}
});

delete.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
if (flag.flag_dialog == 1) {
ProductID_final = ProductID_wishlist[position];
// Toast.makeText(getApplicationContext(),ProductID_final
// , 9000).show();
flag.product_add_delete = 1;

wishlist_delete();
}
}
});

return v;
}

private Context mContext;
Integer[] DATA = new Integer[total_data];
{
for (int o = 0; o < total_data; o++) {
DATA[o] = R.drawable.icon;
}
}

}

public void wishlist_delete() {
flag.flag_dialog = 0;
PropertyInfo p[] = new PropertyInfo[3];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.INTEGER_CLASS;
p[0].setName("CustomerID");
p[0].setValue(LoginActivity.CustomerID);
p[2] = new PropertyInfo();
p[2].type = PropertyInfo.INTEGER_CLASS;
p[2].setName("Storeid");
p[2].setValue(15);

p[1] = new PropertyInfo();
p[1].type = PropertyInfo.INTEGER_CLASS;
p[1].setName("ProductID");
p[1].setValue(ProductID_final);
try {
SoapObject Soapresponse = Ksoap.CallService("DeleteWishlist", 3, p);
// Log.e("ProductID_final", ProductID_final);

if (Soapresponse != null) {
result = Soapresponse.getProperty("DeleteWishlistResult")
.toString();
// if (result.equalsIgnoreCase("Deleted Successfully")) {
dialog = ProgressDialog.show(wishlistdeleteActivity.this, "",
"Loading Data ...Please Wait", true);

// }
// else

// if (count == 1) {
// flag.product_add_delete = 2;
// Intent m = new Intent(wishlistdeleteActivity.this,
// wishlistdeleteActivity.class);
//
// m.putExtra("ProductID", ProductID);
// m.putExtra("CategoryID", CategoryID);
// m.putExtra("MappedParentCategoryID", MappedParentCategoryID);
// startActivity(m);
// }
// if ((((Dialog) dialog).isShowing())) {
// dialog.dismiss();
//
// }
if (result.equalsIgnoreCase("Deleted Successfully")) {
// nothing
} else// if clicked more than once this condition will occur
{
if ((((Dialog) dialog).isShowing())) {
dialog.dismiss();
flag.flag_dialog = 1;
}
}
alertDialog.setMessage("product " + result);
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// if (result
// .equalsIgnoreCase("Deleted Successfully")) {
Log.e("count", "" + count);
if (count <= 1) {
SharedPreferences myPrefs = getSharedPreferences(
PREFS_COUNT, 0);
editor = myPrefs.edit();
editor.putInt("total_data", 0);
for (int i = 0; i < total_data; i++) {

editor.putString("Quantity" + i, null);

editor.putString("Price" + i, null);
editor.putString("ImageName" + i, null);
editor.putString("ProductName" + i,
null);
editor.putString("ProductID_wishlist"
+ i, null);

}
editor.commit();
flag.product_add_delete = 2;
Intent m = new Intent(
wishlistdeleteActivity.this,
wishlistdeleteActivity.class);

m.putExtra("ProductID", ProductID);
m.putExtra("CategoryID", CategoryID);
m.putExtra("MappedParentCategoryID",
MappedParentCategoryID);
startActivity(m);

} else {

startLongRunningOperation();
}
// }
// else
// {
// // if ((((Dialog) dialog).isShowing())) {
// // dialog.dismiss();
// //
// // }
// startLongRunningOperation();
//
// }

}
});

alertDialog.show();

} else {

}

} catch (NullPointerException f) {

} catch (ClassCastException d) {

} catch (ArrayIndexOutOfBoundsException g) {

}
}
}