Professional Documents
Culture Documents
INTRODUCTION
The prevalence of Web and Online To Offline (O2O) marketing model has
led to the boom of various online event-based social networks (EBSNs). For
example, Groupon1 collects group purchase events and recommends these group
discounts to users, and Meet up receives information on recruitment of attendees in
offline events, such as gatherings, sports activities, etc., and sends such information
to users. Such EBSNs facilitate organizing social events and ease the recruitment
of group activity participants.
Recent location-based online social networking services,such as Foursquare
(foursquare.com) and Gowalla (gowalla.com), represent another type of popular
social network, called a location-based social network (LBSN). They are somewhat
similar to EBSNs, as they capture online social interactions as well as offline
location checkins. However, unlike the offline social events that incur a group of
people with social interactions, location checkins from LBSNs mostly represent
individual behaviors, i.e. a particular user was at a specific location at a specific
time. Although adjacent checkins were treated as one kind of reason for social
network tie creation. It is estimated that adjacent checkins have only a 24% chance
to lead to a new social friendship in Gowalla.
According to the Internet Engineering Task Force (IETF), the most basic cloud-
service model is that of providers offering computing infrastructure virtual
machines and other resources as a service to subscribers. Infrastructure as a
service (IaaS) refers to online services that abstract the user from the details of
infrastructure like physical computing resources, location, data partitioning,
scaling, security, backup etc. A hypervisor, such as Xen, Oracle VirtualBox, Oracle
VM, KVM, VMware ESX/ESXi, or Hyper-V, runs the virtual machines as guests.
Pools of hypervisors within the cloud operational system can support large
numbers of virtual machines and the ability to scale services up and down
according to customers' varying requirements. Linux containers run in isolated
partitions of a single Linux kernel running directly on the physical hardware.
Linuxc groups and namespaces are the underlying Linux kernel technologies used
to isolate, secure and manage the containers. Containerisation offers higher
performance than virtualization, because there is no hypervisor overhead. Also,
container capacity auto-scales dynamically with computing load, which eliminates
the problem of over-provisioning and enables usage-based billing.IaaS clouds often
offer additional resources such as a virtual-machine disk-image library, raw block
storage, file or object storage, firewalls, load balancers, IP addresses, virtual local
area networks (VLANs), and software bundles.
IaaS-cloud providers supply these resources on-demand from their large pools
of equipment installed in data centers. For wide-area connectivity, customers can
use either the Internet or carrier clouds (dedicated virtual private networks). To
deploy their applications, cloud users install operating-system images and their
application software on the cloud infrastructure. In this model, the cloud user
patches and maintains the operating systems and the application software. Cloud
providers typically bill IaaS services on a utility computing basis: cost reflects the
amount of resources allocated and consumed
In the software as a service (SaaS) model, users gain access to application software
and databases. Cloud providers manage the infrastructure and platforms that run
the applications. SaaS is sometimes referred to as "on-demand software" and is
usually priced on a pay-per-use basis or using a subscription fees. In the SaaS
model, cloud providers install and operate application software in the cloud and
cloud users access the software from cloud clients. Cloud users do not manage the
cloud infrastructure and platform where the application runs. This eliminates the
need to install and run the application on the cloud user's own computers, which
simplifies maintenance and support. Cloud applications differ from other
applications in their scalabilitywhich can be achieved by cloning tasks onto
multiple virtual machines at run-time to meet changing work demand.Load
balancers distribute the work over the set of virtual machines. This process is
transparent to the cloud user, who sees only a single access-point. To accommodate
a large number of cloud users, cloud applications can be multitenant, meaning that
any machine may serve more than one cloud-user organization.
LITERATURE SURVEY
Jieying She, Yongxin Tong, Lei Chen, Caleb Chen Cao ,Conflict-Aware
Event-Participant Arrangement,IEEE 31st International Conference on Data
Engineering,pp.735-746,2015
With the rapid development of Web 2.0 and Online To Offline (O2O) marketing
model, various online event-based social networks (EBSNs), such as Meet up and
Whoa, are getting popular. An important task of EBSNs is to facilitate the most
satisfactory event-participant arrangement for both sides, i.e. events enroll more
participants and participants are arranged with personally interesting events.
Existing approaches usually focus on the arrangement of each single event to a set
of potential users, and ignore the conflicts between different events, which leads to
infeasible or redundant arrangements.To address the shortcomings of existing
approaches, a more general and useful event-participant arrangement problem,
called Global Event-participant Arrangement with Conflict and Capacity (GEACC)
problem is identified focusing on the conflicts of different events and making
event-participant arrangements in a global view. Though it is useful, unfortunately,
its found that the GEACC problem is NP-hard due to the conflict constraints
among events. Thus two approximation algorithms with provable approximation
ratios and an exact algorithm with pruning technique to address this problem are
defined. Finally the effectiveness and efficiency of the proposed methods through
extensive experiments on real and synthetic datasets is verified.
Xingjie Liu, Qi Hey, Yuanyuan Tiany, Wang-Chien Lee, John McPhersony,
Event-based Social Networks: Linking the Online and Offline Social
Worlds,OCTOBER 2012
Newly emerged event-based online social services, such as Meet up and
Plan cast, have experienced increased popularity and rapid growth. From these
services, we observed a new type of social network { event-based social network}
(EBSN). An EBSN does not only contain online social interactions as in other
conventional online social networks, but also includes valuable offline social
interactions captured in offline activities. By analyzing real data collected from
Meet up, EBSN properties and discovered many unique and interesting
characteristics, such as heavy-tailed degree distributions and strong locality of
social interactions is investigated . Here the heterogeneous nature (co- existence
of both online and offline social interactions) of EBSNs on two challenging
problems: community detection and information overview are studied. Its found
that communities detected in EBSNs are more cohesive than those in other types of
social networks (e.g. location-based social networks). In the context of information
overview, the event recommendation problem is studied . By experimenting
various information discussion patterns, its found that a community-based
discussion model that takes into account of both online and offline interactions
provides the best prediction power. The research to study EBSNs at scale paves
the way for future studies on this new type of social network. A sample dataset of
this study can be down- loaded from http://www.largenetwork.org/ebsn.
CHAPTER 3
SYSTEM DESIGN
SYSTEM IMPLEMENTATION
admin
Existing or new
user? Existing
user Login by entering
database
user no and password
New user
Event name
admin Date Additionof database
event details
Time
Location
Contact
Figure 4.2 Event creation
4.2.3 Listing up the events
This module is used to display the event details. Here the user gives the date as
input and the events on that date will be shown to the user as a response.
Receive the input from the user through the datepicker option which is used to list
the events that are available on the particular date given by the user as request to
the admin.
Create the java files with the necessary files to be imported. Declare the essential
variables that are to be used in the program. Using the functions execute the
program. Login as user. Select the date for the event to be shown using the
datepicker. Select the GetEvent button to see the list of events on that date. The
user can view the list of events and can register for the events. The user can change
their password if they need to do so.
If events are
available?
user Select yes Event 1
date Event2
using .
date
picker
no
No records
found
no
exit
APPENDIX
Splash.java
package com.example.webdata;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread background = new Thread() {
public void run() {
try {
// Thread will sleep for 5 seconds
sleep(4*1000);
// After 5 seconds redirect to another intent
Intent i=new Intent(getApplicationContext(),Login.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
//Remove activity
finish();
}
catch (Exception e) {
}
}
};
// start thread
background.start();
}
}
Login.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class Login extends Activity implements OnClickListener, OnItemSelectedListener
{
EditText e1,e2;
ImageButton b;
TextView t;
Spinner sp;
String spin;
SharedPreferences sh=null;
SharedPreferences.Editor edit;
String[] sname={"User","Admin"};
String number,pass;
public String rollno;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sh=getSharedPreferences("share",Activity.MODE_APPEND);
edit=sh.edit();
e1=(EditText)findViewById(R.id.editText1);
e2=(EditText)findViewById(R.id.editText2);
b=(ImageButton)findViewById(R.id.button1);
sp=(Spinner)findViewById(R.id.spinner1);
t=(TextView)findViewById(R.id.textView2);
b.setOnClickListener(this);
t.setOnClickListener(this);
sp.setOnItemSelectedListener(this);
ArrayAdapter<String>aa=new
ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,sname);
sp.setAdapter(aa);
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
number=e1.getText().toString().trim();
pass=e2.getText().toString().trim();
if(v==b)
{
if(number.equals("")||pass.equals(""))
{
Toast.makeText(getApplicationContext(), "Please enter the value",
Toast.LENGTH_SHORT).show();
}
else
{
// if(spin.equals("User"))
// {
// Intent i=new Intent(getApplicationContext(),Userhome.class);
// startActivity(i);
// }
// else
// {
// Intent i1=new Intent(getApplicationContext(),Adminhome.class);
// startActivity(i1);
// }
new LogIn(Login.this).execute();
e1.setText("");
e2.setText("");
}
}
if(v==t)
{
Intent i=new Intent(getApplicationContext(),Register.class);
startActivity(i);
}
}
private class LogIn extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
public LogIn(Login mainActivity) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Login.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/login.php?
name="+number+"&passwd="+pass;
Log.i("url", url);
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
rollno=(jsonObj.getString("rollno"));
Log.d("Success: ", "> " + success);
if(success.matches("welcome"))
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
if(sp.getSelectedItem().toString().matches("User"))
{
}
}
Register.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class Register extends Activity implements OnClickListener
{
EditText e1,e2,e3,e4;
ImageButton b;
String number,passwd,cpasswd,rnumber;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
e1=(EditText)findViewById(R.id.edit1);
e2=(EditText)findViewById(R.id.edit2);
e3=(EditText)findViewById(R.id.edit3);
e4=(EditText)findViewById(R.id.roll);
b=(ImageButton)findViewById(R.id.button);
b.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
number=e1.getText().toString().trim();
passwd=e2.getText().toString().trim();
cpasswd=e3.getText().toString().trim();
rnumber=e4.getText().toString().trim();
if(number.equals("")||passwd.equals("")||cpasswd.equals("")||rnumber.equals(""))
{
Toast.makeText(getApplicationContext(), "Please enter all value",
Toast.LENGTH_SHORT).show();
}
else if(number.length()>10||number.length()<10)
{
e1.setError("Enter 10 digit value");
e1.setText("");
}
else if(!isValidpass(passwd)||!isValidpass(cpasswd))
{
Toast.makeText(getApplicationContext(), "Please Enter Four Digit
Password", Toast.LENGTH_LONG).show();
return;
}
else if(passwd.equals(cpasswd))
{
new Register1(Register.this).execute();
}
else
{
Toast.makeText(getApplicationContext(),
"PasswordMismatch",Toast.LENGTH_SHORT).show();
}
}
private boolean isValidpass(String passwd2)
{
// TODO Auto-generated method stub
if(passwd2.length()>=4)
{
return true;
}
return false;
}
private class Register1 extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
public Register1(Register register) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Register.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/register.php?
number1="+number+"&passwd1="+passwd+"&roll="+rnumber;
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
Log.d("Success: ", "> " + success);
if(success.matches("Data inserted"))
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();
Intent i=new Intent(getApplicationContext(),Login.class);
startActivity(i);
}
else
{
Toast.makeText(getApplicationContext(), "failed Please try again",
Toast.LENGTH_SHORT).show();
}
}
}
}
Event Creation
Adminhome.java
package com.example.webdata;
import java.io.IOException;
import java.util.Calendar;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TimePicker;
import android.widget.Toast;
public class Adminhome extends Activity implements OnClickListener
{
EditText et1,et2,et3;
Button d1,d2;
Button d3;
String name,address,contact;
Button btnDatePicker, btnTimePicker;
EditText txtDate, txtTime;
privateintmYear, mMonth, mDay, mHour, mMinute;
String format;
@Override
protectedvoid onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.adminhome);
et1=(EditText)findViewById(R.id.s1);
et2=(EditText)findViewById(R.id.s2);
et3=(EditText)findViewById(R.id.s3);
d1=(Button)findViewById(R.id.button1);
d2=(Button)findViewById(R.id.button2);
d3=(Button)findViewById(R.id.button3);
btnDatePicker=(Button)findViewById(R.id.btn_date);
btnTimePicker=(Button)findViewById(R.id.btn_time);
txtDate=(EditText)findViewById(R.id.in_date);
txtTime=(EditText)findViewById(R.id.in_time);
btnDatePicker.setOnClickListener(this);
btnTimePicker.setOnClickListener(this);
d1.setOnClickListener(this);
d2.setOnClickListener(this);
d3.setOnClickListener(this);
}
@Override
publicvoid onClick(View v)
{
// TODO Auto-generated method stub
name=et1.getText().toString().trim();
address=et2.getText().toString().trim();
contact=et3.getText().toString().trim();
// StringBuilder a=new StringBuilder();
// a.append((q.getMonth() + 1)+"/");//month is 0 based
// a.append(q.getDayOfMonth()+"/");
// a.append(q.getYear());
// String date=a.toString();
if(v==d1)
{
Intent i=new Intent(getApplicationContext(),Userrequest.class);
startActivity(i);
}
if(v==d3)
{
Intent i1=new Intent(getApplicationContext(),Login.class);
startActivity(i1);
}
if(v==btnDatePicker)
{
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(this,new
DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) {
txtDate.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
}
if(v==btnTimePicker)
{
if (DateFormat.is24HourFormat(this)) {
Log.i("control","Format 24");
format=("24");
} else {
Log.i("control","Format 12");
format=("12");
}
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
// Launch Time Picker Dialog
TimePickerDialog timePickerDialog = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {
private int hours;
private int minutes;
@Override
public void onTimeSet(TimePicker view, int hourOfDay,int minute)
{
if(format.equals("24"))
{
view.setIs24HourView(true);
} else {
view.setIs24HourView(true);
}
view.setIs24HourView(true);
hours = hourOfDay;
minutes = minute;
String timeSet = "";
if (hours> 12) {
hours -= 12;
timeSet = "PM";
} else if (hours == 0) {
hours += 12;
timeSet = "AM";
} else if (hours == 12){
timeSet = "PM";
}
else
timeSet = "AM";
String min = "";
if (minutes< 10)
min = "0" + minutes ;
else
min = String.valueOf(minutes);
// Append in a StringBuilder
String aTime = new
StringBuilder().append(hours).append(':').append(min).append("").append(timeSet).toString();
txtTime.setText(aTime);
// txtTime.setIs24HourView(true);
// txtTime.setText(hourOfDay + ":" + minute);
}
}, mHour, mMinute, false);
timePickerDialog.show();
}
if(v==d2)
{
if(name.equals("")||address.equals("")||contact.equals(""))
{
Toast.makeText(getApplicationContext(), "Please Insert all the values",
Toast.LENGTH_SHORT).show();
et1.setText("");
et2.setText("");
et3.setText("");
}
else
{
new Add(Adminhome.this).execute();
}
}
}
private class Add extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
public Add(Adminhome mainActivity)
{
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Adminhome.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/add.php?
Ename="+name+"&Eplace="+address+"&Econtact="+contact+"&Edate="+txtDate.getText().to
String()+"&Etime="+txtTime.getText().toString();
String ulink=url.replaceAll(" ","%20");
Log.i("0000",ulink);
HttpGet httpGet = new HttpGet(ulink);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
Log.d("Success: ", "> " + success);
if(success.matches("Data inserted"))
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e) {
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "success", Toast.LENGTH_SHORT).show();
et1.setText("");
et2.setText("");
et3.setText("");
txtDate.setText("");
txtTime.setText("");
}
else
{
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
}
}
}
}
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class Userrequest extends Activity implements OnItemClickListener
{
ListView l;
int position;
String[] web=new String[100];
String[] ename=new String[100];
String[] date=new String[100];
String[] roll=new String[100];
String[] name=new String[100];
String event,dat,rol,nam;
String sta="waiting";
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.userreq);
l=(ListView)findViewById(R.id.lis);
registerForContextMenu(l);
l.setOnItemClickListener(this);
setlistview();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.solu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back:
Intent i=new Intent(getApplicationContext(),Adminhome.class);
startActivity(i);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void setlistview()
{
// TODO Auto-generated method stub
new user(Userrequest.this).execute();
}
private class user extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
JSONArray jsonarray = null;
private user(Userrequest mainActivity) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Userrequest.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0)
{
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/getdetail.php?status1="+sta;
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null)
{
try {
JSONObject jsonObj = new JSONObject(response);
jsonarray=jsonObj.getJSONArray("result");
Log.i("Response jsonstr: ", String.valueOf(jsonarray.length()));
web=new String[jsonarray.length()];
for(int i=0;i<jsonarray.length();i++)
{
JSONObject c = jsonarray.getJSONObject(i);
StringBuffer buffer=new StringBuffer();
buffer.append("Event Name:").append(c.getString("ename")+"\n");
buffer.append("Event Date:").append(c.getString("edate")+"\n");
buffer.append("Students Name:").append(c.getString("name")+"\n");
buffer.append("Roll Number:").append(c.getString("rollno")+"\n");
buffer.append("Department:").append(c.getString("dept")+"\n");
buffer.append("Gender:").append(c.getString("gender")+"\n");
buffer.append("Date of birth:").append(c.getString("dob")+"\n");
buffer.append("Address:").append(c.getString("address")+"\n");
buffer.append("Mail id:").append(c.getString("mail")+"\n");
buffer.append("Mobile number:").append(c.getString("number"));
web[i]=buffer.toString();
ename[i]=c.getString("ename");
date[i]=c.getString("edate");
roll[i]=c.getString("rollno");
name[i]=c.getString("name");
Log.i("DETAILS", web[0]);
}
if(jsonarray.length()>0)
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
ArrayAdapter<String>ad=new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1,web);
l.setAdapter(ad);
}
else
{
Toast.makeText(getApplicationContext(), "No Recordsfound",Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.acceptmain, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
@SuppressWarnings("unused")
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId())
{
case R.id.Accept:
{
new detail(Userrequest.this).execute();
return true;
}
case R.id.Reject:
{
new reject(Userrequest.this).execute();
return true;
}
case R.id.Back:
Intent i1=new Intent(getApplicationContext(),Adminhome.class);
startActivity(i1);
return true;
default:
return super.onContextItemSelected(item);
}
}
class detail extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
JSONArray jsonarray = null;
public detail(Userrequest mainActivity) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Userrequest.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
event=ename[position];
dat=date[position];
rol=roll[position];
nam=name[position];
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instancez
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/enoticeupdateroom.php?
ename="+event+"&edate="+dat+"&rollno="+rol+"&name="+nam;
Log.i("url", url);
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d ("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
if(success.matches("Data updated"))
{
Log.d("Success: ", "Data updated");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e) {
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "Accepted", Toast.LENGTH_SHORT).show();
Intent i=new Intent(getApplicationContext(),Userrequest.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
}
else
{
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
}
}
class reject extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
JSONArray jsonarray = null;
public reject(Userrequest mainActivity) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Userrequest.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
event=ename[position];
dat=date[position];
rol=roll[position];
nam=name[position];
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/reject.php?
ename="+event+"&edate="+dat+"&rollno="+rol+"&name="+nam;
Log.i("url", url);
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
if(success.matches("Data updated"))
{
Log.d("Success: ", "Data updated");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e) {
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "Rejected", Toast.LENGTH_SHORT).show();
Intent i=new Intent(getApplicationContext(),Userrequest.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
}
else
{
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onItemClick(AdapterView<?>parent, View view, int pos,long id) {
// TODO Auto-generated method stub
position=pos;
}
}
GetEvent.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
import android.widget.Toast;
public class GetEvent extends Activity implements OnItemLongClickListener
{
ListView list;
int pos;
String dat;
String[] web=new String[100];;
String[] name=new String[100];
String[] date=new String[100];
String[] Evname=new String[100];
String e_name,e_date,roll;
String[] Evdate=new String[100];
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.cust);
list=(ListView)findViewById(R.id.list);
Intent i=getIntent();
dat=i.getStringExtra("date");
new date(GetEvent.this).execute();
}
private class date extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
private JSONArray jsonArray;
public date(GetEvent getEvent) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(GetEvent.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0)
{
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/appreviewgetalldetails.php?Date="+dat;
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null)
{
try {
JSONObject jsonObj = new JSONObject(response);
jsonArray=jsonObj.getJSONArray("result");
Log.i("Response jsonstr: ", String.valueOf(jsonArray.length()));
web=new String[jsonArray.length()];
name=new String[jsonArray.length()];
date=new String[jsonArray.length()];
for(int i=0;i<jsonArray.length();i++)
{
JSONObject c = jsonArray.getJSONObject(i);
StringBuffer buffer=new StringBuffer();
buffer.append("Event Name:").append(c.getString("Ename")+"\n");
buffer.append("Event Address:").append(c.getString("Eplace")+"\n");
buffer.append("Event Contact:").append(c.getString("Econtact")+"\n");
buffer.append("Event Date:").append(c.getString("Edate")+"\n");
buffer.append("Event Time:").append(c.getString("Etime"));
web[i]=buffer.toString();
name[i]=c.getString("Ename");
date[i]=c.getString("Edate");
// place=c.getString("Eplace")+"\n";
// contact=c.getString("Econtact")+"\n";
// time=c.getString("Etime");
wchecker=1;
Log.i("DETAILS", web[0]);
}
if(jsonArray.length()>0)
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e) {
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
createcustom();
}
else
{
Toast.makeText(getApplicationContext(), "No Event Found", Toast.LENGTH_SHORT).show();
}
}
}
Private void createcustom() {
// TODO Auto-generated method stub
Customlistview adapter=new Customlistview(GetEvent.this, web);
list.setAdapter(adapter);
registerForContextMenu(list);
list.setOnItemLongClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.solu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back:
Intent i=new Intent(getApplicationContext(),Userhome.class);
startActivity(i);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
@SuppressWarnings("unused")
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId())
{
case R.id.REGISTER:
String e_name=name[pos];
String e_date=date[pos];
Intent i=new Intent(GetEvent.this,Register2.class);
i.putExtra("name1", e_name);
i.putExtra("date1", e_date);
startActivity(i);
return true;
case R.id.BACK:
Intent i1=new Intent(getApplicationContext(),Userhome.class);
startActivity(i1);
return true;
default:
return super.onContextItemSelected(item);
}
}
@Override
public boolean onItemLongClick(AdapterView<?>parent, View view, int position, long id)
{
// TODO Auto-generated method stub
pos=position;
return false;
}
}
Settings.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Settings extends Activity implements OnClickListener
{
EditText e1,e2,e3;
Button b1,b2;
TextView t;
String uname,upass;
String pass1,pass2,pass3;
SharedPreferences sh=null;
SharedPreferences.Editor edit;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
e1=(EditText)findViewById(R.id.et1);
e2=(EditText)findViewById(R.id.et2);
e3=(EditText)findViewById(R.id.et3);
b1=(Button)findViewById(R.id.submit);
b2=(Button)findViewById(R.id.logout);
t=(TextView)findViewById(R.id.change);
t.setOnClickListener(this);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
sh=getSharedPreferences("share",0);
edit=sh.edit();
uname=sh.getString("regnumber",null);
upass=sh.getString("passwd",null);
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
pass1=e1.getText().toString().trim();
pass2=e2.getText().toString().trim();
pass3=e3.getText().toString().trim();
if(v==t)
{
e1.setVisibility(View.VISIBLE);
e2.setVisibility(View.VISIBLE);
e3.setVisibility(View.VISIBLE);
b1.setVisibility(View.VISIBLE);
}
if(v==b2)
{
Intent i1=new Intent(getApplicationContext(),Login.class);
i1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i1.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i1);
}
if(v==b1)
{
if(pass1.equals("")||pass2.equals("")||pass3.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter Fields", 4000).show();
}
else
{
if(pass1.equals(upass))
{
if(pass2.equals(pass3))
{
new Changpsd(Settings.this).execute();
}
else
{
Toast.makeText(getApplicationContext(), "pAssword mismatch", 2000).show();
}
}
else
{
Toast.makeText(getApplicationContext(), "InVALID Old pAssword", 2000).show();
}
}
}
}
private class Changpsd extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
public Changpsd(Settings mainActivity)
{
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
/ / Showing progress dialog
pDialog = new ProgressDialog(Settings.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/Setting.php?
username="+uname+"&password="+pass2;
Log.i("url", url);
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity); }
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
Log.d("Success: ", "> " + success);
if(success.matches("Data inserted"))
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
else
{
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "Updated Your Current Password is:"+pass2,
Toast.LENGTH_SHORT).show();
Intent i=new Intent(getApplicationContext(),Settings.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
e1.setText("");
e2.setText("");
e3.setText("");
sh.edit().putString("passwd",pass2).commit();
}
else
{
Toast.makeText(getApplicationContext(), "Not Modified", Toast.LENGTH_SHORT).show();
}
}
}
}
User registration for events
Register2.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class Register2 extends Activity implements OnClickListener, OnItemSelectedListener
{
EditText e3,e4,e5,e6,e7;
Spinner s,s1;
ImageButton b,b1;
String[] Dep={"Select your
department","CSE","EEE","ECE","Mech","IT","CIVIL","ANE","MCA","MBA","Others"};
String[] Gen={"Gender","Male","Female"};
String text1,text2,text3,text4,text5,gender,text6,text7;
TextView txt1,txt2;
String Evnames;
String dates;
SharedPreferences sp=null;
SharedPreferences.Editor edit;
String rnum;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register2);
try
{
s1=(Spinner)findViewById(R.id.ed);
e3=(EditText)findViewById(R.id.edit3);
e4=(EditText)findViewById(R.id.edit4);
e5=(EditText)findViewById(R.id.edit5);
e6=(EditText)findViewById(R.id.edit6);
e7=(EditText)findViewById(R.id.edit7);
txt1=(TextView)findViewById(R.id.textView1);
txt2=(TextView)findViewById(R.id.textView2);
s=(Spinner)findViewById(R.id.spinner1);
b=(ImageButton)findViewById(R.id.button);
b1=(ImageButton)findViewById(R.id.button1);
Intent i=getIntent();
Evnames=i.getStringExtra("name1");
dates=i.getStringExtra("date1");
// Toast.makeText(getApplicationContext(), Evnames+dates, 3000).show();
sp=getSharedPreferences("share",0);
edit=sp.edit();
rnum=sp.getString("rollnum",null);
// Toast.makeText(getApplicationContext(), rnum, 2000).show();
txt1.setText("Event Name:"+Evnames);
txt2.setText("Event Date:"+dates);
android.view.animation.Animation animation2 = AnimationUtils.loadAnimation(this,
R.anim.move1);
txt1.startAnimation(animation2);
android.view.animation.Animation animation = AnimationUtils.loadAnimation(this,
R.anim.move1);
txt2.startAnimation(animation);
s.setOnItemSelectedListener(this);
b.setOnClickListener(this);
b1.setOnClickListener(this);
ArrayAdapter<String>ad=new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,Gen);
s.setAdapter(ad);
ArrayAdapter<String>ss=new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,Dep);
s1.setAdapter(ss);
}
catch(Exception e)
{
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if(v==b1)
{
Intent i2=new Intent(getApplicationContext(),Userhome.class);
startActivity(i2);
}
if(v==b)
{
text2=s1.getSelectedItem().toString();
text3=e3.getText().toString().trim();
text4=e4.getText().toString().trim();
text5=e5.getText().toString().trim();
text6=e6.getText().toString().trim();
text7=e7.getText().toString().trim();
// text8=txt1.getText().toString();
// text9=txt2.getText().toString();
gender=s.getSelectedItem().toString();
if(text3.equals("")||text4.equals("")||text5.equals("")||text6.equals("")||text7.equals(""))
{
Toast.makeText(getApplicationContext(), "Please enter all the values",
Toast.LENGTH_SHORT).show();
e3.setText("");
e4.setText("");
e5.setText("");
e6.setText("");
e7.setText("");
s.setSelection(0);
s1.setSelection(0);
}
else if(text7.length()>10||text7.length()<10)
{
e7.setError("Enter 10digit Mobile Number");
}
else if(!isValidEmail(text6))
{
Toast.makeText(getApplicationContext(), "Enter Valid Email Address",
Toast.LENGTH_LONG).show();
return;
}
else if(gender.equals("Gender"))
{
Toast.makeText(getApplicationContext(), "Please select one",
Toast.LENGTH_SHORT).show();
}
else if(text2.equals("Select your department"))
{
Toast.makeText(getApplicationContext(), "Please select one",
Toast.LENGTH_SHORT).show();
}
else
{
new Register3(Register2.this).execute();
}
}
}
private boolean isValidEmail(String text62)
{
// TODO Auto-generated method stub
return !TextUtils.isEmpty(text62) &&
android.util.Patterns.EMAIL_ADDRESS.matcher(text62).matches();
}
private class Register3 extends AsyncTask<Void, Void, Void>
{
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
public Register3(Register2 register) {
// TODO Auto-generated constructor stub
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(Register2.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
// ServiceHandler sh = new ServiceHandler();
String url="http://baladatabase.96.lt/Webdata/Userregister.php?
ronumber="+rnum+"&Evname="+Evnames+"&Edate="+dates+"&dept="+text2+"&name="+te
xt3+"&gender="+gender+"&dob="+text4+"&address="+text5+"&mail="+text6+"&number="+t
ext7;
String ulink=url.replaceAll(" ","%20");
HttpGet httpGet = new HttpGet(ulink);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Making a request to url and getting response
//String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
Log.d("Response: ", "> " + response);
if (response != null) {
try {
JSONObject jsonObj = new JSONObject(response);
String success=(jsonObj.getString("success"));
Log.d("Success: ", "> " + success);
if(success.matches("Data inserted"))
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if(wchecker==1)
{
Toast.makeText(getApplicationContext(), "Registered Successfully",
Toast.LENGTH_SHORT).show();
s1.setSelection(0);
e3.setText("");
e4.setText("");
e5.setText("");
e6.setText("");
e7.setText("");
s.setSelection(0);
}
else
{
Toast.makeText(getApplicationContext(), "failed", Toast.LENGTH_SHORT).show();
s1.setSelection(0);
e3.setText("");
e4.setText("");
e5.setText("");
e6.setText("");
e7.setText("");
s.setSelection(0);
}
}
}
@Override
public void onItemSelected(AdapterView<?>parent, View view, int position, longid) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected(AdapterView<?>parent) {
// TODO Auto-generated method stub
}
}
Registration status
Status.java
package com.example.webdata;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class Status extends Activity
{
ListView l;
String num1,rnum;
String[] web=new String[100];
SharedPreferences sp=null;
SharedPreferences.Editor edit;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.status);
sp=getSharedPreferences("share",0);
edit=sp.edit();
num1=sp.getString("regnumber",null);
rnum=sp.getString("rollnum",null);
l=(ListView)findViewById(R.id.listVi);
// android.view.animation.Animation animation2 = AnimationUtils.loadAnimation(this,
R.anim.move1);
// l.startAnimation(animation2);
setlist();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.ref, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.refresh:
setlist();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void setlist()
{
// TODO Auto-generated method stub
new built(Status.this).execute();
}
private class built extends AsyncTask<Void, Void, Void>
{
Context _context;
ProgressDialog pDialog;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String response;
int wchecker;
JSONArray jsonarray = null;
public built(Context Status)
{
// TODO Auto-generated constructor stub
_context=Status;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(_context);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0)
{
String url="http://baladatabase.96.lt/Webdata/StatusGet.php?rollno="+rnum;
HttpGet httpGet = new HttpGet(url);
try
{
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
Log.d("Response: ", "> " + response);
if (response != null)
{
try {
JSONObject jsonObj = new JSONObject(response);
jsonarray=jsonObj.getJSONArray("result");
Log.i("Response jsonstr: ", String.valueOf(jsonarray.length()));
web=new String[jsonarray.length()];
for(int i=0;i<jsonarray.length();i++)
{
JSONObject c = jsonarray.getJSONObject(i);
StringBuffer buffer=new StringBuffer();
buffer.append("Event Name:").append(c.getString("ename")+"\n");
buffer.append("Event Date:").append(c.getString("edate")+"\n");
buffer.append("Status:").append(c.getString("status"));
web[i]=buffer.toString();
wchecker=1;
Log.i("DETAILS", web[0]);
}
if(jsonarray.length()>0)
{
Log.d("Success: ", "Data inserted");
wchecker=1;
}
else
{
Log.d("Error: ", "Data not inserted");
wchecker=0;
}
catch (JSONException e) {
e.printStackTrace();
}
}
else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
if (wchecker==1)
{
// Toast.makeText(getApplicationContext(), ""+web, 4000).show();
ArrayAdapter<String>ad=new
ArrayAdapter<String>(_context,android.R.layout.simple_list_item_1,web);
l.setAdapter(ad);
}
else
{
Toast.makeText(getApplicationContext(), "No Records found",Toast.LENGTH_SHORT).show();
}
}
}
}
Customlistview.java
package com.example.webdata;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class Customlistview extends ArrayAdapter<String> {
private final Activity context;
private final String[] web;
public Customlistview(Activity context, String[] web) {
super(context,R.layout.updatetableimplement, web);
// TODO Auto-generated constructor stub
this.context=context;
this.web=web;
}
public View getView(intposition,View view,ViewGroup parent)
{
LayoutInflater inflator=context.getLayoutInflater();
View rowview=inflator.inflate(R.layout.updatetableimplement,null,true);
TextView txtund=(TextView)rowview.findViewById(R.id.textView1);
txtund.setText(web[position]);
return rowview;
}}