private void loadVideo() {
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    mVideoView = (VideoView) findViewById(R.id.imageViewCenter);
    mVideoView.setMediaController(new MediaController(this));
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.water_drop);
    mVideoView.setVideoURI(video);
    mVideoView.start();

    if (isLEFT) {

      lp.setMargins(1200, 0, -1000, 0);
      mThumbnailTopLayout.setVisibility(View.GONE);
      mThumnailBottomLayout.setVisibility(View.GONE);

    } else {
      lp.setMargins(-640, 0, 640, 0);
    }
    mVideoView.setLayoutParams(lp);

    mVideoView.setClickable(true);
    mVideoView.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // System.out.println(mVideoView);
            // mVideoView.stopPlayback();
            lp.setMargins(0, 0, 0, 0);
            mVideoView.setLayoutParams(lp);
            return true;
          }
        });
  }
  /**
   * Updates the View State when the mode has been set. This does not do any checking that the mode
   * is different to current state so always updates.
   */
  protected void updateUIForMode() {
    // Remove Header, and then add Header Loading View again if needed
    if (this == mHeaderLayout.getParent()) {
      removeView(mHeaderLayout);
    }
    if (mMode.canPullDown()) {
      LinearLayout.LayoutParams llp =
          new LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      llp.setMargins(mMargin, 0, mMargin, 0);
      addViewInternal(mHeaderLayout, 0, llp);
    }

    // Remove Footer, and then add Footer Loading View again if needed
    if (this == mFooterLayout.getParent()) {
      removeView(mFooterLayout);
    }
    if (mMode.canPullUp()) {
      LinearLayout.LayoutParams llp =
          new LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      llp.setMargins(mMargin, 0, mMargin, 0);
      addViewInternal(mFooterLayout, 0, llp);
    }

    // Hide Loading Views
    refreshLoadingViewsHeight();

    // If we're not using Mode.BOTH, set mCurrentMode to mMode, otherwise
    // set it to pull down
    mCurrentMode = (mMode != Mode.BOTH) ? mMode : Mode.PULL_DOWN_TO_REFRESH;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = convertView;
    if (rowView == null) {
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      rowView = inflater.inflate(R.layout.card_list_item, null);
    }

    CardView tv = (CardView) rowView.findViewById(R.id.card);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tv.getLayoutParams();
    Resources r = context.getResources();
    int px =
        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, r.getDisplayMetrics());

    if (position == 0) {
      params.setMargins(px, px, px, px); // substitute parameters for left, top, right, bottom
      tv.setLayoutParams(params);
    } else {
      params.setMargins(px, 0, px, px);
      tv.setLayoutParams(params);
    }

    ImageView image = (ImageView) rowView.findViewById(R.id.line_img);
    TextView line = (TextView) rowView.findViewById(R.id.line_name);

    if (position == 0) {
      image.setColorFilter(Color.argb(89, 198, 12, 48));
    } else if (position == 1) {
      image.setColorFilter(Color.argb(89, 0, 161, 222));
    } else if (position == 2) {
      image.setColorFilter(Color.argb(170, 98, 54, 27));
    } else if (position == 3) {
      image.setColorFilter(Color.argb(89, 0, 155, 58));
    } else if (position == 4) {
      image.setColorFilter(Color.argb(117, 249, 70, 28));
    } else if (position == 5) {
      image.setColorFilter(Color.argb(137, 82, 35, 152));
    } else if (position == 6) {
      image.setColorFilter(Color.argb(150, 226, 126, 166));
    } else if (position == 7) {
      image.setColorFilter(Color.argb(89, 249, 227, 0));
    } else {
      image.setColorFilter(Color.argb(0, 255, 255, 255));
    }
    image.setImageResource(images[position]);

    line.setText(lines[position]);
    line.setTextColor(Color.BLACK);

    return rowView;
  }
  public void displayThumbnails() {
    File dir = new File(Environment.getExternalStorageDirectory() + "/galleryandupload");
    final File[] filelist = dir.listFiles();
    LinearLayout.LayoutParams params;
    LinearLayout ll = new LinearLayout(this);
    LinearLayout mainll = (LinearLayout) findViewById(R.id.mainll);

    int count = 0;
    for (int i = filelist.length - 1; i >= 1; --i) {
      final int i2 = i;

      if (count == 0 || count % 3 == 0) {
        ll = new LinearLayout(this);
        params =
            new LinearLayout.LayoutParams(
                (int) getResources().getDimension(R.dimen.n320),
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(0, n10, 0, n10);
        ll.setLayoutParams(params);
        ll.setOrientation(LinearLayout.HORIZONTAL);
        mainll.addView(ll);
      }
      ImageView imageView = new ImageView(this);
      params =
          new LinearLayout.LayoutParams(
              (int) getResources().getDimension(R.dimen.photo_height),
              (int) getResources().getDimension(R.dimen.photo_height));
      if (count == 1 || (count - 1) % 3 == 0) {
        params.setMargins(n10, 0, n10, 0);
      }
      imageView.setLayoutParams(params);
      Bitmap bitmap = BitmapFactory.decodeFile(filelist[i].getPath());
      Log.e("PATTHHHHHHH", filelist[i].getPath());
      imageView.setImageBitmap(bitmap);
      imageView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intent = new Intent(GalleryActivity.this, ImagesSlideshow.class);
              intent.putExtra("page", i2);
              intent.putExtra("total", filelist.length - 1);
              startActivity(intent);
            }
          });
      ll.addView(imageView);
      count++;
    }
  }
  private LinearLayout getMainBody() {
    LinearLayout llMainBody = new LinearLayout(getContext());
    llMainBody.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams lpMain =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpMain.weight = 1;
    int dp_4 = dipToPx(getContext(), 4);
    lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
    llMainBody.setLayoutParams(lpMain);

    LinearLayout llContent = new LinearLayout(getContext());
    LinearLayout.LayoutParams lpContent =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpContent.weight = 1;
    llMainBody.addView(llContent, lpContent);

    // 文字输入区域
    etContent = new EditText(getContext());
    etContent.setGravity(Gravity.LEFT | Gravity.TOP);
    etContent.setBackgroundDrawable(null);
    etContent.setText(String.valueOf(reqData.get("text")));
    etContent.addTextChangedListener(this);
    LinearLayout.LayoutParams lpEt =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpEt.weight = 1;
    etContent.setLayoutParams(lpEt);
    llContent.addView(etContent);

    llContent.addView(getThumbView());
    llMainBody.addView(getBodyBottom());

    return llMainBody;
  }
示例#6
0
  private void addButtons(LinearLayout mainContainer, int id) {
    int identifier[] = {BUTTON_CLEAR, BUTTON_OK, BUTTON_CANCEL};
    LinearLayout.LayoutParams row_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams box_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ConvertToPx(mContext, 45), 1f);

    box_Params.setMargins(
        ConvertToPx(mContext, 4),
        ConvertToPx(mContext, 9),
        ConvertToPx(mContext, 4),
        ConvertToPx(mContext, 9));
    LinearLayout row = new LinearLayout(mContext);
    row.setOrientation(LinearLayout.HORIZONTAL);
    row.setLayoutParams(row_Params);
    mainContainer.addView(row);
    for (int i = 0; i < 3; i++) {
      Button tv = new Button(mContext);
      tv.setText(getText(identifier[i]));
      String tvTag;
      if (identifier[i] == BUTTON_OK) tvTag = id + DELIMITER + getText(identifier[i]);
      else tvTag = identifier[i] + DELIMITER + getText(identifier[i]);
      tv.setTag(tvTag);
      tv.setTextColor(Color.BLACK);
      tv.setBackgroundResource(R.drawable.btn_white_transparency_20);
      tv.setGravity(Gravity.CENTER);
      tv.setPadding(0, ConvertToPx(mContext, 2), 0, 0);
      tv.setLayoutParams(box_Params);
      tv.setOnClickListener(Process_Input);
      row.addView(tv);
    }
  }
