Пример #1
0
 /**
  * Instantiates a new crop image.
  *
  * @param context the context
  * @param imageView the image view
  * @param handler the handler
  */
 public CropImage(Context context, CropImageView imageView, Handler handler) {
   mContext = context;
   mImageView = imageView;
   mImageView.setCropImage(this);
   mHandler = handler;
   // 初始化图片保存路径
   FILE_LOCAL = new File(AbFileUtil.getImageDownloadDir(context));
   if (!FILE_LOCAL.exists()) {
     FILE_LOCAL.mkdirs();
   }
 }
Пример #2
0
 /** Inits the. */
 private void init() {
   mResizeDrawableDiagonal =
       AbImageUtil.bitmapToDrawable(AbFileUtil.getBitmapFormSrc("image/crop_big.png"));
   mResizeDrawableDiagonal2 =
       AbImageUtil.bitmapToDrawable(AbFileUtil.getBitmapFormSrc("image/crop_small.png"));
 }
Пример #3
0
  /**
   * Instantiates a new ab slider button.
   *
   * @param context the context
   * @param attrs the attrs
   */
  public AbSlidingButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    btnWidth = 40;
    btnHeight = 40;
    // 移动的距离
    moveWidth = 45;
    // 每次移动的距离
    movePDis = 5;
    // 覆盖按钮的宽
    WidthOffset = 5;

    WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wManager.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    /*
     2 px = 3 dip if dpi == 80(ldpi), 320x240 screen
     1 px = 1 dip if dpi == 160(mdpi), 480x320 screen
     3 px = 2 dip if dpi == 240(hdpi), 840x480 screen
    */

    if (width < 320) {
      btnWidth = btnWidth - 10;
      btnHeight = btnHeight - 10;
      moveWidth = moveWidth - 10;
    } else if (width > 320 && width < 450) {
      btnWidth = btnWidth + 10;
      btnHeight = btnHeight + 10;
      moveWidth = moveWidth + 10;
    } else if (width >= 450) {
      btnWidth = btnWidth + 20;
      btnHeight = btnHeight + 20;
      moveWidth = moveWidth + 20;
    }

    detector = new GestureDetector(this);

    mRelativeLayout = new RelativeLayout(context);

    ImageButton btnOn = new ImageButton(context);
    ImageButton btnOff = new ImageButton(context);
    btnLeft = new ImageButton(context);
    btnRight = new ImageButton(context);

    btnOn.setFocusable(false);
    btnOff.setFocusable(false);
    btnLeft.setFocusable(false);
    btnRight.setFocusable(false);

    Bitmap onImage = AbFileUtil.getBitmapFormSrc("image/button_on_bg.png");
    Bitmap offImage = AbFileUtil.getBitmapFormSrc("image/button_off_bg.png");
    Bitmap blockImage = AbFileUtil.getBitmapFormSrc("image/button_block.png");

    btnOn.setId(ID_BTN1);
    // btnOn.setImageBitmap(onImage);
    btnOn.setMinimumWidth(btnWidth);
    btnOn.setMinimumHeight(btnHeight);
    btnOn.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(onImage));

    btnOff.setId(ID_BTN2);
    btnOff.setMinimumWidth(btnWidth);
    btnOff.setMinimumHeight(btnHeight);
    // btnOff.setImageBitmap(offImage);
    btnOff.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(offImage));

    btnLeft.setId(ID_BTN3);
    btnLeft.setMinimumWidth(btnWidth + WidthOffset);
    btnLeft.setMinimumHeight(btnHeight);
    // btnLeft.setImageBitmap(blockImage);
    btnLeft.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    btnRight.setId(ID_BTN4);
    btnRight.setMinimumWidth(btnWidth + WidthOffset);
    btnRight.setMinimumHeight(btnHeight);
    // btnRight.setImageBitmap(blockImage);
    btnRight.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    mRelativeLayout.addView(btnOn);
    mRelativeLayout.setFocusable(false);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.RIGHT_OF, ID_BTN1);
    mRelativeLayout.addView(btnOff, lp2);

    RelativeLayout.LayoutParams lp3 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnLeft, lp3);

    RelativeLayout.LayoutParams lp4 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnRight, lp4);

    addView(mRelativeLayout);

    mSwitcherChangeListener =
        new AbOnChangeListener() {

          @Override
          public void onChange(int position) {}
        };
  }
