Commit 2ffe21f5 authored by Dharmakeerthi's avatar Dharmakeerthi

Upload function interfaces

parent 2a084f66
package com.appsnipp.education;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.List;
public class Maintainces extends AppCompatActivity {
TextView textTargetUri;
static ImageView targetImage;
TextView textOwnername;
TextView BrandDe;
TextView Modelde;
TextView ManufacturDateDe;
TextView EngineTypeDe;
TextView vDe;
String test1;
public static Bitmap bitmap;
public static Bitmap bitmap1;
Uri targetUri;
public static int checking2;
public static int checking1;
public String temp1="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maintainces);
ImageButton buttonLoadImage = (ImageButton) findViewById(R.id.imageButton);
//textTargetUri = (TextView)findViewById(R.id.targeturi);
targetImage = (ImageView)findViewById(R.id.vehiclechange);
//targetImage2 = (ImageView)findViewById(R.id.targetimage2);
try{
FileInputStream fin = openFileInput("myfile");
int c;
String temp="";
while((c=fin.read())!=-1){
temp=temp+Character.toString((char) c);
textOwnername = (TextView) findViewById(R.id.owner);
textOwnername.setText(temp);
}
System.out.println(temp);
}catch (Exception e){
e.printStackTrace();
}
try{
FileInputStream fin = openFileInput("myfile1");
int p;
while((p=fin.read())!=-1){
temp1=temp1+Character.toString((char) p);
// textOwnername = (TextView) findViewById(R.id.owner);
// textOwnername.setText(temp);
}
List<String> details = Arrays.asList(temp1.split("/"));
BrandDe = (TextView) findViewById(R.id.BrandDe);
Modelde = (TextView) findViewById(R.id.ModelDe);
ManufacturDateDe=(TextView) findViewById(R.id.makeyearDE);
EngineTypeDe=(TextView) findViewById(R.id.EngineTypeDe);
vDe=(TextView) findViewById(R.id.VDe);
vDe.setText(details.get(0));
BrandDe.setText(details.get(1));
Modelde.setText(details.get(2));
ManufacturDateDe.setText(details.get(3));
EngineTypeDe.setText(details.get(4));
}catch (Exception e){
vDe.setText("Enter your Details");
BrandDe.setText("Enter your Details");
Modelde.setText("Enter your Details");
ManufacturDateDe.setText("Enter your Details");
EngineTypeDe.setText("Enter your Details");
e.printStackTrace();
}
RelativeLayout relativeclic1 =(RelativeLayout)findViewById(R.id.BackToHome);
relativeclic1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
startActivityForResult(new Intent(Maintainces.this,MainActivity.class), 0);
}
});
RelativeLayout relativeclic2 =(RelativeLayout)findViewById(R.id.BackToUpComing);
relativeclic2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v1){
startActivityForResult(new Intent(Maintainces.this, UpComing.class), 0);
}
});
buttonLoadImage.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}});
if (bitmap1 != null) {
targetImage.setImageBitmap(bitmap1);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
targetUri = data.getData();
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
targetImage.setImageBitmap(bitmap);
bitmap1=bitmap;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
\ No newline at end of file
package com.appsnipp.education;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import java.io.FileOutputStream;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class PredictedMileage extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
EditText textName6;
EditText textName7;
EditText textName8;
EditText textName9;
EditText textName10;
EditText textName11;
EditText textName12;
EditText textName15;
public static int cal2;
Switch simpleSwitch1, simpleSwitch2;
public String text6,text7,text8,text9,text10,text11,text12;
Spinner spinner6,spinner7,spinner8,spinner9,spinner10,spinner11,spinner12;
int oilFilter,engine_oil,wash_PD,DA_PF,WA_B,AC_F,cool_ent,Break_Fluid,brake_Pads,F_F,SparkPlug,clut_ch,Break_And_Clutch_Oil,transmission_fluid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_predicted_mileage);
String g;
Button add, clear;
textName6 = (EditText) findViewById(R.id.EditTxtVehicleType);
textName7 = (EditText) findViewById(R.id.EditTxtVehicleBrand);
textName8 = (EditText) findViewById(R.id.EditTxtVehicleModel);
textName9 = (EditText) findViewById(R.id.EditTxtMakeYear);
textName10 = (EditText) findViewById(R.id.EditTxtEngineType);
textName12 = (EditText) findViewById(R.id.EditTxtMileageRange);
textName15 = (EditText) findViewById(R.id.EditTxtRunMileage);
Switch switch_oilfilter = findViewById(R.id.EditTxtOilFilter);
Switch switch_engineoil = findViewById(R.id.EngineOil);
Switch switch_washpD = findViewById(R.id.washPD);
Switch switch_DAPF = findViewById(R.id.EditTxtDAPF);
Switch switch_WAB = findViewById(R.id.EditTxtWAB);
Switch switch_ACF = findViewById(R.id.EditTxtACF);
Switch switch_coolent = findViewById(R.id.EditTxtCoolent);
Switch switch_BreakFluid = findViewById(R.id.BrakeFluid);
Switch switch_brakePads = findViewById(R.id.brakePads);
Switch switch_FF = findViewById(R.id.EditTxtFF);
Switch switch_Sparkplug = findViewById(R.id.Sparkplug);
Switch switch_clutch = findViewById(R.id.clutch);
Switch switch_BreakAndClutchOil = findViewById(R.id.BreakAndClutchOil);
Switch switch_transmission_fluid = findViewById(R.id.Edittransmission_fluid);
//
switch_oilfilter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton1, boolean b1) {
if(b1) {
oilFilter = 1;
}else{
oilFilter = 0;
}
}
});
switch_engineoil.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton2, boolean b2) {
if(b2) {
engine_oil = 1;
}else{
engine_oil = 0;
}
}
});
switch_washpD.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton3, boolean b3) {
if(b3) {
wash_PD = 1;
}else{
wash_PD = 0;
}
}
});
switch_DAPF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton4, boolean b4) {
if(b4) {
DA_PF = 1;
}else{
DA_PF = 0;
}
}
});
switch_WAB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton5, boolean b5) {
if(b5) {
WA_B = 1;
}else{
WA_B = 0;
}
}
});
switch_ACF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton6, boolean b6) {
if(b6) {
AC_F = 1;
}else{
AC_F = 0;
}
}
});
switch_coolent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton7, boolean b7) {
if(b7) {
cool_ent = 1;
}else{
cool_ent = 0;
}
}
});
switch_BreakFluid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton8, boolean b8) {
if(b8) {
Break_Fluid = 1;
}else{
Break_Fluid = 0;
}
}
});
switch_brakePads.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton9, boolean b9) {
if(b9) {
brake_Pads = 1;
}else{
brake_Pads = 0;
}
}
});
switch_FF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton10, boolean b10) {
if(b10) {
F_F = 1;
}else{
F_F = 0;
}
}
});
switch_Sparkplug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton11, boolean b11) {
if(b11) {
SparkPlug = 1;
}else{
SparkPlug = 0;
}
}
});
switch_clutch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton12, boolean b12) {
if(b12) {
clut_ch = 1;
}else{
clut_ch = 0;
}
}
});
switch_BreakAndClutchOil.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton13, boolean b13) {
if(b13) {
Break_And_Clutch_Oil = 1;
}else{
Break_And_Clutch_Oil = 0;
}
}
});
switch_transmission_fluid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton14, boolean b14) {
if(b14) {
transmission_fluid = 1;
}else{
transmission_fluid = 0;
}
}
});
// togglebutton = (ToggleButton) findViewById(R.id.toggleButton);
spinner6 = findViewById(R.id.spinner6);
ArrayAdapter<CharSequence> adapter6 = ArrayAdapter.createFromResource(this,
R.array.vehicleType, android.R.layout.simple_spinner_item);
adapter6.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner6.setAdapter(adapter6);
spinner6.setOnItemSelectedListener(this);
spinner7 = findViewById(R.id.spinner7);
ArrayAdapter<CharSequence> adapter7 = ArrayAdapter.createFromResource(this,
R.array.vehicleBrand, android.R.layout.simple_spinner_item);
adapter7.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner7.setAdapter(adapter7);
spinner7.setOnItemSelectedListener(this);
spinner8 = findViewById(R.id.spinner8);
ArrayAdapter<CharSequence> adapter8 = ArrayAdapter.createFromResource(this,
R.array.VehicleModel, android.R.layout.simple_spinner_item);
adapter8.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner8.setAdapter(adapter8);
spinner8.setOnItemSelectedListener(this);
spinner9 = findViewById(R.id.spinner9);
ArrayAdapter<CharSequence> adapter9 = ArrayAdapter.createFromResource(this,
R.array.MakeYear, android.R.layout.simple_spinner_item);
adapter9.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner9.setAdapter(adapter9);
spinner9.setOnItemSelectedListener(this);
spinner10 = findViewById(R.id.spinner10);
ArrayAdapter<CharSequence> adapter10 = ArrayAdapter.createFromResource(this,
R.array.EngineType, android.R.layout.simple_spinner_item);
adapter10.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner10.setAdapter(adapter10);
spinner10.setOnItemSelectedListener(this);
spinner12 = findViewById(R.id.spinner12);
ArrayAdapter<CharSequence> adapter12 = ArrayAdapter.createFromResource(this,
R.array.MileageRange, android.R.layout.simple_spinner_item);
adapter12.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner12.setAdapter(adapter12);
spinner12.setOnItemSelectedListener(this);
add = findViewById(R.id.btnSendForm);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (textName6 .getText().toString().isEmpty() || textName7.getText().toString().isEmpty() || textName8.getText().toString().isEmpty()||
textName9.getText().toString().isEmpty() ||
textName10.getText().toString().isEmpty() ||
textName12.getText().toString().isEmpty()) {
System.out.println("HY1");
Toast.makeText(PredictedMileage.this, "Please enter All the values", Toast.LENGTH_SHORT).show();
return;
}else{
System.out.println("HY2");
String TypeD=textName6 .getText().toString();
String ModelD=textName8.getText().toString();
String make_yearD=textName10.getText().toString();
String BrandD=textName7.getText().toString();
String EngineTypeD=textName9.getText().toString();
String vehicleD=TypeD+"/"+ModelD+"/"+make_yearD+"/"+BrandD+"/"+EngineTypeD;
FileOutputStream outputStream;
try{
outputStream = openFileOutput("myfile1",MODE_PRIVATE);
outputStream.write(vehicleD.getBytes());
outputStream.close();
}catch (Exception e){
e.printStackTrace();
}
postData(textName6.getText().toString(), textName7.getText().toString(),textName8.getText().toString(),textName10.getText().toString(),textName9.getText().toString(),textName12.getText().toString(),"Chennai",
textName15.getText().toString(),oilFilter,wash_PD,WA_B,F_F,Break_Fluid,transmission_fluid,clut_ch,engine_oil,
DA_PF,AC_F,SparkPlug,Break_And_Clutch_Oil,brake_Pads,cool_ent);
Toast.makeText(PredictedMileage.this, "You form is sucessfull", Toast.LENGTH_SHORT).show();
}
}
});
clear = findViewById(R.id.btnclearForm);
clear.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
spinner6.setSelection(0,true);
spinner7.setSelection(0,true);
spinner8.setSelection(0,true);
spinner9.setSelection(0,true);
spinner10.setSelection(0,true);
spinner12.setSelection(0,true);
textName15.getText().clear();
}
});
}
private void postData(String vehicle_type,
String brand,
String model,
String engine_type,
String make_year,
String mileage_range,
String region,
String mileage,
int oil_filter,
int washer_plug_drain,
int Wheel_alignment_and_balance,
int Fuel_filter,
int Break_fluid,
int Transmission_Fluid,
int clutch,
int Engine_Oil,
int Dust_and_pollen_filter,
int Air_clean_filter,
int Spark_plug,
int Break_and_Clutch_oil,
int Break_Pads,
int Coolant
){
// builder and passing our base url
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.1.6:8000/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
// Gson gson = new Gson();
RetrofitAPI retrofitAPI = retrofit.create(RetrofitAPI.class);
// passing data from our text fields to our modal class.
DataModal modal = new DataModal(vehicle_type, brand,model,engine_type,make_year,mileage_range,region,mileage,oil_filter,
washer_plug_drain,Wheel_alignment_and_balance,Fuel_filter,Break_fluid,Transmission_Fluid,clutch,Engine_Oil,
Dust_and_pollen_filter,Air_clean_filter,Spark_plug,Break_and_Clutch_oil,Break_Pads,Coolant);
Call<DataModal> call = retrofitAPI.createPost(modal);
call.enqueue(new Callback<DataModal>() {
@Override
public void onResponse(Call<DataModal> call, Response<DataModal> response) {
Toast.makeText(PredictedMileage.this, "Data added to API", Toast.LENGTH_SHORT).show();
DataModal responseFromAPI1 = response.body();
TextView textName19 = (TextView) findViewById(R.id.textView19);
textName19.setText(responseFromAPI1.getPredictedVal()+"km");
cal2=Math.round(responseFromAPI1.getPredictedVal());
System.out.println(responseFromAPI1.getPredictedVal());
}
@Override
public void onFailure(Call<DataModal> call, Throwable t) {
Toast.makeText(PredictedMileage.this, "Data can't added to API", Toast.LENGTH_SHORT).show();
System.out.println(t.getMessage());
}
});
}
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Spinner spinner = (Spinner) parent;
if(spinner.getId() == R.id.spinner6)
{
text6 = parent.getItemAtPosition(position).toString();
textName6.setText(text6);
}
else if(spinner.getId() == R.id.spinner7)
{
String text7 = parent.getItemAtPosition(position).toString();
textName7.setText(text7);
}else if(spinner.getId() == R.id.spinner8)
{
String text8 = parent.getItemAtPosition(position).toString();
textName8.setText(text8);
}else if(spinner.getId() == R.id.spinner9)
{
String text9 = parent.getItemAtPosition(position).toString();
textName9.setText(text9);
}else if(spinner.getId() == R.id.spinner10)
{
String text10 = parent.getItemAtPosition(position).toString();
textName10.setText(text10);
}
else if(spinner.getId() == R.id.spinner12)
{
String text12 = parent.getItemAtPosition(position).toString();
textName12.setText(text12);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
\ No newline at end of file
package com.appsnipp.education;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class predicted_suggestions extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
TextView textName6;
TextView textName7;
TextView textName8;
TextView textName9;
TextView textName10;
TextView textName11;
TextView textName12;
EditText textName14;
EditText textName15;
public static int oil_filter,washer_plug_drain, Wheel_alignment_and_balance,
Fuel_filter, Break_fluid, Transmission_Fluid, clutch, Engine_Oil, Dust_and_pollen_filter,
Air_clean_filter, Spark_plug, Break_and_Clutch_oil,Break_Pads,Coolant;
public static int checking1;
public static int checking2;
Spinner spinner6,spinner7,spinner8,spinner9,spinner10,spinner12;
Button clear,add;
String text6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_predicted_suggestions);
textName6 = (TextView) findViewById(R.id.EditTxtVehicleType);
textName7 = (TextView) findViewById(R.id.EditTxtVehicleBrand);
textName8 = (TextView) findViewById(R.id.EditTxtVehicleModel);
textName9 = (TextView) findViewById(R.id.EditTxtMakeYear);
textName10 = (TextView) findViewById(R.id.EditTxtEngineType);
textName12 = (TextView) findViewById(R.id.EditTxtMileageRange);
textName14=(EditText) findViewById(R.id.EditTxtMileage);
textName15 = (EditText) findViewById(R.id.EditTxtpredictedMileage);
//
//
spinner6 = findViewById(R.id.spinner6);
ArrayAdapter<CharSequence> adapter6 = ArrayAdapter.createFromResource(this,
R.array.vehicleType, android.R.layout.simple_spinner_item);
adapter6.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner6.setAdapter(adapter6);
spinner6.setOnItemSelectedListener(this);
spinner7 = findViewById(R.id.spinner7);
ArrayAdapter<CharSequence> adapter7 = ArrayAdapter.createFromResource(this,
R.array.vehicleBrand, android.R.layout.simple_spinner_item);
adapter7.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner7.setAdapter(adapter7);
spinner7.setOnItemSelectedListener(this);
spinner8 = findViewById(R.id.spinner8);
ArrayAdapter<CharSequence> adapter8 = ArrayAdapter.createFromResource(this,
R.array.VehicleModel, android.R.layout.simple_spinner_item);
adapter8.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner8.setAdapter(adapter8);
spinner8.setOnItemSelectedListener(this);
spinner9 = findViewById(R.id.spinner9);
ArrayAdapter<CharSequence> adapter9 = ArrayAdapter.createFromResource(this,
R.array.MakeYear, android.R.layout.simple_spinner_item);
adapter9.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner9.setAdapter(adapter9);
spinner9.setOnItemSelectedListener(this);
spinner10 = findViewById(R.id.spinner10);
ArrayAdapter<CharSequence> adapter10 = ArrayAdapter.createFromResource(this,
R.array.EngineType, android.R.layout.simple_spinner_item);
adapter10.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner10.setAdapter(adapter10);
spinner10.setOnItemSelectedListener(this);
spinner12 = findViewById(R.id.spinner12);
ArrayAdapter<CharSequence> adapter12 = ArrayAdapter.createFromResource(this,
R.array.MileageRange, android.R.layout.simple_spinner_item);
adapter12.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner12.setAdapter(adapter12);
spinner12.setOnItemSelectedListener(this);
add = findViewById(R.id.btnSend);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
System.out.println("HY1");
if (textName6.getText().toString().isEmpty() || textName7.getText().toString().isEmpty() || textName8.getText().toString().isEmpty() ||
textName9.getText().toString().isEmpty() ||
textName10.getText().toString().isEmpty() ||
textName12.getText().toString().isEmpty()) {
System.out.println("HY1");
Toast.makeText(predicted_suggestions.this, "Please enter All the values", Toast.LENGTH_SHORT).show();
return;
}else{
System.out.println("HY2");
float f=Float.parseFloat(textName15.getText().toString());
postData12(textName6.getText().toString(), textName7.getText().toString(),textName8.getText().toString(),textName10.getText().toString(),textName9.getText().toString(),textName12.getText().toString(),"Chennai",
textName14.getText().toString(),f);
Toast.makeText(predicted_suggestions.this, "You form is sucessfull", Toast.LENGTH_SHORT).show();
}
}
});
clear = findViewById(R.id.btnclear);
clear.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
spinner6.setSelection(0,true);
spinner7.setSelection(0,true);
spinner8.setSelection(0,true);
spinner9.setSelection(0,true);
spinner10.setSelection(0,true);
spinner12.setSelection(0,true);
textName14.getText().clear();
textName15.getText().clear();
}
});
//
}
private void postData12(String vehicle_type,
String brand,
String model,
String engine_type,
String make_year,
String mileage_range,
String region,
String mileage,
float predicted_data
){
Retrofit retrofit2 = new Retrofit.Builder()
.baseUrl("http://192.168.1.6:8000/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitAPI2 retrofitAPI2 = retrofit2.create(RetrofitAPI2.class);
DataModal2 modal2 = new DataModal2(vehicle_type, brand,model,make_year,engine_type,mileage_range,mileage,region,predicted_data);
Call<DataModal2> call2 = retrofitAPI2.createPost2(modal2);
call2.enqueue(new Callback<DataModal2>() {
@Override
public void onResponse(Call<DataModal2> call2, Response<DataModal2> response2) {
Toast.makeText(predicted_suggestions.this, "Data added to API", Toast.LENGTH_SHORT).show();
List<Integer> predicted_value_ss=new ArrayList<Integer>();
predicted_value_ss=response2.body().getPredictedVals();
// Maintainces classone1 = new Maintainces();
// checking2=classone1.checking2;
oil_filter=predicted_value_ss.get(0);
washer_plug_drain=predicted_value_ss.get(1);
Wheel_alignment_and_balance=predicted_value_ss.get(2);
Fuel_filter=predicted_value_ss.get(3);
Break_fluid=predicted_value_ss.get(4);
Transmission_Fluid=predicted_value_ss.get(5);
clutch=predicted_value_ss.get(6);
Engine_Oil=predicted_value_ss.get(7);
Dust_and_pollen_filter=predicted_value_ss.get(8);
Air_clean_filter=predicted_value_ss.get(9);
Spark_plug=predicted_value_ss.get(10);
Break_and_Clutch_oil=predicted_value_ss.get(11);
Break_Pads=predicted_value_ss.get(12);
Coolant=predicted_value_ss.get(13);
System.out.println(predicted_value_ss);
startActivityForResult(new Intent(predicted_suggestions.this, SuggestionAnswer.class), 0);
// System.out.println(predicted_value_ss.get(0));
// System.out.println(predicted_value_ss.get(1));
// System.out.println(predicted_value_ss.get(2));
// System.out.println(predicted_value_ss.get(3));
// System.out.println(predicted_value_ss.get(4));
// System.out.println(predicted_value_ss.get(5));
// System.out.println(predicted_value_ss.get(6));
// System.out.println(predicted_value_ss.get(7));
// System.out.println(predicted_value_ss.get(8));
// System.out.println(predicted_value_ss.get(9));
// System.out.println(predicted_value_ss.get(10));
// System.out.println(predicted_value_ss.get(11));
// System.out.println(predicted_value_ss.get(12));
// System.out.println(predicted_value_ss.get(13));
}
@Override
public void onFailure(Call<DataModal2> call2, Throwable t) {
Toast.makeText(predicted_suggestions.this, "Data can't added to API", Toast.LENGTH_SHORT).show();
System.out.println(t.getMessage());
}
});
}
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Spinner spinner = (Spinner) parent;
if(spinner.getId() == R.id.spinner6)
{
text6 = parent.getItemAtPosition(position).toString();
textName6.setText(text6);
}
else if(spinner.getId() == R.id.spinner7)
{
String text7 = parent.getItemAtPosition(position).toString();
textName7.setText(text7);
}else if(spinner.getId() == R.id.spinner8)
{
String text8 = parent.getItemAtPosition(position).toString();
textName8.setText(text8);
}else if(spinner.getId() == R.id.spinner9)
{
String text9 = parent.getItemAtPosition(position).toString();
textName9.setText(text9);
}else if(spinner.getId() == R.id.spinner10)
{
String text10 = parent.getItemAtPosition(position).toString();
textName10.setText(text10);
}
else if(spinner.getId() == R.id.spinner12)
{
String text12 = parent.getItemAtPosition(position).toString();
textName12.setText(text12);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Changers_in_one">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/finalback">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include layout="@layout/oil_filter" android:id="@+id/layoutoilfilter" />
<include layout="@layout/engine_oil" android:id="@+id/layoutengineoil" />
<include layout="@layout/washer_plug" android:id="@+id/layoutwasher_plug" />
<include layout="@layout/dust_filter" android:id="@+id/layoutdust_filter" />
<include layout="@layout/wheel_align" android:id="@+id/layoutwheel_align" />
<include layout="@layout/air_clean_filter" android:id="@+id/layoutair_clean_filter" />
<include layout="@layout/fuel_filter" android:id="@+id/layoutfuel_filter" />
<include layout="@layout/spark_plug" android:id="@+id/layoutspark_plug" />
<include layout="@layout/brake_fluid" android:id="@+id/layoutbrake_fluid" />
<include layout="@layout/break_oil" android:id="@+id/layoutbreak_oil" />
<include layout="@layout/transmission_fluid" android:id="@+id/layouttransmission_fluid" />
<include layout="@layout/break_pads" android:id="@+id/layoutbreak_pads" />
<include layout="@layout/clutch" android:id="@+id/layoutclutch" />
<include layout="@layout/coolant" android:id="@+id/layoutcoolant" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Changers_in_two">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/finalback">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include layout="@layout/oil_filter" android:id="@+id/layoutoilfilter" />
<include layout="@layout/engine_oil" android:id="@+id/layoutengineoil" />
<include layout="@layout/washer_plug" android:id="@+id/layoutwasher_plug" />
<include layout="@layout/dust_filter" android:id="@+id/layoutdust_filter" />
<include layout="@layout/wheel_align" android:id="@+id/layoutwheel_align" />
<include layout="@layout/air_clean_filter" android:id="@+id/layoutair_clean_filter" />
<include layout="@layout/fuel_filter" android:id="@+id/layoutfuel_filter" />
<include layout="@layout/spark_plug" android:id="@+id/layoutspark_plug" />
<include layout="@layout/brake_fluid" android:id="@+id/layoutbrake_fluid" />
<include layout="@layout/break_oil" android:id="@+id/layoutbreak_oil" />
<include layout="@layout/transmission_fluid" android:id="@+id/layouttransmission_fluid" />
<include layout="@layout/break_pads" android:id="@+id/layoutbreak_pads" />
<include layout="@layout/clutch" android:id="@+id/layoutclutch" />
<include layout="@layout/coolant" android:id="@+id/layoutcoolant" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Prediction">
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/headerLayout"
android:layout_width="315dp"
android:layout_height="395dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="24dp"
android:layout_marginTop="69dp"
android:layout_marginEnd="32dp"
android:background="@drawable/reports_header_bk"
android:paddingLeft="20dp"
android:paddingTop="6dp"
android:paddingRight="20dp"
android:paddingBottom="20dp">
<TextView
android:id="@+id/salesHeaderTextView"
style="@style/reportContentText"
android:layout_width="335dp"
android:layout_height="67dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="0dp"
android:layout_marginTop="45dp"
android:layout_marginEnd="0dp"
android:gravity="center"
android:text="@string/total_mileage"
android:textSize="40sp" />
<TextView
android:id="@+id/f89"
style="@style/viewParent.headerText"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_below="@+id/salesHeaderTextView"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="0dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="0dp"
android:layout_marginBottom="70dp"
android:gravity="center"
android:text="@string/_15_290_km"
android:textColor="@color/whiteTextColor" />
<TextView
android:id="@+id/textView2"
android:layout_width="67dp"
android:layout_height="51dp"
android:layout_alignStart="@+id/progress_bar"
android:layout_alignBottom="@+id/progress_bar"
android:layout_marginStart="45dp"
android:layout_marginBottom="60dp"
android:gravity="center"
android:text="60%"
android:textSize="30dp" />
<ProgressBar
android:id="@+id/progress_bar"
style="@style/CircularDeterminateProgressBar"
android:layout_width="172dp"
android:layout_height="192dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="67dp"
android:layout_marginTop="-64dp"
android:layout_marginBottom="34dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:progress="60" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp">
<include
android:id="@+id/includepredictedSugestions"
layout="@layout/predict_suggesstions"
android:layout_width="359dp"
android:layout_height="99dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="22dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="1dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp">
<include
android:id="@+id/includepredicted_mileage"
layout="@layout/predict_mileage"
android:layout_width="359dp"
android:layout_height="97dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="22dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="3dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<!-- <LinearLayout-->
<!-- android:id="@+id/cardLayout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="320dp"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@+id/headerLayout">-->
<!-- <android.support.v7.widget.CardView-->
<!-- style="@style/reportsCardStyle"-->
<!-- app:cardBackgroundColor="@color/whiteTextColor"-->
<!-- app:cardCornerRadius="16dp">-->
<!-- <LinearLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center"-->
<!-- android:orientation="vertical">-->
<!-- <TextView-->
<!-- android:id="@+id/this_month"-->
<!-- style="@style/reportContentText"-->
<!-- android:text="@string/this_month"-->
<!-- android:textColor="#79D0A3" />-->
<!-- <TextView-->
<!-- android:id="@+id/valuethismonth"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/km"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="27sp"-->
<!-- android:textStyle="bold" />-->
<!-- </LinearLayout>-->
<!-- </android.support.v7.widget.CardView>-->
<!-- <android.support.v7.widget.CardView-->
<!-- style="@style/reportsCardStyle"-->
<!-- app:cardBackgroundColor="@color/whiteTextColor"-->
<!-- app:cardCornerRadius="16dp">-->
<!-- <LinearLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center"-->
<!-- android:orientation="vertical">-->
<!-- <TextView-->
<!-- style="@style/reportContentText"-->
<!-- android:text="@string/thisweekkm"-->
<!-- android:textColor="#79D0A3" />-->
<!-- <TextView-->
<!-- android:id="@+id/valuethisWeek"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/km"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="27sp"-->
<!-- android:textStyle="bold" />-->
<!-- </LinearLayout>-->
<!-- </android.support.v7.widget.CardView>-->
<!-- </LinearLayout>-->
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment