public String getName() {
   if (user.getString("nickname").isEmpty()) {
     return "Anonymous";
   } else {
     return user.getString("nickname");
   }
 }
Пример #2
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;
  }
Пример #3
0
    @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;
    }
  @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();
          }
        });
  }
Пример #5
0
 public SharesModel(ParseObject parseObject, Context context) {
   startDay = HelperClass.getStringFormatDate(parseObject.getDate("share_due_date"), context);
   shareOrder = parseObject.getInt("share_order");
   isShareDelivered = parseObject.getBoolean("share_status");
   jamId = parseObject.getString("shares_jamNo");
   shareOwnerId = parseObject.getString("share_owner_id");
   shareId = parseObject.getObjectId();
   sharePaidAmount = parseObject.getInt("share_paid_amount");
 }
  @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);
  }
  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;
  }
Пример #8
0
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    ParseObject message = mMessages.get(position);
    String messageType = message.getString(ParseConstant.KEY_FILE_TYPE);
    ParseFile file = message.getParseFile(ParseConstant.KEY_FILE);
    Uri fileUri = Uri.parse(file.getUrl());

    if (messageType.equals(ParseConstant.TYPE_IMAGE)) {
      Intent intent = new Intent(getActivity(), ViewimageActivity.class);
      intent.setData(fileUri);
      startActivity(intent);
    } else {
      Intent intent = new Intent(Intent.ACTION_VIEW, fileUri);
      intent.setDataAndType(fileUri, "video/*");
      startActivity(intent);
    }

    // Delete it
    List<String> ids = message.getList(ParseConstant.KEY_RECIPIENT_IDS);
    if (ids.size() == 1) {
      // last recipients
      message.deleteInBackground();
    } else {
      ids.remove(ParseUser.getCurrentUser().getObjectId());
      ArrayList<String> idsToRemove = new ArrayList<String>();
      idsToRemove.add(ParseUser.getCurrentUser().getObjectId());

      message.removeAll(ParseConstant.KEY_RECIPIENT_IDS, idsToRemove);
      message.saveInBackground();
    }
  }
Пример #9
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()));
  }