Пример #4
0
  /**
   * Creates a new graphical view.
   *
   * @param context the context
   * @param chart the chart to be drawn
   */
  public GraphicalView(Context context, AbstractChart chart) {
    super(context);
    mContext = context;
    mChart = chart;
    mHandler = new Handler();
    if (mChart instanceof XYChart) {
      mRenderer = ((XYChart) mChart).getRenderer();
    } else {
      mRenderer = ((RoundChart) mChart).getRenderer();
    }
    if (mRenderer.isZoomButtonsVisible()) {
      zoomInImage = AbFileUtil.getBitmapFromSrc("image/zoom_in.png");
      zoomOutImage = AbFileUtil.getBitmapFromSrc("image/zoom_out.png");
      fitZoomImage = AbFileUtil.getBitmapFromSrc("image/zoom-1.png");
    }

    if (mRenderer instanceof XYMultipleSeriesRenderer
        && ((XYMultipleSeriesRenderer) mRenderer).getMarginsColor()
            == XYMultipleSeriesRenderer.NO_COLOR) {
      ((XYMultipleSeriesRenderer) mRenderer).setMarginsColor(mPaint.getColor());
    }
    if (mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible()
        || mRenderer.isExternalZoomEnabled()) {
      mZoomIn = new Zoom(mChart, true, mRenderer.getZoomRate());
      mZoomOut = new Zoom(mChart, false, mRenderer.getZoomRate());
      mFitZoom = new FitZoom(mChart);
    }
    mTouchHandler = new TouchHandler(this, mChart);

    if (mChart instanceof XYChart) {
      XYMultipleSeriesRenderer mXYMultipleSeriesRenderer = ((XYChart) mChart).getRenderer();

      // 根据屏幕大小重置所有尺寸
      int explainTextSize1 = mXYMultipleSeriesRenderer.getExplainTextSize1();
      int explainTextSize2 = mXYMultipleSeriesRenderer.getExplainTextSize2();
      int scaleCircleRadius = mXYMultipleSeriesRenderer.getScaleCircleRadius();
      int scaleRectWidth = mXYMultipleSeriesRenderer.getScaleRectWidth();
      int scaleRectHeight = mXYMultipleSeriesRenderer.getScaleRectHeight();
      // 按分辨率转换
      mXYMultipleSeriesRenderer.setExplainTextSize1(AbViewUtil.scale(mContext, explainTextSize1));
      mXYMultipleSeriesRenderer.setExplainTextSize2(AbViewUtil.scale(mContext, explainTextSize2));
      mXYMultipleSeriesRenderer.setScaleCircleRadius(AbViewUtil.scale(mContext, scaleCircleRadius));
      mXYMultipleSeriesRenderer.setScaleRectWidth(AbViewUtil.scale(mContext, scaleRectWidth));
      mXYMultipleSeriesRenderer.setScaleRectHeight(AbViewUtil.scale(mContext, scaleRectHeight));

      SimpleSeriesRenderer[] mSimpleSeriesRenderers = mRenderer.getSeriesRenderers();
      if (mSimpleSeriesRenderers != null && mSimpleSeriesRenderers.length > 0) {
        for (int i = 0; i < mSimpleSeriesRenderers.length; i++) {
          SimpleSeriesRenderer mSimpleSeriesRenderer = mSimpleSeriesRenderers[i];
          int mChartValuesTextSize = (int) mSimpleSeriesRenderer.getChartValuesTextSize();
          mSimpleSeriesRenderer.setChartValuesTextSize(
              AbViewUtil.scale(mContext, mChartValuesTextSize));
        }
      }
    }

    int chartTitleTextSize = (int) mRenderer.getChartTitleTextSize();
    mRenderer.setChartTitleTextSize(AbViewUtil.scale(mContext, chartTitleTextSize));
    // 轴线上标签文字大小
    int mLabelsTextSize = (int) mRenderer.getLabelsTextSize();
    mRenderer.setLabelsTextSize(AbViewUtil.scale(mContext, mLabelsTextSize));
    // 说明文字大小
    int mLegendTextSize = (int) mRenderer.getLegendTextSize();
    mRenderer.setLegendTextSize(AbViewUtil.scale(mContext, mLegendTextSize));
  }
