Search the Blog
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
Wednesday, September 4, 2019
Thursday, August 29, 2019
Palindrome number program in Pythan
In this post i will explain the palindome number program in python and also to expalin the same i also created a youtube video so you can check also complete step by step and also output in IDE.
Palindrome number program in Pythan |
Palindrome No Program in Python-
num = int(input("enter a number: ")) temp = num rev = 0while temp: rev = (rev * 10) + (temp % 10) temp = temp // 10if num == rev: print("No is palindrome") else: print("No is not palindrome")
Output-
When entered Item is- 747
No is Palindrome.
when entered Item is- 67
No is notb Palindrome.
See Also-Pythan All type of program
Labels:
Android,
Code,
CSS,
database,
DIZSWEB,
example,
HTML,
INFORMATION QUERY,
Interview,
JAVA,
JavaScript,
JS,
Online Exam,
Ouery,
pattern,
program,
Python,
Query Optimization,
SERVERS,
SQL
Monday, August 26, 2019
Pyhtan * Pattern Program with Space
As all of us knows that as we used to print the pattern program in C, C++, JAVA,Net, etc. to make comfortable to the new user as we started learning that programming language.
In the same way to make confidence and learn syntax and logic writting style in Python. We can practice as many prgram for this i am showing to all of you more than 20 pattern program code in Python.
You can copy and paste these code and even test at your own system. Users can modify these Codes too.
Python pattern program with space and Star(*)
Program Code-
def python_pattern(n):
# outer loop will handle number of rows
# n in this case
for i in range(0, n):
# inner loop will handle number
of columns for space printing
for k in range(0, n-i):
# printing stars
print(" ", end="")
# inner loop will handle number of columns
for star printing
for j in range(0, i + 1):
# printing stars
print("* ", end="")
# ending line after each row
print("\r")
# Driver Code
n = 6python_pattern(n)
Output-
Friday, August 16, 2019
Android- JSON Parser Code for server request and responce
In this post i will explain the palindome number program in python and also to expalin the same i also created a youtube video so you can check also complete step by step and also output in IDE.
package com.example.sawan.onlineattendance;
import android. util.Log;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* Created by sawan on 9/28/2016.
*/
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
static InputStream iStream = null;
static JSONArray jarray = null;
public JSONParser() {}
public JSONObject makeHttpRequest(String url1, String method, List < NameValuePair > params){
try {
if (method == "POST") {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
else {
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
}
catch(UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException");
e.printStackTrace();
}
catch(ClientProtocolException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch(Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
}
catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
public JSONArray getJSONFromUrl(String url) {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
}
else {
Log.e("==>", "Failed to download file");
}
} catch(ClientProtocolException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
try {
jarray = new JSONArray(builder.toString());
} catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jarray;
}
public JSONObject makeHttpRequest2(String url) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch(UnsupportedEncodingException e) {
e.printStackTrace();
} catch(ClientProtocolException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch(Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
} catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
}
Thursday, August 15, 2019
Json Parser Code for Android to JAVA MVC Project Uploading The Image
This Blog post have the complete Code for an Android Application which have database at cload and running on apache TOMCAT.
In this blog post you can get all information easily which is required to send a request from android application to server(cloud) and receive and extract the data in usable format.
This Code is used in School ERP Application for uploading The Image of Code
package com.example.sawan.onlineattendance; // Package Name of Project
import android.util.Log;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* Created by sawan on 9/28/2016.
*/
public class JSONParser {
static InputStream is = null;static JSONObject jObj = null;
static String json = "";
static InputStream iStream = null;
static JSONArray jarray = null;
public JSONParser() {}
public JSONObject makeHttpRequest(String url2, String method, List < NameValuePair > params)\ {
try {
if (method == "POST") {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
else {
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
}
catch(UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException");
e.printStackTrace();
}
catch(ClientProtocolException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch(Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
}
catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
public JSONArray getJSONFromUrl(String url) {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
}
else {
Log.e("==>", "Failed to download file");
}
} catch(ClientProtocolException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
try {
jarray = new JSONArray(builder.toString());
} catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jarray;
}
public JSONObject makeHttpRequest2(String url) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch(UnsupportedEncodingException e) {
e.printStackTrace();
} catch(ClientProtocolException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch(Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
} catch(JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
}
100+ JAVA Pattern Program
50+ Python Pattern Program
Labels:
Android,
Cloud Server,
Code,
CSS,
database,
DIZSWEB,
example,
HTML,
INFORMATION QUERY,
Interview,
JAVA,
JavaScript,
JS,
Online Exam,
Ouery,
pattern,
program,
Query Optimization,
SERVERS
Android Code for opening Multiple Screen from a single Activity
This Blog post have the complete Code for an Android Application about various activity opening from ia single screen
In this blog post you can get all information relatated activating new activity from previous activity with actual runnable code.
This code is part of Android application MVC Project of School ERP. If you are faminliar with java and also have some good hands on Anadroid then you can easilly understand the code and can use this code in your own project.
package com.example.sawan.onlineattendance;
import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class HOD extends AppCompatActivity {
Button studentremark,
btn2,
notice,
drictorNotice,
hodNotice,
Defaulter,
Inforamtion,
teacherLogin,
teacherremak;
JSONParser jParser = new JSONParser();
JSONObject json;
String buttton;
static String button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hod);
btn2 = (Button) findViewById(R.id.sdudent_lecture);
btn2.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, Student_subject_setting.class);
startActivity(intent);
}
});
studentremark = (Button) findViewById(R.id.studentNotification);
studentremark.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStudentRemark.class);
startActivity(intent);
}
});
teacherremak = (Button) findViewById(R.id.HomeWork);
teacherremak.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HomeWork.class);
startActivity(intent);
}
});
teacherLogin = (Button) findViewById(R.id.TeacherLogin);
teacherLogin.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODTeacherLogin.class);
startActivity(intent);
}
});
notice = (Button) findViewById(R.id.update);
notice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStudentNotification.class);
startActivity(intent);
}
});
hodNotice = (Button) findViewById(R.id.TecherNotification);
hodNotice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStaffNotice.class);
startActivity(intent);
}
});
Defaulter = (Button) findViewById(R.id.DefaulterStudent);
Defaulter.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, DefaulterCutOf.class);
startActivity(intent);
}
});
Inforamtion = (Button) findViewById(R.id.StudentDetail);
Inforamtion.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, DirectorStudentFinal.class);
startActivity(intent);
}
});
drictorNotice = (Button) findViewById(R.id.DirectorNotice);
drictorNotice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
new Login().execute();
}
});
}
private class Login extends AsyncTask < String,
String,
String > {@SuppressWarnings("WrongThread")@Override
protected String doInBackground(String...strings) {
String table = Identification.TableName; {
String url_login2 = "http://192.168.43. 156:8081/OnlineAttendance/DirectorNoticeServlet";
List < NameValuePair > params_dizsweb = new ArrayList < NameValuePair > ();
params_dizsweb .add(new BasicNameValuePair("t", Identification.TableName));
params_dizsweb .add(new BasicNameValuePair("cutoff", "HODDrictor"));
params_dizsweb .add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices = json.getString("name");
Intent login = new Intent(getApplicationContext(), HODDrictorNotice.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(login);
}
else {
Intent login = new Intent(getApplicationContext(), Error.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(login);
}
} catch(Exception e) {
e.printStackTrace();
}
}
return null;
}
}
}
Star Pattern Program JAVA
Android java code settiong of subject in MVC
package com.example.sawan.onlineattendance;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class FacultySubjectSetting extends AppCompatActivity {
Button btn;
String fca;
JSONParser jParser = new JSONParser();
JSONObject json;
private static String url_login = "http:// 192. 168. 43. 156: 8081 /OnlineAttendance/UpdateTeaherSubjectSettingSearch";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_faculty_subject_setting);
btn=(Button)findViewById(R.id.search);
Spinner spinner4 = (Spinner) findViewById(R.id.spinner_faculty);
ArrayAdapter<CharSequence> adapter4 = ArrayAdapter.createFromResource(
this, R.array.Faculty, android.R.layout.simple_spinner_item);
adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner4.setAdapter(adapter4);
spinner4.setOnItemSelectedListener(new MyOnItemSelectedListener());
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Spinner sp4 = (Spinner)findViewById(R.id.spinner_faculty);
String facu = sp4.getSelectedItem().toString();
fca=Integer.parseInt(facu)+"";
new Login().execute();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String username = fca;
String table = Identification.TableName;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("u",username));
params.add(new BasicNameValuePair("t",table));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
System.out.println(json.getString("info"));
int m=json.getInt("row");
if( json.getString("info").equals("success"))
{
int j=1;
Identification.FacultySubjectRecord=new String[m][3];
Identification.FacultyCode=json.getString("facultyCode");
System.out.println("condition is : "+(j<=m));
while(j<=m)
{
String sub=json.getString("sub"+j);
System.out.println("inseide "+sub);
System.out.println("inseide "+Identification.FacultySubjectRecord.length);
System.out.println("inseide "+(j-1));
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
Identification.FacultySubjectRecord[j-1][0]=sub;
System.out.println("nrfjnkmlk kgkm :");
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
String branch=json.getString("branch"+j);
Identification.FacultySubjectRecord[j-1][1]=branch;
String section=json.getString("section"+j);
Identification.FacultySubjectRecord[j-1][2]=section;
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][2]);
System.out.println("j value is : "+j);
j++;
}
Intent login = new Intent(getApplicationContext(),FacultySubjectSettingPage.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch (Exception e)
{
}
return null;
}
}
}
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class FacultySubjectSetting extends AppCompatActivity {
Button btn;
String fca;
JSONParser jParser = new JSONParser();
JSONObject json;
private static String url_login = "http:// 192. 168. 43. 156: 8081 /OnlineAttendance/UpdateTeaherSubjectSettingSearch";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_faculty_subject_setting);
btn=(Button)findViewById(R.id.search);
Spinner spinner4 = (Spinner) findViewById(R.id.spinner_faculty);
ArrayAdapter<CharSequence> adapter4 = ArrayAdapter.createFromResource(
this, R.array.Faculty, android.R.layout.simple_spinner_item);
adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner4.setAdapter(adapter4);
spinner4.setOnItemSelectedListener(new MyOnItemSelectedListener());
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Spinner sp4 = (Spinner)findViewById(R.id.spinner_faculty);
String facu = sp4.getSelectedItem().toString();
fca=Integer.parseInt(facu)+"";
new Login().execute();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String username = fca;
String table = Identification.TableName;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("u",username));
params.add(new BasicNameValuePair("t",table));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
System.out.println(json.getString("info"));
int m=json.getInt("row");
if( json.getString("info").equals("success"))
{
int j=1;
Identification.FacultySubjectRecord=new String[m][3];
Identification.FacultyCode=json.getString("facultyCode");
System.out.println("condition is : "+(j<=m));
while(j<=m)
{
String sub=json.getString("sub"+j);
System.out.println("inseide "+sub);
System.out.println("inseide "+Identification.FacultySubjectRecord.length);
System.out.println("inseide "+(j-1));
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
Identification.FacultySubjectRecord[j-1][0]=sub;
System.out.println("nrfjnkmlk kgkm :");
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
String branch=json.getString("branch"+j);
Identification.FacultySubjectRecord[j-1][1]=branch;
String section=json.getString("section"+j);
Identification.FacultySubjectRecord[j-1][2]=section;
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][2]);
System.out.println("j value is : "+j);
j++;
}
Intent login = new Intent(getApplicationContext(),FacultySubjectSettingPage.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch (Exception e)
{
}
return null;
}
}
}
Android JAVA Code for Staff Main Page
package com.example.sawan.onlineattendance;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class Faculty extends AppCompatActivity {
JSONParser jParser = new JSONParser();
JSONObject json;
static String button;
Button update, continu, dricNotice,hodNotice,notice;
static boolean ma = false;
Context ctx;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ctx = this;
setContentView(R.layout.activity_faculty);
update = (Button) findViewById(R.id.faculty_code_button);
continu = (Button) findViewById(R.id.continu);
dricNotice = (Button) findViewById(R.id.PrincipalNotice);
hodNotice = (Button) findViewById(R.id.HODNotice);
notice = (Button) findViewById(R.id.HODLogin);
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "update";
new Login().execute();
}
});
dricNotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "dricNotice";
new Login().execute();
}
});
hodNotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "hodNotice";
new Login().execute();
}
});
notice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent login = new Intent(getApplicationContext(), TeacherHODLogin.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
});
continu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent login = new Intent(getApplicationContext(), FacultyPage.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String table = Identification.TableName;
// if(button.equals("HOD"))
// {
// String url_login = "http 192.168.43.156:8081/OnlineAttendance/Student";
// List<NameValuePair> params = new ArrayList<NameValuePair>();
// for (int i = 0; i < Identification.FacultySubjectRecord.length; i++)
// {
// params.add(new BasicNameValuePair("Branch" + i, Identification.FacultySubjectRecord[i][0]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][0]);
// params.add(new BasicNameValuePair("Section" + i, Identification.FacultySubjectRecord[i][1]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][1]);
// params.add(new BasicNameValuePair("Subject" + i, Identification.FacultySubjectRecord[i][2]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][2]);
// }
// params.add(new BasicNameValuePair("t", table));
// params.add(new BasicNameValuePair("row", Identification.FacultySubjectRecord.length + ""));
// params.add(new BasicNameValuePair("faculty", Identification.StudentRoll));
// params.add(new BasicNameValuePair("download", button));
// json = jParser.makeHttpRequest(url_login, "GET", params);
// String Sname = null;
// DataBase db=new DataBase(ctx);
// db.deleteData(db);
// try
// {
// System.out.println(Sname=json.getString("info"));
// int m = json.getInt("row");
// System.out.println("m value....."+m) ;
// if (Sname.equals("success"))
// {
// int j = 0;
// int k=0;
// Identification.StudentRecord = new String[m][6];
// System.out.println("inseide " + Identification.StudentRecord.length);
// System.out.println("condition is : " + (j <= m));
// while (j < m)
// {
// String name = json.getString("name" + k);
// k++;
// Identification.StudentRecord[j][0] = name;
// String rool = json.getString("roll" + k);
// k++;
// Identification.StudentRecord[j][1] = rool;
// String branch = json.getString("branch" + k);
// k++;
// Identification.StudentRecord[j][2] = branch;
// String section = json.getString("Section" + k);
// k++;
// Identification.StudentRecord[j][3] = section;
// System.out.println("section value " + Identification.StudentRecord[j][2]);
// String Attendance = json.getString("Attendance" + k);
// k++;
// Identification.StudentRecord[j][4] = Attendance;
// String SubCode= json.getString("SubjectCode" + k);
// k++;
// Identification.StudentRecord[j][5] = SubCode;
// System.out.println("j value is : " + j);
// j++;
// }
// for (int i = 0; i < m; i++)
// {
// System.out.println("...........DataBase class Insert Method is called..........");
//
// db.insertRecord(Identification.StudentRecord[i][0], Identification.StudentRecord[i][1], Identification.StudentRecord[i][2], Identification.StudentRecord[i][3], Identification.StudentRecord[i][4],Identification.StudentRecord[i][5]);
// System.out.println("...........DataBase class Insert Method is called succeful..........");
// }
//
//
// Intent login = new Intent(getApplicationContext(), FacultySubjectSettingPage.class);
// System.out.println("........................................ login.....................................................");
// login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// System.out.println("........................................ 1......................................................");
// startActivity(login);
// finish();
// }
// else
// {
// Intent login = new Intent(getApplicationContext(), Error.class);
// System.out.println("........................................ login.....................................................");
// login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// System.out.println("........................................ 1......................................................");
// startActivity(login);
// finish();
// }
//
// } catch (Exception e) {
// System.out.println("........................................ 1......................................................");
// e.printStackTrace();
// }
// }
// else
if(button.equals("facultydata"))
{
Intent login = new Intent(getApplicationContext(), TeacherNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else if(button.equals("update"))
{
String url_login = http:// 192.168.43.156:8081/OnlineAttendance/StudentUpdate";
List<NameValuePair> params = new ArrayList<NameValuePair>();
DataBase db=new DataBase(ctx);
Cursor cs=db.getInformation(db);
int ror=cs.getCount();
cs.moveToNext();
System.out.println( " row value is : "+ror);
int k=0;
for(int i=0;i<cs.getCount();i++)
{
params.add(new BasicNameValuePair("name"+k,cs.getString(0)));
System.out.println( " name vzlue is : "+cs.getString(0));
k++;
params.add(new BasicNameValuePair("roll"+k,cs.getString(1)));
System.out.println( " roll no is : "+cs.getString(1));
k++;
params.add(new BasicNameValuePair("branch"+k,cs.getInt(2)+""));
System.out.println( " branch no is : "+cs.getString(2));
k++;
params.add(new BasicNameValuePair("section"+k,cs.getString(3)));
System.out.println( " roll no is : "+cs.getString(3));
k++;
params.add(new BasicNameValuePair("attendance"+k,cs.getInt(4)+""));
System.out.println( " attendance no is : "+cs.getString(4));
k++;
params.add(new BasicNameValuePair("subjectcode"+k,cs.getInt(5)+""));
System.out.println("..........subcode value is........."+cs.getInt(5));
k++;
cs.moveToNext();
}
params.add(new BasicNameValuePair("row",ror+""));
params.add(new BasicNameValuePair("table",Identification.TableName));
params.add(new BasicNameValuePair("facultyCode",Identification.FacultyCode));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
if (json.getString("info").equals("success")) {
Cursor cs2=db.getInformation3(db);
int ror2=cs2.getCount();
cs2.moveToFirst();
List<NameValuePair> params2 = new ArrayList<NameValuePair>();
for(int i=0;i<cs2.getCount();i++)
{
params2.add(new BasicNameValuePair("faccode"+i,cs2.getInt(0)+""));
params2.add(new BasicNameValuePair("subcode"+i,cs2.getInt(1)+""));
params2.add(new BasicNameValuePair("lecno"+i,cs2.getInt(2)+""));
params2.add(new BasicNameValuePair("str"+i,cs2.getInt(3)+""));
params2.add(new BasicNameValuePair("br"+i,cs2.getInt(4)+""));
params2.add(new BasicNameValuePair("sec"+i,cs2.getString(5)+""));
cs2.moveToNext();
}
params2.add(new BasicNameValuePair("row",ror2+""));
params2.add(new BasicNameValuePair("table",Identification.TableName));
String url_login2 = "http:/ /192.168.43.156:8081/OnlineAttendance/FacultyDataUpdation";
json = jParser.makeHttpRequest(url_login2, "GET", params2);
String Sname2=null;
if(json.getString("info2").equals("success"))
{
String url_login3 = http:// 192.168.43.156:8081/OnlineAttendance/Student";
List<NameValuePair> params3 = new ArrayList<NameValuePair>();
for (int i = 0; i < Identification.FacultySubjectRecord.length; i++)
{
params3.add(new BasicNameValuePair("Branch" + i, Identification.FacultySubjectRecord[i][0]));
System.out.println("....." + Identification.FacultySubjectRecord[i][0]);
params3.add(new BasicNameValuePair("Section" + i, Identification.FacultySubjectRecord[i][1]));
System.out.println("....." + Identification.FacultySubjectRecord[i][1]);
params3.add(new BasicNameValuePair("Subject" + i, Identification.FacultySubjectRecord[i][2]));
System.out.println("....." + Identification.FacultySubjectRecord[i][2]);
}
params3.add(new BasicNameValuePair("t", table));
params3.add(new BasicNameValuePair("row", Identification.FacultySubjectRecord.length + ""));
params3.add(new BasicNameValuePair("faculty", Identification.StudentRoll));
params3.add(new BasicNameValuePair("download", button));
json = jParser.makeHttpRequest(url_login3, "GET", params3);
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
String Sname3 = null;
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
db.deleteData(db);
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
try
{
System.out.println(Sname3=json.getString("info"));
int m = json.getInt("row");
System.out.println("m value....."+m) ;
if (Sname3.equals("success")) {
int j = 0;
int q = 0;
Identification.StudentRecord = new String[m][6];
System.out.println("inseide " + Identification.StudentRecord.length);
System.out.println("condition is : " + (j <= m));
while (j < m) {
String name = json.getString("name" + q);
q++;
Identification.StudentRecord[j][0] = name;
String rool = json.getString("roll" + q);
q++;
Identification.StudentRecord[j][1] = rool;
String branch = json.getString("branch" + q);
q++;
Identification.StudentRecord[j][2] = branch;
String section = json.getString("Section" + q);
q++;
Identification.StudentRecord[j][3] = section;
System.out.println("section value " + Identification.StudentRecord[j][2]);
String Attendance = json.getString("Attendance" + q);
q++;
Identification.StudentRecord[j][4] = Attendance;
String SubCode = json.getString("SubjectCode" + q);
q++;
Identification.StudentRecord[j][5] = SubCode;
System.out.println("j value is : " + j);
j++;
}
for (int i = 0; i < m; i++) {
System.out.println("...........DataBase class Insert Method is called..........");
db.insertRecord(Identification.StudentRecord[i][0], Identification.StudentRecord[i][1], Identification.StudentRecord[i][2], Identification.StudentRecord[i][3], Identification.StudentRecord[i][4], Identification.StudentRecord[i][5]);
System.out.println("...........DataBase class Insert Method is called succeful..........");
}
}
String url_login4 = "http: 192.168.43.156:8081/OnlineAttendance/StudentRecordUpdateAttendance";
List<NameValuePair> params4 = new ArrayList<NameValuePair>();
Cursor cs3=db.getInformation5(db);
int ror3=cs3.getCount();
cs3.moveToNext();
System.out.println( " row value is : "+ror3);
k=0;
for(int i=0;i<cs3.getCount();i++)
{
params4.add(new BasicNameValuePair("name"+k,cs3.getString(0)));
System.out.println("................"+cs3.getString(0));
k++;
params4.add(new BasicNameValuePair("roll"+k,cs3.getString(1)));
System.out.println("................"+cs3.getString(1));
k++;
params4.add(new BasicNameValuePair("subject"+k,cs3.getInt(2)+""));
System.out.println("................"+cs3.getString(2));
k++;
params4.add(new BasicNameValuePair("faculty"+k,cs3.getString(3)));
System.out.println("................"+cs3.getString(3));
k++;
params4.add(new BasicNameValuePair("day"+k,cs3.getString(4)+""));
System.out.println("................"+cs3.getString(4));
k++;
params4.add(new BasicNameValuePair("month"+k,cs3.getString(5)+""));
System.out.println("................"+cs3.getString(5));
k++;
params4.add(new BasicNameValuePair("year"+k,cs3.getString(6)+""));
System.out.println("................"+cs3.getString(6));
k++;
params4.add(new BasicNameValuePair("hour"+k,cs3.getString(7)+""));
System.out.println("................"+cs3.getString(7));
k++;
params4.add(new BasicNameValuePair("minu"+k,cs3.getString(8)+""));
System.out.println("................"+cs3.getString(8));
k++;
params4.add(new BasicNameValuePair("number"+k,cs3.getInt(9)+""));
System.out.println("................"+cs3.getString(9));
k++;
cs3.moveToNext();
}
params4.add(new BasicNameValuePair("row",ror3+""));
params4.add(new BasicNameValuePair("table",Identification.TableName));
json = jParser.makeHttpRequest(url_login4, "GET", params4);
String Sname5=null;
if(json.getString("info6").equals("success"))
{
db.deleteData4(db);
Intent login = new Intent(getApplicationContext(),Successful.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch (Exception e)
{
System.out.println("...........Dtadata download error in upadation..........");
e.printStackTrace();
}
}
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
else if(button.equals("dricNotice"))
{
String url_login2 = "http 192.168.43.156:8081/OnlineAttendance/DirectorNoticeServlet";
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("t", Identification.TableName));
params.add(new BasicNameValuePair("cutoff", button));
params.add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
System.out.println("................ 7......................." + json);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices=json.getString("name");
Intent login = new Intent(getApplicationContext(), FacultyDrictorNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
} catch (Exception e) {
e.printStackTrace();
}
}
else if(button.equals("hodNotice"))
{
String url_login2 = "http 192.168.43.156:8081/OnlineAttendance/DirectorNoticeServlet";
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("t", Identification.TableName));
params.add(new BasicNameValuePair("cutoff", button));
params.add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
System.out.println("................ 7......................." + json);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices=json.getString("name");
Intent login = new Intent(getApplicationContext(), FacultyHODNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
} catch (Exception e) {
e.printStackTrace();
}
}
else if(button.equals("HOD"))
{
Intent login = new Intent(getApplicationContext(), TeacherHODLogin.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
return null;
}
}
}
Subscribe to:
Posts (Atom)