Пример #10
0
  private void initializeData() {

    ParseUser current = ParseUser.getCurrentUser();

    if (current != null) {
      String[] classes = new String[1];
      if (current.getBoolean("isteach")) {
        c.setText("Create Class");
      } else {
        c.setText("Add Class");
      }
      if (current.getString("Classes").contains(",")) {
        classes = current.getString("Classes").split(",");
      } else {
        classes[0] = current.getString("Classes");
      }
      ParseObject[] classesList = new ParseObject[classes.length];
      int z = 0;

      for (z = 0; z < classes.length; z++) {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Classes");
        query.whereEqualTo("objectId", classes[z]);
        try {
          ParseObject f = query.getFirst();
          classesList[z] = f;
        } catch (ParseException e) {
          Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
      }
      courses = new ArrayList<>();
      for (ParseObject g : classesList) {
        courses.add(
            new Courses(
                g.getString("ClassName"),
                g.getString("Teacher"),
                R.drawable.logo_audio,
                g.getObjectId()));
      }
    } else {
      courses = new ArrayList<>();
      courses.add(new Courses("Physics", "Culbertson", R.drawable.physics));
      courses.add(new Courses("Mobile App Dev", "Galanos", R.drawable.mobile));
      courses.add(new Courses("AP Calculus BC", "Spoden", R.drawable.integral));
      courses.add(new Courses("AP Chemistry", "Acio", R.drawable.chemistry));
      courses.add(new Courses("DNA Science", "Cobb", R.drawable.dna));
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
      viewHolder = new ViewHolder();
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(layoutId, null);
      viewHolder.gridViewItem = (CardView) convertView.findViewById(R.id.historyOrderItemHOI);
      viewHolder.price = (TextView) convertView.findViewById(R.id.productPriceHOI);
      viewHolder.productImage = (ImageView) convertView.findViewById(R.id.productImageHOI);
      viewHolder.productName = (TextView) convertView.findViewById(R.id.productNameHOI);
      viewHolder.ratingBar = (RatingBar) convertView.findViewById(R.id.ratingBarGridItemHOI);
      viewHolder.quantity = (TextView) convertView.findViewById(R.id.productQuantityHOI);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    final ParseObject item = items.get(position);
    final ParseObject product = item.getParseObject(CART_PRODUCT_ID);
    final ViewHolder finalViewHolder = viewHolder;
    Log.w(TAG, position + "");
    finalViewHolder.quantity.setText(
        context.getString(R.string.quantity) + item.getNumber(SHIP_QUANTITY).toString());
    imageLoader.displayImage(
        product.getString(PRODUCT_THUMBNAIL_IMAGE), finalViewHolder.productImage, options);
    finalViewHolder.productName.setText(product.getString(PRODUCT_NAME));
    finalViewHolder.ratingBar.setRating(Float.parseFloat(product.getString(NUMBER_STAR)));
    finalViewHolder.price.setText(
        StringProcess.formatPrice((Integer) product.getNumber(PRODUCT_PRICE)));
    finalViewHolder.gridViewItem.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, ProductDetailActivity.class);
            intent.putExtra("productName", product.getString(PRODUCT_NAME));
            intent.putExtra("productId", product.getObjectId());
            context.startActivity(intent);
          }
        });

    return convertView;
  }
  @Override
  public View getItemView(ParseObject object, View v, ViewGroup parent) {
    if (v == null) {
      v = View.inflate(getContext(), R.layout.shopping_list_item, null);
    }

    super.getItemView(object, v, parent);

    TextView titleTextView = (TextView) v.findViewById(R.id.text1);
    titleTextView.setText(object.getString("productName"));

    TextView timestampView = (TextView) v.findViewById(R.id.timestamp);
    //  timestampView.setText(object.getDate("expiry").toString());

    // timestampView.setText("Barcode: " + object.getString("ISDN"));
    timestampView.setText(object.getString("quantity") + " " + object.getString("unit"));

    return v;
  }
Пример #13
0
 private void initializeData(String oid) {
   ParseQuery query = ParseQuery.getQuery("Classes");
   String assignment = new String();
   query.whereEqualTo("objectId", oid);
   try {
     ParseObject f = query.getFirst();
     assignment = f.getString("assignments");
   } catch (ParseException e) {
     Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
   }
   Log.e("Testing", assignment);
   String[] assignments = new String[1];
   if (assignment.length() < 10) {
     return;
   } else if (assignment.contains(",")) {
     assignments = assignment.split(",");
   } else {
     assignments = new String[1];
     assignments[0] = assignment;
   }
   ParseObject[] assignmentsList = new ParseObject[assignments.length];
   Log.e("Testing", Integer.toString(assignments.length));
   int z = 0;
   for (z = 0; z < assignments.length; z++) {
     ParseQuery<ParseObject> query3 = ParseQuery.getQuery("Assignments");
     Log.e("Testing", "a " + assignments[z]);
     Log.e("Testing", Integer.toString(z));
     try {
       ParseObject f = query3.get(assignments[z]);
       assignmentsList[z] = f;
     } catch (ParseException e) {
       Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
     }
   }
   courses = new ArrayList<>();
   for (ParseObject g : assignmentsList) {
     courses.add(
         new Assignments(g.getString("Assignment"), g.getString("Question"), g.getObjectId()));
   }
 }
Пример #14
0
 public void setData(ParseObject object) {
   mId = object.getString("id");
   mType = object.getString("type");
   mContentType = object.getString("contentType");
   mRating = object.getString("rating");
   mCaption = object.getString("caption");
   mCreationDateTime = object.getString("creationDateTime");
   mTrendingDateTime = object.getString("trendingDateTime");
   mSourceUrl = object.getString("sourceUrl");
   mImages = new Images(object.getParseObject("images"));
 }
