@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;
    }
Example #2
0
 private void submitEssay() {
   final ProgressDialog progress = new ProgressDialog(CopyEssay.this);
   progress.setMessage(getString(R.string.please_wait_message));
   progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   progress.setCancelable(false);
   progress.show();
   String t = title.getText().toString();
   String s = subject.getText().toString();
   ParseObject essay = new ParseObject("essays");
   essay.put("title", t);
   essay.put("subject", s);
   essay.put("content", essay_txt.getText().toString());
   essay.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(com.parse.ParseException e) {
           if (e != null) {
             e.printStackTrace();
           } else {
             progress.dismiss();
             displaySnackbar();
             Intent intent = new Intent(CopyEssay.this, HomeScreen.class);
             startActivity(intent);
           }
         }
       });
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
      Bundle extras = data.getExtras();
      Bitmap imageBitmap = (Bitmap) extras.get("data");
      mImageView = (ImageView) findViewById(R.id.imgView);

      // Saving in Parse server
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
      byte[] dataTostore = stream.toByteArray();

      final ParseFile imgFile = new ParseFile("img.png", dataTostore);
      imgFile.saveInBackground();

      GalleryObj tempPicObj = new GalleryObj();
      ParseObject obj = new ParseObject("Gallery");

      obj.put("pic", imgFile);
      obj.put("Apartment", ParseUser.getCurrentUser().getString("Apartment"));
      try {
        obj.save();
        tempPicObj.id = obj.getObjectId();
        tempPicObj.pic = imageBitmap;
        STgallery.getInstance().add(tempPicObj);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      adapter.notifyDataSetChanged();
    }
  }
  public UpdateImage(Activity activity) {

    Bitmap bitmap =
        BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_action_name);
    // Convert it to byte
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    // Compress image to lower quality scale 1 - 100
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
    byte[] image = stream.toByteArray();

    // Create the ParseFile
    ParseFile file = new ParseFile("androidbegin.png", image);
    // Upload the image into Parse Cloud
    file.saveInBackground();

    // Create a New Class called "ImageUpload" in Parse
    ParseObject imgupload = new ParseObject("ImageUpload");

    // Create a column named "ImageName" and set the string
    imgupload.put("ImageName", "AndroidBegin Logo");

    // Create a column named "ImageFile" and insert the image
    imgupload.put("ImageFile", file);

    // Create the class and the columns
    imgupload.saveInBackground();
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    if (isNetworkAvailable() == false) noInternetAccess();

    super.onListItemClick(l, v, position, id);
    ParseObject message = mMessages.get(position);
    String post = message.getString(ParseConstants.KEY_POST);
    String sendername = message.getString(ParseConstants.KEY_SENDER_NAME);

    final Dialog dialog = new Dialog(RumourActivity.this, R.style.Theme_Dialog);
    dialog.setContentView(R.layout.rumour_custom_alert);

    final TextView userInput3 = (TextView) dialog.findViewById(R.id.rumour_custom_et);
    final TextView sender = (TextView) dialog.findViewById(R.id.sender_custom_et);
    final Button ok = (Button) dialog.findViewById(R.id.btn_ok);

    sender.setText(sendername);
    userInput3.setText(post);
    dialog.show();
    ok.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });
  }
    @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();
    }
Example #7
0
 private void createItsBetaRelationForCurrentUser() {
   final ParseObject itsbeta = new ParseObject("ItsBeta");
   itsbeta.put("facebookAccessToken", auth.getAccessToken());
   itsbeta.put("facebookUserId", auth.getFacebookId());
   itsbeta.put("type", "fb_user_id");
   itsbeta.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(ParseException e) {
           if (e != null) {
             finishBackgroundProcess();
           }
           ParseUser user = ParseUser.getCurrentUser();
           ParseRelation relation = user.getRelation("ItsBeta");
           relation.add(itsbeta);
           user.saveEventually(
               new SaveCallback() {
                 @Override
                 public void done(ParseException e) {
                   if (e != null) {
                     finishBackgroundProcess();
                   }
                 }
               });
         }
       });
 }
Example #8
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.message_item, null);
      holder = new ViewHolder();
      holder.iconImageView = (ImageView) convertView.findViewById(R.id.messageIcon);
      holder.nameLabel = (TextView) convertView.findViewById(R.id.senderLabel);
      holder.timeLabel = (TextView) convertView.findViewById(R.id.timeLabel);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    ParseObject message = mMessages.get(position);
    Date createdAt = message.getCreatedAt();
    long now = new Date().getTime();
    String convertedDate =
        DateUtils.getRelativeTimeSpanString(createdAt.getTime(), now, DateUtils.SECOND_IN_MILLIS)
            .toString();

    if (message.getString(ParseConstants.KEY_FILE_TYPE).equals(ParseConstants.TYPE_IMAGE)) {
      holder.iconImageView.setImageResource(R.drawable.ic_picture);
    } else {
      holder.iconImageView.setImageResource(R.drawable.ic_video);
    }
    holder.nameLabel.setText(message.getString(ParseConstants.KEY_SENDER_NAME));
    holder.timeLabel.setText(convertedDate);

    return convertView;
  }
 public String getName() {
   if (user.getString("nickname").isEmpty()) {
     return "Anonymous";
   } else {
     return user.getString("nickname");
   }
 }
Example #10
0
  public void saveNote() {
    String titleToSave = titleEditText.getText().toString().trim();
    String contentToSave = contentEditText.getText().toString().trim();

    if (!contentToSave.isEmpty() || !titleToSave.isEmpty()) {
      if (note == null) {
        ParseObject post = new ParseObject("Post");
        post.put("title", titleToSave);
        post.put("content", contentToSave);
        post.put("author", ParseUser.getCurrentUser());
        post.saveInBackground();
        callback.onNoteAdded(titleToSave, contentToSave);
      } else {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");
        final String newTitleToSave = titleToSave;
        final String newContentToSave = contentToSave;
        query.getInBackground(
            note.getId(),
            new GetCallback<ParseObject>() {
              @Override
              public void done(ParseObject parseObject, ParseException e) {
                if (e == null) {
                  parseObject.put("title", newTitleToSave);
                  parseObject.put("content", newContentToSave);
                  callback.onNoteChanged(new Note(newTitleToSave, newContentToSave), note);
                  parseObject.saveInBackground();
                }
              }
            });
      }
    }
  }
Example #11
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;
    }
    @Override
    protected String doInBackground(String... params) {

      // Notify Parse Analytics that the app has been opened
      ParseAnalytics.trackAppOpenedInBackground(getIntent());

      CardDbHelper cardDbHelper = new CardDbHelper(getBaseContext());

      SQLiteDatabase db = cardDbHelper.getWritableDatabase();
      cardDbHelper.onCreate(db);

      try {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Card");
        query.setLimit(1000);
        query.selectKeys(Arrays.asList(""));
        List<ParseObject> results = query.find();

        Iterator<ParseObject> iterator = results.iterator();

        // Writing values to DB
        ContentValues values = new ContentValues();

        while (iterator.hasNext()) {
          ParseObject next = iterator.next();
          values.put("cardId", next.getObjectId().toString());
          db.insert(CardDbHelper.TABLE_NAME, "null", values);
        }

      } catch (ParseException e) {
        e.printStackTrace();
      }

      return "";
    }
  private void activePatientData() {

    ParseQuery<ParseObject> query = ParseQuery.getQuery("PatientDetails");
    query.whereEqualTo("patientId", patientIdRemove);
    try {
      ParseObject object = query.getFirst();
      object.put("status", "Active");
      object.save();
    } catch (ParseException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }

    /*	ParseQuery<ParseObject> query3 = ParseQuery.getQuery("_User");
    query3.whereEqualTo("userId", patientIdRemove);
    try {
    	ParseObject object = query3.getFirst();
    	object.put("status", "Active");
    	object.save();

    	}catch (ParseException e2) {
    	// TODO Auto-generated catch block
    	e2.printStackTrace();
    }*/

    Toast.makeText(SearchPatientByAdmin.this, "Patient Active", Toast.LENGTH_SHORT).show();
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   super.onActivityResult(requestCode, resultCode, intent);
   Bundle extras = intent.getExtras();
   switch (requestCode) {
     case ACTIVITY_FRIEND_LIST_SHOW:
       ArrayList<String> flist;
       Log.d("BuganizerParseEdit", "onActivityResult:ACTIVITY_FRIEND_LIST_SHOW");
       flist = extras.getStringArrayList(BuganizerParseConstants.friendslist);
       for (String f : flist) {
         Log.d("BuganizerParseEdit", "Adding user to ACL " + f);
         if (acl == null) {
           Log.d("BuganizerParseEdit", "Creating ACL");
           acl = new ParseACL();
         }
         acl.setWriteAccess(f, true);
         acl.setReadAccess(f, true);
       }
       if ((acl != null) && (flist.size() > 0)) {
         Log.d("BuganizerParseEdit", "Saving object with ACL in background");
         pObject.setACL(acl);
         pObject.saveInBackground();
       }
       break;
   }
 }
    @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;
    }
