/** Sets the KitKat translucent status/nav bar and adjusts the views' boundaries. */
  private void setKitKatTranslucentBars() {
    // KitKat translucent status bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      int statusBarHeight = Common.getStatusBarHeight(mContext);
      int navigationBarHeight = Common.getNavigationBarHeight(mContext);

      if (mDrawerParentLayout != null) {
        mDrawerParentLayout.setClipToPadding(false);
        mDrawerParentLayout.setPadding(0, 0, 0, 0);
      }

      if (mControlsLayoutHeaderParent != null) {
        int bottomPadding = mControlsLayoutHeaderParent.getPaddingBottom();
        mControlsLayoutHeaderParent.setClipToPadding(false);
        RelativeLayout.LayoutParams params =
            (RelativeLayout.LayoutParams) mControlsLayoutHeaderParent.getLayoutParams();

        if (navigationBarHeight > 0) {
          /* The nav bar already has padding, so remove the extra 15dp
           * margin that was applied in the layout file.
           */
          params.bottomMargin = 0;
        }

        params.bottomMargin += navigationBarHeight;
        mControlsLayoutHeaderParent.setLayoutParams(params);
      }
    }
  }
Пример #2
0
  public HsvColorPickerDialog(
      Context context, int initialColor, final OnColorSelectedListener listener) {
    super(context);
    this.listener = listener;
    this.selectedColor = initialColor;
    this.density = context.getResources().getDisplayMetrics().density;
    RelativeLayout layout = new RelativeLayout(context);

    colorWheel = new HSVColorWheel(context, initialColor);
    colorWheel.setId(ViewDefine.ViewID_Color_Wheel);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    layout.addView(colorWheel, lp);

    valueSlider = new HSVValueSlider(context);
    valueSlider.setId(ViewDefine.ViewID_Value_Slider);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Color_Wheel);
    layout.addView(valueSlider, lp);

    selectedColorView = new View(context);
    selectedColorView.setBackgroundColor(selectedColor);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Value_Slider);
    FrameLayout selectedColorborder = new FrameLayout(context);
    selectedColorborder.addView(selectedColorView);
    layout.addView(selectedColorborder, lp);
    selectedColorView.setBackgroundColor(ViewDefine.BORDER_COLOR);

    colorWheel.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            valueSlider.setColor(color, true);
          }
        });
    valueSlider.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            selectedColor = color;
            selectedColorView.setBackgroundColor(color);
          }
        });

    setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), clickListener);
    setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), clickListener);

    int tmp = getViewDP(ViewDefine.Type_Whole_Padding);
    setView(layout, tmp, tmp / 2, tmp, tmp / 2);
    setTitle("Pick a Color(HSV)");
  }
Пример #3
0
  private RelativeLayout getPageView() {
    rlPage = new RelativeLayout(getContext());
    rlPage.setBackgroundDrawable(background);
    if (dialogMode) {
      RelativeLayout rlDialog = new RelativeLayout(getContext());
      rlDialog.setBackgroundColor(0xc0323232);
      int dp_8 = dipToPx(getContext(), 8);
      int width = getScreenWidth(getContext()) - dp_8 * 2;
      RelativeLayout.LayoutParams lpDialog =
          new RelativeLayout.LayoutParams(width, LayoutParams.WRAP_CONTENT);
      lpDialog.topMargin = dp_8;
      lpDialog.bottomMargin = dp_8;
      lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlDialog.setLayoutParams(lpDialog);
      rlPage.addView(rlDialog);

      rlDialog.addView(getPageTitle());
      rlDialog.addView(getPageBody());
      rlDialog.addView(getImagePin());
    } else {
      rlPage.addView(getPageTitle());
      rlPage.addView(getPageBody());
      rlPage.addView(getImagePin());
    }
    return rlPage;
  }
 private void initDeleteIcons() {
   int deleteIconViews[] = {
     R.id.deleteIcon1,
     R.id.deleteIcon2,
     R.id.deleteIcon3,
     R.id.deleteIcon4,
     R.id.deleteIcon5,
     R.id.deleteIcon6,
     R.id.deleteIcon7,
     R.id.deleteIcon8,
     R.id.deleteIcon9,
     R.id.deleteIcon10
   };
   RelativeLayout.LayoutParams deleteIconParams =
       new RelativeLayout.LayoutParams(screenHeight / 20, screenHeight / 20);
   deleteIconParams.alignWithParent = true;
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
   deleteIconParams.bottomMargin = 3;
   deleteIconParams.rightMargin = 3;
   for (int i = 0; i < deleteIconViews.length; i++) {
     ImageView deleteIcon = (ImageView) findViewById(deleteIconViews[i]);
     deleteIcon.setLayoutParams(deleteIconParams);
     deleteIcon.setOnClickListener(deleteIconClickListener);
     deleteIcon.setVisibility(View.GONE);
     deleteIcons.add(deleteIcon);
   }
 }
 private void b(Configuration paramConfiguration)
 {
   int j = 1;
   float f1 = q().getDisplayMetrics().density;
   if (f1 != 1.0D);
   View localView;
   RelativeLayout.LayoutParams localLayoutParams;
   do
   {
     return;
     localView = this.aC.findViewById(2131296921);
     localLayoutParams = (RelativeLayout.LayoutParams)localView.getLayoutParams();
   }
   while (localLayoutParams == null);
   if (paramConfiguration.orientation == j);
   while (true)
   {
     int k = 0;
     if (j != 0)
       k = (int)(0.5F + 20.0F * f1);
     localLayoutParams.bottomMargin = k;
     localView.setLayoutParams(localLayoutParams);
     break;
     j = 0;
   }
 }
 private void a(int paramInt1, int paramInt2, int paramInt3)
 {
   float f1 = q().getDisplayMetrics().density;
   RelativeLayout.LayoutParams localLayoutParams = (RelativeLayout.LayoutParams)this.as.getLayoutParams();
   localLayoutParams.topMargin = (int)(0.5F + f1 * paramInt1);
   localLayoutParams.bottomMargin = (int)(0.5F + f1 * paramInt2);
   localLayoutParams.leftMargin = (int)(0.5F + f1 * paramInt3);
   localLayoutParams.rightMargin = localLayoutParams.leftMargin;
   this.as.setLayoutParams(localLayoutParams);
   this.as.requestLayout();
 }
Пример #7
0
  /**
   * Show this SnackBar. Make sure it already attached to a parent view or this method will do
   * nothing.
   */
  public void show() {
    ViewGroup parent = (ViewGroup) getParent();
    if (parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING) return;

    if (parent instanceof FrameLayout) {
      LayoutParams params = (LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.gravity = Gravity.START | Gravity.BOTTOM;
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    } else if (parent instanceof RelativeLayout) {
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      params.addRule(RelativeLayout.ALIGN_PARENT_START);
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    }

    if (mInAnimationId != 0 && mState != STATE_SHOWN) {
      Animation anim = AnimationUtils.loadAnimation(getContext(), mInAnimationId);
      anim.setAnimationListener(
          new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
              setState(STATE_SHOWING);
              setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              setState(STATE_SHOWN);
              startTimer();
            }
          });
      startAnimation(anim);
    } else {
      setVisibility(View.VISIBLE);
      setState(STATE_SHOWN);
      startTimer();
    }
  }
Пример #8
0
 public static void resetRL(View... view) {
   float rote = Handler_System.getWidthRoate(ApplicationBean.getApplication().getMode_w());
   if (view == null || rote == 1) {
     return;
   }
   for (View view2 : view) {
     RelativeLayout.LayoutParams layoutParams =
         (RelativeLayout.LayoutParams) view2.getLayoutParams();
     layoutParams.leftMargin = (int) (layoutParams.leftMargin * rote);
     layoutParams.rightMargin = (int) (layoutParams.rightMargin * rote);
     layoutParams.topMargin = (int) (layoutParams.topMargin * rote);
     layoutParams.bottomMargin = (int) (layoutParams.bottomMargin * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
  public void setProgressViewHidden(boolean hidden) {
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(mTextView.getLayoutParams());
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(
        RelativeLayout.LEFT_OF, hidden ? mLearningStatisticImageView.getId() : mImageView.getId());
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.leftMargin = (int) (10 * mScale);
    layoutParams.rightMargin = (int) (20 * mScale);
    layoutParams.bottomMargin = (int) (20 * mScale);
    layoutParams.topMargin = (int) (20 * mScale);
    mWrapper.setLayoutParams(layoutParams);

    mProgressBar.setVisibility(hidden ? View.GONE : View.VISIBLE);
  }
Пример #10
0
  private void showPayPalButton() {

    // Generate the PayPal checkout button and save it for later use
    PayPal pp = PayPal.getInstance();
    launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);

    // The OnClick listener for the checkout button
    launchPayPalButton.setOnClickListener(this);

    // Add the listener to the layout
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.bottomMargin = 10;
    launchPayPalButton.setLayoutParams(params);
    launchPayPalButton.setId(PAYPAL_BUTTON_ID);
    ((LinearLayout) findViewById(R.id.about_the_app)).addView(launchPayPalButton);
    ((LinearLayout) findViewById(R.id.about_the_app)).setGravity(Gravity.CENTER_HORIZONTAL);
  }
Пример #11
0
  private void showPayPalButton(View v) {

    // Generate the PayPal checkout button and save it for later use
    PayPal pp = PayPal.getInstance();
    launchPayPalButton =
        pp.getCheckoutButton(this.getContext(), PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);

    // The OnClick listener for the checkout button
    launchPayPalButton.setOnClickListener(this);

    // Add the listener to the layout
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.bottomMargin = 10;
    launchPayPalButton.setLayoutParams(params);
    launchPayPalButton.setId(launchPayPalButton.getId());
    ((RelativeLayout) v.findViewById(R.id.payment_layout)).addView(launchPayPalButton);
    ((RelativeLayout) v.findViewById(R.id.payment_layout)).setGravity(Gravity.CENTER_HORIZONTAL);
  }
Пример #12
0
  @Override
  public boolean onTouch(View view, MotionEvent event) {
    if (detectors != null) detectors.onTouchEvent(event);

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mSurfaceSizes.dx = event.getX();
        mSurfaceSizes.dy = event.getY();
        break;

      case MotionEvent.ACTION_MOVE:
        float x = event.getX();
        float y = event.getY();
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
        float left = lp.leftMargin + (x - mSurfaceSizes.dx);
        float top = lp.topMargin + (y - mSurfaceSizes.dy);
        if (mSurfaceSizes.listnrr != null && mSurfaceSizes.listnrr.zoom) {
          int srcw = lp.width;
          int srch = lp.height;

          int left_offset =
              (int)
                  (mSurfaceSizes.orig_width
                      - (mSurfaceSizes.orig_width * mSurfaceSizes.listnrr.scaleFactor));
          int top_offset =
              (int)
                  (mSurfaceSizes.orig_height
                      - (mSurfaceSizes.orig_height * mSurfaceSizes.listnrr.scaleFactor));
          Log.e("Player", "ACTION_MOVE2 " + left_offset + "," + top_offset);

          lp.leftMargin = left_offset;
          lp.topMargin = top_offset;
          lp.rightMargin = left_offset;
          lp.bottomMargin = top_offset;
        }
        view.setLayoutParams(lp);
        break;
    }
    return true;
  }
Пример #13
0
  @SuppressWarnings("static-access")
  private void init() {

    this.setBackgroundResource(R.drawable.cs_recommend_bg);
    this.setOrientation(LinearLayout.VERTICAL);
    RelativeLayout contentLayout = new RelativeLayout(context);
    LayoutParams layoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    contentLayout.setLayoutParams(layoutParams);
    this.addView(contentLayout);

    TextView titleTextView = new TextView(context);
    titleTextView.setText(R.string.download_manager);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 3);
    titleTextView.setTextColor(Color.WHITE);
    int titleMargin = 20;
    RelativeLayout.LayoutParams titleParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleParams.leftMargin = titleMargin;
    titleParams.rightMargin = titleMargin;
    titleParams.topMargin = titleMargin;
    titleParams.bottomMargin = titleMargin;
    titleTextView.setLayoutParams(titleParams);
    contentLayout.addView(titleTextView);

    LinearLayout managerLayout = new LinearLayout(context);
    managerLayout.setId(MANAGERLAYOUT_ID);
    managerLayout.setOrientation(LinearLayout.VERTICAL);
    int managerPad = 10;
    managerLayout.setPadding(managerPad, managerPad, managerPad, managerPad);
    int height = DisplayManager.getInstance(context).getScreenHeight() - 150;
    int width = DisplayManager.getInstance(context).getScreenWidth() - 200;
    RelativeLayout.LayoutParams managerLayoutParams =
        new RelativeLayout.LayoutParams(width, height);
    managerLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    managerLayout.setLayoutParams(managerLayoutParams);
    managerLayout.setBackgroundResource(R.drawable.bg_downmanger_content);
    // managerLayout.setBackgroundColor(Color.parseColor("#99000000"));
    contentLayout.addView(managerLayout);

    LinearLayout managerPathLayout = new LinearLayout(context);
    managerPathLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams managerPathParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerPathLayout.setLayoutParams(managerPathParams);
    managerPathLayout.setPadding(managerPad, 0, managerPad, managerPad);

    TextView pathText = new TextView(context);
    pathText.setText(R.string.present_path);
    pathText.setGravity(Gravity.CENTER);
    pathText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    pathText.setTextColor(Color.parseColor("#ffffff"));
    pathTextParams.setMargins(0, 0, 0, 0);
    pathTextParams.gravity = Gravity.CENTER;
    pathText.setLayoutParams(pathTextParams);
    managerPathLayout.addView(pathText);

    final CheckDownDialogView checkDialog = new CheckDownDialogView(context);
    String present_edit = "";
    if (checkDialog.DetectionDisk() != null) {
      present_edit = checkDialog.getDownPathname();
    }
    pathEdit = new EditText(context);
    pathEdit.setText(present_edit);
    pathEdit.setFocusable(false);
    pathEdit.setGravity(Gravity.CENTER_VERTICAL);
    pathEdit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathEditParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 12);
    pathEdit.setTextColor(Color.parseColor("#ffffff"));
    pathEdit.setBackgroundResource(R.drawable.present_path);
    pathEditParams.gravity = Gravity.CENTER_VERTICAL;
    pathEdit.setLayoutParams(pathEditParams);
    managerPathLayout.addView(pathEdit);

    Button pathButton = new FocusAbleButton(context);
    pathButton.setText(R.string.present_sele);
    pathButton.setTextColor(Color.parseColor("#ffffff"));
    pathButton.setGravity(Gravity.CENTER);
    pathButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathButtonViewParams =
        new LinearLayout.LayoutParams(0, layoutParams.WRAP_CONTENT, 2);
    pathButtonViewParams.gravity = Gravity.CENTER;
    pathButtonViewParams.setMargins(35, 0, 0, 0);
    pathButton.setLayoutParams(pathButtonViewParams);
    managerPathLayout.addView(pathButton);
    pathButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            //				Map<String, String> labMap = checkDialog.DetectionDisk();
            List<String> pathsStr = DownloadResourceManager.getInstance().getFileDir();
            if (pathsStr != null) {
              checkDialog.choiceUsbDialog();
              checkDialog.setListener(
                  new PathChoiceClickListener() {
                    @Override
                    public void onClick(View v) {
                      // 下载进度保存
                      LinkedHashMap<String, FilmDownLoad4k> downStatus =
                          DownloadResourceManager.getInstance().getDLStatus();
                      if (downStatus != null) {
                        DownloadResourceManager.getInstance().writeDownStatus(downStatus);
                      }
                      DownloadResourceManager.getInstance().clearDLData();
                      String path = (String) v.getTag();
                      DownloadResourceManager.getInstance().initDownPath(path);
                      // Log.e(dlStatus +" "+dlStatus.size());
                      if (context instanceof DownManagerActivity) {
                        ((DownManagerActivity) context).setData(true);
                      }

                      String present_edit = checkDialog.getDownPathname();
                      pathEdit.setText(present_edit);

                      // 初始化新路径后  检测U盘下载 更新UI
                      //							LinkedHashMap<String, FilmDownLoad4k> downStatu =
                      // DownloadResourceManager.getInstance().getDLStatus();
                      //							String path_dir =
                      // DownloadResourceManager.getInstance().getDownLoadPath();
                      //							if(downStatu != null){
                      //								if((path+"/voole_video").equalsIgnoreCase(path_dir)){

                      //									File downPath = new File(path_dir);
                      //									if (TextUtils.isEmpty(DownloadResourceManager.getInstance()
                      //											.getDownLoadPath())
                      //									|| !downPath.getParentFile().exists() || !downPath.exists()){
                      //										if(clickNum == 0){
                      //											managerAct.updateDownItem();
                      //										}
                      //										clickNum ++;
                      //									}
                      if (context instanceof DownManagerActivity) {
                        if (!((DownManagerActivity) context).isAlive) { // 如果下载线程停止
                          ((DownManagerActivity) context).setData(true); // 存放数据
                          ((DownManagerActivity) context).updateDownItem(); // 启动下载线程
                        }
                      }
                    }
                  });

            } else {
              // 没插入U盘
              TVAlertDialog tvDialog = new TVAlertDialog(context);
              tvDialog.showInspectDialog(context);
            }
          }
        });

    LayoutParams parmsPath = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parmsPath.weight = 1;
    parmsPath.topMargin = 20;
    parmsPath.leftMargin = 40;
    parmsPath.rightMargin = 90;
    managerLayout.addView(managerPathLayout, parmsPath);

    LinearLayout managerTitleLayout = new LinearLayout(context);
    managerTitleLayout.setOrientation(LinearLayout.HORIZONTAL);
    managerTitleLayout.setBackgroundResource(R.drawable.bg_down_title);
    LayoutParams managerTitleLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerTitleLayout.setLayoutParams(managerTitleLayoutParams);
    managerTitleLayout.setPadding(managerPad, managerPad - 4, managerPad, managerPad + 4);

    TextView nameText = new TextView(context);
    nameText.setText(R.string.filename);
    nameText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nameTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    nameText.setTextColor(Color.parseColor("#d5ac84"));
    nameText.setGravity(Gravity.CENTER);
    nameText.setLayoutParams(nameTextParams);
    managerTitleLayout.addView(nameText);

    TextView progressText = new TextView(context);
    LayoutParams progressTextParams =
        new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4);
    progressText.setText(R.string.progress);
    progressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    progressText.setTextColor(Color.parseColor("#d5ac84"));
    progressText.setGravity(Gravity.CENTER);
    progressText.setLayoutParams(progressTextParams);
    managerTitleLayout.addView(progressText);

    TextView speedText = new TextView(context);
    speedText.setText(R.string.speed);
    speedText.setTextColor(Color.parseColor("#d5ac84"));
    speedText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams speedTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    speedText.setGravity(Gravity.CENTER);
    speedText.setLayoutParams(speedTextParams);
    managerTitleLayout.addView(speedText);

    TextView sizeText = new TextView(context);
    sizeText.setText(R.string.size);
    sizeText.setTextColor(Color.parseColor("#d5ac84"));
    sizeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams sizeTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
    sizeText.setGravity(Gravity.CENTER);
    sizeText.setLayoutParams(sizeTextParams);
    managerTitleLayout.addView(sizeText);

    TextView handleText = new TextView(context);
    handleText.setText(R.string.operation);
    handleText.setTextColor(Color.parseColor("#d5ac84"));
    handleText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams handleTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    handleText.setGravity(Gravity.CENTER);
    handleText.setLayoutParams(handleTextParams);
    managerTitleLayout.addView(handleText);
    LayoutParams parms = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parms.weight = 1;
    parms.leftMargin = 30;
    parms.rightMargin = 30;
    parms.topMargin = managerPad - 5;
    managerLayout.addView(managerTitleLayout, parms);

    adapterLinearLayout = new FilmLinearLayout(context);
    LayoutParams adapterLinearLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    adapterLinearLayoutParams.weight = 6;
    managerLayout.addView(adapterLinearLayout, adapterLinearLayoutParams);
    adapterLinearLayout.setId(FilmLinearLayout.ADAPTERLINEARLAYOUT_ID);

    int pading = 20;
    LinearLayout pageIndexLayout = new LinearLayout(context);
    pageIndexLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams pageIndexLayoutLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    pageIndexLayout.setLayoutParams(pageIndexLayoutLayoutParams);
    pageIndexLayoutLayoutParams.setMargins(0, pading, 0, 0);
    pageIndexLayout.setGravity(Gravity.CENTER);

    Button preButton = new FocusAbleButton(context);
    preButton.setText(R.string.pre_page);
    preButton.setTextColor(Color.WHITE);
    preButton.setGravity(Gravity.CENTER);
    preButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams preButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    preButton.setLayoutParams(preButtonViewParams);
    pageIndexLayout.addView(preButton);
    preButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showPrePage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    preButton.setPadding(pading, 0, pading, 0);

    Button nextButton = new FocusAbleButton(context);
    nextButton.setText(R.string.next_page);
    nextButton.setTextColor(Color.WHITE);
    nextButton.setGravity(Gravity.CENTER);
    nextButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nextButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    nextButtonViewParams.leftMargin = textSize - 5;
    nextButton.setLayoutParams(nextButtonViewParams);
    pageIndexLayout.addView(nextButton);
    nextButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showNextPage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    nextButton.setPadding(pading, 0, pading, 0);

    pageIndexTextview = new TextView(context);
    pageIndexTextview.setText(
        adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
    pageIndexTextview.setTextColor(Color.WHITE);
    pageIndexTextview.setGravity(Gravity.CENTER);
    pageIndexTextview.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams pageIndexTextviewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pageIndexTextviewParams.leftMargin = textSize - 5;
    pageIndexTextview.setLayoutParams(pageIndexTextviewParams);
    pageIndexLayout.addView(pageIndexTextview);
    LayoutParams pageIndexLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    pageIndexLayoutParams.weight = 1;
    managerLayout.addView(pageIndexLayout, pageIndexLayoutParams);

    TextView warnInfoTextView = new TextView(getContext());
    warnInfoTextView.setText(R.string.down_manager_warn_info);
    warnInfoTextView.setTextColor(Color.WHITE);
    warnInfoTextView.setGravity(Gravity.CENTER);
    warnInfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    android.widget.RelativeLayout.LayoutParams warnInfoLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    warnInfoLayoutParams.addRule(RelativeLayout.BELOW, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.topMargin = textSize - 10;
    contentLayout.addView(warnInfoTextView, warnInfoLayoutParams);
  }
  public DownloadConfirmLayout(
      final Context context,
      String adm,
      String message,
      String appName,
      String okText,
      OnClickListener okListener,
      String cancelText,
      OnClickListener cancelListener)
      throws Exception {
    super(context);

    this.setBackgroundColor(Color.WHITE);

    JSONObject nativeAdAdm = new JSONObject(adm);
    String logoUrl = nativeAdAdm.getString("logo");
    String title = appName;
    String desc = nativeAdAdm.getString("desc");
    double density = context.getResources().getDisplayMetrics().density;
    RelativeLayout titleLayout = new RelativeLayout(context);
    titleLayout.setId(titleLayout.hashCode());

    iconContainer = new RelativeLayout(context);
    iconContainer.setId(iconContainer.hashCode());
    iconContainer.setVisibility(GONE);
    //        iconContainer.setBackgroundColor(Color.parseColor("#CCCCCC"));
    iconImageView = new ImageView(context);
    iconImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams rllp = new LayoutParams(getPx(178, density), getPx(178, density));
    rllp.addRule(CENTER_IN_PARENT);
    rllp.topMargin = getPx(1, density);
    rllp.leftMargin = getPx(1, density);
    iconContainer.addView(iconImageView, rllp);

    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.addRule(ALIGN_PARENT_TOP);
    titleLayout.addView(iconContainer, rllp);

    RelativeLayout titleDescLayout = new RelativeLayout(context);
    titleDescLayout.setId(titleDescLayout.hashCode());

    TextView titleTextView = new TextView(context);
    titleTextView.setId(titleTextView.hashCode());
    titleTextView.setEllipsize(TextUtils.TruncateAt.END);
    titleTextView.setSingleLine();
    titleTextView.setText(title);
    titleTextView.setTextSize(20);
    titleTextView.setTypeface(Typeface.DEFAULT_BOLD);
    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    titleDescLayout.addView(titleTextView, rllp);

    TextView descTextView = new TextView(context);
    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.addRule(BELOW, titleTextView.getId());
    rllp.topMargin = getPx(24, density);
    descTextView.setText(desc);
    descTextView.setTextSize(13);
    descTextView.setEllipsize(TextUtils.TruncateAt.END);
    descTextView.setSingleLine();
    titleDescLayout.addView(descTextView, rllp);

    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.leftMargin = getPx(44, density);
    rllp.addRule(RIGHT_OF, iconContainer.getId());
    titleLayout.addView(titleDescLayout, rllp);

    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.leftMargin = getPx(56, density);
    rllp.topMargin = getPx(56, density);
    rllp.addRule(ALIGN_PARENT_TOP);
    addView(titleLayout, rllp);

    View ToplineView = new View(context);
    ToplineView.setId(ToplineView.hashCode());
    ToplineView.setBackgroundColor(Color.parseColor("#1C1C1C"));
    rllp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getPx(3, density));
    rllp.addRule(BELOW, titleLayout.getId());
    rllp.topMargin = getPx(21, density);
    addView(ToplineView, rllp);

    TextView messageTextView = new TextView(context);
    messageTextView.setText(message);
    messageTextView.setTextSize((float) 49.0 / 3);
    messageTextView.setId(messageTextView.hashCode());
    rllp =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.addRule(CENTER_HORIZONTAL);
    rllp.addRule(BELOW, ToplineView.getId());
    rllp.topMargin = getPx(39, density);
    rllp.bottomMargin = rllp.topMargin;
    rllp.leftMargin = getPx(56, density);
    addView(messageTextView, rllp);

    View ButtomlineView = new View(context);
    ButtomlineView.setId(ButtomlineView.hashCode());
    ButtomlineView.setBackgroundColor(Color.parseColor("#929292"));
    rllp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getPx(2, density));
    rllp.addRule(BELOW, messageTextView.getId());
    addView(ButtomlineView, rllp);

    LinearLayout buttonLayout = new LinearLayout(context);
    buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
    Button okBtn = new Button(context);
    okBtn.setId(okBtn.hashCode());
    okBtn.setText(okText);
    okBtn.setOnClickListener(okListener);
    LinearLayout.LayoutParams lllp =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lllp.weight = 0.5f;
    buttonLayout.addView(okBtn, lllp);

    View MiddlelineView = new View(context);
    MiddlelineView.setId(ButtomlineView.hashCode());
    MiddlelineView.setBackgroundColor(Color.parseColor("#929292"));
    rllp = new LayoutParams(getPx(2, density), ViewGroup.LayoutParams.MATCH_PARENT);
    rllp.addRule(RIGHT_OF, okBtn.getId());
    buttonLayout.addView(MiddlelineView, rllp);

    Button cancelBtn = new Button(context);
    cancelBtn.setOnClickListener(cancelListener);
    cancelBtn.setText(cancelText);
    buttonLayout.addView(cancelBtn, lllp);
    rllp =
        new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rllp.addRule(BELOW, messageTextView.getId());
    addView(buttonLayout, rllp);

    okBtn.setBackgroundColor(Color.argb(0, 0, 0, 0));
    cancelBtn.setBackgroundColor(Color.argb(0, 0, 0, 0));

    okBtn.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            Button btn = (Button) v;
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn.setBackgroundColor(Color.argb(130, 0, 0, 0));
            }
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn.setBackgroundColor(Color.argb(0, 0, 0, 0));
            }
            if (event.getAction() == MotionEvent.ACTION_CANCEL) {
              btn.setBackgroundColor(Color.argb(0, 0, 0, 0));
            }

            return false;
          }
        });

    cancelBtn.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            Button btn = (Button) v;
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn.setBackgroundColor(Color.argb(130, 0, 0, 0));
            }
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn.setBackgroundColor(Color.argb(0, 0, 0, 0));
            }
            if (event.getAction() == MotionEvent.ACTION_CANCEL) {
              btn.setBackgroundColor(Color.argb(0, 0, 0, 0));
            }

            return false;
          }
        });

    HttpRequester.getAsynData(
        context,
        logoUrl,
        true,
        new HttpRequester.Listener() {
          @Override
          public void onGetDataSucceed(byte[] data) {
            Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
            iconImageView.setImageBitmap(bitmap);
            iconContainer.setVisibility(VISIBLE);
          }

          @Override
          public void onGetDataFailed(String error) {
            MVLog.e(MvErrorCode.COMMON_ERROR, error);
          }
        });
  }