示例#7
0
  private View createNameDialog(String titleText, String value, int identifier) {
    Point windowSize = getWindowSize(mContext.getWindowManager().getDefaultDisplay());
    int five_dip = ConvertToPx(mContext, 5);
    int dialogWidth = windowSize.x - 10 * five_dip;

    LinearLayout mainContainer = new LinearLayout(mContext);
    mainContainer.setOrientation(LinearLayout.VERTICAL);
    mainContainer.addView(getTitleTextView(titleText));
    mainContainer.setBackgroundColor(Color.argb(180, 255, 255, 255));

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(dialogWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams verticalDivider_params =
        new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
    layoutParams.gravity = Gravity.CENTER;
    mainContainer.setLayoutParams(layoutParams);

    EditText tv = new EditText(mContext);
    tv.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    tv.setText(value);
    tv.setEnabled(false);
    tv.setTextColor(Color.BLACK);
    tv.setGravity(Gravity.CENTER);
    layoutParams.setMargins(five_dip, five_dip * 3, five_dip, five_dip);
    tv.setLayoutParams(layoutParams);
    mainContainer.addView(tv);
    mainContainer.addView(getDivider(verticalDivider_params));
    addAlphabets(mainContainer);

    addButtons(mainContainer, identifier);
    edit_PlayerName = tv;
    return mainContainer;
  }
 /**
  * 装填图片数据
  *
  * @param imageUrlList
  * @param imageCycleViewListener
  */
 public void setImageResources(
     ArrayList<FindBean> infoList, ImageCycleViewListener imageCycleViewListener) {
   // 清除所有子视图
   mGroup.removeAllViews();
   // 图片广告数量
   final int imageCount = infoList.size();
   mImageViews = new ImageView[imageCount];
   for (int i = 0; i < imageCount; i++) {
     mImageView = new ImageView(mContext);
     int imageParams = (int) (mScale * 20 + 0.5f); // XP与DP转换,适应不同分辨率
     int imagePadding = (int) (mScale * 5 + 0.5f);
     LinearLayout.LayoutParams layout =
         new LinearLayout.LayoutParams(
             android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
             android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
     layout.setMargins(3, 0, 3, 0);
     mImageView.setLayoutParams(layout);
     // mImageView.setPadding(imagePadding, imagePadding, imagePadding, imagePadding);
     mImageViews[i] = mImageView;
     if (i == 0) {
       mImageViews[i].setBackgroundResource(R.drawable.icon_point_pre);
     } else {
       mImageViews[i].setBackgroundResource(R.drawable.icon_point);
     }
     mGroup.addView(mImageViews[i]);
   }
   mAdvAdapter = new ImageCycleAdapter(mContext, infoList, imageCycleViewListener);
   mBannerPager.setAdapter(mAdvAdapter);
   startImageTimerTask();
 }
  // 动态设置小点
  private void initDots() {
    LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
    // ll.setOrientation(LinearLayout.HORIZONTAL);

    ImageView[] image_dot = new ImageView[4];

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setGravity(Gravity.CENTER_HORIZONTAL);
    params.setMargins(10, 10, 10, 10);

    for (int i = 0; i < 4; i++) {
      image_dot[i] = new ImageView(this);
      image_dot[i].setClickable(true);
      // image_dot[i].setPadding(5, 5, 5, 5);
      image_dot[i].setLayoutParams(params);
      image_dot[i].setBackgroundResource(R.drawable.dot);
    }

    dots = new ImageView[imageurl.size()];

    // 循环取得小点图片
    for (int i = 0; i < imageurl.size(); i++) {
      ll.addView(image_dot[i]);

      dots[i] = (ImageView) ll.getChildAt(i);
      dots[i].setEnabled(true); // 都设为黄色
      dots[i].setOnClickListener(this);
      dots[i].setTag(i); // 设置位置tag,方便取出与当前位置对应
    }

    currentIndex = 0;
    dots[currentIndex].setEnabled(false); // 设置为白色,即选中状态
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
      if (requestCode == 1000) {
        Uri uri = data.getData();
        ContentResolver cr = getActivity().getContentResolver();
        try {
          Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));
          ImageView ivHead = new ImageView(getActivity());
          ivHead.setImageBitmap(ImageViewUtil.centerSquareScaleBitmap(bitmap, 60));

          LinearLayout.LayoutParams lp =
              new LinearLayout.LayoutParams(
                  (int) getResources().getDimension(R.dimen.refresh_header_height),
                  (int) getResources().getDimension(R.dimen.refresh_header_height));
          lp.setMargins(5, 0, 5, 0);
          vContainer.addView(ivHead, lp);
          // TODO 命名规则??
          new GetAndUploadFile(getActivity()).resumableUpload(uri.getPath(), "user/head.jpg");
        } catch (FileNotFoundException e) {

        }
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
示例#11
0
 public void initViews(Context context) {
   DisplayMetrics dm = getResources().getDisplayMetrics();
   int size = (int) (dm.density * SIZE);
   int margin = (int) (dm.density * MARGIN);
   lp = new LinearLayout.LayoutParams(size, size);
   lp.setMargins(margin, margin, margin, margin);
 }
 private void initDots() {
   // TODO Auto-generated method stub
   dotList.clear();
   advll_dot.removeAllViews();
   dotPosition = -1;
   LinearLayout.LayoutParams lp =
       new LinearLayout.LayoutParams(
           ContextUtil.dip2px(PreMainActivity.this, 8),
           ContextUtil.dip2px(PreMainActivity.this, 8));
   lp.setMargins(
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0,
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0);
   int count = companies.size();
   int size = 0;
   if (count % 6 == 0) {
     size = count / 6;
   } else {
     size = count / 6 + 1;
   }
   for (int i = 0; i < size; i++) {
     ImageView iv_dot = new ImageView(PreMainActivity.this);
     iv_dot.setLayoutParams(lp);
     iv_dot.setBackgroundResource(R.drawable.app_dot_normal);
     if (i == 0) {
       iv_dot.setBackgroundResource(R.drawable.app_dot_focused);
     }
     advll_dot.addView(iv_dot);
     dotList.add(iv_dot);
   }
 }
  /** Crystal: add the plus button to the bottom bar */
  public void plusButtonSetUp(int position) {
    LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW);
    lp.setMargins(0, 0, Values.iconBorderPaddingH, 0);
    ImageView plus =
        PrivateSpaceIconView.plusSpaceButton(getResources().getColor(R.color.off_white), this);
    plus.setBackgroundColor(getResources().getColor(R.color.dark_grey));

    plus.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO NORA - might need to change to mainspace in Space class
            try {
              // Space.getMainSpace().getSpaceController().addSpace(Space.getMainSpace().getContext());
              Space newSpace = SpaceController.addSpace(Space.getMainSpace().getContext());
              PrivateSpaceIconView psIcon =
                  new PrivateSpaceIconView(Space.getMainSpace().getContext(), newSpace);
              newSpace.getSpaceController().setPSIV(psIcon);
            } catch (XMPPException e) {
              Log.d("MainApplication plusButtonSetUp()", "Could not add a Space");
            }
            // MainApplication.this.init_createPrivateSpace(false);
          }
        });
    bottomBar.addView(plus, position, lp);
    bottomBar.invalidate();
  }
