@Override
    protected void onPostExecute(Void result) {
      iornItemsList.clear();

      for (ParseObject ironItems : ironItemsObject) {
        // stateList.add((String) stateName.get("Name"));
        DC_InsertFields insert = new DC_InsertFields();
        IornItems iornItem = new IornItems();

        iornItem.setItemName(ironItems.get("ItemName").toString());
        iornItem.setPrice(ironItems.get("Price").toString());

        insert.setItemName(ironItems.get("ItemName").toString());
        insert.setPrice(ironItems.get("Price").toString());
        helper.InserIronValues(insert);

        iornItemsList.add(iornItem);
      }

      if (pDialog != null && pDialog.isShowing()) {
        pDialog.dismiss();
      }

      setWashAndFoldAdapter();
    }
    @Override
    protected Void doInBackground(Void... params) {
      // Create the array
      worldpopulationlist = new ArrayList<WorldPopulation>();
      try {
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Product");
        // query.orderByAscending("Product");
        ob = query.find();
        for (ParseObject Product : ob) {
          // Locate images in Picture column
          ParseFile image = (ParseFile) Product.get("Picture");

          WorldPopulation map = new WorldPopulation();
          if (Product.get("Category").equals("fruits and vegetables")) {
            map.setPrice((String) Product.get("Price"));
            map.setProduct((String) Product.get("Product"));
            map.setCategory((String) Product.get("Category"));
            map.setPicture(image.getUrl());
            worldpopulationlist.add(map);
          }
        }
      } catch (ParseException e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
      }
      return null;
    }
Ejemplo n.º 3
0
    @Override
    protected Void doInBackground(Void... params) {
      // Create the array
      photoarraylist = new ArrayList<PhotoList>();
      try {
        // Locate the class table named "ImageUpload" in Parse.com
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("ImageUpload");
        // Locate the column named "position" in Parse.com and order list
        // by descending order of created.
        query.orderByDescending("createdAt");
        query.setLimit(15);
        ob = query.find();
        for (ParseObject po : ob) {
          // retrieve objectID and Title
          String stringTitle = (String) po.get("Title");
          String stringObjectID = po.getObjectId();

          // retrieve the image file
          ParseFile image = (ParseFile) po.get("Photo");
          PhotoList map = new PhotoList();
          map.setPhoto(image.getUrl());
          map.setObjectID(stringObjectID);
          map.setTitle(stringTitle);
          photoarraylist.add(map);
        }
      } catch (ParseException e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
      }
      return null;
    }
Ejemplo n.º 4
0
    @Override
    protected Void doInBackground(Void... params) {
      // Create the array
      menulista = new ArrayList<MenuSetGet>();
      try {
        // Locate the class table named "Country" in Parse.com
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("computadoras");
        // Locate the column named "ranknum" in Parse.com and order list
        // by ascending
        query.orderByAscending("orden");
        ob = query.find();
        for (ParseObject country : ob) {
          // Locate images in flag column
          ParseFile image = (ParseFile) country.get("imagen");

          MenuSetGet map = new MenuSetGet();
          map.setNombre((String) country.get("nombre"));
          map.setDetalle((String) country.get("Detalle"));
          map.setPrecio((String) country.get("precio"));
          map.setImagen(image.getUrl());
          menulista.add(map);
        }
      } catch (ParseException e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
      }
      return null;
    }
Ejemplo n.º 5
0
    @Override
    protected Void doInBackground(Void... params) {
      // Create the array
      userProfileList = new ArrayList<UserProfile>();
      try {

        // Locate the class table named "Country" in Parse.com
        ParseQuery<ParseUser> query = ParseUser.getQuery();

        Log.d("UserListActivity", "In asynctask.. username - " + currentUser.getUsername());

        query.whereNotEqualTo("username", currentUser.getUsername());

        // by ascending LastName
        query.orderByAscending("lastName");
        ob = query.find();
        for (ParseObject userProfile : ob) {

          UserProfile map = new UserProfile();
          map.setFirstName((String) userProfile.get("firstName"));
          map.setLastName((String) userProfile.get("lastName"));
          map.setDepartment((String) userProfile.get("department"));
          map.setUsername((String) userProfile.get("username"));

          userProfileList.add(map);
        }
      } catch (ParseException e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
      }
      return null;
    }
