protected void sendSMSMessage(String phone) { Log.i("Send SMS", "in sms"); ParseUser currentUser = ParseUser.getCurrentUser(); currentUser.fetchInBackground(); String phoneNo = (currentUser.getNumber("phoneNumber")).toString(); String curr_fname = currentUser.getString("firstName"); String curr_lname = currentUser.getString("lastName"); String curr_name = curr_fname + curr_lname; Toast.makeText(getBaseContext(), "user number - " + phoneNo, Toast.LENGTH_SHORT).show(); try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage( phone, null, "A Donor has responded to your blood Request. You can contact " + curr_name + " on - " + phoneNo, null, null); Toast.makeText(getBaseContext(), "SMS sent.", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getBaseContext(), "SMS failed, please try again.", Toast.LENGTH_LONG).show(); e.printStackTrace(); } }
@Override public View getItemView(SingleWorkout workout, View convertView, ViewGroup parent) { super.getItemView(workout, convertView, parent); final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item_cards, parent, false); holder = new ViewHolder(); holder.ivImage = (ImageView) convertView.findViewById(R.id.imageViewProfilePic); holder.ivPeek1 = (ImageView) convertView.findViewById(R.id.imageViewPeek1); holder.ivPeek2 = (ImageView) convertView.findViewById(R.id.imageViewPeek2); holder.ivPeek3 = (ImageView) convertView.findViewById(R.id.imageViewPeek3); holder.tvTitle = (TextView) convertView.findViewById(R.id.textViewTitle); holder.tvDifficulty = (TextView) convertView.findViewById(R.id.textViewDifficulty); holder.tvTime = (TextView) convertView.findViewById(R.id.textViewTime); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tvTitle.setText(workout.get_title()); holder.tvTime.setText(workout.get_time()); holder.tvDifficulty.setText(workout.get_difficulty()); try { JSONArray mJsonArray = new JSONArray(workout.get_pictureArrayJSON()); String pictureVal1 = "w" + mJsonArray.getString(0); String pictureVal2 = "w" + mJsonArray.getString(1); String pictureVal3 = "w" + mJsonArray.getString(2); holder.ivPeek1.setImageResource( getContext() .getResources() .getIdentifier(pictureVal1, "drawable", getContext().getPackageName())); holder.ivPeek2.setImageResource( getContext() .getResources() .getIdentifier(pictureVal2, "drawable", getContext().getPackageName())); holder.ivPeek3.setImageResource( getContext() .getResources() .getIdentifier(pictureVal3, "drawable", getContext().getPackageName())); } catch (JSONException e) { e.printStackTrace(); } // needed to get User profile pic for parse feed try { ParseUser mUser = workout.getParseUser("user"); mUser.fetchInBackground( new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { try { final byte[] mBytes = parseObject.getBytes("photo"); if (mBytes != null) { new Handler() .post( new Runnable() { @Override public void run() { Bitmap bitmap = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length); holder.ivImage.setImageBitmap(bitmap); } }); } } catch (Exception f) { Log.e(TAG, f.getMessage()); } } }); } catch (Exception e) { Log.e(TAG, e.getMessage()); } // still need to populate the ivPeek with icons return convertView; }