コード例 #1
0
  protected void apply_leave() {
    // TODO Auto-generated method stub
    JsonObjectRequest jsonObjectRequest =
        new JsonObjectRequest(
            Const.Leave.URL_COMPENSATORY_OFF_p1
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p2
                + employeeID
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p3
                + companyID
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p4
                + getLeaveTypeID()
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p5
                + Leavedate.getText()
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p6
                + sessioncompo.getSelectedItem().toString()
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p7
                + totaldayscompo.getText()
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p8
                + compodate.getSelectedItem().toString()
                + Const.Leave.URL_COMPENSATORY_OFF_p1_p9
                + leavereasoncompo.getText(),
            null,
            new Listener<JSONObject>() {

              @Override
              public void onResponse(JSONObject response) {
                // TODO Auto-generated method stub
                // LeaveCategory
                try {
                  JSONArray jsonArray = response.getJSONArray("applyCompOffResult");

                  JSONObject jsonObj = jsonArray.getJSONObject(0);
                  if (jsonObj.getString("result").equals("1")) {
                    Custom_alert("Comp-off applied!..");
                  } else if (jsonObj.getString("result").equals("2")) {
                    Custom_alert("Sorry cannot apply for Comp-off!..");
                  }
                } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            },
            new Response.ErrorListener() {

              @Override
              public void onErrorResponse(VolleyError error) {
                VolleyLog.d("JSON", "Error: " + error.getMessage());
                // hideProgressDialog();
              }
            });
    AppController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
  }
コード例 #2
0
  public void get_leave_TypeID() {
    // TODO Auto-generated method stub
    String catid = "1";
    GetLeaveTypeID = Const.Leave.URL_GENERAL_P1 + catid + Const.Leave.URL_GENERAL_P2 + employeeID;
    System.out.println("GetLeaveTypeID:" + GetLeaveTypeID);

    JsonObjectRequest jsonObjectRequest =
        new JsonObjectRequest(
            GetLeaveTypeID,
            null,
            new Listener<JSONObject>() {

              @Override
              public void onResponse(JSONObject response) {
                // TODO Auto-generated method stub
                // LeaveCategory
                System.out.println("" + response);

                try {
                  JSONArray jsonArray = response.getJSONArray("leavetypeResult");

                  for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObj = jsonArray.getJSONObject(i);
                    if (jsonObj.getString("LeaveCategory").equals("2")) {
                      setLeaveTypeID(jsonObj.getString("LeaveTypeID"));
                      System.out.println("LeaveTypeID " + getLeaveTypeID());
                    }
                  }
                  apply_leave();
                } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                VolleyLog.d("JSON", "Error: " + error.getMessage());
                // hideProgressDialog();
              }
            });

    AppController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
  }
コード例 #3
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public void makeJsonObjReq() {

    // showProgressDialog();

    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    String sysDate = year + "-" + month + "-" + day;

    System.out.println("EMPLOYEE ID:" + employeeID);
    System.out.println("Company ID:" + companyID);

    JsonObjectRequest jsonObjReq =
        new JsonObjectRequest(
            Const.Leave.URL_COMPENSATORY_OFF + employeeID,
            null,
            new Response.Listener<JSONObject>() {

              @Override
              public void onResponse(JSONObject response) {

                System.out.println("URL REQUEST:" + Const.Leave.URL_COMPENSATORY_OFF + employeeID);

                Log.d("JSON", response.toString());
                System.out.println(response.toString());
                jsondata = response.toString();

                if (jsondata != null) {
                  compdate.clear();
                  compdate.add("Please Select");
                  System.out.println("in" + jsondata);
                  try {
                    JSONObject jsonObject = new JSONObject(jsondata.trim());
                    JSONArray jsonArray = jsonObject.getJSONArray("compOffRequestorListResult");
                    JSON_Length = jsonArray.length();
                    System.out.println("jarrayyy2" + jsonArray.length());
                    // leaverequest=new LeaveRequestmodel();
                    for (int i = 0; i < JSON_Length; i++) {
                      JSONObject jsonObj = jsonArray.getJSONObject(i);
                      System.out.println("Comp-OFF:" + jsonObj.getString("workDate"));
                      compdate.add(jsonObj.getString("workDate"));
                      totaldayscompo.setText(jsonObj.getString("days"));
                    }
                    ArrayAdapter<String> dataAdapter =
                        new ArrayAdapter<String>(
                            getActivity(), android.R.layout.simple_spinner_item, compdate);
                    dataAdapter.setDropDownViewResource(
                        android.R.layout.simple_spinner_dropdown_item);
                    compodate.setAdapter(dataAdapter);
                  } catch (Exception e) {
                    System.out.println(e);
                  }
                }
              }
            },
            new Response.ErrorListener() {

              @Override
              public void onErrorResponse(VolleyError error) {
                VolleyLog.d("JSON", "Error: " + error.getMessage());
                // hideProgressDialog();
              }
            });

    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(jsonObjReq, tag_json_obj);
  }