Пример #5
0
  @Override
  public void onClick(View v) {
    if (v == btn1) {
      showToast(this, "点击了1");
    } else if (v == btn2) {
      showToast(this, "点击了2");
      // DmHttpHelper helper = new DmHttpHelper(this, new ResultListener() {
      //
      // @Override
      // public void onSuccess(int statusCode, String successContent) {
      // showToast(TextActivity.this, successContent);
      // Log.i("winbo", "onSuccess:" + successContent);
      // }
      //
      // @Override
      // public void onFailure(int statusCode, String failContent) {
      // showToast(TextActivity.this, failContent);
      // Log.i("winbo", "onFail:" + failContent);
      // }
      // });
      // helper.setUrl(Constant.Server.ADDRESS);
      // helper.putParams("nickname", "davi");
      // helper.putParams("password", "123456");
      // helper.postRequest();

      // String filepath = "/storage/sdcard0/download/com.hh.tennets/text.html";
      // String path = "http://101.251.213.18/snstransfer/snstransfer.html";
      // try {
      // URL url = new URL(path);
      // HttpURLConnection connection = (HttpURLConnection) url.openConnection();// 从网络获得链接
      // connection.setRequestMethod("GET");// 获得
      // connection.setConnectTimeout(5000);// 设置超时时间为5s
      //
      // if (connection.getResponseCode() == 200)// 检测是否正常返回数据请求 详情参照http协议
      // {
      // Log.i("winbo", "connection.getResponseCode():" + connection.getResponseCode());
      // InputStream is = connection.getInputStream();// 获得输入流
      // File file = new File(filepath);// 新建一个file文件
      // FileOutputStream fos = new FileOutputStream(file);// 对应文件建立输出流
      // byte[] buffer = new byte[1024];// 新建缓存 用来存储 从网络读取数据 再写入文件
      // int len = 0;
      // while ((len = is.read(buffer)) != -1) {// 当没有读到最后的时候
      // fos.write(buffer, 0, len);// 将缓存中的存储的文件流秀娥问file文件
      // }
      // fos.flush();// 将缓存中的写入file
      // fos.close();
      // is.close();// 将输入流 输出流关闭
      // }
      // } catch (Exception e) {
      // Log.e("winbo", e.getMessage()+"");
      // }//
      AbFileUtil.initFileDir(this);
      //            final String url = "http://101.251.213.18/snstransfer/snstransfer.html";
      final String url = "http://101.251.213.18/snstransfer/aaaaa.jpg";
      // File fileTemp = new File("/storage/sdcard0/download/com.hh.tennets/text.jpg");
      new Thread(
              new Runnable() {

                @Override
                public void run() {
                  String path = AbFileUtil.downloadFile(url, "");
                  Log.i("winbo", "path:" + path);
                }
              })
          .start();

      // AbHttpUtil httpUtil = AbHttpUtil.getInstance(this);
      // // String url = "http://101.251.213.18/snstransfer/snstransfer.html";
      // String url = "http://101.251.213.18/snstransfer/aaaaa.jpg";
      // AbRequestParams params = new AbRequestParams();
      // params.put("name", "强哥好牛逼");
      // httpUtil.setTimeout(5000);
      // httpUtil.setEncode(HTTP.UTF_8);
      // final File fileTemp = new File("/storage/sdcard0/download/com.hh.tennets/text.jpg");
      // httpUtil.get(url, params, new AbFileHttpResponseListener() {
      //
      // @Override
      // public void onStart() {}
      //
      // @Override
      // public void onFinish() {}
      //
      // @Override
      // public void onFailure(int arg0, String arg1, Throwable arg2) {}
      //
      // @Override
      // public void onSuccess(int statusCode, File file) {
      // super.onSuccess(statusCode, file);
      // Log.i("winbo", file.getAbsolutePath());
      // file.renameTo(fileTemp);
      // }
      // });

      // AbHttpUtil httpUtil = AbHttpUtil.getInstance(this);
      // String url = Constant.Server.ADDRESS;
      // AbRequestParams params = new AbRequestParams();
      // params.put("name", "老大是个坑");
      // params.put("password", "123456");
      // httpUtil.setTimeout(5000);
      // httpUtil.post(url, params, new AbStringHttpResponseListener() {
      // @Override
      // public void onSuccess(int arg0, String arg1) {
      // Log.i("winbo", "arg1:" + arg1);
      // }
      //
      // @Override
      // public void onFailure(int arg0, String arg1, Throwable arg2) {
      // Log.i("winbo", "onFailure");
      // }
      //
      // @Override
      // public void onFinish() {
      // Log.i("winbo", "onFinish");
      // }
      //
      // @Override
      // public void onStart() {
      // Log.i("winbo", "onStart");
      // }
      // });
    }
  }
Пример #6
0
 public WeatherDBHelper(Context context) {
   super(context, AbFileUtil.getDbDownloadDir(context), DB_NAME, null, VERSION, modelClasses);
 }