Ejemplo n.º 6
0
 private void setSongList(List<ParseObject> list) {
   for (ParseObject song : list) {
     String id = song.get("songId").toString();
     String url = song.get("url").toString();
     String title = song.get("title").toString();
     String artist = song.get("artist").toString();
     Song s = new Song(url, title, artist, id);
     songList.add(s);
     Log.i("Frag", "setSongList " + title);
   }
   //        addSong("");
   //        addSong("");
   //        addSong("");
   displaySongs();
   playSongList();
 }
Ejemplo n.º 7
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      View v = convertView;

      if (v == null) {
        LayoutInflater vi;
        vi = LayoutInflater.from(getContext());
        v = vi.inflate(R.layout.hotellistitem, null);
      }

      final ParseObject hotel = (ParseObject) getItem(position);

      if (hotel != null) {
        ImageView resPicView = (ImageView) v.findViewById(R.id.venue_image);
        TextView resNameView = (TextView) v.findViewById(R.id.venue_name);
        TextView resLocView = (TextView) v.findViewById(R.id.venue_cuisine_location);
        TextView resCuisinesView = (TextView) v.findViewById(R.id.venue_brag_text);

        JSONArray resPicturesAry = hotel.getJSONArray("Pictures");
        JSONArray resCuisinesAry = hotel.getJSONArray("Cuisines");

        String respic = "",
            resname = hotel.get("Name").toString(),
            rescuisines = "",
            reslocation = hotel.get("LocationName").toString();
        try {
          respic = resPicturesAry.getString(0);

          for (int i = 0; i < resCuisinesAry.length(); ++i) {
            rescuisines += resCuisinesAry.getString(i) + ", ";
          }

          rescuisines = rescuisines.substring(0, rescuisines.length() - 2);

        } catch (JSONException e) {

        }

        Picasso.with(context).load(respic).resize(1850, 900).centerCrop().into(resPicView);
        resNameView.setText(resname);
        resCuisinesView.setText(rescuisines);
        resLocView.setText(reslocation);
      }

      return v;
    }
