Exemple #1
0
 public int DbInsertCarInfo(CarInfo ci) throws SQLException {
   String sql =
       "insert into CarInfo values(default,'"
           + ci.getCarPlate()
           + "','"
           + ci.getCarModel()
           + "','"
           + ci.getCarLeaseDate()
           + "','"
           + ci.getCarReaturnDate()
           + "');";
   return state.executeUpdate(sql);
 }
  private void loadCarDetails() {
    // TODO Auto-generated method stub
    String url =
        "http://www.unitedcarexchange.com/MobileService/ServiceMobile.svc/FindCarID/"
            + getIntent().getStringExtra("CAR_ID")
            + "/"
            + aid
            + "/"
            + uid
            + "/";
    JSONParser jParser = new JSONParser();
    JSONObject json = jParser.getJSONFromUrl(url);
    //	System.out.println("this is url" + url);
    try {
      // Getting Array of Contacts
      contacts = json.getJSONArray("FindCarIDResult");
      if (contacts != null) {
        for (int i = 0; i < contacts.length(); i++) {
          jsonobject = contacts.getJSONObject(i);
          imageURL =
              domainName
                  + jsonobject.getString("_PICLOC1").replace(" ", "%20").replace("Emp", "")
                  + jsonobject.getString("_PIC0").replace(" ", "%20").replace("Emp", "");
          // .replace("Emp", "");
          //	System.out.println("this is imageurl" + imageURL);
          ImageLoaders imageLoader = new ImageLoaders(getApplicationContext());
          imageLoader.displayImage(imageURL, imageView);
          phone = jsonobject.getString("_phone");
          // System.out.println("this is phone" + phone);
          email = jsonobject.getString("_email");
          /*address = jsonobject.getString("_city").trim().replace("Emp", "") + "," + " "
          + jsonobject.getString("_state").trim().replace("Emp", "") + " "
          + jsonobject.getString("_zip").replace("Emp", "");*/
          if (jsonobject.getString("_city").equals("Emp")) {

            address =
                jsonobject.getString("_state").trim().replace("Emp", "")
                    + " "
                    + jsonobject.getString("_zip").replace("Emp", "");
          } else {
            address =
                jsonobject.getString("_city").trim().replace("Emp", "")
                    + ","
                    + " "
                    + jsonobject.getString("_state").trim().replace("Emp", "")
                    + " "
                    + jsonobject.getString("_zip").replace("Emp", "");
          }
          price1 = jsonobject.getString("_price").trim();
          make1 = jsonobject.getString("_make").trim();
          model1 = jsonobject.getString("_model").trim();
          year1 = jsonobject.getString("_yearOfMake").trim();
          bodystyle = jsonobject.getString("_bodytype");
          exteriorcolor1 = jsonobject.getString("_exteriorColor");
          interiorcolor1 = jsonobject.getString("_interiorColor");
          doors = jsonobject.getString("_numberOfDoors");
          vehiclecondition = jsonobject.getString("_ConditionDescription");
          mileage = jsonobject.getString("_mileage");
          fuel1 = jsonobject.getString("_Fueltype");
          transmission = jsonobject.getString("_Transmission");
          engine = jsonobject.getString("_numberOfCylinder");
          drivetrain = jsonobject.getString("_DriveTrain");
          vin1 = jsonobject.getString("_VIN");
          description = jsonobject.getString("_description");
          carInfo.setPIC1(
              domainName
                  + jsonobject.getString("_PICLOC1")
                  + jsonobject.getString("_PIC1").replace(" ", "%20").replace("Emp", ""));
          carInfo.setPIC2(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC2"));
          carInfo.setPIC3(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC3"));

          carInfo.setPIC4(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC4"));

          carInfo.setPIC5(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC5"));

          carInfo.setPIC6(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC6"));

          carInfo.setPIC7(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC7"));

          carInfo.setPIC8(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC8"));
          carInfo.setPIC9(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC9"));
          carInfo.setPIC10(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC10"));
          carInfo.setPIC11(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC11"));
          carInfo.setPIC12(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC12"));
          carInfo.setPIC13(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC13"));
          carInfo.setPIC14(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC14"));
          carInfo.setPIC15(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC15"));
          carInfo.setPIC16(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC16"));
          carInfo.setPIC17(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC17"));
          carInfo.setPIC18(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC18"));
          carInfo.setPIC19(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC19"));
          carInfo.setPIC20(
              domainName + jsonobject.getString("_PICLOC1") + jsonobject.getString("_PIC20"));

          NumberFormat format = NumberFormat.getCurrencyInstance();
          format.setMinimumFractionDigits(0);

          NumberFormat Millageformat = NumberFormat.getNumberInstance();
          Millageformat.setMinimumIntegerDigits(1);

          Phone1.setText(phone);
          Email.setText(email);
          Email.setText("Send an email to seller " + "");
          SpannableString emailunderline = new SpannableString("Send an email to seller " + "");
          emailunderline.setSpan(new UnderlineSpan(), 0, emailunderline.length(), 0);
          Email.setText(emailunderline);
          Zip.setText(address);
          price.setText(price1);
          Make.setText(make1);
          Model.setText(model1);
          Year.setText(year1);
          tv_year.setText(year1 + " " + make1 + " " + model1);
          Bodystyle.setText(bodystyle);
          exteriorcolor.setText(exteriorcolor1);
          interiorcolor.setText(interiorcolor1);
          Doors.setText(doors);
          ConditionDescription.setText(vehiclecondition);
          Millage.setText(Millageformat.format(Double.parseDouble(mileage + "")) + " Mi");
          fuel.setText(fuel1);
          Engione.setText(engine);
          Transmission.setText(transmission);
          Drive.setText(drivetrain);
          if (vin1.equals("Emp")) {
            Vin.setText("");
          } else {
            Vin.setText(vin1);
          }
          if (description.equals("Emp")) {
            Description.setText("");
          } else {
            Description.setText(description);
          }
          for (int j = 0; j <= 20; j++) {
            if (jsonobject.getString("_PIC1").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC1());
            }
            if (jsonobject.getString("_PIC2").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC2());
            }
            if (jsonobject.getString("_PIC3").equalsIgnoreCase("Emp")) {
              break;
              //
            } else {
              carGallerList.add(carInfo.getPIC3());
            }
            if (jsonobject.getString("_PIC4").equalsIgnoreCase("Emp")) {
              break;
            } else {

              carGallerList.add(carInfo.getPIC4());
            }
            if (jsonobject.getString("_PIC5").equalsIgnoreCase("Emp")) {
              break;

            } else {
              carGallerList.add(carInfo.getPIC5());
            }
            if (jsonobject.getString("_PIC6").equalsIgnoreCase("Emp")) {
              break;
              //
            } else {
              carGallerList.add(carInfo.getPIC6());
            }
            if (jsonobject.getString("_PIC7").equalsIgnoreCase("Emp")) {
              break;
              //
            } else {
              carGallerList.add(carInfo.getPIC7());
            }
            if (jsonobject.getString("_PIC8").equalsIgnoreCase("Emp")) {

            } else {
              carGallerList.add(carInfo.getPIC8());
            }
            if (jsonobject.getString("_PIC9").equalsIgnoreCase("Emp")) {

            } else {
              carGallerList.add(carInfo.getPIC9());
            }
            if (jsonobject.getString("_PIC10").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC10());
            }
            if (jsonobject.getString("_PIC11").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC11());
            }
            if (jsonobject.getString("_PIC12").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC12());
            }
            if (jsonobject.getString("_PIC13").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC13());
            }
            if (jsonobject.getString("_PIC14").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC14());
            }
            if (jsonobject.getString("_PIC15").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC15());
            }
            if (jsonobject.getString("_PIC16").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC16());
            }
            if (jsonobject.getString("_PIC17").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC17());
            }
            if (jsonobject.getString("_PIC18").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC18());
            }
            if (jsonobject.getString("_PIC19").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC19());
            }
            if (jsonobject.getString("_PIC20").equalsIgnoreCase("Emp")) {
              break;
            } else {
              carGallerList.add(carInfo.getPIC20());
            }
            break;
          }
        }
      } else {
        Toast.makeText(getApplicationContext(), "No Deatils for this car", Toast.LENGTH_LONG)
            .show();
      }
    } catch (JSONException e) {
      e.printStackTrace();

      Toast.makeText(
              getApplicationContext(), "Server Error occured,Please try again", Toast.LENGTH_LONG)
          .show();
    }
    Email.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub

            Intent frequentMessages =
                new Intent(getApplicationContext(), EmailActivity.class)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            frequentMessages.putExtra("Make", Make.getText().toString());
            frequentMessages.putExtra("Model", Model.getText().toString());
            frequentMessages.putExtra("Price", price.getText().toString());
            frequentMessages.putExtra("Year", Year.getText().toString());
            frequentMessages.putExtra("Cid", getIntent().getStringExtra("CAR_ID"));
            frequentMessages.putExtra("Phone", phone + "");

            startActivity(frequentMessages);
          }
        });
  }
Exemple #3
0
public class Home extends AppCompatActivity {

  @Bind(R.id.carList)
  RecyclerView carList;

  @Bind(R.id.homeFab)
  FloatingActionButton homeFab;

  private List<CarInfo> cars = CarInfo.listAll(CarInfo.class);
  private CarAdapter carAdapter;
  private static final String TAG = "Home";
  private int selectedPosition;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);
    Log.d(TAG, "Cars in list: " + cars.size());
    // homeFab.attachToListView(carList);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    carList.setLayoutManager(llm);
    carAdapter = new CarAdapter(cars, Home.this);
    carList.setAdapter(carAdapter);
    registerForContextMenu(carList);
    carAdapter.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            Intent carPage = new Intent(getApplicationContext(), CarPage.class);
            Bundle b = new Bundle();
            b.putString("vin", cars.get(position).getVin());
            carPage.putExtras(b);
            startActivity(carPage);
          }

          @Override
          public void onItemLongClick(View view, int position) {
            Log.d(TAG, "ITEM WAS LONG PRESSED!");
            openContextMenu(view);
            selectedPosition = position;
          }
        });
  }

  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.cardeletemenu, menu);
    menu.setHeaderTitle("Delete Car?");
  }

  @Override
  public boolean onContextItemSelected(MenuItem item) {
    Log.d(
        TAG,
        "Selected position = " + selectedPosition + " and title = " + item.getTitle().toString());

    if (item.getTitle().equals("Delete Car")) {
      cars.get(selectedPosition).delete();
      resetCarList();
    } else {
      return false;
    }
    return true;
  }

  @Override
  protected void onResume() {
    super.onResume();
    Log.d(TAG, "onResume Called");
    resetCarList();
  }

  private void resetCarList() {
    cars = CarInfo.listAll(CarInfo.class);
    carAdapter.setCars(cars);
    carAdapter.notifyDataSetChanged();
  }

  @OnClick(R.id.homeFab)
  public void addCar(View view) {
    Intent carAddPage = new Intent(getApplicationContext(), CarSetUp.class);
    startActivityForResult(carAddPage, 0);
  }
}
Exemple #4
0
 private void resetCarList() {
   cars = CarInfo.listAll(CarInfo.class);
   carAdapter.setCars(cars);
   carAdapter.notifyDataSetChanged();
 }