示例#14
0
  private void addPhoto(int position, LinearLayout layout, JSONArray imgs) {
    ImageView photo = new ImageView(context);
    // 设置当前图像的图像(position为当前图像列表的位置)
    photo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(5, 0, 0, 0);
    photo.setLayoutParams(lp);
    // 设置Gallery组件的背景风格
    // oneHolder.photo.setVisibility(View.VISIBLE);
    if (position < imgs.length())
      try {
        ImagerLoader loader = new ImagerLoader();
        loader.LoadImage(imgs.getJSONObject(position).getString("url"), photo);

        // new DownAndShowImageTask(imgs.getJSONObject(position)
        // .getString("url"), photo).execute();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    layout.addView(photo);
  }
示例#15
0
  public LinearLayout crearImagen(Bitmap bitmap, final int nIdFoto) {
    ImageView ivImagen = new ImageView(this);

    LinearLayout linear_contenedorRegistro = (LinearLayout) new LinearLayout(this);
    linear_contenedorRegistro.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 0, 0, 0);
    lp.weight = 1;
    linear_contenedorRegistro.setLayoutParams(lp);
    linear_contenedorRegistro.setPadding(2, 2, 2, 2);

    if (bitmap != null) {
      // android:adjustViewBounds
      ivImagen.setImageBitmap(RotateBitmap(bitmap, 90));
      ivImagen.setAdjustViewBounds(true);

      ivImagen.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
              // TODO Auto-generated method stub
              irPreview(nIdFoto);
            }
          });
    }

    linear_contenedorRegistro.addView(ivImagen);

    return linear_contenedorRegistro;
  }
  public void changeusername() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Edit Name");
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(1);
    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 0, 10, 0);
    final EditText fname = new EditText(this);
    final EditText sname = new EditText(this);
    fname.setHint("first");
    sname.setHint("last");
    fname.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    sname.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    linearLayout.addView(fname, layoutParams);
    linearLayout.addView(sname, layoutParams);
    alert.setView(linearLayout);

    alert.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {}
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {}
        });

    alert.show();
  }