Пример #15
0
  public void sendAlert(String stockSymbol, String targetPrice, String stockState) {
    Notification.Builder mBuilder =
        new Notification.Builder(this)
            .setSmallIcon(R.drawable.appicon)
            .setContentTitle("EZQuote - '" + stockSymbol + "'")
            .setContentText(stockState + " Target Price " + targetPrice + " reached. Hurry!");
    // Creates an explicit intent for an Activity in your app

    Intent resultIntent = new Intent(this, MarketSummaryActivity.class);

    // The stack builder object will contain an artificial back stack for
    // the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MarketSummaryActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent =
        stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(getRandomNumber(), mBuilder.build());

    // Delete the alarm after it goes off.
    for (ParseObject o : alertObjs) {
      if (stockSymbol.equalsIgnoreCase((o.getString("symbol")))
          && targetPrice.equals(o.getString("targetPrice"))
          && stockState.equals(o.getString("StockState"))) {

        o.deleteInBackground();
      }
    }
  }
Пример #16
0
  public static Board createBoard(ParseObject o) {
    if (o == null) {
      return null;
    }
    cache().put(o);

    Board board = new Board(o.getObjectId());
    if (o.has("category")) {
      board.setCategory(ParseHelper.createCategory(o.getParseObject("category")));
    }
    if (o.has("name")) {
      board.setName(o.getString("name"));
    }
    if (o.has("description")) {
      board.setDescription(o.getString("description"));
    }
    if (o.has("owner")) {
      board.setOwner(ParseHelper.createUser(o.getParseObject("owner")));
    }
    if (o.has("followers_count")) {
      board.setFollowersCount(o.getInt("followers_count"));
    }
    return board;
  }
Пример #17
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;
  }
Пример #18
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.inbox_message_item, null);
      holder = new ViewHolder();
      holder.icon = (ImageView) convertView.findViewById(R.id.inbox_img_icon);
      holder.sender = (TextView) convertView.findViewById(R.id.sender_label);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    ParseObject message = mMessages.get(position);
    Log.i("messageadapter", "fILE tYPE " + message.getString(ParseConstants.KEY_FILE_TYPE));
    if (message.getString(ParseConstants.KEY_FILE_TYPE).equals("Image")) {
      holder.icon.setImageResource(R.drawable.ic_action_picture);
    } else {
      holder.icon.setImageResource(R.drawable.ic_action_play_over_video);
    }
    holder.sender.setText(message.getString(ParseConstants.KEY_SENDERNAME));
    return convertView;
  }
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.home_page_custom_layout, null);
      holder = new ViewHolder();
      holder.usernameHomepage = (TextView) convertView.findViewById(R.id.usernameHP);
      holder.statusHomepage = (TextView) convertView.findViewById(R.id.statusHP);
      // holder.homeImage = (ImageView) convertView
      //    .findViewById(R.id.ivContactImage);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    ParseObject statusObject = mStatus.get(position);

    // username
    String username = statusObject.getString("user");
    holder.usernameHomepage.setText(username);

    // content
    String status = statusObject.getString("newStatus");
    holder.statusHomepage.setText(status);

    //
    // ParseObject object = mImages.get(position);
    // get the image
    // object
    // Picasso.with(getContext().getApplicationContext()).load(statusObject
    // .getParseFile("StatusPhoto").getUrl()).noFade().into(holder.homeImage);

    //

    return convertView;
  }
    @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.item_userbookinghistory, null);
      }

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

      if (userbooking != null) {
        TextView tv_bookedTime = (TextView) v.findViewById(R.id.tv_hotel_booked_time);
        TextView tv_hotel_name = (TextView) v.findViewById(R.id.tv_hotel_name);
        TextView tv_status = (TextView) v.findViewById(R.id.tv_status);

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss");
        ParseObject hotel = userbooking.getParseObject("BookedHotel");

        Date reservationTime = userbooking.getDate("ReservationTime");
        tv_bookedTime.setText(formatter.format(reservationTime));

        tv_hotel_name.setText(hotel.getString("Name"));

        int status = userbooking.getInt("BookingState");
        String status_message = "";

        if (status == 1) {
          status_message = "Under Process";
        } else if (status == 2) {
          status_message = "Confirmed";
        } else if (status == -1) {
          status_message = "Canceled";
        } else if (status == -2) {
          status_message = "Not Confirmed";
        }

        tv_status.setText(status_message);
      }

      return v;
    }
