Пример #1
0
  void SendShareListToServer(
      final String ShoppingListName, final String nick, final String nickID) {
    try {

      RequestQueue MyRequestQueue = Volley.newRequestQueue(context);
      // Create data variable for sent values to server
      DebugLog.console("[ShoppingListAdapter]:Calling SendShareListToServer");

      String url = Commonthings.LocalServerAddress + "/qshop/client.php";
      StringRequest MyStringRequest =
          new StringRequest(
              Request.Method.POST,
              url,
              new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                  // This code is executed if the server responds, whether or not the response
                  // contains data.
                  // The String 'response' contains the server's response.
                  DebugLog.console(
                      "[ShoppingListAdapter]:Success Server Response " + response.toString());
                  Toast.makeText(
                          context,
                          ShoppingListName + " List Successfully Shared With " + nick,
                          Toast.LENGTH_LONG)
                      .show();
                }
              },
              new Response
                  .ErrorListener() { // Create an error listener to handle errors appropriately.
                @Override
                public void onErrorResponse(VolleyError error) {
                  // This code is executed if there is an error.
                  DebugLog.console(
                      "[ShoppingListAdapter]:Fail Server Response " + error.getMessage());
                  Toast.makeText(
                          context, "Something went wrong.Please try again.", Toast.LENGTH_LONG)
                      .show();
                }
              }) {
            protected Map<String, String> getParams() {
              Map<String, String> MyData = new HashMap<String, String>();
              MyData.put(
                  "action",
                  "setitemsnotificationAction"); // Add the data you'd like to send to the server.
              MyData.put("itemlist_to", "123"); // Add the data you'd like to send to the server.
              MyData.put("itemlist_from", "14444444");
              MyData.put("flag", "0");
              MyData.put("itemlist", ShoppingListName);
              return MyData;
            }
          };

      MyRequestQueue.add(MyStringRequest);

    } catch (Exception ex) {
      DebugLog.console(ex, "[ShoppingListAdapter]:Exception inside SendShareListToServer");
    }
  }
Пример #2
0
  public void CreateDialogue(final String LName) {
    try {

      ContactList.add("Add New COntact");
      final String[] arr = ContactList.toArray(new String[ContactList.size()]);
      dialog =
          new AlertDialog.Builder(context)
              .setTitle("Select Contact")
              .setNegativeButton("Cancel", null)
              .setItems(
                  arr,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, final int position) {

                      Toast.makeText(context, arr[position], Toast.LENGTH_SHORT).show();
                      SendShareListToServer(
                          LName, arr[position], "123"); // pass list name and friend Nick, friend id
                    }
                  })
              .create();

      dialog.show();

    } catch (Exception ex) {
      DebugLog.console(ex, "[ShoppingListAdapter]:Exception inside CreateDialogue");
    }
  }
Пример #3
0
  void ShareListWithUsers(String ListName) {
    try {
      database = new QairusDataBase(context);
      database.open();
      ContactList = database.GetContactListString();
      database.close();
      CreateDialogue(ListName);

    } catch (Exception ex) {
      DebugLog.console(ex, "[ShoppingListAdapter]:Exception inside ShareListWithUsers");
    }
  }
Пример #4
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View rowView;
    rowView = inflater.inflate(R.layout.custom_shoppinglist, null);
    try {

      final ShoppingListItem item = ShoppingList.get(position);
      Holder holder = new Holder();

      holder.tvListName = (TextView) rowView.findViewById(R.id.tv_listName);
      holder.ibShare = (ImageButton) rowView.findViewById(R.id.ib_listshare);
      holder.ibDelete = (ImageButton) rowView.findViewById(R.id.ib_delete);

      holder.tvListName.setText(item.getShoppinglistname());

      holder.ibShare.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //                    Toast.makeText(context, "You Clicked Share Button ",
              // Toast.LENGTH_LONG).show();
              ShareListWithUsers(item.getShoppinglistname());
              //                    ShoppingList.remove(position); //or some other task
              //                    notifyDataSetChanged();
            }
          });

      holder.ibDelete.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //                    Toast.makeText(context, "You Clicked Delete Button ",
              // Toast.LENGTH_LONG).show();

              database = new QairusDataBase(context);
              database.open();
              database.deleteShoppingList(context, item.getShoppinglistname());
              database.close();

              ShoppingList.remove(position); // or some other task
              notifyDataSetChanged();
            }
          });

      rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              //                    Toast.makeText(context, "You Clicked " +
              // item.getShoppinglistname(), Toast.LENGTH_LONG).show();
              in = new Intent(context, SubItemsShoppingList.class);
              in.putExtra("mainListName", item.getShoppinglistname());
              context.startActivity(in);
              context.finish();
            }
          });
      return rowView;
    } catch (Exception ex) {
      DebugLog.console(ex, "[ShoppingListAdapter]:Exception inside getView");
      return rowView;
    }
  }