示例#17
0
  @SuppressWarnings("unused")
  private void initSubFragmentProgress() {
    RelativeLayout subFragmentHolder =
        (RelativeLayout) rootView.findViewById(R.id.wizard_sub_fragments_holder);
    subFragmentHolder.setVisibility(View.VISIBLE);

    subFragmentProgress = (LinearLayout) rootView.findViewById(R.id.wizard_sub_fragments_progress);

    for (int i = 0; i < subFragmentProgress.getChildCount(); i++) {
      try {
        View v = subFragmentProgress.getChildAt(i);
        ((LinearLayout) v.getParent()).removeView(v);
      } catch (NullPointerException e) {
      }
    }

    for (Fragment f : subFragments) {
      ImageView p = new ImageView(a);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lp.setMargins(5, 0, 5, 0);
      p.setLayoutParams(lp);
      subFragmentProgress.addView(p);
    }

    subFragmentNext = (ImageButton) rootView.findViewById(R.id.wizard_sub_fragment_next);
    subFragmentNext.setOnClickListener(this);

    advanceWizardSubFragment(subFragments.get(0));
  }
  public void changeemail() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Edit Email");
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(1);

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 0, 10, 0);
    final EditText email = new EditText(this);
    email.setHint("Email");
    email.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    linearLayout.addView(email, layoutParams);
    alert.setView(linearLayout);

    alert.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {}
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {}
        });

    alert.show();
  }
