Beispiel #1
0
 @Override
 public void afterTextChanged(Editable s) {
   if (StringUtil.isEmpty(etScreenName.getText().toString())) {
     btnProfileUpdate.setEnabled(false);
   } else if (StringUtil.isEquals(user.getScreenName(), etScreenName.getText().toString())
       && StringUtil.isEquals(user.getDescription(), etDescription.getText().toString())) {
     btnProfileUpdate.setEnabled(false);
   } else {
     btnProfileUpdate.setEnabled(true);
   }
 }
Beispiel #2
0
  public static YiBoMe getYiBoMeOAuth(Context context) {
    if (context == null) {
      return null;
    }

    ConfigSystemDao configDao = new ConfigSystemDao(context);
    String authToken = configDao.getString(Constants.PASSPORT_TOKEN);
    String authSecret = configDao.getString(Constants.PASSPORT_SECRET);
    if (StringUtil.isEmpty(authToken) || StringUtil.isEmpty(authSecret)) {
      return null;
    }

    OAuthAuthorization auth = new OAuthAuthorization(authToken, authSecret, ServiceProvider.YiBoMe);
    return new YiBoMeImpl(auth);
  }
  @Override
  public void afterTextChanged(Editable s) {
    String filterName = s.toString();
    if (StringUtil.isEmpty(filterName)) {
      filterName = " ";
    }

    usersAdapter.getFilter().filter(filterName);
    usersAdapter.notifyDataSetChanged();
  }
Beispiel #4
0
  protected Context getPackageContext(Context context, String packageName) {
    Context packageContext = null;
    if (StringUtil.isEmpty(packageName)) {
      return packageContext;
    }
    try {
      packageContext = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY);
    } catch (NameNotFoundException e) {
      if (Constants.DEBUG) Log.e(TAG, e.getMessage(), e);
    }

    return packageContext;
  }
Beispiel #5
0
 public LocalGroup getGroup(LocalAccount account, Group group) {
   if (account == null || group == null) {
     return null;
   }
   String groupName = group.getName();
   if (StringUtil.isNotEmpty(groupName)) {
     groupName = groupName.replace("'", "''");
   }
   String sql =
       "select * from Group_Info where SP_Group_ID = '"
           + group.getId()
           + "' and Account_ID = "
           + account.getAccountId()
           + " and Group_Name = '"
           + groupName
           + "'";
   return (LocalGroup) this.query(sql);
 }
  @Override
  protected Integer doInBackground(Void... params) {
    if (statusUpdate == null
        || StringUtil.isBlank(statusUpdate.getStatus())
        || ListUtil.isEmpty(listAccount)) {
      return 0;
    }

    if (statusUpdate.getImage() != null && isRetry) {
      rotateImage();
      compressImage();
    }

    String text = statusUpdate.getStatus();
    net.dev123.mblog.entity.Status newStatus = null;
    for (int i = 0; i < listAccount.size(); i++) {
      LocalAccount account = listAccount.get(i);

      if (account == null) {
        continue;
      }

      ProgressHolder holder = new ProgressHolder();
      holder.account = account;
      holder.state = State.Loading;
      newStatus = null;
      this.publishProgress(holder);

      try {
        StatusUpdate toUpdate = new StatusUpdate(text);
        toUpdate.setImage(statusUpdate.getImage());
        toUpdate.setLocation(statusUpdate.getLocation());
        if (account.isSnsAccount()) {
          Sns sns = GlobalVars.getSns(account);
          if (sns != null) {
            boolean result = false;
            if (statusUpdate.getImage() != null) {
              result = sns.uploadPhoto(statusUpdate.getImage(), statusUpdate.getStatus());
            } else {
              result = sns.createStatus(statusUpdate.getStatus());
            }
            if (result) {
              newStatus = new net.dev123.mblog.entity.Status();
            }
          }
        } else {
          MicroBlog microBlog = GlobalVars.getMicroBlog(account);
          if (microBlog != null) {
            newStatus = microBlog.updateStatus(toUpdate);
          }
        }
      } catch (LibException e) {
        if (Constants.DEBUG) Log.e(TAG, "Task", e);
        resultMsg = ResourceBook.getStatusCodeValue(e.getExceptionCode(), context);
      }

      if (newStatus != null) {
        holder.state = State.Success;
      } else {
        holder.state = State.Failed;
        listFailedAccount.add(account);
      }
      this.publishProgress(holder);
    }
    if (listFailedAccount.size() < 1) {
      SystemClock.sleep(1000);
    }

    return listAccount.size() - listFailedAccount.size();
  }