Пример #15
0
  /**
   * Update the "permanent" position (ie. the actual layout params) of the sliding card based on the
   * current call state.
   *
   * <p>This method sets mCardAtTop, mCallEndedState, mCardPreferredX, and mCardPreferredY. It also
   * repositions the PopupWindow if it's showing.
   *
   * <p>Note that *while sliding* we manually reposition the card on every motion event that comes
   * in. The x/y position we set here determines where the card should be while *not* sliding.
   *
   * <p>TODO: If the card position changes for some reason *other* than user action (i.e. as a
   * result of an onPhoneStateChanged() callback), we should smoothly animate the position change!
   * (For example, if you're in a call and the other end hangs up, the card should switch to "Call
   * ended" mode and smoothly animate to the bottom position.)
   */
  public /* package */ void updateCardPreferredPosition() {
    if (DBG) log("updateCardPreferredPosition()...");
    // if (DBG) log("- card's LayoutParams: " + mCallCard.getLayoutParams());

    // Bail out if our View hierarchy isn't attached to a Window yet
    // (since the mMainFrame.getLocationOnScreen() call below
    // will fail.)
    if (mMainFrame.getWindowToken() == null) {
      if (DBG) log("updateCardPreferredPosition: View hierarchy unattached; bailing...");
      return;
    }

    /*
    if (mMainFrame.getHeight() == 0) {
        // The code here needs to know the sizes and positions of some
        // views in the mMainFrame view hierarchy, so you're only
        // allowed to call this method *after* the whole in-call UI
        // has been measured and laid out.
        // (This is why we defer calling showPopup() until an
        // onGlobalLayout() call comes in.)
        throw new IllegalStateException(
                "updateCardPreferredPosition: main frame not measured yet");
    }
    */

    // Given the current state of the Phone and the UI, decide whether
    // the card should be at the TOP or BOTTOM of the screen right now.

    // Compute the possible coordinates onscreen for the popup.
    // TODO: this block is duplicated below; use a single helper method instead.
    mMainFrame.getLocationInWindow(mTempLocation);
    final int mainFrameX = mTempLocation[0];
    final int mainFrameY = 0; // mTempLocation[1];
    if (DBG) log("- mMainFrame loc in window: " + mainFrameX + ", " + mainFrameY);

    // In the "top" position the CallCard is aligned exactly with the
    // top edge of the main frame.
    final int popupTopPosY = mainFrameY;

    // And in the "bottom" position, the bottom of the CallCard is
    // aligned exactly with the bottom of the main frame.
    if (height == 0) {
      height = mCallCard.getHeight();
      // Reposition the "slide hints".
      RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mSlideUp.getLayoutParams();
      // Equivalent to setting android:layout_marginTop in XML
      lp.bottomMargin = height;
      mSlideUp.setLayoutParams(lp);
      lp = (RelativeLayout.LayoutParams) mSlideDown.getLayoutParams();
      // Equivalent to setting android:layout_marginTop in XML
      lp.topMargin = height;
      mSlideDown.setLayoutParams(lp);
      height += 10;
    }
    final int popupBottomPosY = mainFrameY + mMainFrame.getHeight() - height;

    if (Receiver.ccCall != null && Receiver.ccCall.getState() != Call.State.DISCONNECTED) {
      // When the phone is in use, the position of the card is
      // determined solely by whether an incoming call is ringing or
      // not.
      final boolean hasRingingCall = Receiver.ccCall.getState() == Call.State.INCOMING;
      mCardAtTop = !hasRingingCall;
      mCallEndedState = false;
    } else {
      // Phone is completely idle!  Display the CALL ENDED state
      // with the card at the bottom of the screen.
      mCardAtTop = false;
      mCallEndedState = true;
    }
    mCardPreferredX = mainFrameX;
    mCardPreferredY = mCardAtTop ? popupTopPosY : popupBottomPosY;

    if (DBG)
      log(
          "==> Setting card preferred position (mCardAtTop = "
              + mCardAtTop
              + ") to: "
              + mCardPreferredX
              + ", "
              + mCardPreferredY);

    // This is a no-op if the PopupWindow isn't showing.
    mCallCard.update(mCardPreferredX, mCardPreferredY, -1, -1);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    windowwidth = getWindowManager().getDefaultDisplay().getWidth();
    windowheight = getWindowManager().getDefaultDisplay().getHeight();
    // mainLayout = new LinearLayout(this);
    mainLayout = new RelativeLayout(this);
    mainLayout.setBackgroundColor(Color.rgb(61, 0, 61));
    // mainLayout.setOrientation(LinearLayout.VERTICAL);
    image = new ImageView(this);

    messageView = new TextView(this);
    messageView.setTextColor(Color.WHITE);
    messageView.setTextSize(30f);

    button = new Button(this);
    button.setTextSize(20f);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(windowwidth / 2, windowheight / 4);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.topMargin = (windowheight / 10);
    RelativeLayout.LayoutParams params2 =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    params2.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params2.addRule(RelativeLayout.CENTER_IN_PARENT);
    RelativeLayout.LayoutParams params3 =
        new RelativeLayout.LayoutParams(windowwidth / 2, windowheight / 8);
    params3.bottomMargin = (windowheight / 5);
    params3.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    image.setLayoutParams(params);
    messageView.setLayoutParams(params2);
    button.setLayoutParams(params3);
    button.setBackgroundColor(Color.WHITE);
    button.setTextColor(Color.BLACK);
    /*subLayout = new LinearLayout(this);
    subLayout.setOrientation(LinearLayout.HORIZONTAL);
    subLayout.setLayoutParams(new LinearLayout.LayoutParams(
    		LayoutParams.MATCH_PARENT, 0, (float) 0.2));*/

    // messageView.setLayoutParams(new
    // LinearLayout.LayoutParams(0,LayoutParams.MATCH_PARENT, (float) 0.7));

    /*button.setLayoutParams(new LinearLayout.LayoutParams(0,LayoutParams.MATCH_PARENT, (float) 0.3));


    subLayout.addView(messageView);
    subLayout.addView(button);

    scrollView = new ScrollView(this);
    scrollView.setLayoutParams(new LinearLayout.LayoutParams(
    		LayoutParams.MATCH_PARENT, 0, (float) 0.5));*/

    updateScreen();
    setBtnListeners(this);
    mainLayout.addView(image);

    mainLayout.addView(messageView);
    mainLayout.addView(button);
    setContentView(mainLayout);
  }