示例#19
0
  @Override
  public View getView(Context context) {

    View view = LayoutInflater.from(context).inflate(getCardLayout(), null);

    mCardLayout = view;

    try {
      ((FrameLayout) view.findViewById(R.id.cardContent)).addView(getCardContent(context));
    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    view.setLayoutParams(lp);

    return view;
  }
 /** 图片循环 */
 private void initViewPager() {
   ViewGroup.LayoutParams mViewPagerlayoutParams = mViewPager.getLayoutParams();
   if (mViewPagerlayoutParams != null) {
     mViewPagerlayoutParams.width = Misc.getScreenDisplay(this)[0];
     mViewPagerlayoutParams.height = (int) (mViewPagerlayoutParams.width);
     mViewPager.setLayoutParams(mViewPagerlayoutParams);
   }
   mViewPager.setAdapter(new ProductDetailPicAdapter2(this, product.getImgList()));
   mViewPager.setOnPageChangeListener(this);
   // 设置布局参数
   LinearLayout.LayoutParams params =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int marginParam = Misc.dip2px(this, 10) / 2;
   llytPagerPoiner.removeAllViewsInLayout();
   for (int i = 0; i < product.getImgList().size(); i++) {
     // 设置按钮属性
     View item = new ImageView(this);
     item.setBackgroundResource(R.drawable.recommend_gallery);
     item.setTag(String.valueOf(i));
     // item.setOnClickListener(parentActivity);
     params.setMargins(marginParam, 0, marginParam, 0);
     params.weight = 1;
     llytPagerPoiner.addView(item, params);
   }
   llytPagerPoiner.getChildAt(0).setBackgroundResource(R.drawable.recommend_gallery_select);
 }
示例#21
0
  public void addAvailableAddresses() {

    for (int i = 0; i < Constants.addressData.size(); i++) {

      rowView = layoutInflater.inflate(R.layout.include_available_address, null);
      LinearLayout.LayoutParams params =
          (LinearLayout.LayoutParams)
              new LinearLayout.LayoutParams(
                  LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      params.setMargins(0, 0, 0, 5);
      rowView.setLayoutParams(params);

      address = (CustomTextView) rowView.findViewById(R.id.address_text_included);
      address.setTag("address_" + i);
      address.setVisibility(View.VISIBLE);
      Log.d(
          Constants.LOG_TAG,
          " Setting the adress " + Constants.addressData.get(i).getFullAddress());
      address.setText(Constants.addressData.get(i).getFullAddress());
      address.setOnClickListener(inflatedViewListener);

      mobileNumber = (CustomTextView) rowView.findViewById(R.id.mobile_number_text_included);
      mobileNumber.setTag("number_" + i);
      mobileNumber.setVisibility(View.VISIBLE);
      Log.d(
          Constants.LOG_TAG,
          " Setting the mobile number " + Constants.addressData.get(i).getMobileNumber());
      mobileNumber.setText(Constants.addressData.get(i).getMobileNumber());
      mobileNumber.setOnClickListener(inflatedViewListener);

      selectAddressChild.addView(rowView);
    }
  }
示例#22
0
 private void initView() {
   Object localObject = (TextView) findViewById(R.id.title);
   LinearLayout localLinearLayout1;
   LinearLayout.LayoutParams localLayoutParams;
   Iterator localIterator;
   if (TextUtils.isEmpty(this.tip)) {
     ((TextView) localObject).setVisibility(8);
     localObject = (LinearLayout) findViewById(R.id.normal_rules);
     localLinearLayout1 = (LinearLayout) findViewById(R.id.special_rules);
     localLayoutParams = new LinearLayout.LayoutParams(-1, -2);
     localLayoutParams.setMargins(0, ViewUtils.dip2px(this, 22.0F), 0, 0);
     localIterator = this.rules.iterator();
   }
   while (true) {
     if (!localIterator.hasNext()) return;
     DPObject localDPObject = (DPObject) localIterator.next();
     LinearLayout localLinearLayout2 = buildRule(localDPObject);
     if (localDPObject.getInt("Type") == 1) {
       if (((LinearLayout) localObject).getChildCount() > 0) {
         ((LinearLayout) localObject).addView(localLinearLayout2, localLayoutParams);
         continue;
         ((TextView) localObject).setText(this.tip);
         break;
       }
       ((LinearLayout) localObject).addView(localLinearLayout2);
       continue;
     }
     if (localLinearLayout1.getChildCount() > 0) {
       localLinearLayout1.addView(localLinearLayout2, localLayoutParams);
       continue;
     }
     localLinearLayout1.addView(localLinearLayout2);
   }
 }
  boolean resizeCameras() {
    try {
      int screen_width = readScreenWidth(this);
      camerasPerRow = recalculateCameraPerRow();

      io.evercam.androidapp.custom.FlowLayout camsLineView =
          (io.evercam.androidapp.custom.FlowLayout) this.findViewById(R.id.cameras_flow_layout);
      for (int i = 0; i < camsLineView.getChildCount(); i++) {
        LinearLayout pview = (LinearLayout) camsLineView.getChildAt(i);
        CameraLayout cameraLayout = (CameraLayout) pview.getChildAt(0);

        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        params.width =
            ((i + 1 % camerasPerRow == 0)
                ? (screen_width - (i % camerasPerRow) * (screen_width / camerasPerRow))
                : screen_width / camerasPerRow);
        params.width = params.width - 1; // 1 pixels spacing between cameras
        params.height = (int) (params.width / (1.25));
        params.setMargins(1, 1, 0, 0); // 1 pixels spacing between cameras
        cameraLayout.setLayoutParams(params);
      }
      return true;
    } catch (Exception e) {
      Log.e(TAG, e.toString() + "::" + Log.getStackTraceString(e));

      sendToMint(e);

      EvercamPlayApplication.sendCaughtException(this, e);
      CustomedDialog.showUnexpectedErrorDialog(CamerasActivity.this);
    }
    return false;
  }
  // 动态添加一个新视频
  private void addNewVideo() {
    final FrameLayout fLayoutOther = new FrameLayout(EditNoteActivity.this);

    VideoView videoView = new VideoView(EditNoteActivity.this);
    // videoView.setVideoURI(uri);
    fLayoutOther.addView(videoView);

    ImageView iv_delete = new ImageView(EditNoteActivity.this);
    iv_delete.setImageResource(R.drawable.ic_delete);
    iv_delete.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            llayoutEditNewOther.removeView(fLayoutOther);
          }
        });
    FrameLayout.LayoutParams fParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    fLayoutOther.addView(iv_delete, fParams);

    LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(150, 150);
    lParams.setMargins(0, 10, 15, 10);
    llayoutEditNewOther.addView(fLayoutOther, lParams);
  }
  public void changemobile() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Edit Phone");
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(1);
    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 0, 10, 0);
    final EditText mobileNo = new EditText(this);
    mobileNo.setHint("Mobile No");
    mobileNo.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE);
    linearLayout.addView(mobileNo, layoutParams);
    alert.setView(linearLayout);

    alert.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            addContact();
          }
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {}
        });

    alert.show();
  }
