Example #1
0
    @SuppressWarnings("deprecation")
    @Override
    protected String doInBackground(String... arg0) {
      // TODO Auto-generated method stub

      SiteList.Log_reps.clear();

      SiteList.Exc_Name.clear();

      SiteList.Exces_Id.clear();

      SiteList.Log_Date.clear();

      SiteList.Log_Ints.clear();

      SiteList.Log_Sets.clear();

      SiteList.Vid_imgList.clear();

      SiteList.Vid_descriptionList.clear();

      SiteList.Vid_pathList.clear();

      SiteList.Vid_titleList.clear();

      SiteList.Dir_imageList.clear();

      SiteList.Dir_descriptionList.clear();

      SiteList.Error.clear();

      if (Methodcall.equalsIgnoreCase("submit")) {

        Date dt = new Date();
        fromUser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        myFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dat = "";
        dat = myFormat.format(new Date());

        System.out.println("dat   " + dat);

        System.out.println(
            "comlete string is              "
                + "     "
                + AllLink.putLogs
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + "\"execid\""
                + ":"
                + "\""
                + Id
                + "\""
                + " , "
                + "\"logintensity\""
                + ":"
                + "\""
                + Ed3.getText().toString()
                + "\""
                + " , "
                + "\"logset\""
                + ":"
                + "\""
                + Ed1.getText().toString()
                + "\""
                + " , "
                + "\"logrep\""
                + ":"
                + "\""
                + Ed2.getText().toString()
                + "\""
                + " , "
                + "\"lognotes\""
                + ":"
                + "\""
                + Ed4.getText().toString()
                + "\""
                + " , "
                + "\"logdate\""
                + ":"
                + "\""
                + dat
                + "\""
                + "}");

        String encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + " , "
                    + "\"logintensity\""
                    + ":"
                    + "\""
                    + Ed3.getText().toString()
                    + "\""
                    + " , "
                    + "\"logrep\""
                    + ":"
                    + "\""
                    + Ed1.getText().toString()
                    + "\""
                    + " , "
                    + "\"logset\""
                    + ":"
                    + "\""
                    + Ed2.getText().toString()
                    + "\""
                    + " , "
                    + "\"lognotes\""
                    + ":"
                    + "\""
                    + Ed4.getText().toString()
                    + "\""
                    + " , "
                    + "\"logdate\""
                    + ":"
                    + "\""
                    + dat
                    + "\""
                    + "}");

        jsonObject_Put = jsonParser.getJSONFromUrl(AllLink.putLogs + encoded);

        System.out.println("jsonObject_Put    " + jsonObject_Put);

        try {
          if (jsonObject_Put != null) {
            System.out.println("status of put is  inside1   ");
            if (jsonObject_Put.getString("status").equals("success")) {
              System.out.println("status of put is   inside2  ");
              if (jsonObject_Put.getString("message") != null) {

                System.out.println("status of put is   inside3  ");
                done_is = true;
                MessageDisplay_Submit = jsonObject_Put.getString("message");

                System.out.println("status of put is     " + MessageDisplay);
              }
            } else {
              System.out.println("status of put is   inside4  ");
              MessageDisplay_Submit = jsonObject_Put.getString("error");
            }
          }

        } catch (JSONException e) {

          // TODO Auto-generated catch block
          e.printStackTrace();
          try {
            System.out.println("status of put is   inside5  ");
            MessageDisplay = jsonObject_Put.getString("error");
          } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }

        Methodcall = "show";
      }

      /* here "show" tells which action to be performed */

      if (Methodcall.equalsIgnoreCase("show")) {

        System.out.println("inside show");

        System.out.println(
            "comlete string is              "
                + "     "
                + AllLink.CheckExcercise
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + "\"execid\""
                + " : "
                + ""
                + "\""
                + Id
                + "\""
                + "}");

        String encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + "}");

        jsonObject = jsonParser.getJSONFromUrl(AllLink.CheckExcercise + encoded);

        if (jsonObject != null) {
          try {

            Status = jsonObject.getString("status");

            if (Status.equalsIgnoreCase("success")) {

              MessageDisplay = jsonObject.getString("msg");

            } else {
              MessageDisplay = "Error";
            }
          } catch (JSONException e1) {
            // TODO Auto-generated catch block

            e1.printStackTrace();
          }
        }

        encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + ""
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + "}");

        System.out.println(
            "complete link is     "
                + AllLink.getLogs
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + ""
                + "\"execid\""
                + ":"
                + "\""
                + Id
                + "\""
                + "}");

        jsonObject2 = jsonParser.getJSONFromUrl(AllLink.getLogs + encoded);

        System.out.println("jsonObject2     " + jsonObject2);
        if (jsonObject2 != null) {

          try {

            StatusLog = jsonObject2.getString("status");

            System.out.println("StatusLog     " + StatusLog);

            if (StatusLog.equalsIgnoreCase("success")) {

              try {
                MesageList = jsonObject2.getJSONArray("data");

                if (MesageList.length() > 0) {
                  for (int i = 0; i < MesageList.length(); i++) {

                    JSONObject c = MesageList.getJSONObject(i);
                    //

                    /* log_reps */

                    if ((c.getString("log_reps")).length() > 0) {
                      SiteList.Log_reps.add(c.getString("log_reps"));
                    } else {
                      SiteList.Log_reps.add("");
                    }

                    /* excercise Name */

                    if ((c.getString("execname")).length() > 0) {

                      SiteList.Exc_Name.add(c.getString("execname"));
                    } else {
                      SiteList.Exc_Name.add("");
                    }

                    /* Log Date */

                    if ((c.getString("log_date")).length() > 0) {

                      SiteList.Log_Date.add(c.getString("log_date"));
                    } else {

                      SiteList.Log_Date.add("");
                    }

                    /* log_intensity */

                    if ((c.getString("log_intensity")).length() > 0) {

                      SiteList.Log_Ints.add(c.getString("log_intensity"));
                    } else {
                      SiteList.Log_Ints.add("");
                    }

                    /* -----------    execid  --------------  */

                    if ((c.getString("execid")).length() > 0) {

                      SiteList.Exces_Id.add(c.getString("execid"));
                    } else {
                      SiteList.Exces_Id.add("");
                    }

                    /* -----------    execid  --------------  */

                    if ((c.getString("log_sets")).length() > 0) {

                      SiteList.Log_Sets.add(c.getString("log_sets"));
                    } else {
                      SiteList.Log_Sets.add("");
                    }
                  }

                } else {
                  SiteList.Error.add(jsonObject2.getString("error") + " " + " data exist");
                }
              } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

            } else {

              System.out.println("status log is    " + StatusLog);

              oneValue[0] = MessageDisplay;
            }
          } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
        System.out.println("Status Status    " + Status);

        //						if(Status.equalsIgnoreCase("success"))
        //						{
        try {
          String query =
              URLEncoder.encode(
                  "{"
                      + "\"execid\""
                      + ":"
                      + "\""
                      + Id
                      + "\""
                      + ","
                      + "\"auth\""
                      + ":"
                      + "\""
                      + customDialogClass.pref.getString(AllLink.AuthKey, "")
                      + "\""
                      + "}",
                  "utf-8");

          String url = AllLink.Excercise + query;

          jsonObject3 = jsonParser.getJSONFromUrl(url);

          Videos = jsonObject3.getJSONArray(VideoParentTag);

          Desc = jsonObject3.getJSONArray(DirectionTag);

          //							System.out.println("contacts length is    " +contacts);

          //		String Exc_name        = jsonObject3.getString("exc_name");
          //		String Exc_description = jsonObject3.getString("exc_description");

          // looping through All Contacts

          for (int i = 0; i < Desc.length(); i++) {

            System.out.println("i   " + i);
            JSONObject c = Desc.getJSONObject(i);

            if (c.getString(Dir_image) != null) {
              SiteList.Dir_imageList.add(c.getString(Dir_image));
            } else {

              SiteList.Dir_imageList.add("");
            }
            if (c.getString(Dir_description) != null) {
              SiteList.Dir_descriptionList.add(c.getString(Dir_description));
            } else {

              SiteList.Dir_descriptionList.add("");
            }
          }

          for (int i = 0; i < Videos.length(); i++) {

            System.out.println("i   " + i);
            JSONObject c = Videos.getJSONObject(i);

            if (c.getString(Vid_img) != null) {
              SiteList.Vid_imgList.add(c.getString(Vid_img));
            } else {

              SiteList.Vid_imgList.add("");
            }

            if (c.getString(Vid_description) != null) {
              SiteList.Vid_descriptionList.add(c.getString(Vid_description));
            } else {

              SiteList.Vid_descriptionList.add("");
            }

            if (c.getString(Vid_path) != null) {

              SiteList.Vid_pathList.add(c.getString(Vid_path));
            } else {

              SiteList.Vid_pathList.add("");
            }

            if (c.getString(Vid_title) != null) {
              SiteList.Vid_titleList.add(c.getString(Vid_title));
            } else {

              SiteList.Vid_titleList.add("");
            }
          }

          System.out.println("Dir_imageList is         " + SiteList.Dir_imageList);
          System.out.println("Dir_descriptionList is   " + SiteList.Dir_descriptionList);
          System.out.println("Vid_imgList is           " + SiteList.Vid_imgList);
          System.out.println("Vid_descriptionList is   " + SiteList.Vid_descriptionList);

        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        //						}
        //						else {
        //
        //
        //							System.out.println("error in fetching " +
        //									"exercise data");
        //						}
      }

      return null;
    }
