예제 #1
1
  private void noticeNewBlog(Context context) {
    NotificationManager notiManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notiManager.cancel(Constants.NOTIFICATION_NEW_MICRO_BLOG); // 先清除上一次提醒;

    Intent intent = new Intent();
    // 粉丝
    if (entity.getContentType() == Skeleton.TYPE_MORE) {
      intent.setAction("com.shejiaomao.weibo.SOCIAL_GRAPH");
      intent.addCategory("android.intent.category.DEFAULT");
      intent.putExtra("SOCIAL_GRAPH_TYPE", SocialGraphTask.TYPE_FOLLOWERS);
      intent.putExtra("USER", account.getUser());
    } else {
      intent.setAction("com.shejiaomao.weibo.MAIN");
      intent.addCategory("android.intent.category.DEFAULT");
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    }
    intent.putExtra("CONTENT_TYPE", entity.getContentType());
    intent.putExtra("ACCOUNT", account);

    Notification notification = new Notification();
    notification.icon = R.drawable.icon_notification;
    notification.flags = Notification.FLAG_AUTO_CANCEL;
    notification.tickerText = entity.getTickerText();

    if (sheJiaoMao.isVibrateNotification()) {
      notification.defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (sheJiaoMao.isRingtoneNotification()) {
      if (StringUtil.isNotEmpty(sheJiaoMao.getRingtoneUri())) {
        notification.sound = Uri.parse(sheJiaoMao.getRingtoneUri());
      } else {
        notification.defaults |= Notification.DEFAULT_SOUND;
      }
    }

    if (sheJiaoMao.isFlashingLEDNotification()) {
      notification.ledARGB = Color.GREEN;
      notification.ledOffMS = 1000;
      notification.ledOnMS = 1000;
      notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    }

    int requestCode = account.getAccountId().intValue() * 100 + entity.getContentType();
    PendingIntent pendingIntent =
        PendingIntent.getActivity(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(
        context, entity.getContentTitle(), entity.getContentText(), pendingIntent);

    notiManager.notify(requestCode, notification);
  }
예제 #2
0
 public static String getImageFolder(String imageType) {
   String tempFolder = SheJiaoMaoApplication.getSdcardCachePath() + File.separator + imageType;
   if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
     tempFolder = SheJiaoMaoApplication.getInnerCachePath() + File.separator + imageType;
   }
   return tempFolder;
 }
예제 #3
0
  @Override
  protected Bitmap doInBackground(Void... params) {
    if (imageView == null || url == null) {
      return bitmap;
    }

    if (Logger.isDebug()) Log.i(LOG_TAG, "Get Header image from remote!");
    try {
      Bitmap newBitmap = ImageUtil.getBitmapByUrl(url);

      /** 加入cache中* */
      if (newBitmap != null) {
        // 生成mini图
        Bitmap scaleBitmap =
            ImageUtil.scaleBitmapTo(newBitmap, SheJiaoMaoApplication.getSmallAvatarSize());
        Bitmap roundBitmap = ImageUtil.getRoundedCornerBitmap(scaleBitmap);
        if (scaleBitmap != newBitmap) {
          scaleBitmap.recycle();
        }

        CachedImage resultWrap = new CachedImage(roundBitmap);
        if (isMini) {
          bitmap = roundBitmap;
        }
        imageInfo.setCacheType(CachedImageKey.IMAGE_HEAD_MINI);
        imageCache.put(imageInfo, resultWrap);

        // 生成normal图
        scaleBitmap =
            ImageUtil.scaleBitmapTo(newBitmap, SheJiaoMaoApplication.getNormalAvatarSize());
        roundBitmap = ImageUtil.getRoundedCornerBitmap(scaleBitmap);
        scaleBitmap.recycle();

        resultWrap = new CachedImage(roundBitmap);
        imageInfo.setCacheType(CachedImageKey.IMAGE_HEAD_NORMAL);
        imageCache.put(imageInfo, resultWrap);

        newBitmap.recycle();
        if (!isMini) {
          bitmap = roundBitmap;
        }
      }
    } catch (LibException e) {
      if (Logger.isDebug()) Log.e(LOG_TAG, e.getMessage(), e);
    }

    return bitmap;
  }
예제 #4
0
 public UpdateProfilePhotoTask(ProfileEditActivity context, File image) {
   this.context = context;
   this.sheJiaoMao = (SheJiaoMaoApplication) context.getApplication();
   this.accountId = sheJiaoMao.getCurrentAccount().getAccountId();
   this.image = image;
   this.isShowDialog = true;
 }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
    LocalAccount account = (LocalAccount) adapter.getItem(position);
    if (selectorWindow.isSelected(account)) {
      selectorWindow.removeSelectedAccount(account);
    } else {
      selectorWindow.addSelectedAccount(account);
    }

    Context context = view.getContext();
    SheJiaoMaoApplication sheJiaoMao = (SheJiaoMaoApplication) context.getApplicationContext();
    sheJiaoMao.setCurrentAccount(account);

    HomePageActivity activity = (HomePageActivity) context;
    Skeleton skeleton = activity.getSkeleton();
    if (skeleton != null) {
      skeleton.setCurrentAccount(account, true);
      skeleton.setContentType(skeleton.getContentType());
    }

    selectorWindow.dismiss();
  }
예제 #6
0
  @Override
  protected User doInBackground(Void... params) {
    if (image == null) {
      return null;
    }

    Weibo microBlog = GlobalVars.getMicroBlog(accountId);
    if (microBlog == null) {
      return null;
    }

    User user = null;
    try {

      if (image != null) {
        String fileExtension = FileUtil.getFileExtensionFromName(image.getName());
        int size = ImageQuality.Low.getSize();
        ImageQuality quality = sheJiaoMao.getImageUploadQuality();
        if (quality == ImageQuality.High || GlobalVars.NET_TYPE == NetType.WIFI) {
          size = ImageQuality.High.getSize();
        } else if (quality == ImageQuality.Middle || quality == ImageQuality.Low) {
          size = quality.getSize();
          if (Logger.isDebug()) Log.d(TAG, "prefix size: " + size);
          // 对低速网络进行压缩
          if (GlobalVars.NET_TYPE == NetType.MOBILE_GPRS
              || GlobalVars.NET_TYPE == NetType.MOBILE_EDGE) {
            size = ImageQuality.Low.getSize();
          }
        }
        String destName =
            ImageCache.getTempFolder()
                + File.separator
                + System.currentTimeMillis()
                + "."
                + fileExtension;
        File dest = new File(destName);
        boolean isSuccess = ImageUtil.scaleImageFile(image, dest, size);
        if (isSuccess) {
          image = dest;
        }
        user = microBlog.updateProfileImage(image);
      }
    } catch (LibException e) {
      if (Logger.isDebug()) Log.e(TAG, "Task", e);
      resultMsg = ResourceBook.getResultCodeValue(e.getErrorCode(), context);
    }

    return user;
  }