Пример #21
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LinearLayout newsView;
    ParseObject news = getItem(position);

    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      newsView = (LinearLayout) inflater.inflate(R.layout.layout_news, parent, false);
    } else {
      newsView = (LinearLayout) convertView;
    }
    TextView tvTitle = (TextView) newsView.findViewById(R.id.tvType);

    switch (news.getInt("Type")) {
      case 0:
        tvTitle.setText("新貨");
        newsView.setBackgroundColor(getContext().getResources().getColor(R.color.new_blue));
        break;
      default:
      case 1:
        tvTitle.setText("公告");
        newsView.setBackgroundColor(getContext().getResources().getColor(R.color.declare_green));
        break;
      case 2:
        tvTitle.setText("活動");
        newsView.setBackgroundColor(getContext().getResources().getColor(R.color.activty_gray));
        break;
      case 3:
        tvTitle.setText("公休");
        newsView.setBackgroundColor(getContext().getResources().getColor(R.color.holiday_red));
        break;
    }

    TextView tvContent = (TextView) newsView.findViewById(R.id.tvNewsContent);
    tvContent.setText(news.getString("Content"));

    return newsView;
  }
Пример #22
0
 public MoveVenue(ParseObject po) {
   venuePicture = po.getParseFile(MOVEVENUE_PICTURE);
   venueName = po.getString(MOVEVENUE_NAME);
 }
Пример #23
0
 private static String getStringIfHas(ParseObject object, String key) {
   return object.has(key) ? object.getString(key) : "";
 }