Ejemplo n.º 8
0
  private void prepareListData() {
    listDataHeader = new ArrayList<String>();
    listDataChild = new HashMap<String, List<String>>();
    listDataChildObject = new HashMap<String, List<ParseObject>>();

    // Adding child data
    ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Category");
    List<ParseObject> listHeaders = null;
    try {
      listHeaders = query1.find();
    } catch (Exception e) {
    }

    for (ParseObject x : listHeaders) {
      listDataHeader.add((String) x.get("category_name"));
    }

    int n = listDataHeader.size();

    // Adding child data
    for (int i = 0; i < n; i++) {
      String s = listDataHeader.get(i);
      ParseObject obj = listHeaders.get(i);
      List<String> list = new ArrayList<String>();
      List<ParseObject> listObject = new ArrayList<ParseObject>();

      ParseQuery<ParseObject> query =
          ParseQuery.getQuery("Menu_Item").whereEqualTo("category", obj);

      List<ParseObject> matches = null;

      try {
        matches = query.find();
      } catch (Exception e) {
      }

      for (ParseObject a : matches) {
        // if(isActive(a)) {
        list.add((String) a.get("item_name"));
        listObject.add(a);
        // }
      }
      listDataChild.put(s, list);
      listDataChildObject.put(s, listObject);
    }
  }
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    List<ParseObject> ob;

    try {
      // Locate the class table named "stansbeers" in Parse.com
      ParseQuery<ParseObject> query = new ParseQuery<>("capitolbeers").fromLocalDatastore();
      // Locate the column named "name" in Parse.com and order list
      // by ascending

      query.orderByAscending("name").whereEqualTo("group", "IMPORT_BOTTLES_CANS");

      ob = query.find();

      beerObject = new ArrayList<>();

      for (ParseObject beers : ob) {
        // Locate images in flag column

        //  ParseFile image = (ParseFile) stansbeers.get("image");

        BeerListObject beer = new BeerListObject();
        beer.setBeerName((String) beers.get("name"));
        beer.setBeerWhereFrom((String) beers.get("wherefrom"));
        beer.setBeerAbv(beers.getDouble("abvinteger"));
        beer.setBeerGroup((String) beers.get("group"));
        beer.setBeerAbout((String) beers.get("about"));
        beer.setBeerPrice((String) beers.get("price"));
        beer.setBeerSize((String) beers.get("size"));
        //   beer.setBeerImage(image.getUrl());
        beerObject.add(beer);
      }

    } catch (ParseException e) {
      Log.e("Error", e.getMessage());
      e.printStackTrace();
    }

    adapter = new BeersListViewAdapter(getActivity(), beerObject);
    setListAdapter(adapter);
  }
  public ParseProxyObject(ParseObject object) {

    // Loop the keys in the ParseObject
    for (String key : object.keySet()) {
      @SuppressWarnings("rawtypes")
      Class classType = object.get(key).getClass();
      if (classType == byte[].class
          || classType == String.class
          || classType == Integer.class
          || classType == Boolean.class
          || classType == Double.class
          || classType == Date.class) {
        values.put(key, object.get(key));
      } else if (classType == ParseUser.class) {
        ParseProxyObject parseUserObject = new ParseProxyObject((ParseObject) object.get(key));
        values.put(key, parseUserObject);
      } else {
        // You might want to add more conditions here, for embedded ParseObject, ParseFile, etc.
      }
    }
    values.put("ObjectId", object.getObjectId());
  }
Ejemplo n.º 11
0
    @Override
    public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
      // try {
      String key = m.getName();

      if (args.length == 0) {
        // built-in
        if ("objectData".equals(key)) return new ParseObjectData(obj);
        if (ParseBase.PARSE_OBJECT.equals(key)) return obj;

        // user define
        final Class<?> returnType = m.getReturnType();
        String typeName = returnType.getName();
        if (typeName.equalsIgnoreCase("float")) {
          return (float) obj.getDouble(key);
        } else {
          Object object = obj.get(key);
          if (returnType.isPrimitive() && object == null) {
            return 0;
          } else if (object != null
              && ParseObject.class.isInstance(object)
              && ParseBase.class.isAssignableFrom(returnType)) {
            return ((ParseFacade<?>) ParseFacade.get(returnType)).wrap((ParseObject) object);
          } else if (object != null
              && !returnType.isInstance(object)
              && !returnType.isPrimitive()) {
            return null;
          } else {
            return object;
          }
        }
      } else { // arg.length == 1
        // set value
        Object object = args[0];
        if (key.equals("objectId")) System.out.println("value " + object);

        if (object instanceof ParseBase) {
          obj.put(key, ((ParseBase) object).parseObject());
        } else {
          obj.put(key, object);
        }

        return null;
      }
      // } catch (InvocationTargetException e) {
      // throw e.getTargetException();
      // } catch (Exception e) {
      // throw e;
      // }
      // return something
    }
Ejemplo n.º 12
0
    @Override
    protected Void doInBackground(Void... params) {
      // Create the array

      try {
        // Locate the class table named "Country" in Parse.com
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("r" + route);
        // Locate the column named "ranknum" in Parse.com and order list
        // by ascending
        query.orderByAscending("s_name");
        ob = query.find();
        for (ParseObject student : ob) {
          // Locate images in flag column
          name[count] = student.get("s_name").toString();
          numbers[count] = student.get("phone_no").toString();
          count++;

          /*ParseQuery<ParseObject> query1 = ParseQuery.getQuery("User");
          query1.whereEqualTo("username", Route_info.teachuser);
          query1.getFirstInBackground(new GetCallback<ParseObject>() {
              public void done(ParseObject object, ParseException e) {
                  if (object == null) {
                      Toast.makeText(getApplicationContext(),"Failed",Toast.LENGTH_SHORT).show();
                      Log.d("score", "The getFirst request failed.");
                  } else {
                      teachpass = object.getString("password");
                      //Log.d("score", "Retrieved the object.");
                  }
              }
          });*/

        }
      } catch (ParseException e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
      }
      return null;
    }