Example #16
0
  private void sendMessage() {
    EditText messageTxt = (EditText) findViewById(R.id.txt);
    if (messageTxt.length() == 0) {
      return;
    }

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(messageTxt.getWindowToken(), 0);

    ReliUser user = MainActivity.user;

    String s = messageTxt.getText().toString();
    final Message message = new Message(s, new Date(), user.getParseID(), user.getFullName());
    messagesList.add(message);
    chatAdapter.notifyDataSetChanged();
    messageTxt.setText(null);

    ParseObject po = new ParseObject(discussionTableName);
    po.put(Const.COL_MESSAGE_SENDER_ID, user.getParseID());
    po.put(Const.COL_MESSAGE_SENDER_NAME, user.getFullName());
    po.put(Const.COL_MESSAGE_CONTENT, s);
    po.saveEventually(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            message.setStatus(
                (e == null) ? MessageStatus.STATUS_SENT : MessageStatus.STATUS_FAILED);

            chatAdapter.notifyDataSetChanged();
          }
        });
  }
 private void createAlbum() {
   if (albumName.getText() != null) {
     ParseObject album = new ParseObject("albums");
     album.put("userId", mUser.getUserId());
     album.put("nameAlbum", albumName.getText().toString());
     album.saveInBackground(
         new SaveCallback() {
           @Override
           public void done(ParseException e) {
             if (e == null) {
               ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("albums");
               query.whereEqualTo("userId", mUser.getUserId());
               query.whereEqualTo("nameAlbum", albumName.getText().toString());
               query.getFirstInBackground(
                   new GetCallback<ParseObject>() {
                     @Override
                     public void done(ParseObject parseObject, ParseException e) {
                       savePhoto(parseObject.getObjectId());
                     }
                   });
             }
           }
         });
   }
 }
Example #18
0
  @Override
  public void onBindViewHolder(final ViewHolder viewHolder, int i) {
    ParseObject gasto = mDataset.get(i);

    viewHolder.categoria.setText(gasto.getString("tpCota"));
    viewHolder.valor.setText("R$ " + formatter.formata(gasto.getNumber("total").floatValue()));
  }
Example #19
0
 public void parseOutbreak(String sickness, double latitude, double longitude) {
   ParseObject outbreak = new ParseObject("Outbreak");
   ParseGeoPoint point = new ParseGeoPoint(latitude, longitude);
   outbreak.put("sickness", sickness);
   outbreak.put("location", point);
   outbreak.saveInBackground();
 }
    @Override
    public View getItemView(ParseObject object, View v, ViewGroup parent) {

      if (v == null) {
        v = View.inflate(getContext(), R.layout.adapter_show_info, null);
      }

      l_nome_pianta = (TextView) v.findViewById(R.id.l_nick_pianta);
      l_tipo_pianta = (TextView) v.findViewById(R.id.l_tipo_pianta);
      l_descrizione = (TextView) v.findViewById(R.id.l_descrizione);

      // Take advantage of ParseQueryAdapter's getItemView logic for
      // populating the main TextView/ImageView.
      // The IDs in your custom layout must match what ParseQueryAdapter expects
      // if it will be populating a TextView or ImageView for you.
      super.getItemView(object, v, parent);

      img_immagine = (ParseImageView) v.findViewById(R.id.img_avatar);
      img_immagine.setParseFile(object.getParseFile("Immagine"));
      img_immagine.loadInBackground();

      l_nome_pianta.setText(object.getString("Nome"));
      l_tipo_pianta.setText(object.getString("Tipo"));
      l_descrizione.setText(object.getString("Descrizione"));

      return v;
    }
Example #21
0
  public void post() {
    buffer = new ByteArrayOutputStream();
    scaledTakenImage.compress(Bitmap.CompressFormat.JPEG, 100, buffer);
    photoFile = new ParseFile(buffer.toByteArray());
    photoFile.saveInBackground();

    if (etFoodDesc.getText() == null
        || etFeedCap.getText() == null
        || etExp.getText() == null
        || location == null
        || photoFile == null) {
      Toast.makeText(this, "Please provide all the information", Toast.LENGTH_SHORT).show();
      return;
    }

    ParseObject parseObject = new ParseObject("FoodData");
    parseObject.put("fooddesc", etFoodDesc.getText().toString());
    parseObject.put("feedcap", etFeedCap.getText().toString());
    parseObject.put("timeexp", etExp.getText().toString());
    parseObject.put("lat", location.getLatitude());
    parseObject.put("lon", location.getLongitude());
    parseObject.put("photo", photoFile);
    parseObject.put("ownerid", ParseUser.getCurrentUser().getObjectId());
    parseObject.put("ownername", ParseUser.getCurrentUser().getUsername());
    parseObject.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (e == null)
              Toast.makeText(PostActivity.this, "Posted Sucessfully", Toast.LENGTH_SHORT).show();
          }
        });
  }
 @Before
 public void setUp() throws Exception {
   MockitoAnnotations.initMocks(this);
   ParseObject.registerSubclass(Language.class);
   ParseObject.registerSubclass(BookDetail.class);
   downloadsPresenter = new DownloadsPresenter(bookRepository, downloadsView);
   language = new Language("English", "EN", "1");
 }