Пример #17
0
  private void makeNumPad(Context context) {
    textView = new TextView(context);
    textView.setBackgroundColor(0x00000000);
    TableLayout tableLayout = new TableLayout(context);

    tableLayout.setId(41);
    int numRows = 5;
    int numCols = 3;

    htKeys = new Hashtable<Button, String>();
    int[] bgRscs =
        new int[] {
          R.drawable.key1,
          R.drawable.key2,
          R.drawable.key3,
          R.drawable.key4,
          R.drawable.key5,
          R.drawable.key6,
          R.drawable.key7,
          R.drawable.key8,
          R.drawable.key9,
          R.drawable.key_star,
          R.drawable.key0,
          R.drawable.key_sharp,
          R.drawable.key_speed_dial,
          R.drawable.key_call,
          R.drawable.key_delete
        };

    String[] keyChars = new String[] {"1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#"};

    int cntKey = 0;
    int w = APPWIDTH / numCols;
    int h = w * 2 / 3;
    for (int i = 0; i < numRows; i++) {
      TableRow tr = new TableRow(context);
      for (int j = 0; j < numCols; j++) {
        TableRow.LayoutParams params = new TableRow.LayoutParams(j);
        Button btn = new Button(context);
        btn.setBackgroundResource(bgRscs[cntKey]);
        btn.setLayoutParams(params);
        btn.setAlpha(0.60f);

        if (i < numRows - 1) {
          if (i == 0 && j == 0) {
            btnVoiceMail = btn;
            btn.setOnLongClickListener(
                new View.OnLongClickListener() {

                  @Override
                  public boolean onLongClick(View arg0) {
                    if (isCalling) {
                      return false;
                    }

                    posture = xacPostureSenseFeatureMaker.calculatePosture();
                    if (posture != xacPostureSenseFeatureMaker.NONE) {
                      return false;
                    }

                    //								Log.d(LOGTAG, "voice mail!");
                    LauncherManager.vibrate(500);
                    CallManager.playNextVoiceMail();
                    wasLongClick = true;
                    return false;
                  }
                });
          }

          htKeys.put(btn, keyChars[cntKey]);
          btn.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  if (isCalling) {
                    return;
                  }

                  posture = xacPostureSenseFeatureMaker.calculatePosture();
                  if (posture != xacPostureSenseFeatureMaker.NONE) {
                    return;
                  }

                  Button btn = (Button) view;
                  if (btn == btnVoiceMail && wasLongClick) {
                    wasLongClick = false;
                    return;
                  }
                  strKeys += htKeys.get(btn);
                  textView.setText(
                      new StringBuffer(
                              new StringBuffer(strKeys)
                                  .reverse()
                                  .toString()
                                  .substring(0, Math.min(strKeys.length(), 10)))
                          .reverse()
                          .toString());
                }
              });
        } else {
          if (i == 4 && j == 1) {
            // phone call

            btn.setOnClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    if (isCalling) {
                      return;
                    }
                    //								layoutCallScreen.setBackgroundResource(R.drawable.call_out);
                    RelativeLayout.LayoutParams paramsCallScreen =
                        new RelativeLayout.LayoutParams(
                            RelativeLayout.LayoutParams.MATCH_PARENT,
                            RelativeLayout.LayoutParams.MATCH_PARENT);
                    //								paramsCallScreen.addRule(RelativeLayout.ABOVE, layoutViews.getId());
                    appLayout.addView(layoutCallScreen, paramsCallScreen);
                    isCalling = true;
                  }
                });

          } else if (i == 4 && j == 2) {
            // delete

            btn.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    if (isCalling) {
                      return;
                    }

                    posture = xacPostureSenseFeatureMaker.calculatePosture();
                    if (posture != xacPostureSenseFeatureMaker.NONE) {
                      return;
                    }

                    if (strKeys.length() > 0) {
                      strKeys = strKeys.substring(0, strKeys.length() - 1);
                      textView.setText(
                          new StringBuffer(
                                  new StringBuffer(strKeys)
                                      .reverse()
                                      .toString()
                                      .substring(0, Math.min(strKeys.length(), 10)))
                              .reverse()
                              .toString());
                    }
                  }
                });
          }
        }

        tr.addView(btn, w, h);

        cntKey++;
      }
      tableLayout.addView(
          tr,
          new TableLayout.LayoutParams(
              TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
    }

    RelativeLayout.LayoutParams paramsKeys =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    paramsKeys.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    layoutCall.addView(tableLayout, paramsKeys);

    //		textView.setBackgroundColor(0xFF000000);
    textView.setText("");
    textView.setTextColor(0xFFFFFFFF);
    textView.setTextSize(60);
    textView.setTypeface(LauncherManager.getTypeface(LauncherManager.NORMAL));
    RelativeLayout.LayoutParams paramsText =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, layoutCall.getMeasuredHeight() - h * numRows);
    paramsText.addRule(RelativeLayout.ABOVE, tableLayout.getId());
    paramsText.bottomMargin = 100;
    layoutCall.addView(textView, paramsText);
  }