Ejemplo n.º 13
0
  public static User createUser(ParseObject parseObject) {
    cache().put(parseObject);

    String profilePictureUrl = null;
    Object object;
    if (parseObject.has("profile_picture")) {
      profilePictureUrl = parseObject.getString("profile_picture");
      object = parseObject.get("profile_picture");
      ParseFile file = (ParseFile) object;
      String url = file.getUrl();
      profilePictureUrl = url;
    }

    User user = new User(parseObject.getObjectId());
    user.setProfilePictureUrl(profilePictureUrl);
    if (parseObject.has("username")) {
      user.setName(parseObject.getString("username"));
    }
    if (parseObject.has("info")) {
      user.setInfo(parseObject.getString("info"));
    }

    return user;
  }
Ejemplo n.º 14
0
  public Politic(ParseObject parseObject) {

    setObjectId(parseObject.getObjectId());
    setCandidateName((String) parseObject.get(POLITIC_NAME));
    setCandidateNumber((String) parseObject.get(POLITIC_NUM));
    setElectionYear((String) parseObject.get(POLITIC_YEAR));
    setCompositionLegend((String) parseObject.get(POLITIC_LEGEND));
    setCandidateDocumentNumber((String) parseObject.get(POLITIC_CPF));
    setTurnNumber((String) parseObject.get(POLITIC_NUM_TURNO));
    setCandidatePartyNumber((String) parseObject.get(POLITIC_NUM_PART));
    setCandidateUf((String) parseObject.get(POLITIC_UF));
    setCandidateOffice((String) parseObject.get(POLITIC_CARGO));
    setCandidateUrnName((String) parseObject.get(POLITIC_URNA));
    setCandidatePartyName((String) parseObject.get(POLITIC_NOME_PART));
    setCandidateTurnDescription((String) parseObject.get(POLITIC_DESC_TURN));
    setCandidateEmail((String) parseObject.get(POLITIC_EMAIL));
    setCandidatePartyInitials((String) parseObject.get(POLITIC_PARTY_INIT));
  }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {

    x = x + 1;

    if (x == 6) {

      x = 0;
    }

    String[] toastSort = new String[8];
    toastSort[0] = "Sorted by name Ascending";
    toastSort[1] = "by name descending";
    toastSort[2] = "by A.B.V ascending";
    toastSort[3] = "by A.B.V descending";
    toastSort[4] = "by where from ascending";
    toastSort[5] = "by where from descending";

    String tm = toastSort[x];

    Toast sort = Toast.makeText(getActivity(), tm, Toast.LENGTH_LONG);
    sort.setGravity(Gravity.CENTER, 0, 0);
    sort.show();

    List<ParseObject> ob;

    try {
      // Locate the class table named "stansbeers" in Parse.com
      ParseQuery<ParseObject> query = new ParseQuery<>("capitolbeers").fromLocalDatastore();
      // Locate the column named "name" in Parse.com and order list
      // by ascending

      query.orderByAscending("name").whereEqualTo("group", "IMPORT_BOTTLES_CANS");

      switch (x) {
        case 0:
          query.orderByAscending("name");
          break;
        case 1:
          query.orderByDescending("name");
          break;
        case 2:
          query.orderByAscending("abvinteger");
          break;
        case 3:
          query.orderByDescending("abvinteger");
          break;
        case 4:
          query.orderByAscending("wherefrom");
          break;
        case 5:
          query.orderByDescending("wherefrom");
          break;
      }

      ob = query.find();

      beerObject = new ArrayList<>();

      for (ParseObject beers : ob) {
        // Locate images in flag column

        //   ParseFile image = (ParseFile) stansbeers.get("image");

        BeerListObject beer = new BeerListObject();
        beer.setBeerName((String) beers.get("name"));
        beer.setBeerWhereFrom((String) beers.get("wherefrom"));
        beer.setBeerAbv(beers.getDouble("abvinteger"));
        beer.setBeerGroup((String) beers.get("group"));
        beer.setBeerAbout((String) beers.get("about"));
        beer.setBeerPrice((String) beers.get("price"));
        beer.setBeerSize((String) beers.get("size"));
        beerObject.add(beer);
      }
    } catch (ParseException e) {
      Log.e("Error", e.getMessage());
      e.printStackTrace();
    }

    adapter = new BeersListViewAdapter(getActivity(), beerObject);
    setListAdapter(adapter);

    adapter.notifyDataSetChanged();
  }
