Beispiel #1
0
  @Override
  protected void requestData(boolean refresh) {

    if (event_type == EventList.EVENT_LIST_TYPE_NEW_EVENT) {
      mCatalog = -1;
      super.requestData(refresh);
      return;
    }
    if (AppContext.getInstance().isLogin()) {
      mCatalog = AppContext.getInstance().getLoginUid();
      super.requestData(refresh);
    } else {
      mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR);
      mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip));
    }
  }
Beispiel #2
0
 private void clickErrorLayout() {
   if (event_type == EventList.EVENT_LIST_TYPE_NEW_EVENT) {
     mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
     requestData(true);
   } else {
     if (AppContext.getInstance().isLogin()) {
       mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
       requestData(true);
     } else {
       UIHelper.showLoginActivity(getActivity());
     }
   }
 }
  private void goToSelectPicture(int position) {
    switch (position) {
      case ACTION_TYPE_ALBUM:
        Intent intent;
        if (Build.VERSION.SDK_INT < 19) {
          intent = new Intent();
          intent.setAction(Intent.ACTION_GET_CONTENT);
          intent.setType("image/*");
          startActivityForResult(
              Intent.createChooser(intent, "选择图片"), ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD);
        } else {
          intent = new Intent(Intent.ACTION_PICK, Images.Media.EXTERNAL_CONTENT_URI);
          intent.setType("image/*");
          startActivityForResult(
              Intent.createChooser(intent, "选择图片"), ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD);
        }
        break;
      case ACTION_TYPE_PHOTO:
        // 判断是否挂载了SD卡
        String savePath = "";
        String storageState = Environment.getExternalStorageState();
        if (storageState.equals(Environment.MEDIA_MOUNTED)) {
          savePath =
              Environment.getExternalStorageDirectory().getAbsolutePath() + "/oschina/Camera/";
          File savedir = new File(savePath);
          if (!savedir.exists()) {
            savedir.mkdirs();
          }
        }

        // 没有挂载SD卡,无法保存文件
        if (StringUtils.isEmpty(savePath)) {
          AppContext.showToastShort("无法保存照片,请检查SD卡是否挂载");
          return;
        }

        String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "osc_" + timeStamp + ".jpg"; // 照片命名
        File out = new File(savePath, fileName);
        Uri uri = Uri.fromFile(out);

        theLarge = savePath + fileName; // 该照片的绝对路径

        intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(intent, ImageUtils.REQUEST_CODE_GETIMAGE_BYCAMERA);
        break;
      default:
        break;
    }
  }