Пример #18
0
  public boolean onTouch(View view, MotionEvent event) {
    float scale;
    final int X = (int) event.getRawX();
    final int Y = (int) event.getRawY();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        view.setBackgroundResource(R.drawable.border);
        garbage.setVisibility(View.VISIBLE);
        RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
        _xDelta = X - lParams.leftMargin;
        _yDelta = Y - lParams.topMargin;

        start.set(event.getX(), event.getY());
        mode = DRAG;
        break;
      case MotionEvent.ACTION_UP:
        Iterator<View> iterator;
        mode = NONE;
        garbage.setVisibility(View.INVISIBLE);
        view.setBackgroundResource(R.color.none);
        if (event.getRawY() > 1530) {
          if (position_status == FRONT) {
            iterator = ViewList.iterator();
          } else {
            iterator = ViewListBack.iterator();
          }
          view.setVisibility(View.GONE);

          while (iterator.hasNext()) {
            View i = iterator.next();
            if (i == view) {
              iterator.remove();
            }
          }
        }
        break;
      case MotionEvent.ACTION_POINTER_DOWN:
        oldDist = spacing(event);
        if (oldDist > 8f) {
          RelativeLayout.LayoutParams zParams =
              (RelativeLayout.LayoutParams) view.getLayoutParams();
          midPoint(mid, event);
          _xDelta = (int) mid.x - zParams.leftMargin;
          _yDelta = (int) mid.y - zParams.topMargin;
          mode = ZOOM;
        }
        break;
      case MotionEvent.ACTION_POINTER_UP:
        mode = NONE;
        break;
      case MotionEvent.ACTION_MOVE:
        RelativeLayout.LayoutParams layoutParams =
            (RelativeLayout.LayoutParams) view.getLayoutParams();
        if (mode == DRAG) {
          layoutParams.leftMargin = X - _xDelta;
          layoutParams.topMargin = Y - _yDelta;
          layoutParams.rightMargin = -250;
          layoutParams.bottomMargin = -250;
          view.setLayoutParams(layoutParams);
          rectView = new Rect();
          view.getDrawingRect(rectView);
          if (event.getRawY() > 1530) {
            view.setBackgroundResource(R.color.deletecolor);
          } else view.setBackgroundResource(R.drawable.border);

        } else if (mode == ZOOM) {
          // pinch zooming
          float newDist = spacing(event);
          if (newDist > 8f) {
            // setting the scaling of the
            scale = newDist / oldDist;

            if (view instanceof ImageView) {
              int imgSizeH = view.getHeight();
              int imgSizeW = view.getWidth();
              imgSizeH = (int) (imgSizeH * scale);
              imgSizeW = (int) (imgSizeW * scale);
              layoutParams.width = imgSizeW;
              layoutParams.height = imgSizeH;
              layoutParams.leftMargin = (int) mid.x - _xDelta;
              layoutParams.topMargin = (int) mid.y - _yDelta;
              layoutParams.rightMargin = -250;
              layoutParams.bottomMargin = -250;
              view.setLayoutParams(layoutParams);

            } else if (view instanceof TextView) {
              // textSize = ((TextView) view).getTextSize();
              textSize = textSize * scale;
              ((TextView) view).setTextSize(textSize);
            }
            oldDist = newDist;
          }
        }
        break;
    }
    mRrootLayout.invalidate();
    return true;
  }