Ejemplo n.º 16
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LinearLayout ll = null;
    LinearLayout columnLayout = null;
    LinearLayout valueLayout = null;
    TextView noResultsTextView = null;
    TextView tv = null;
    TextView col = null;

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // if user scrolls, reuse view without re-inflating
    if (convertView == null) {
      ll = (LinearLayout) inflater.inflate(R.layout.partial_parseobjectadapter_row, null);
    } else {
      ll = (LinearLayout) convertView;
    }

    valueLayout = (LinearLayout) ll.findViewById(R.id.ParseObjectAdapterValueLayout);
    columnLayout = (LinearLayout) ll.findViewById(R.id.ParseObjectAdapterColumnLayout);
    noResultsTextView = (TextView) ll.findViewById(R.id.ParseObjectAdapterNoResults);

    // set up the displays of our xml controls
    if (position == 0) {
      // if we're setting up the columns, ensure the columnlayout is visible
      columnLayout.setVisibility(View.VISIBLE);
    } else {
      columnLayout.setVisibility(View.INVISIBLE);
    }
    noResultsTextView.setVisibility(View.INVISIBLE);

    if (objects != null && !objects.isEmpty()) {
      ParseObject object = (ParseObject) objects.get(position);
      if (object != null) {
        int i = 0;
        // get the total columns and make a textview for each
        // check if we've passed some columns
        Set<String> collection = object.keySet();
        if (columns != null) {
          collection = columns;
        }
        // now loop through the columns
        for (String key : collection) {
          if (position == 0) {
            // set up columns
            col =
                (TextView)
                    inflater.inflate(R.layout.partial_parseobjectadapter_row_cell_header, null);
            col.setWidth(columnWidth);

            int col_id =
                context
                    .getResources()
                    .getIdentifier(
                        "parse_attributes_quest_" + key.toLowerCase(),
                        "string",
                        context.getPackageName());
            if (col_id != 0) {
              col.setText(context.getResources().getString(col_id));
            } else {
              String column_text = "";
              String words[] = key.split("_");
              for (String word : words) {
                column_text = column_text + WordUtils.capitalize(word) + " ";
              }
              column_text = column_text.trim();
              col.setText(column_text);
            }
            columnLayout.addView(col);
          }

          tv = (TextView) inflater.inflate(R.layout.partial_parseobjectadapter_row_cell, null);
          tv.setWidth(columnWidth);

          // depending on our type of parse object, get the string correctly
          Object value = object.get(key);
          if (value instanceof ParseGeoPoint) {
            value =
                String.valueOf(((ParseGeoPoint) value).getLatitude())
                    + ", "
                    + String.valueOf(((ParseGeoPoint) value).getLongitude());
          }

          tv.setText(value.toString());
          valueLayout.addView(tv);
          i++;
        }
      }
    } else {
      columnLayout.setVisibility(View.INVISIBLE);
      valueLayout.setVisibility(View.INVISIBLE);

      noResultsTextView.setVisibility(View.VISIBLE);
      noResultsTextView.setText(R.string.parse_no_results);
    }

    return ll;
  }