Beispiel #1
0
 public UIShowBox(Page page) {
   super(page.getRawContext());
   mPage = page;
   DisplayMetrics dm = BaseHelper.getDisplayMetrics((Activity) mPage.getRawContext());
   this.heightPixels = dm.heightPixels;
   this.widthPixels = dm.widthPixels;
 }
Beispiel #2
0
 @Override
 public boolean onSingleTapConfirmed(MotionEvent e) {
   LogUtil.logAnyTime(TAG, "onSingleTapConfirmed");
   Object id = getTag() == null ? "" : getTag();
   mPage.interpreter("ShowBox::" + id.toString(), (itemExps.get(currentIndex)).toString());
   return true;
 }
Beispiel #3
0
  private void getImage(ArrayList<Object> uris) {
    final BitmapDrawable[] drawables = new BitmapDrawable[uris.size()];

    for (int i = 0; i < uris.size(); i++) {
      final int j = i;
      BitmapDownloadListener listener =
          new BitmapDownloadListener() {
            @Override
            public void onComplete(Bitmap bm) {
              drawables[j] = new BitmapDrawable(bm);
              imgCount++;
              if (imgCount == drawables.length) {
                ((Activity) mPage.getRawContext())
                    .runOnUiThread(
                        new Runnable() {
                          public void run() {
                            getImage(drawables);
                            imgCount = 0;
                          }
                        });
              }
            }
          };

      String uri = (String) uris.get(i);
      String scheme = Uri.parse(uri).getScheme();
      if (scheme != null && scheme.indexOf("http") != -1) {
        StringBuffer sb = new StringBuffer(uri);
        sb.append(
            "?screenWidthPixels="
                + String.valueOf(widthPixels)
                + "&screenHeightPixels="
                + String.valueOf(heightPixels));
        uri = sb.toString();
        Helper.bitmapFromUriString(mPage.getRawContext(), uri, listener, R.drawable.app_default);
      } else {
        File file = mPage.getEngine().getFile(uri);

        Bitmap bitmap =
            Helper.bitmapFromUriString(
                mPage.getRawContext(), file, listener, R.drawable.app_default);
        if (bitmap != null) listener.onComplete(bitmap);
      }
    }
  }
Beispiel #4
0
  private void init(ViewGroup parent, int orientation) {
    showBox_Type = orientation;

    flipper =
        (ViewFlipper)
            LayoutInflater.from(mPage.getRawContext()).inflate(R.layout.uishowbox, this, false);
    this.addView(flipper);

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    setLayoutParams(params);

    if (showBox_Type == UISHOWBOX_H) {
      flipper.setInAnimation(mPage.getRawContext(), R.anim.push_left_in);
      flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_left_out);
    } else {
      flipper.setInAnimation(mPage.getRawContext(), R.anim.push_top_in);
      flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_top_out);
    }
  }
Beispiel #5
0
 private void getImage(BitmapDrawable[] drawables) {
   imageViews = new ImageView[drawables.length];
   for (int i = 0; i < drawables.length; i++) {
     imageViews[i] = new ImageView(mPage.getRawContext());
     imageViews[i].setScaleType(ImageView.ScaleType.FIT_XY);
     LinearLayout.LayoutParams params =
         new LinearLayout.LayoutParams(new LayoutParams(imgWidth, imgHeight));
     imageViews[i].setLayoutParams(params);
     imageViews[i].setImageDrawable(drawables[i]);
     flipper.addView(imageViews[i]);
   }
 }
Beispiel #6
0
 @Override
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
   LogUtil.logAnyTime(TAG, "onFling");
   if (showBox_Type == UISHOWBOX_H) {
     if (e1.getX() > e2.getX()) { // move to left
       flipper.showNext();
       currentIndex += 1;
       if (currentIndex == uris.size()) {
         currentIndex = 0;
       }
     } else if (e1.getX() < e2.getX()) {
       flipper.setInAnimation(mPage.getRawContext(), R.anim.push_right_in);
       flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_right_out);
       flipper.showPrevious();
       flipper.setInAnimation(mPage.getRawContext(), R.anim.push_left_in);
       flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_left_out);
       currentIndex -= 1;
       if (currentIndex == -1) {
         currentIndex = uris.size() - 1;
       }
     } else {
       return false;
     }
   } else {
     if (e1.getY() < e2.getY()) { // move to bottom
       System.out.println("onFling" + "1");
       flipper.showNext();
     } else if (e1.getY() > e2.getY()) {
       flipper.setInAnimation(mPage.getRawContext(), R.anim.push_bottom_in);
       flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_bottom_out);
       flipper.showPrevious();
       flipper.setInAnimation(mPage.getRawContext(), R.anim.push_top_in);
       flipper.setOutAnimation(mPage.getRawContext(), R.anim.push_top_out);
     } else {
       return false;
     }
   }
   return true;
 }