Пример #19
0
  private void initRight(Context context) {
    RelativeLayout layout_right = new RelativeLayout(context);
    LinearLayout.LayoutParams param_layout_right =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    int margin = 35;
    param_layout_right.setMargins(margin, margin, margin, margin);
    layout_right.setLayoutParams(param_layout_right);

    text_filmName = new AlwaysMarqueeTextView(context);
    text_filmName.setId(text_filmName_id);
    text_filmName.setMarquee(true);
    text_filmName.setTextColor(Color.WHITE);
    text_filmName.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 8);
    RelativeLayout.LayoutParams param_text_filmName =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_text_filmName.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_text_filmName.bottomMargin = 5;
    text_filmName.setLayoutParams(param_text_filmName);
    layout_right.addView(text_filmName);

    text_year_mins_area_type = new TextView(context);
    text_year_mins_area_type.setId(text_year_mins_area_type_id);
    text_year_mins_area_type.setTextColor(Color.WHITE);
    text_year_mins_area_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_text_year_mins_area_type =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_year_mins_area_type.addRule(RelativeLayout.BELOW, text_filmName_id);
    param_text_year_mins_area_type.bottomMargin = 5;
    text_year_mins_area_type.setLayoutParams(param_text_year_mins_area_type);
    layout_right.addView(text_year_mins_area_type);

    TextView text_movie_class = new TextView(context); // 电影分类
    text_movie_class.setId(text_movie_class_id);

    barginPrice = new TextView(context);
    barginPrice.append("¥0");
    barginPrice.setTextColor(Color.parseColor("#00c1ea"));
    barginPrice.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 5);
    RelativeLayout.LayoutParams barginPriceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_BOTTOM, text_year_mins_area_type_id);
    barginPrice.setLayoutParams(barginPriceParams);
    barginPrice.setId(price_id);
    layout_right.addView(barginPrice);

    TextView barginPriceTextView = new TextView(context);
    barginPriceTextView.setText(" 促销价: ");
    barginPriceTextView.setTextColor(Color.GRAY);
    barginPriceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_price =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_price.addRule(RelativeLayout.LEFT_OF, price_id);
    param_price.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    barginPriceTextView.setLayoutParams(param_price);
    barginPriceTextView.setId(price_tv_id);
    layout_right.addView(barginPriceTextView);

    price = new TextView(context);
    price.setText("¥0 ");
    price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    price.setId(10012);
    price.setTextColor(Color.GRAY);
    price.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    price.setId(bargin_id);
    RelativeLayout.LayoutParams priceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    priceParams.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    priceParams.addRule(RelativeLayout.LEFT_OF, price_tv_id);
    price.setLayoutParams(priceParams);
    layout_right.addView(price);

    TextView priceTextView = new TextView(context);
    priceTextView.setText("原价:");
    priceTextView.setId(10012);
    priceTextView.setTextColor(Color.GRAY);
    priceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_barginPrice =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //		param_barginPrice.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    param_barginPrice.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    param_barginPrice.addRule(RelativeLayout.LEFT_OF, bargin_id);
    priceTextView.setLayoutParams(param_barginPrice);
    layout_right.addView(priceTextView);

    text_introduce = new TextView(context);
    text_introduce.setTextColor(Color.WHITE);
    text_introduce.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_introduce.setEllipsize(TruncateAt.END);
    text_introduce.setId(text_introduce_id);
    text_introduce.setMaxLines(3);
    text_introduce.setLineSpacing(3f, 1f);
    RelativeLayout.LayoutParams param_text_introduce =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_introduce.addRule(RelativeLayout.BELOW, text_year_mins_area_type_id);
    text_introduce.setLayoutParams(param_text_introduce);
    layout_right.addView(text_introduce);

    text_director = new AlwaysMarqueeTextView(context);
    text_director.setId(text_director_id);
    text_director.setTextColor(Color.WHITE);
    text_director.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_director =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_director.addRule(RelativeLayout.BELOW, text_introduce_id);
    param_text_director.topMargin = 4;
    text_director.setLayoutParams(param_text_director);
    layout_right.addView(text_director);

    text_actor = new AlwaysMarqueeTextView(context);
    text_actor.setId(text_actor_id);
    text_actor.setTextColor(Color.WHITE);
    text_actor.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_actor =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_actor.addRule(RelativeLayout.BELOW, text_director_id);
    param_text_actor.topMargin = 4;
    text_actor.setLayoutParams(param_text_actor);
    layout_right.addView(text_actor);

    text_dl_info = new TextView(context);
    text_dl_info.setText(R.string.watch_worning_for4k);
    text_dl_info.setTextColor(Color.parseColor("#FFC125"));
    text_dl_info.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 2);
    RelativeLayout.LayoutParams param_text_dl_info =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_dl_info.addRule(RelativeLayout.BELOW, text_actor_id);
    param_text_dl_info.topMargin = textSize - 10;
    text_dl_info.setLayoutParams(param_text_dl_info);
    layout_right.addView(text_dl_info);
    if (F4kDownResourceUtils.getDownLoadFlag() == null
        || !F4kDownResourceUtils.getDownLoadFlag().equals("1")) {
      text_dl_info.setVisibility(View.INVISIBLE);
    }

    layout_btn = new RelativeLayout(context);
    layout_btn.setId(layout_btn_id);
    RelativeLayout.LayoutParams param_layout_btn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_layout_btn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    //		param_layout_btn.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_layout_btn.bottomMargin = 10;
    layout_btn.setLayoutParams(param_layout_btn);

    leftBtn = new FocusAbleButton(context);
    leftBtn.setTextSize(textSize);
    leftBtn.setTextColor(Color.WHITE);
    leftBtn.setGravity(Gravity.CENTER);
    leftBtn.setTextSize(textSize);
    leftBtn.setId(detail_left_btn_id);

    leftBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              listener.onPlay(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_leftBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_leftBtn.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    param_leftBtn.rightMargin = 45;
    leftBtn.setLayoutParams(param_leftBtn);
    layout_btn.addView(leftBtn);

    leftBtn_playlow = new FocusAbleButton(context);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setTextColor(Color.WHITE);
    leftBtn_playlow.setGravity(Gravity.CENTER);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setId(ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);

    leftBtn_playlow.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              if (info instanceof F4kFilmAndPageInfo) {
                F4kFilmAndPageInfo info4k = (F4kFilmAndPageInfo) info;
                if (info4k.getFilmListLowRate().size() > index) {
                  listener.onPlay(((F4kFilmAndPageInfo) info).getFilmListLowRate().get(index));
                } else {
                  Log.d("can not play l080p case no fid for it");
                }
              }
            }
          }
        });
    RelativeLayout.LayoutParams leftBtn_playlowBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    leftBtn_playlowBtn.addRule(RelativeLayout.RIGHT_OF, detail_left_btn_id);
    leftBtn_playlowBtn.rightMargin = 45;
    leftBtn_playlow.setLayoutParams(leftBtn_playlowBtn);
    layout_btn.addView(leftBtn_playlow);

    middleBtn = new FocusAbleButton(context);
    middleBtn.setTextColor(Color.WHITE);
    middleBtn.setGravity(Gravity.CENTER);
    middleBtn.setTextSize(textSize);
    middleBtn.setId(middleBtn_id);
    middleBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onDwonload(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_middleBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_middleBtn.addRule(RelativeLayout.RIGHT_OF, ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);
    middleBtn.setLayoutParams(param_middleBtn);
    layout_btn.addView(middleBtn);

    rightBtn = new FocusAbleButton(context);
    rightBtn.setTextColor(Color.WHITE);
    rightBtn.setGravity(Gravity.CENTER);
    rightBtn.setTextSize(textSize);
    rightBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onCancel(film);
            }
          }
        });
    rightBtn.setId(rightBtn_id);
    RelativeLayout.LayoutParams param_rightBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_rightBtn.leftMargin = 45;
    param_rightBtn.addRule(RelativeLayout.RIGHT_OF, middleBtn_id);
    rightBtn.setLayoutParams(param_rightBtn);
    layout_btn.addView(rightBtn);
    layout_right.addView(layout_btn);

    RelativeLayout layout_love = new RelativeLayout(context);
    layout_love.setId(layout_love_id);
    RelativeLayout.LayoutParams param_layout_lov =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_layout_lov.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    layout_love.setLayoutParams(param_layout_lov);
    layout_right.addView(layout_love);

    addView(layout_right);
    leftBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    leftBtn_playlow.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    middleBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    rightBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
  }
Пример #20
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (camera == null) {
      return inflater.inflate(R.layout.fragment_no_camera, container, false);
    }
    View view = inflater.inflate(layoutId, container, false);

    try {
      previewContainer = (ViewGroup) view.findViewById(R.id.camera_preview);
    } catch (NullPointerException e) {
      throw new RuntimeException(
          "You should add container that extends ViewGroup for CameraPreview.");
    }
    ImageView canvasFrame = new ImageView(activity);
    cameraPreview = new CameraPreview(activity, camera, canvasFrame, this, this);
    previewContainer.addView(cameraPreview);
    previewContainer.addView(canvasFrame);
    cameraPreview.setFocusMode(focusMode);

    progressBar = (ProgressBar) view.findViewById(R.id.progress);

    mCapture = view.findViewById(R.id.capture);
    if (mCapture != null) {
      mCapture.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              takePhoto();
            }
          });
    }

    flashModeButton = (ImageButton) view.findViewById(R.id.flash_mode);
    if (flashModeButton != null) {
      if (supportedFlash) {
        flashModeButton.setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                switchFlashMode();
                onFlashModeChanged(flashMode.getId());
              }
            });
        setFlashModeImage(flashMode);
      } else {
        flashModeButton.setVisibility(Button.GONE);
      }
    }

    setPreviewContainerSize(mScreenWidth, mScreenHeight, ratio);

    mZoomRatioTextView = (TextView) view.findViewById(R.id.zoom_ratio);
    if (mZoomRatioTextView != null) {
      setZoomRatioText(zoomIndex);
    }

    View cameraSettings = view.findViewById(R.id.camera_settings);
    if (cameraSettings != null) {
      view.findViewById(R.id.camera_settings)
          .setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  com.yalantis.cameramodule.fragment.CameraSettingsDialogFragment.newInstance(
                          packSettings(), CameraFragment.this)
                      .show(getFragmentManager());
                }
              });
    }

    View controls = view.findViewById(R.id.controls_layout);
    if (controls != null) {
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
      params.topMargin = mStatusBarHeight;
      params.bottomMargin = mNavigationBarHeight;
      controls.setLayoutParams(params);
    }

    return view;
  }