Example #2
0
    @Override
    protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);

      Ed1.setText("");

      Ed2.setText("");

      Ed3.setText("");

      Ed4.setText("");

      if (done_is == true) {

        ConditionClas.Toastmethod(LogView.this, " " + MessageDisplay_Submit);
      }
      if (Methodcall.equalsIgnoreCase("submit")) {

        ConditionClas.Toastmethod(LogView.this, " " + MessageDisplay);

      } else if (Methodcall.equalsIgnoreCase("show")) {

        System.out.println("inside showLog_reps " + SiteList.Log_reps);
        System.out.println("inside show Exc_Namel " + SiteList.Exc_Name);
        System.out.println("inside showLog_Date " + SiteList.Log_Date);
        System.out.println("inside show Log_Ints " + SiteList.Log_Ints);
        System.out.println("inside show Log_Sets " + SiteList.Log_Sets);
        System.out.println("inside show exc_Name " + method(exc_Name));
        Log_reps.clear();

        Exc_Namel.clear();

        Log_Date.clear();

        Log_Ints.clear();

        Log_Sets.clear();

        for (int i = 0; i < SiteList.Exc_Name.size(); i++) {

          //					if(SiteList.Exc_Name.get(i).toLowerCase().
          //							contains(method(exc_Name).toLowerCase()))
          if (SiteList.Exces_Id.get(i).toLowerCase().contains(Id.toLowerCase())) {

            Log_reps.add(SiteList.Log_reps.get(i));

            Exc_Namel.add(SiteList.Exc_Name.get(i));

            Log_Date.add(SiteList.Log_Date.get(i));

            Log_Ints.add(SiteList.Log_Ints.get(i));

            Log_Sets.add(SiteList.Log_Sets.get(i));
          }
        }
        System.out.println("inside show");

        System.out.println("inside showLog_reps " + Log_reps);
        System.out.println("inside show Exc_Namel " + Exc_Namel);
        System.out.println("inside showLog_Date " + Log_Date);
        System.out.println("inside show Log_Ints " + Log_Ints);
        System.out.println("inside show Log_Sets " + Log_Sets);

        System.out.println("StatusStatusStatus " + Status);
        System.out.println("MessageDisplay    " + MessageDisplay);
        //				if (Status.equalsIgnoreCase("success"))
        //
        //				{
        System.out.println("inside if  ");
        System.out.println("MessageDisplay    " + MessageDisplay);

        Excercise.setAdapter(new CustomListExcercise());

        //					VideoList.setAdapter()
        VideoList.setAdapter(new CustomListVideo());

        //				}
        //
        //				else
        //
        //				{
        //					System.out.println(" in side elese " +
        //							"MessageDisplay    "+MessageDisplay);
        //
        //					twoValue[0] = " Error";
        //					VideoList.setAdapter(new ArrayAdapter<String>(LogView.this,
        //							android.R.layout.simple_list_item_1 ,
        //							android.R.id.text1 ,twoValue ));
        //					ConditionClas.Toastmethod(LogView.this, MessageDisplay);
        //
        //					Excercise.setAdapter(new ArrayAdapter<String>(LogView.this,
        //							android.R.layout.simple_list_item_1 ,
        //							android.R.id.text1 ,twoValue ));
        //					ConditionClas.Toastmethod(LogView.this, MessageDisplay);
        //
        //
        //				}

        /* This part checks is the log link hit was successful
         *  so on basis of that it shall set an adapter */

        if (StatusLog.equalsIgnoreCase("success")) {
          System.out.println("inside if StatusLog   ");
          if (MesageList.length() > 0) {

            //						SelectList.setAdapter(new CustomList());
            updateTable();

          } else {

            //						SelectList.setAdapter(new ArrayAdapter<String>(LogView.this,
            //								android.R.layout.simple_list_item_1 ,
            //								android.R.id.text1 ,SiteList.Error ));
          }
        }
      }
      dialog.dismiss();
    }