示例#26
0
  public void drawChart(List<Properties> walks) {
    View view;
    TextView km;
    float scaleFactor;
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    scaleFactor = metrics.density;
    System.out.println("scaleFactor : " + scaleFactor);

    float maxValue = 0;
    for (Properties p : walks) {
      if (toKMFloat(p) > maxValue) maxValue = toKMFloat(p);
    }

    int barWidth = (int) (30 * scaleFactor);
    int barHeight;
    System.out.println("barWidth : " + barWidth);

    String color = GRAY;
    int count = 0;
    float normalWalk = 3.5f;
    for (Properties p : walks) {
      view = new View(this);
      km = new TextView(this);

      LinearLayout linearLayout = new LinearLayout(this);
      linearLayout.setOrientation(LinearLayout.VERTICAL);
      linearLayout.setGravity(Gravity.BOTTOM);
      linearLayout.setLayoutParams(
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

      LinearLayout.LayoutParams linearLayoutlp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      if (toKMFloat(p) > normalWalk) color = BLUE;
      else color = GRAY;
      view.setBackgroundColor(Color.parseColor(color));
      km.setTextColor(Color.parseColor(color));
      km.setText(toKMString(p));

      barHeight = (int) (toKMFloat(p) / maxValue * 100 * scaleFactor);
      if (barHeight == 0) barHeight = (int) scaleFactor;
      view.setLayoutParams(new LinearLayout.LayoutParams(barWidth, barHeight));
      km.setLayoutParams(
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
      km.setGravity(Gravity.CENTER_HORIZONTAL);

      linearLayout.addView(km, linearLayoutlp);
      linearLayout.addView(view);

      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) linearLayout.getLayoutParams();
      params.setMargins(5 * (int) scaleFactor, 5 * (int) scaleFactor, 0, 0);
      linearLayout.setLayoutParams(params);
      barChart.addView(linearLayout);

      count++;
    }
  }
  public void showEditDialog(final int position, final QuickAnswer item) {
    AlertDialog.Builder builder =
        new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.QAPopup));
    builder.setTitle(position >= 0 ? R.string.edit : R.string.add);

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final EditText et = (EditText) inflater.inflate(R.layout.edittext_holo, null);
    LinearLayout.LayoutParams p =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    p.setMargins(
        MeasuresUtils.DpToPx(4),
        MeasuresUtils.DpToPx(15),
        MeasuresUtils.DpToPx(4),
        MeasuresUtils.DpToPx(15));
    et.setHint(R.string.edittext_hint_qa);
    et.setLayoutParams(p);
    if (item != null) {
      et.setText(item.getMessage());
      et.setSelection(item.getMessage().length());
    }
    et.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            InputMethodManager keyboard =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            keyboard.showSoftInput(et, 0);
          }
        },
        200);
    builder.setView(et);
    builder.setNegativeButton(
        R.string.cancel,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
          }
        });

    builder.setPositiveButton(
        R.string.valid,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            if (et.getText() != null && et.getText().length() > 0) {
              if (item != null) {
                mAdapter.setMessageEdited(position, et.getText().toString());
              } else {
                mAdapter.addNewMessage(et.getText().toString());
              }
              dialogInterface.dismiss();
            }
          }
        });

    builder.create().show();
  }
示例#28
0
  private void setHwView() {
    int displayHeight = ((XiwaoApplication) getApplication()).getDisplayHeight();
    int displayWidth = ((XiwaoApplication) getApplication()).getDisplayWidth();
    // title高度
    RelativeLayout title = (RelativeLayout) findViewById(R.id.header);
    LinearLayout.LayoutParams titleParams =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, (int) (displayHeight * 0.08f + 0.5f));
    title.setLayoutParams(titleParams);

    // 所在网点
    RelativeLayout websitInfo = (RelativeLayout) findViewById(R.id.websit);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, (int) (displayHeight * 0.08f + 0.5f));
    params.setMargins(0, (int) (displayHeight * 0.04f + 0.5f), 0, 0);
    websitInfo.setLayoutParams(params);

    // 详细地址
    RelativeLayout detailAddress = (RelativeLayout) findViewById(R.id.address);
    params =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, (int) (displayHeight * 0.08f + 0.5f));
    params.setMargins(0, (int) (displayHeight * 0.001f + 0.5f), 0, 0);
    detailAddress.setLayoutParams(params);

    // 按钮
    LinearLayout buttonGroup = (LinearLayout) findViewById(R.id.button_group);
    LinearLayout.LayoutParams sureBtnParams =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, (int) (displayHeight * 0.12f + 0.5f));
    sureBtnParams.setMargins(0, (int) (displayHeight * 0.04f + 0.5f), 0, 0);
    buttonGroup.setLayoutParams(sureBtnParams);

    LinearLayout.LayoutParams btnParams =
        new LinearLayout.LayoutParams(
            (int) (displayWidth * 0.4f + 0.5f), (int) (displayHeight * 0.08f + 0.5f));
    btnParams.setMargins((int) (displayWidth * 0.05f + 0.5f), 0, 0, 0);
    cancelBtn.setLayoutParams(btnParams);
    btnParams =
        new LinearLayout.LayoutParams(
            (int) (displayWidth * 0.9f + 0.5f), (int) (displayHeight * 0.08f + 0.5f));
    btnParams.setMargins(
        (int) (displayWidth * 0.05f + 0.5f), 0, (int) (displayWidth * 0.05f + 0.5f), 0);
    sureBtn.setLayoutParams(btnParams);
  }