Пример #24
0
  public static void setPreferences(ParseObject userObject, final Context context) {
    PrefManager.with(context)
        .save(
            User.FIRST_NAME,
            userObject.getString(User.FIRST_NAME) != null
                ? userObject.getString(User.FIRST_NAME)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            User.LAST_NAME,
            userObject.getString(User.LAST_NAME) != null
                ? userObject.getString(User.LAST_NAME)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            PreferenceUtils.EMAIL,
            userObject.getString(PreferenceUtils.EMAIL) != null
                ? userObject.getString(PreferenceUtils.EMAIL)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            PreferenceUtils.AVATAR_URL,
            userObject.getString(PreferenceUtils.AVATAR_URL) != null
                ? userObject.getString(PreferenceUtils.AVATAR_URL)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            User.OBJECT_ID,
            userObject.getObjectId() != null ? userObject.getObjectId() : BuildConfig.FLAVOR);
    PrefManager.with(context).save(User.HAS_FITBIT, userObject.getBoolean(User.HAS_FITBIT));
    PrefManager.with(context).save(User.HAS_JAWBONE, userObject.getBoolean(User.HAS_JAWBONE));
    PrefManager.with(context).save(User.HAS_GOOGLEFIT, userObject.getBoolean(User.HAS_GOOGLEFIT));
    PrefManager.with(context).save(User.HAS_MISFIT, userObject.getBoolean(User.HAS_MISFIT));
    PrefManager.with(context).save(User.HAS_MOVES, userObject.getBoolean(User.HAS_MOVES));
    PrefManager.with(context)
        .save(
            User.MOVES_TOKEN,
            userObject.getString(User.MOVES_TOKEN) != null
                ? userObject.getString(User.MOVES_TOKEN)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            User.MOVES_REFRESH_TOKEN,
            userObject.getString(User.MOVES_REFRESH_TOKEN) != null
                ? userObject.getString(User.MOVES_REFRESH_TOKEN)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            User.UNITS,
            userObject.getString(User.UNITS) != null
                ? userObject.getString(User.UNITS)
                : context.getString(R.string.pref_units_imperial));
    try {
      String[] fitbitToken = userObject.getString(User.FITBIT_TOKEN).split(",");
      if (fitbitToken.length > 0) {
        PrefManager.with(context).save(FitbitClient.FITBIT_TOKEN, fitbitToken[0]);
        PrefManager.with(context).save(FitbitClient.FITBIT_TOKEN_SECRET, fitbitToken[1]);
        PrefManager.with(context).save(FitbitClient.FITBIT_TOKEN_RAW, fitbitToken[2]);
      }
    } catch (Exception ex) {
      if (ex.getMessage() != null) {
        Log.d(LOG_TAG, ex.getMessage());
      } else {
        Log.d(LOG_TAG, "Exception!", ex);
      }
    }
    if (userObject.getBoolean(User.HAS_MOVES)) {
      MoveApiClient.getBaseRestAdapter(context)
          .create(MoveApiClient.MovesConnector.class)
          .getUser(
              new Callback<MovesUser>() {
                @Override
                public void success(MovesUser movesUser, Response response) {
                  PrefManager.with(context)
                      .save(MoveApiClient.MOVES_FIRST_DATE, movesUser.getProfile().getFirstDate());
                }

                @Override
                public void failure(RetrofitError error) {}
              });
    }
    PrefManager.with(context)
        .save(
            MisfitClient.MISFIT_TOKEN,
            userObject.getString(MisfitClient.MISFIT_TOKEN) != null
                ? userObject.getString(MisfitClient.MISFIT_TOKEN)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(
            ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
            userObject.getString(User.JAWBONE_TOKEN) != null
                ? userObject.getString(User.JAWBONE_TOKEN)
                : BuildConfig.FLAVOR);
    PrefManager.with(context)
        .save(PreferenceUtils.WEEK_AVERAGE, String.valueOf(userObject.getInt(User.STEPS_AVERAGE)));
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final boolean customTitle = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    final Intent i = new Intent(this, BuganizerCreateParseUserActivity.class);

    setContentView(R.layout.bug_edit);

    if (customTitle) {
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_layout);
    }

    TextView tt = (TextView) findViewById(R.id.logout);
    tt.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Log.d("BuganizerParseEdit", "logout clicked ");
            ParseUser.logOut();
            startActivity(i);
          }
        });

    arrayPeople = new ArrayList<String>();

    mLinLayout = (LinearLayout) findViewById(R.id.EditVertLayout);

    Button bsave = (Button) findViewById(R.id.BugSave);
    Button bAddComment = (Button) findViewById(R.id.AddComment);
    Button bAddFriend = (Button) findViewById(R.id.AddUser);

    Log.d("BuganizerParseEdit", "hare krsna showing bug details ");

    Bundle extras = getIntent().getExtras();

    if (extras != null) {

      objectid = extras.getString(BuganizerParseConstants.objectid);
      Log.d("BuganizerParseEdit", "object id is  " + objectid);

      ParseQuery query = new ParseQuery("BugObject");
      try {
        pObject = query.get(objectid);
      } catch (ParseException e1) {
        e1.printStackTrace();
      }

      mAssTo = (TextView) findViewById(R.id.EditBugAssignedTo);
      mDetails = (TextView) findViewById(R.id.EditBugDetails);
      mTitle = (TextView) findViewById(R.id.EditBugTitle);
      mCreatedTS = (TextView) findViewById(R.id.EditBugCreatedTS);
      mPriority = (TextView) findViewById(R.id.EditBugPriority);
      mLayout = (LinearLayout) findViewById(R.id.EditVertLayout);

      String title = pObject.getString(BuganizerParseConstants.title);
      String body = pObject.getString(BuganizerParseConstants.body);
      String assto = pObject.getString(BuganizerParseConstants.assignedto);
      Date ts2 = pObject.getCreatedAt();
      int pri = pObject.getInt(BuganizerParseConstants.priority);

      acl = pObject.getACL();

      SimpleDateFormat dateFormatISO8601 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

      String ts = dateFormatISO8601.format(ts2);

      if (title != null) {
        mTitle.setText(title);
      }
      if (body != null) {
        mDetails.setText(body);
      }
      if (assto != null) {
        mAssTo.setText(assto);
      }
      if (ts != null) {
        mCreatedTS.setText(ts);
      }
      if (pri != 0) {
        mPriority.setText(Integer.toString(pri));
      } else {
        mPriority.setText("undefined");
      }

      if (acl != null) {
        Log.d("BuganizerParseEdit", "The bug has an ACL!");
        if (acl.getWriteAccess(ParseUser.getCurrentUser()) == true) {
          CheckBox chk = new CheckBox(this);
          chk.setChecked(true);
          chk.setText("Mark as private");
          mLayout.addView(chk, 5);
        }
      }
    }

    GetCommentsForBug();

    // fetch the comments first in the background
    ParseQuery query = new ParseQuery("CommentObject");
    query.whereEqualTo("bug", pObject);
    query.findInBackground(
        new FindCallback() {

          @Override
          public void done(List<ParseObject> objects, ParseException arg1) {

            // TODO Auto-generated method stub
            for (ParseObject ob : objects) {
              Log.d(
                  "BuganizerParseEdit",
                  "comments are : "
                      + ob.getString(BuganizerParseConstants.comments)
                      + " created at TS: "
                      + ob.getCreatedAt());
              AddCommentView(ob.getString(BuganizerParseConstants.comments), "", "", false);
            }
          }
        });

    bAddComment.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Log.d("BuganizerParseEdit", "Adding a new comment... ");
            final EditText bdetails = (EditText) findViewById(R.id.BugCommentAdd);
            String cmnt = bdetails.getText().toString();

            arrayPeople.add(cmnt);
            bdetails.setText("");
            AddCommentView(cmnt, "", "", false);
          }
        });

    bAddFriend.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Log.d("BuganizerParseEdit", "Adding a user to bug... ");
            Intent i2 = new Intent(BuganizerParseEdit.this, BuganizerListFriendsActivity.class);
            BuganizerParseEdit.this.startActivityForResult(i2, ACTIVITY_FRIEND_LIST_SHOW);
          }
        });

    bsave.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Intent mIntent = new Intent();
            Bundle bundle = new Bundle();

            for (String s : arrayPeople) Log.d("BuganizerParseEdit", "Comment: " + s);

            bundle.putString(BuganizerParseConstants.objectid, objectid);
            bundle.putStringArrayList(BuganizerParseConstants.comments, arrayPeople);

            mIntent.putExtras(bundle);
            setResult(RESULT_OK, mIntent);
            finish();
          }
        });
  }
    @Override
    protected Void doInBackground(Void... arg0) {
      if (isHoneycomb) {
        final ParseQuery query = new ParseQuery(Preferences.PARSE_TABLE_SMS);
        // Sort the Parse Object so only the username of the current
        // user can be accessed.
        query.whereEqualTo(Preferences.PARSE_USERNAME_ROW, Util.getUsernameString());
        // The most recent message added will be on top.
        query.orderByDescending("createdAt");
        // Only need to get one message from the server, each message
        // will be from a push
        query.setLimit(1);
        try {
          List<ParseObject> messageList = query.find();
          for (ParseObject messageObject : messageList) {
            // Open up the database
            // Get the parse object id
            String objectId = messageObject.objectId();
            // with the objectid you can query the server
            ParseObject message = query.get(objectId);
            // Get the time the message was added to the server
            Date time = message.createdAt();
            // Format the time to (Fri Jan 13 12:00)
            SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd hh:mm");
            String formatedTime = sdf.format(time);
            String timeDB = formatedTime.toString();
            String addressDB = message.getString("address");
            String bodyDB = message.getString("body");
            int readDB = message.getInt("read");
            int smsIdDB = message.getInt("smsId");
            String subjectDB = message.getString("subject");
            int threadIdDB = message.getInt("threadId");
            int typeDB = message.getInt("type");
            int onDeviceDB = message.getInt("onDevice");
            String usernameDB = message.getString("username");
            // Display the total message queryed for
            // logging
            String totalMessage =
                "Sent: "
                    + timeDB
                    + "\n"
                    + "Address: "
                    + addressDB
                    + "\n"
                    + "Message : "
                    + bodyDB
                    + "\n";
            Log.d(TAG, "New message is: " + totalMessage);
            // Get the MessageItem object so you can
            // create the db entry.
            MessageItem item =
                new MessageItem(
                    timeDB,
                    addressDB,
                    bodyDB,
                    readDB,
                    smsIdDB,
                    subjectDB,
                    threadIdDB,
                    typeDB,
                    onDeviceDB,
                    usernameDB);
            // Insert the MessageItem into the sms2honeycomb.db.
            dbAdapter.insertMessageItem(item);

            // TODO update the listadapter to display the new
            // message via an intent/ service?

            String intentString = "com.asa.texttotab.UPDATE_LIST";
            Intent updateIntent = new Intent();
            updateIntent.setAction(intentString);
            mContext.sendBroadcast(updateIntent);

            // TODO NOTICIFATIONS
          }
        } catch (ParseException e) {
          // TODO - Handle situation where querying server failed
          dbAdapter.close();
          Log.e(TAG, "querying server failed");
          e.printStackTrace();
        }
      } else {
        Log.e(TAG, "The device is not honeycomb is its a phone.");
        // If the device is not a tablet it is a phone so you pull from
        // the
        // server, but then send a sms message from the data recived.
        // We want to query the sms table
        final ParseQuery query = new ParseQuery(Preferences.PARSE_TABLE_SMS);
        // Sort the Parse Object so only the username of the current
        // user
        // can be accessed.
        query.whereEqualTo(Preferences.PARSE_USERNAME_ROW, Util.getUsernameString());
        // The most recent message added will be on top.
        query.orderByDescending("createdAt");
        // Only need to get one message from the server, each message
        // will be from a push
        query.setLimit(1);
        try {
          List<ParseObject> messageList = query.find();
          // For the ParseObjects quering get all that needs
          // to be done.
          for (ParseObject messageObject : messageList) {
            // Get the parse object id
            String objectId = messageObject.objectId();
            // with the objectid you can query the
            // server
            ParseObject message = query.get(objectId);
            // Get the time the message was created at
            // for
            // logging, do not need a time to send a
            // message.
            Date time = message.createdAt();
            String timeString = time.toString();
            // Get who the message is coming from
            // (phonenumber).
            String address = message.getString(Preferences.PARSE_SMS_ADDRESS);
            // Get the body of the message
            String body = message.getString(Preferences.PARSE_SMS_BODY);
            // Display the total message queryed for
            // logging
            String totalMessage =
                "Sent: " + timeString + "\n" + "To: " + address + "\n" + "Message : " + body + "\n";
            Log.d(TAG, "New message is: " + totalMessage);
            // get the smsmanager as sms
            SmsManager sms = SmsManager.getDefault();
            // If the message is over the 160 Char limit
            // it
            // will be choped up.
            if (body.length() > 160) {
              // Chops up the message
              sms.divideMessage(body);
              // Send the sms message in its parts
              sms.sendMultipartTextMessage(address, null, sms.divideMessage(body), null, null);
            } else {
              // Sends the message without cutting it
              sms.sendTextMessage(address, null, body, null, null);
            }
          }
        } catch (ParseException e) {
          // TODO - Handle situation where querying server failed
          e.printStackTrace();
        }
      }
      return null;
    }