Пример #21
0
  /**
   * Initializing the QuickScroll, this function must be called.
   *
   * <p>
   *
   * @param type the QuickScroll type. Available inputs: <b>QuickScroll.TYPE_POPUP</b> or
   *     <b>QuickScroll.TYPE_INDICATOR</b>
   * @param list the ListView
   * @param scrollable the adapter, must implement Scrollable interface
   */
  public void init(
      final int type, final ListView list, final Scrollable scrollable, final int style) {
    if (mInitialized) return;

    mType = type;
    mList = list;
    mScrollable = scrollable;
    mGroupPosition = -1;
    mFadeIn = new AlphaAnimation(.0f, 1.0f);
    mFadeIn.setFillAfter(true);
    mFadeOut = new AlphaAnimation(1.0f, .0f);
    mFadeOut.setFillAfter(true);
    mFadeOut.setAnimationListener(
        new AnimationListener() {

          public void onAnimationStart(Animation animation) {}

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationEnd(Animation animation) {
            mScrolling = false;
          }
        });
    mScrolling = false;

    final float density = getResources().getDisplayMetrics().density;

    mList.setOnTouchListener(
        new OnTouchListener() {

          public boolean onTouch(View v, MotionEvent event) {
            if (mScrolling
                && (event.getAction() == MotionEvent.ACTION_MOVE
                    || event.getAction() == MotionEvent.ACTION_DOWN)) {
              return true;
            }
            return false;
          }
        });

    final RelativeLayout.LayoutParams containerparams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final RelativeLayout container = new RelativeLayout(getContext());
    container.setBackgroundColor(Color.TRANSPARENT);
    containerparams.addRule(RelativeLayout.ALIGN_TOP, getId());
    containerparams.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
    container.setLayoutParams(containerparams);

    if (mType == TYPE_POPUP || mType == TYPE_POPUP_WITH_HANDLE) {

      mScrollIndicatorText = new TextView(getContext());
      mScrollIndicatorText.setTextColor(Color.WHITE);
      mScrollIndicatorText.setVisibility(View.INVISIBLE);
      mScrollIndicatorText.setGravity(Gravity.CENTER);
      final RelativeLayout.LayoutParams popupparams =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

      popupparams.addRule(RelativeLayout.CENTER_IN_PARENT);
      mScrollIndicatorText.setLayoutParams(popupparams);

      setPopupColor(GREY_LIGHT, GREY_DARK, 1, Color.WHITE, 1);
      setTextPadding(mTextPadding, mTextPadding, mTextPadding, mTextPadding);

      container.addView(mScrollIndicatorText);
    } else if (mType == TYPE_INDICATOR || mType == TYPE_INDICATOR_WITH_HANDLE) {
      mScrollIndicator = createPin();
      mScrollIndicatorText = (TextView) mScrollIndicator.findViewById(ID_PIN_TEXT);

      (mScrollIndicator.findViewById(ID_PIN)).getLayoutParams().width = 25;

      container.addView(mScrollIndicator);
    }

    // setting scrollbar width
    getLayoutParams().width = (int) (30 * density);
    mScrollIndicatorText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 32);

    // scrollbar setup
    if (style != STYLE_NONE) {
      final RelativeLayout layout = new RelativeLayout(getContext());
      final RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      params.addRule(RelativeLayout.ALIGN_LEFT, getId());
      params.addRule(RelativeLayout.ALIGN_TOP, getId());
      params.addRule(RelativeLayout.ALIGN_RIGHT, getId());
      params.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
      layout.setLayoutParams(params);

      mScrollbar = new View(getContext());
      mScrollbar.setBackgroundColor(GREY_SCROLLBAR);
      final RelativeLayout.LayoutParams scrollbarparams =
          new RelativeLayout.LayoutParams(1, LayoutParams.MATCH_PARENT);
      scrollbarparams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      scrollbarparams.topMargin = mScrollbarMargin;
      scrollbarparams.bottomMargin = mScrollbarMargin;
      mScrollbar.setLayoutParams(scrollbarparams);
      layout.addView(mScrollbar);
      ((ViewGroup) mList.getParent()).addView(layout);
      // creating the handlebar
      if (mType == TYPE_INDICATOR_WITH_HANDLE || mType == TYPE_POPUP_WITH_HANDLE) {
        mHandlebar = new View(getContext());
        setHandlebarColor(BLUE_LIGHT, BLUE_LIGHT, BLUE_LIGHT_SEMITRANSPARENT);
        final RelativeLayout.LayoutParams handleparams =
            new RelativeLayout.LayoutParams((int) (12 * density), (int) (36 * density));
        mHandlebar.setLayoutParams(handleparams);
        ((RelativeLayout.LayoutParams) mHandlebar.getLayoutParams())
            .addRule(RelativeLayout.CENTER_HORIZONTAL);
        layout.addView(mHandlebar);

        mList.setOnScrollListener(
            new OnScrollListener() {

              public void onScrollStateChanged(AbsListView view, int scrollState) {}

              @SuppressLint("NewApi")
              public void onScroll(
                  AbsListView view,
                  int firstVisibleItem,
                  int visibleItemCount,
                  int totalItemCount) {
                if (!mScrolling && totalItemCount - visibleItemCount > 0) {
                  moveHandlebar(
                      getHeight() * firstVisibleItem / (totalItemCount - visibleItemCount));
                }
              }
            });
      }
    }

    mInitialized = true;

    ((ViewGroup) mList.getParent()).addView(container);
  }