示例#29
0
  public void showDialogInitializingCommandPlayer(
      final Activity uiContext, boolean warningNoneProvider, Runnable run, boolean showDialog) {
    String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
    if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
      if (warningNoneProvider && voiceProvider == null) {
        Builder builder = new AccessibleAlertBuilder(uiContext);
        LinearLayout ll = new LinearLayout(uiContext);
        ll.setOrientation(LinearLayout.VERTICAL);
        final TextView tv = new TextView(uiContext);
        tv.setPadding(7, 3, 7, 0);
        tv.setText(R.string.voice_is_not_available_msg);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
        ll.addView(tv);

        final CheckBox cb = new CheckBox(uiContext);
        cb.setText(R.string.shared_string_remember_my_choice);
        LinearLayout.LayoutParams lp =
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(7, 10, 7, 0);
        cb.setLayoutParams(lp);
        ll.addView(cb);

        builder.setCancelable(true);
        builder.setNegativeButton(
            R.string.shared_string_cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                if (cb.isChecked()) {
                  osmandSettings.VOICE_PROVIDER.set(OsmandSettings.VOICE_PROVIDER_NOT_USE);
                }
              }
            });
        builder.setPositiveButton(
            R.string.shared_string_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(uiContext, SettingsActivity.class);
                intent.putExtra(
                    SettingsActivity.INTENT_KEY_SETTINGS_SCREEN,
                    SettingsActivity.SCREEN_GENERAL_SETTINGS);
                uiContext.startActivity(intent);
              }
            });

        builder.setTitle(R.string.voice_is_not_available_title);
        builder.setView(ll);
        // builder.setMessage(R.string.voice_is_not_available_msg);
        builder.show();
      }

    } else {
      if (player == null || !Algorithms.objectEquals(voiceProvider, player.getCurrentVoice())) {
        appInitializer.initVoiceDataInDifferentThread(uiContext, voiceProvider, run, showDialog);
      }
    }
  }
示例#30
0
  private void displayOutput(String site, String restoredAccount) {
    // Get a reference to the layout where the card will be displayed
    final LinearLayout layout = (LinearLayout) findViewById(R.id.now_layout);

    // Create the View for the card
    final CardView card = new CardView(this);

    // Specify layout parameters to be applied
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 20, 0, 0);

    // Set the internal state of the card
    card.setSite(site);

    // Show the prettier string if available
    if (siteNames.containsKey(site)) {
      card.setSiteHeaderText(siteNames.get(site));
    } else {
      card.setSiteHeaderText(site);
    }

    // Check if account is specified or pick the most recent from the search history if not
    if (restoredAccount == null) {
      if (!searchHistory.isEmpty()) {
        card.setSiteAccountText("Compromised: " + searchHistory.peekLast());
      }
    } else {
      card.setSiteAccountText(restoredAccount);
    }

    if (siteDescriptions.containsKey(site)) {
      card.setSiteDescriptionText(siteDescriptions.get(site));
    } else {
      card.setSiteDescriptionText(getString(R.string.card_description_unavailable));
    }
    card.setLayoutParams(lp);

    // Create the swipe-to-dismiss touch listener.
    card.setOnTouchListener(
        new SwipeDismissTouchListener(
            card,
            null,
            new SwipeDismissTouchListener.DismissCallbacks() {
              @Override
              public boolean canDismiss(Object token) {
                return true;
              }

              @Override
              public void onDismiss(View view, Object token) {
                layout.removeView(card);
              }
            }));

    layout.addView(card);
  }