Example #23
0
    public ParseObject createParseObject() {
      ParseObject parseObject = new ParseObject("Images");
      parseObject.put("downsized", mDownSized.createParseObject());
      parseObject.put("downsizedStill", mDownSizedStill.createParseObject());
      parseObject.put("original", mOriginal.createParseObject());
      parseObject.put("small", mSmall.createParseObject());

      return parseObject;
    }
Example #24
0
  public static ParseObject createCommunity(String title, Location location) {
    ParseObject newCommunity = new ParseObject(Common.OBJECT_COMMUNITY);
    newCommunity.put(Common.OBJECT_COMMUNITY_TITLE, title);
    newCommunity.put(Common.OBJECT_COMMUNITY_LAT, String.valueOf(location.getLatitude()));
    newCommunity.put(Common.OBJECT_COMMUNITY_LONG, String.valueOf(location.getLongitude()));
    newCommunity.saveInBackground();

    return newCommunity;
  }
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    // find all the views
    mListView = (ListView) view.findViewById(R.id.listViewApp);

    Lappointment.clear();

    List<String> doctorID;
    Log.d("Chan", "Username: "******"doctorUsername"));
    username = getArguments().getString("doctorUsername");
    List<ParseObject> list2 = new ArrayList<>();
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Doctor");
    query.whereEqualTo("Doctor", username);
    try {
      list2 = query.find();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    for (ParseObject obj : list2) {
      doctorIDf = obj.getString("doctorID");
      Log.d("chan", "Doctor ID :  " + String.valueOf(doctorIDf));
    }

    List<ParseObject> list = new ArrayList<>();
    ParseQuery<ParseObject> query2 = ParseQuery.getQuery("Appointment");
    query2.whereEqualTo("DoctorID", doctorIDf);
    try {
      list = query2.find();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    for (ParseObject obj : list) {
      //            Appointments appt = new Appointments(obj.getString("AppointmentID"),
      // obj.getString("AppointmentDate"), obj.getString("PatientID"), obj.getString("DoctorID"),
      // obj.getString("AppointmentTime"), obj.getString("Status"));

      //            Lappointment.add(appt);
      Log.d("chan", "Status: " + obj.getString("Status"));
      Log.d("chan", "Status: " + obj.getString("Status"));
    }

    Log.d("chan", "Appointment size : " + String.valueOf(Lappointment.size()));
    // create a new instance of adapter
    ViewAppointmentRequest adapter =
        new ViewAppointmentRequest(getActivity(), R.layout.item_appointment, Lappointment);

    // set the adapter
    mListView.setAdapter(adapter);

    // set item click listener

    // handle Parse Exception here

    // set item click listener
    mListView.setOnItemClickListener(this);
  }
Example #26
0
 private void initParse() {
   Parse.initialize(this, getString(R.string.parseAppId), getString(R.string.parseAppKey));
   ParseObject.registerSubclass(Tour.class);
   ParseObject.registerSubclass(Node.class);
   CalligraphyConfig.initDefault(
       new CalligraphyConfig.Builder()
           .setDefaultFontPath("fonts/Roboto-Light.ttf")
           .setFontAttrId(R.attr.fontPath)
           .build());
 }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    ParseObject statusObject = mStatus.get(position);
    String objectId = statusObject.getObjectId();

    Intent goToDetailView = new Intent(HomepageActivity.this, StatusDetailView.class);
    goToDetailView.putExtra("objectID", objectId);
    startActivity(goToDetailView);
  }
 private void savePic() {
   String fileName = Long.toString(System.currentTimeMillis()) + ".png";
   ParseFile file = new ParseFile(fileName, photoBytes);
   file.saveInBackground();
   ParseObject pictureSave = new ParseObject("Album");
   pictureSave.put("userName", UserInfo.username);
   pictureSave.put("picture", file);
   pictureSave.put("fileName", fileName);
   pictureSave.saveInBackground();
   Toast.makeText(getApplicationContext(), "Picture has been saved", Toast.LENGTH_SHORT).show();
 }
  protected static Category createCategory(ParseObject parseObject) {

    Category category = new Category(parseObject.getObjectId());
    Log.i("parse", "category " + parseObject);
    if (parseObject.has("category_name")) {
      category.setName(parseObject.getString("category_name"));
    }
    if (parseObject.has("short")) {
      category.setShortName(parseObject.getString("short"));
    }
    return category;
  }
Example #30
0
 public static void savePictureToPostSync(ParseObject mPost, Bitmap picture) {
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   picture.compress(Bitmap.CompressFormat.JPEG, 100, stream);
   byte[] bytearray = stream.toByteArray();
   ParseFile questionPicture = new ParseFile(mPost.getObjectId() + "_picture.jpg", bytearray);
   try {
     questionPicture.save();
     mPost.put(Common.OBJECT_POST_PICTURE, questionPicture);
     mPost.save();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }