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;
  }
 public static void imageLLViewReset(ImageView imageView, int bitmapW, int bitmapH) {
   LinearLayout.LayoutParams layoutParams =
       (LinearLayout.LayoutParams) imageView.getLayoutParams();
   HashMap<String, Integer> data = Handler_System.getDisplayMetrics();
   int width = data.get(Handler_System.systemWidth);
   int height = data.get(Handler_System.systemHeight);
   if (width > height) {
     layoutParams.width = (int) (bitmapW * 1.00f / bitmapH * height);
     layoutParams.height = height;
   } else {
     layoutParams.width = width;
     layoutParams.height = (int) (bitmapH * 1.00f / bitmapW * width);
   }
   imageView.setLayoutParams(layoutParams);
 }
  private void populateTabStrip() {
    final PagerAdapter adapter = viewPager.getAdapter();

    for (int i = 0; i < adapter.getCount(); i++) {

      final View tabView =
          (tabProvider == null)
              ? createDefaultTabView(adapter.getPageTitle(i))
              : tabProvider.createTabView(tabStrip, i, adapter);

      if (tabView == null) {
        throw new IllegalStateException("tabView is null.");
      }

      if (distributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
      }

      if (internalTabClickListener != null) {
        tabView.setOnClickListener(internalTabClickListener);
      }

      tabStrip.addView(tabView);

      if (i == viewPager.getCurrentItem()) {
        tabView.setSelected(true);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.public_video_xml);
    initView();
    // 跳转到录制页面
    Init_View();

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    surfaceView = (TextureView) findViewById(R.id.preview_video);

    RelativeLayout preview_video_parent = (RelativeLayout) findViewById(R.id.preview_video_parent);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) preview_video_parent.getLayoutParams();
    layoutParams.width = displaymetrics.widthPixels;
    layoutParams.height = displaymetrics.widthPixels;
    preview_video_parent.setLayoutParams(layoutParams);

    surfaceView.setSurfaceTextureListener(this);
    surfaceView.setOnClickListener(this);

    path = getIntent().getStringExtra("path");

    imagePlay = (ImageView) findViewById(R.id.previre_play);
    imagePlay.setOnClickListener(this);
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnCompletionListener(this);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView =
            LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_toc_entry, parent, false);
      }
      Section section = (Section) getItem(position);
      TextView sectionHeading = (TextView) convertView.findViewById(R.id.page_toc_item_text);
      View sectionFiller = convertView.findViewById(R.id.page_toc_filler);

      LinearLayout.LayoutParams indentLayoutParameters =
          new LinearLayout.LayoutParams(sectionFiller.getLayoutParams());
      indentLayoutParameters.width =
          (section.getLevel() - 1)
              * (int) (INDENTATION_WIDTH_DP * WikipediaApp.getInstance().getScreenDensity());
      sectionFiller.setLayoutParams(indentLayoutParameters);

      sectionHeading.setText(Html.fromHtml(section.getHeading()));

      if (section.getLevel() > 1) {
        sectionHeading.setTextColor(
            WikipediaApp.getInstance()
                .getResources()
                .getColor(getThemedAttributeId(parentActivity, R.attr.toc_subsection_text_color)));
      } else {
        sectionHeading.setTextColor(
            WikipediaApp.getInstance()
                .getResources()
                .getColor(getThemedAttributeId(parentActivity, R.attr.toc_section_text_color)));
      }
      return convertView;
    }
Exemple #6
0
  /**
   * Add buttons to the Dialog which has button area.
   *
   * @param context
   * @param buttonType The type of button that want to adds to Dialog. TCLAlertDialog.ONE_BUTTON :
   *     adds only one button. TCLAlertDialog.TWO_BUTTON : adds two button. Other : adds custom
   *     button.
   */
  public View setButton(Context context, int buttonType) {
    LayoutInflater inflate =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    switch (buttonType) {
      case ONE_BUTTON:
        // mButtonView =
        // inflate.inflate(com.android.internal.R.layout.tcl_alert_button_one_especial, null);
        break;
      case TWO_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_two_especial, null);
        break;
      case THREE_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_three_especial, null);
        break;
      default:
        mButtonView = inflate.inflate(buttonType, null);
        break;
    }
    LinearLayout layout = getLayout(mButtonLayout.getId());

    lp.width = 700; // add by gaodw.
    // lp.height = 150; //add by gaodw.

    layout.addView(mButtonView, lp);
    return mButtonView;
  }
    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
      HolerView holerView = null;
      if (arg1 == null) {
        holerView = new HolerView();
        arg1 =
            LayoutInflater.from(ChoiceCollActivity.this)
                .inflate(R.layout.classification_item, arg2, false);
        holerView.table = (TextView) arg1.findViewById(R.id.table);
        holerView.img = (ImageView) arg1.findViewById(R.id.img);
        arg1.setTag(holerView);
      } else {
        holerView = (HolerView) arg1.getTag();
      }
      holerView.table.setText(mCommodityListData.get(arg0));
      LinearLayout.LayoutParams param = (LinearLayout.LayoutParams) holerView.img.getLayoutParams();
      param.width =
          (mClassificationGridView.getWidth() - DensityUtils.dp2px(ChoiceCollActivity.this, 16))
              / 3;
      param.height =
          (mClassificationGridView.getWidth() - DensityUtils.dp2px(ChoiceCollActivity.this, 16))
              / 3;
      holerView.img.setLayoutParams(param);

      return arg1;
    }
 private void populateTabStrip() {
   final PagerAdapter adapter = mViewPager.getAdapter();
   final View.OnClickListener tabClickListener = new TabClickListener();
   for (int i = 0; i < adapter.getCount(); i++) {
     View tabView = null;
     TextView tabTitleView = null;
     if (mTabViewLayoutId != 0) {
       // If there is a custom tab view layout id set, try and inflate it
       tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
       tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
     }
     if (tabView == null) {
       tabView = createDefaultTabView(getContext());
     }
     if (tabTitleView == null && TextView.class.isInstance(tabView)) {
       tabTitleView = (TextView) tabView;
     }
     if (mDistributeEvenly) {
       LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
       lp.width = 0;
       lp.weight = 1;
     }
     tabTitleView.setText(adapter.getPageTitle(i));
     tabView.setOnClickListener(tabClickListener);
     String desc = mContentDescriptions.get(i, null);
     if (desc != null) {
       tabView.setContentDescription(desc);
     }
     mTabStrip.addView(tabView);
     if (i == mViewPager.getCurrentItem()) {
       tabView.setSelected(true);
     }
   }
 }
  /** 设置显示的图片 */
  public void setImage(int[] res) {
    imgIds = res;

    linearLayout = (LinearLayout) findViewById(R.id.viewGroup);

    tips = new ImageView[imgIds.length];
    for (int i = 0; i < imgIds.length; i++) {
      ImageView mImageView = new ImageView(mContext);
      tips[i] = mImageView;
      LinearLayout.LayoutParams layoutParams =
          new LinearLayout.LayoutParams(
              new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      layoutParams.rightMargin = AppUtil.dip2px(mContext, 4);
      layoutParams.leftMargin = AppUtil.dip2px(mContext, 4);
      layoutParams.width = AppUtil.dip2px(mContext, 7);
      layoutParams.height = AppUtil.dip2px(mContext, 7);

      mImageView.setBackgroundResource(R.drawable.page_indicator_unfocused);
      linearLayout.addView(mImageView, layoutParams);
    }

    // 这个我是从上一个界面传过来的,上一个界面是一个GridView
    mImageSwitcher.setImageResource(imgIds[currentPosition]);

    setImageBackground(currentPosition);
  }
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (type == Type.Centered) {
      if (maxTabWidth == Integer.MIN_VALUE) {
        for (int i = 0; i < tabWidget.getTabCount(); i++) {
          View tabView = tabWidget.getChildTabViewAt(i);
          if (tabView.getMeasuredWidth() > maxTabWidth) {
            maxTabWidth = tabView.getMeasuredWidth();
          }
        }

        if (maxTabWidth > 0) {
          for (int i = 0; i < tabWidget.getTabCount(); i++) {
            View tabView = tabWidget.getChildTabViewAt(i);
            LinearLayout.LayoutParams params =
                (LinearLayout.LayoutParams) tabView.getLayoutParams();
            params.width = maxTabWidth;
            tabView.setLayoutParams(params);
          }
        }
      }
    }

    super.onLayout(changed, left, top, right, bottom);
  }
 /** 设置滑动条的宽度为屏幕的1/tabNum(根据Tab的个数而定) */
 private void initTabLineWidth() {
   DisplayMetrics dpMetrics = new DisplayMetrics();
   getWindow().getWindowManager().getDefaultDisplay().getMetrics(dpMetrics);
   screenWidth = dpMetrics.widthPixels;
   LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mTabLineIv.getLayoutParams();
   lp.width = screenWidth / tabNum;
   mTabLineIv.setLayoutParams(lp);
 }
Exemple #12
0
  /*
   * Adjusting imageview height
   * */
  private void adjustImageAspect(int bWidth, int bHeight) {
    LinearLayout.LayoutParams params = (LayoutParams) getLayoutParams();

    if (bWidth == 0 || bHeight == 0) return;

    int swidth = getWidth();
    int new_height = 0;
    new_height = swidth * bHeight / bWidth;
    params.width = swidth;
    params.height = new_height;
    setLayoutParams(params);
  }
 /**
  * 根据分辨率设置透明按钮的大小
  *
  * @author [email protected] 2013-7-29 下午5:12:27
  * @param view
  * @return void
  */
 public static void resetLLBack(View... view) {
   float rote = Handler_System.getWidthRoate(ApplicationBean.getApplication().getMode_w());
   if (view == null || rote == 1) {
     return;
   }
   for (View view2 : view) {
     LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view2.getLayoutParams();
     layoutParams.height = (int) (layoutParams.height * rote);
     layoutParams.width = (int) (layoutParams.width * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
 /** Center the action bar */
 protected void centerActionBarTitle() {
   int titleId;
   titleId = getResources().getIdentifier("action_bar_title", "id", "android");
   TextView titleTextView = (TextView) findViewById(titleId);
   DisplayMetrics metrics = getResources().getDisplayMetrics();
   // Fetch layout parameters of titleTextView (LinearLayout.LayoutParams : Info from
   // HierarchyViewer)
   LinearLayout.LayoutParams txvPars = (LinearLayout.LayoutParams) titleTextView.getLayoutParams();
   txvPars.gravity = Gravity.CENTER_HORIZONTAL;
   txvPars.width = metrics.widthPixels;
   titleTextView.setLayoutParams(txvPars);
   titleTextView.setGravity(Gravity.CENTER);
 }
 private void setTitle(ArrayList<TextView> text, int[] id) {
   LinearLayout.LayoutParams lp;
   for (int i = 0; i < ITEM_NUM; i++) {
     text.get(i).setText(id[i]);
     text.get(i)
         .setTextSize(
             getResources().getDimensionPixelSize(R.dimen.quickly_start_bar_title_normal));
     lp = (android.widget.LinearLayout.LayoutParams) text.get(i).getLayoutParams();
     lp.width = getResources().getDimensionPixelSize(R.dimen.quickly_start_bar_title_normal_width);
     text.get(i).setLayoutParams(lp);
     text.get(i).setTextColor(Color.WHITE);
     if (i == mSelectedPosition % ITEM_NUM) {
       text.get(i)
           .setTextColor(text_selected_color[mSelectedPosition % text_selected_color.length]);
       text.get(i)
           .setTextSize(getResources().getDimensionPixelSize(R.dimen.quickly_start_bar_title_sel));
       lp = (android.widget.LinearLayout.LayoutParams) text.get(i).getLayoutParams();
       lp.width = getResources().getDimensionPixelSize(R.dimen.quickly_start_bar_title_sel_width);
       text.get(i).setLayoutParams(lp);
     }
   }
 }
 public void setVerticalEqually() {
   for (Pair<View, View> tab : tabs) {
     ViewGroup.LayoutParams params = tab.first.getLayoutParams();
     if (params instanceof LinearLayout.LayoutParams) {
       LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) params;
       lp.weight = 1;
       lp.height = 0;
       lp.width = -1;
       tab.first.setLayoutParams(lp);
     }
   }
   onGlobalLayout();
 }
  private void displayPosts(PostThread postThread) {
    // Resources res = getResources();

    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    List<Post> posts = postThread.getPosts();
    for (int i = 0; i < posts.size(); i++) {
      Post post = posts.get(i);
      PostView PView = new PostView(getApplicationContext(), post);
      LinearLayout.LayoutParams linearParam =
          new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT / 2, 40);
      linearParam.width = LinearLayout.LayoutParams.MATCH_PARENT;
      linearParam.height = LinearLayout.LayoutParams.WRAP_CONTENT;
      PView.setLayoutParams(linearParam);
      PView.setTag(i);
      ll.addView(PView);
      PView.setOnClickListener(postListener);
    }
    contextContainer.addView(ll);
  }
  protected final void refreshRefreshableViewSize(int width, int height) {
    // We need to set the Height of the Refreshable View to the same as
    // this layout
    LinearLayout.LayoutParams lp =
        (LinearLayout.LayoutParams) mRefreshableViewWrapper.getLayoutParams();

    switch (getPullToRefreshScrollDirection()) {
      case HORIZONTAL:
        if (lp.width != width) {
          lp.width = width;
          mRefreshableViewWrapper.requestLayout();
        }
        break;
      case VERTICAL:
        if (lp.height != height) {
          lp.height = height;
          mRefreshableViewWrapper.requestLayout();
        }
        break;
    }
  }
    public ProcessWatcher(Context context, AttributeSet attrs) {
      super(context, attrs);

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

      mText = new TextView(getContext());
      mText.setTextColor(TEXT_COLOR);
      mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, 10 * dp);
      mText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

      final int p = (int) (2 * dp);
      setPadding(p, 0, p, 0);

      mRamGraph = new GraphView(getContext());

      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, (int) (14 * dp), 1f);

      addView(mText, params);
      params.leftMargin = (int) (4 * dp);
      params.weight = 0f;
      params.width = (int) (200 * dp);
      addView(mRamGraph, params);
    }
Exemple #20
0
 private void Init_Point() {
   layout_point = (LinearLayout) findViewById(R.id.iv_image);
   pointViews = new ArrayList<ImageView>();
   ImageView imageView;
   System.out.println(views.size() + "init_point");
   for (int i = 0; i < views.size(); i++) {
     imageView = new ImageView(this);
     imageView.setBackgroundResource(R.drawable.d1);
     LinearLayout.LayoutParams layoutParams =
         new LinearLayout.LayoutParams(
             new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
     layoutParams.leftMargin = 10;
     layoutParams.rightMargin = 10;
     layoutParams.width = 8;
     layoutParams.height = 8;
     layout_point.addView(imageView, layoutParams);
     if (i == 0) {
       imageView.setBackgroundResource(R.drawable.d2);
     } else {
       imageView.setBackgroundResource(R.drawable.d1);
     }
     pointViews.add(imageView);
   }
 }
  private void updateTagsContent() {
    int x = getResources().getDimensionPixelSize(R.dimen.tag_margin_x);
    int y = getResources().getDimensionPixelSize(R.dimen.tag_margin_y);
    int min_width = getResources().getDimensionPixelSize(R.dimen.tag_title_width);

    // Add Parodies Tags
    if (!TextUtils.isEmpty(book.parodies)) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setMinWidth(min_width);
      groupNameView.setText(R.string.tag_type_parodies);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      TextView tagView =
          (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
      tagView.setText(book.parodies);
      tagView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              CategoryActivity.launch(
                  BookDetailsActivity.this, new Category(Category.Type.PARODY, book.parodies));
            }
          });
      AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
      alp.setMargins(x, y, x, y);
      tagLayout.addView(tagView, alp);
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }

    // Add Characters
    if (!book.characters.isEmpty()) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setMinWidth(min_width);
      groupNameView.setText(R.string.tag_type_characters);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      for (final String tag : book.characters) {
        TextView tagView =
            (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
        tagView.setText(tag);
        tagView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                CategoryActivity.launch(
                    BookDetailsActivity.this, new Category(Category.Type.CHARACTER, tag));
              }
            });
        AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
        alp.setMargins(x, y, x, y);
        tagLayout.addView(tagView, alp);
      }
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }

    // Add Tags
    if (!book.tags.isEmpty()) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setMinWidth(min_width);
      groupNameView.setText(R.string.tag_type_tag);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      for (final String tag : book.tags) {
        TextView tagView =
            (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
        tagView.setText(tag);
        tagView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                CategoryActivity.launch(
                    BookDetailsActivity.this, new Category(Category.Type.TAG, tag));
              }
            });
        AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
        alp.setMargins(x, y, x, y);
        tagLayout.addView(tagView, alp);
      }
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }

    // Add Artist Tag
    if (!book.artists.isEmpty()) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setMinWidth(min_width);
      groupNameView.setText(R.string.tag_type_artists);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      for (final String artist : book.artists) {
        TextView tagView =
            (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
        tagView.setText(artist);
        tagView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                CategoryActivity.launch(
                    BookDetailsActivity.this, new Category(Category.Type.ARTIST, artist));
              }
            });
        AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
        alp.setMargins(x, y, x, y);
        tagLayout.addView(tagView, alp);
      }
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }

    // Add Groups Tag
    if (!TextUtils.isEmpty(book.group)) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setMinWidth(min_width);
      groupNameView.setText(R.string.tag_type_group);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      TextView tagView =
          (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
      tagView.setText(book.group);
      tagView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              CategoryActivity.launch(
                  BookDetailsActivity.this, new Category(Category.Type.GROUP, book.group));
            }
          });
      AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
      alp.setMargins(x, y, x, y);
      tagLayout.addView(tagView, alp);
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }

    // Add Language Tag
    if (!TextUtils.isEmpty(book.language)) {
      LinearLayout tagGroupLayout = new LinearLayout(this);
      tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
      AutoWrapLayout tagLayout = new AutoWrapLayout(this);

      TextView groupNameView = new TextView(this);
      groupNameView.setText(R.string.tag_type_language);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(x, y, x, y);
      lp.width = min_width;
      tagGroupLayout.addView(groupNameView, lp);

      TextView tagView =
          (TextView) View.inflate(getApplicationContext(), R.layout.layout_tag, null);
      tagView.setText(book.language);
      tagView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              CategoryActivity.launch(
                  BookDetailsActivity.this, new Category(Category.Type.LANGUAGE, book.language));
            }
          });
      AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
      alp.setMargins(x, y, x, y);
      tagLayout.addView(tagView, alp);
      tagGroupLayout.addView(tagLayout);
      mTagsLayout.addView(tagGroupLayout);
    }
  }
 /** 处理入口按钮 */
 public void dealEntry() {
   scrollEntry.setHorizontalScrollBarEnabled(false);
   DisplayMetrics metrics = new DisplayMetrics();
   this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
   LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) viewEntry1.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry1.setLayoutParams(lp);
   viewEntry1.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent0 =
               new Intent(HomeActivity.this.getActivity(), SelectDoctorActivity.class);
           HomeActivity.this.startActivity(intent0);
         }
       });
   lp = (LinearLayout.LayoutParams) viewEntry2.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry2.setLayoutParams(lp);
   viewEntry2.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           if (null == Profile.instance().region) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), RegionActivity.class);
             HomeActivity.this.startActivityForResult(intent, MESSAGE_REGION);
             Toast.makeText(HomeActivity.this.getActivity(), "请设置所在小区", Toast.LENGTH_LONG).show();
             return;
           }
           if (null == Me.instance) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), LoginActivity.class);
             HomeActivity.this.startActivity(intent);
             Toast.makeText(HomeActivity.this.getActivity(), "请先登录账号", Toast.LENGTH_LONG).show();
             return;
           }
           Helper.openBrowser(
               HomeActivity.this.getActivity(),
               Networking.fetchURL(
                   "yuyuetijian", Profile.instance().region.id, Me.instance.token));
         }
       });
   lp = (LinearLayout.LayoutParams) viewEntry3.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry3.setLayoutParams(lp);
   viewEntry3.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           if (null == Profile.instance().region) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), RegionActivity.class);
             HomeActivity.this.startActivityForResult(intent, MESSAGE_REGION);
             Toast.makeText(HomeActivity.this.getActivity(), "请设置所在小区", Toast.LENGTH_LONG).show();
             return;
           }
           if (null == Me.instance) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), LoginActivity.class);
             HomeActivity.this.startActivity(intent);
             Toast.makeText(HomeActivity.this.getActivity(), "请先登录账号", Toast.LENGTH_LONG).show();
             return;
           }
           Helper.openBrowser(
               HomeActivity.this.getActivity(),
               Networking.fetchURL(
                   "yuyueliliao", Profile.instance().region.id, Me.instance.token));
         }
       });
   lp = (LinearLayout.LayoutParams) viewEntry4.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry4.setLayoutParams(lp);
   viewEntry4.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(HomeActivity.this.getActivity(), ArchiveActivity.class);
           intent.putExtra("password", 0);
           HomeActivity.this.startActivity(intent);
         }
       });
   lp = (LinearLayout.LayoutParams) viewEntry5.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry5.setLayoutParams(lp);
   viewEntry5.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           if (null == Profile.instance().region) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), RegionActivity.class);
             HomeActivity.this.startActivityForResult(intent, MESSAGE_REGION);
             Toast.makeText(HomeActivity.this.getActivity(), "请设置所在小区", Toast.LENGTH_LONG).show();
             return;
           }
           if (null == Me.instance) {
             Intent intent = new Intent(HomeActivity.this.getActivity(), LoginActivity.class);
             HomeActivity.this.startActivity(intent);
             Toast.makeText(HomeActivity.this.getActivity(), "请先登录账号", Toast.LENGTH_LONG).show();
             return;
           }
           Helper.openBrowser(
               HomeActivity.this.getActivity(),
               Networking.fetchURL(
                   "yuyueguahao", Profile.instance().region.id, Me.instance.token));
         }
       });
   lp = (LinearLayout.LayoutParams) viewEntry6.getLayoutParams();
   lp.width = metrics.widthPixels / 4;
   viewEntry6.setLayoutParams(lp);
   viewEntry6.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent =
               new Intent(HomeActivity.this.getActivity(), SelfDiagnosticActivity.class);
           HomeActivity.this.startActivity(intent);
         }
       });
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details_match);

    initialize();

    Intent i = getIntent();
    if (i.hasExtra("ONE_MATCH")) {
      MatchEntity oneMatch = (MatchEntity) i.getSerializableExtra("ONE_MATCH");

      queue = MySingleton.getInstance(this).getRequestQueue();
      request = new ApiRequest(queue, this);
      if (oneMatch.isWinner()) {
        rlInfosJoueur.setBackgroundColor(getResources().getColor(R.color.win_row_bg));
      } else {
        rlInfosJoueur.setBackgroundColor(getResources().getColor(R.color.lose_row_bg));
      }

      Picasso.with(this)
          .load(
              "http://ddragon.leagueoflegends.com/cdn/5.16.1/img/champion/"
                  + oneMatch.getChampName())
          .into(portrait);
      if (oneMatch.getSum1().equals("Default")) {
        Picasso.with(this).load(R.drawable.empty).into(sum1);
      } else {
        Picasso.with(this)
            .load("http://ddragon.leagueoflegends.com/cdn/5.16.1/img/spell/" + oneMatch.getSum1())
            .into(sum1);
      }
      if (oneMatch.getSum2().equals("Default")) {
        Picasso.with(this).load(R.drawable.empty).into(sum2);
      } else {
        Picasso.with(this)
            .load("http://ddragon.leagueoflegends.com/cdn/5.16.1/img/spell/" + oneMatch.getSum2())
            .into(sum2);
      }

      // Rajout des items

      Helper.setImageItems(this, oneMatch.getItems()[0], item1);
      Helper.setImageItems(this, oneMatch.getItems()[1], item2);
      Helper.setImageItems(this, oneMatch.getItems()[2], item3);
      Helper.setImageItems(this, oneMatch.getItems()[3], item4);
      Helper.setImageItems(this, oneMatch.getItems()[4], item5);
      Helper.setImageItems(this, oneMatch.getItems()[5], item6);
      Helper.setImageItems(this, oneMatch.getItems()[6], item7);

      // Rajout des infos
      typeMatch.setText(oneMatch.getTypeMatch());
      level.setText("Level " + String.valueOf(oneMatch.getChampLevel()));
      gold.setText(String.valueOf(Math.round(oneMatch.getGold() / 1000.0)) + "K");
      cs.setText(String.valueOf(oneMatch.getCs()));
      kda.setText(oneMatch.getKills() + "/" + oneMatch.getDeaths() + "/" + oneMatch.getAssists());
      duration.setText(Helper.convertDuration(oneMatch.getMatchDuration()));
      creation.setText(Helper.convertDate(oneMatch.getMatchCreation()));

      // Rajout des Vainqueurs
      float density = getResources().getDisplayMetrics().density;
      int size = (int) (70 * density);

      Helper.setImagePortraits(this, oneMatch.getTeamWinner().get(0), vainqueur1, request);
      Helper.setImagePortraits(this, oneMatch.getTeamWinner().get(1), vainqueur2, request);
      Helper.setImagePortraits(this, oneMatch.getTeamWinner().get(2), vainqueur3, request);
      Helper.setImagePortraits(this, oneMatch.getTeamWinner().get(3), vainqueur4, request);

      if (oneMatch.getChampId() == oneMatch.getTeamWinner().get(4) && oneMatch.isWinner() == true) {
        vainqueur5.getLayoutParams().height = size;
        vainqueur5.getLayoutParams().width = size;
      }
      Helper.setImagePortraits(this, oneMatch.getTeamWinner().get(4), vainqueur5, request);

      // Rajout des perdants

      if (oneMatch.getTeamLoser().size()
          > 0) { // Si c'est un match contre l'ordinateur cette liste sera vide. On fait donc une
                 // vérification
        Helper.setImagePortraits(this, oneMatch.getTeamLoser().get(0), perdant1, request);
        Helper.setImagePortraits(this, oneMatch.getTeamLoser().get(1), perdant2, request);
        Helper.setImagePortraits(this, oneMatch.getTeamLoser().get(2), perdant3, request);
        Helper.setImagePortraits(this, oneMatch.getTeamLoser().get(3), perdant4, request);

        if (oneMatch.getChampId() == oneMatch.getTeamLoser().get(4)
            && oneMatch.isWinner() == false) {
          perdant5.getLayoutParams().height = size;
          perdant5.getLayoutParams().width = size;
        }
        Helper.setImagePortraits(this, oneMatch.getTeamLoser().get(4), perdant5, request);
      }
      // Affichage des statistiques

      Iterator iterator = oneMatch.getStats().entrySet().iterator();
      while (iterator.hasNext()) {

        HashMap.Entry key = (HashMap.Entry) iterator.next();

        TableRow row = new TableRow(this);
        TextView tv_key = new TextView(this);
        tv_key.setTextSize(15);
        TextView tv_value = new TextView(this);
        tv_value.setTextSize(15);
        row.addView(tv_key);
        row.addView(tv_value);

        LinearLayout.LayoutParams key_params = (LinearLayout.LayoutParams) tv_key.getLayoutParams();
        key_params.width = 0;
        key_params.weight = 1;
        key_params.height = (int) (20 * density);
        tv_key.setLayoutParams(key_params);

        LinearLayout.LayoutParams value_params =
            (LinearLayout.LayoutParams) tv_value.getLayoutParams();
        value_params.gravity = Gravity.RIGHT;
        value_params.height = (int) (20 * density);
        tv_value.setLayoutParams(value_params);

        tv_key.setText(key.getKey().toString());
        tv_value.setText(key.getValue().toString());

        statistiques.addView(
            row,
            new TableLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      }
    }
  }
Exemple #24
0
  private void createUI_OldStyle() {
    int panelWidth = LayoutUtil.getNavigationPanelWidth();
    this.setBackgroundResource(R.drawable.stone_narrow_bg);
    RelativeLayout.LayoutParams navigationBarLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);

    navigationBarLP.width = LayoutUtil.getNavigationPanelWidth();

    this.setLayoutParams(navigationBarLP);

    View logoView = new View(mContext);
    logoView.setBackgroundResource(R.drawable.logo);
    LinearLayout.LayoutParams logoLP =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    logoLP.width = LayoutUtil.getNavigationPanelWidth();
    logoLP.height = LayoutUtil.getNavigationPanelWidth();

    this.addView(logoView, logoLP);

    this.addView(
        ControlFactory.createHoriSeparatorForRelativeLayout(mContext, panelWidth, logoLP.height));

    // Create buttons
    // Sign up
    mSignUpBtn = new HaloButton(mContext, R.drawable.register);
    mSignUpBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            HomeActivity.getApp().toggleSignUpPanel(true);
          }
        });

    RelativeLayout.LayoutParams regBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    int y = logoLP.height + DensityAdaptor.getDensityIndependentValue(10);
    int buttonGap = DensityAdaptor.getDensityIndependentValue(34);
    regBtnLP.topMargin = y;
    regBtnLP.addRule(RelativeLayout.CENTER_HORIZONTAL);
    this.addView(mSignUpBtn, regBtnLP);

    this.addView(
        ControlFactory.createHoriSeparatorForRelativeLayout(
            mContext, panelWidth, y + regBtnLP.height + buttonGap));

    // Login
    mLoginBtn = new HaloButton(mContext, R.drawable.login);
    mLoginBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            LoginDialog loginDialog = new LoginDialog(v.getContext());
            loginDialog.show();
          }
        });
    RelativeLayout.LayoutParams loginBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    y += buttonGap + DensityAdaptor.getDensityIndependentValue(8);
    loginBtnLP.topMargin = y;
    loginBtnLP.addRule(RelativeLayout.CENTER_HORIZONTAL);
    this.addView(mLoginBtn, loginBtnLP);

    this.addView(
        ControlFactory.createHoriSeparatorForRelativeLayout(
            mContext, panelWidth, y + loginBtnLP.height + buttonGap));

    if (AppConfig.isDebugMode) {
      HaloButton testTokenBtn = new HaloButton(mContext, R.drawable.test);
      testTokenBtn.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              String testToken = "7a3cf000-0662-715b-a6a8-89feb8466014";
              CloudUtility.setAccessToken(testToken);
              CloudAPI.getLoggedInUserInfo(
                  v.getContext(),
                  new ICloudAPITaskListener() {

                    @Override
                    public void onFinish(int returnCode) {
                      doAfterGetUserInfoByToken(returnCode);
                    }
                  });
            }
          });
      RelativeLayout.LayoutParams testTokenBtnLP =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      y += buttonGap + DensityAdaptor.getDensityIndependentValue(8);
      testTokenBtnLP.topMargin = y;
      testTokenBtnLP.addRule(RelativeLayout.CENTER_HORIZONTAL);
      this.addView(testTokenBtn, testTokenBtnLP);

      this.addView(
          ControlFactory.createHoriSeparatorForRelativeLayout(
              mContext, panelWidth, y + loginBtnLP.height + buttonGap));
    }
  }
  @Override
  public View createView(Context context, LayoutInflater inflater) {
    searching = false;
    searchWas = false;

    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Language", R.string.Language));

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            }
          }
        });

    ActionBarMenu menu = actionBar.createMenu();
    ActionBarMenuItem item =
        menu.addItem(0, R.drawable.ic_ab_search)
            .setIsSearchField(true)
            .setActionBarMenuItemSearchListener(
                new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
                  @Override
                  public void onSearchExpand() {
                    searching = true;
                  }

                  @Override
                  public void onSearchCollapse() {
                    search(null);
                    searching = false;
                    searchWas = false;
                    if (listView != null) {
                      emptyTextView.setVisibility(View.GONE);
                      listView.setAdapter(listAdapter);
                    }
                  }

                  @Override
                  public void onTextChanged(EditText editText) {
                    String text = editText.getText().toString();
                    search(text);
                    if (text.length() != 0) {
                      searchWas = true;
                      if (listView != null) {
                        listView.setAdapter(searchListViewAdapter);
                      }
                    }
                  }
                });
    item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));

    listAdapter = new ListAdapter(context);
    searchListViewAdapter = new SearchAdapter(context);

    fragmentView = new FrameLayout(context);

    LinearLayout emptyTextLayout = new LinearLayout(context);
    emptyTextLayout.setVisibility(View.INVISIBLE);
    emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
    ((FrameLayout) fragmentView).addView(emptyTextLayout);
    FrameLayout.LayoutParams layoutParams =
        (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    emptyTextLayout.setLayoutParams(layoutParams);
    emptyTextLayout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    emptyTextView = new TextView(context);
    emptyTextView.setTextColor(0xff808080);
    emptyTextView.setTextSize(20);
    emptyTextView.setGravity(Gravity.CENTER);
    emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
    emptyTextLayout.addView(emptyTextView);
    LinearLayout.LayoutParams layoutParams1 =
        (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
    layoutParams1.width = LayoutHelper.MATCH_PARENT;
    layoutParams1.height = LayoutHelper.MATCH_PARENT;
    layoutParams1.weight = 0.5f;
    emptyTextView.setLayoutParams(layoutParams1);

    FrameLayout frameLayout = new FrameLayout(context);
    emptyTextLayout.addView(frameLayout);
    layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
    layoutParams1.width = LayoutHelper.MATCH_PARENT;
    layoutParams1.height = LayoutHelper.MATCH_PARENT;
    layoutParams1.weight = 0.5f;
    frameLayout.setLayoutParams(layoutParams1);

    listView = new ListView(context);
    listView.setEmptyView(emptyTextLayout);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setAdapter(listAdapter);
    ((FrameLayout) fragmentView).addView(listView);
    layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    listView.setLayoutParams(layoutParams);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            LocaleController.LocaleInfo localeInfo = null;
            if (searching && searchWas) {
              if (i >= 0 && i < searchResult.size()) {
                localeInfo = searchResult.get(i);
              }
            } else {
              if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
                localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
              }
            }
            if (localeInfo != null) {
              LocaleController.getInstance().applyLanguage(localeInfo, true);
              parentLayout.rebuildAllFragmentViews(false);
            }
            finishFragment();
          }
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            LocaleController.LocaleInfo localeInfo = null;
            if (searching && searchWas) {
              if (i >= 0 && i < searchResult.size()) {
                localeInfo = searchResult.get(i);
              }
            } else {
              if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
                localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
              }
            }
            if (localeInfo == null
                || localeInfo.pathToFile == null
                || getParentActivity() == null) {
              return false;
            }
            final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setMessage(
                LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setPositiveButton(
                LocaleController.getString("Delete", R.string.Delete),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) {
                      if (searchResult != null) {
                        searchResult.remove(finalLocaleInfo);
                      }
                      if (listAdapter != null) {
                        listAdapter.notifyDataSetChanged();
                      }
                      if (searchListViewAdapter != null) {
                        searchListViewAdapter.notifyDataSetChanged();
                      }
                    }
                  }
                });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return true;
          }
        });

    listView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView absListView, int i) {
            if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
              AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
          }

          @Override
          public void onScroll(
              AbsListView absListView,
              int firstVisibleItem,
              int visibleItemCount,
              int totalItemCount) {}
        });

    return fragmentView;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    faceGridViewList = new ArrayList<View>();
    pointViews = new ArrayList<ImageView>();

    View rootView = inflater.inflate(R.layout.face_fragment, null);
    faceViewPager = (ViewPager) rootView.findViewById(R.id.faceViewPager);
    pagePointLayout = (LinearLayout) rootView.findViewById(R.id.pagePointLayout);

    for (int x = 0; x < (data.size() % 12 == 0 ? data.size() / 12 : (data.size() / 12) + 1); x++) {
      GridView view = new GridView(activity);
      final List<String> tempData =
          data.subList(x * 12, ((x + 1) * 12) > data.size() ? data.size() : ((x + 1) * 12));
      FaceAdapter faceAdapter = new FaceAdapter(activity, tempData);
      view.setAdapter(faceAdapter);

      view.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              if (onOperationListener != null) {
                onOperationListener.selectedFace(tempData.get(position));
              }
            }
          });
      view.setNumColumns(4);

      view.setBackgroundColor(Color.TRANSPARENT);
      view.setHorizontalSpacing(1);
      view.setVerticalSpacing(1);
      view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
      view.setCacheColorHint(0);
      view.setPadding(5, 0, 5, 0);
      view.setSelector(new ColorDrawable(Color.TRANSPARENT));
      view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
      view.setGravity(Gravity.CENTER);

      faceGridViewList.add(view);

      ImageView imageView = new ImageView(activity);
      imageView.setBackgroundResource(R.drawable.point_normal);
      LinearLayout.LayoutParams layoutParams =
          new LinearLayout.LayoutParams(
              new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      layoutParams.leftMargin = 10;
      layoutParams.rightMargin = 10;
      layoutParams.width = 8;
      layoutParams.height = 8;
      pagePointLayout.addView(imageView, layoutParams);
      if (x == 0) {
        imageView.setBackgroundResource(R.drawable.point_selected);
      }
      pointViews.add(imageView);
    }

    PagerAdapter facePagerAdapter = new FacePagerAdapter(faceGridViewList);
    faceViewPager.setAdapter(facePagerAdapter);
    faceViewPager.addOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageSelected(int index) {

            for (int i = 0; i < pointViews.size(); i++) {
              if (index == i) {
                pointViews.get(i).setBackgroundResource(R.drawable.point_selected);
              } else {
                pointViews.get(i).setBackgroundResource(R.drawable.point_normal);
              }
            }
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });

    return rootView;
  }
  /**
   * Add all camera views to the main grid page
   *
   * @param reloadImages reload camera images or not
   * @param showThumbnails show thumbnails that returned by Evercam or not, if true and if thumbnail
   *     not available, it will request latest snapshot instead. If false, it will request neither
   *     thumbnail nor latest snapshot.
   */
  public boolean addAllCameraViews(final boolean reloadImages, final boolean showThumbnails) {
    try {
      // Recalculate camera per row
      camerasPerRow = recalculateCameraPerRow();

      io.evercam.androidapp.custom.FlowLayout camsLineView =
          (io.evercam.androidapp.custom.FlowLayout) this.findViewById(R.id.cameras_flow_layout);

      int screen_width = readScreenWidth(this);

      int index = 0;

      for (final EvercamCamera evercamCamera : AppData.evercamCameraList) {
        // Don't show offline camera
        if (!PrefsManager.showOfflineCameras(this) && !evercamCamera.isActive()) {
          continue;
        }

        final LinearLayout cameraListLayout = new LinearLayout(this);

        int indexPlus = index + 1;

        if (reloadImages) evercamCamera.loadingStatus = ImageLoadingStatus.not_started;

        final CameraLayout cameraLayout = new CameraLayout(this, evercamCamera, showThumbnails);

        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        params.width =
            ((indexPlus % camerasPerRow == 0)
                ? (screen_width - (index % 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(0, 0, 0, 0); // No spacing between cameras
        cameraLayout.setLayoutParams(params);

        cameraListLayout.addView(cameraLayout);

        camsLineView.addView(
            cameraListLayout, new io.evercam.androidapp.custom.FlowLayout.LayoutParams(0, 0));

        index++;

        new Handler()
            .postDelayed(
                new Runnable() {
                  @Override
                  public void run() {

                    Rect cameraBounds = new Rect();
                    cameraListLayout.getHitRect(cameraBounds);

                    Rect offlineIconBounds = cameraLayout.getOfflineIconBounds();
                    int layoutWidth = cameraBounds.right - cameraBounds.left;
                    int offlineStartsAt = offlineIconBounds.left;
                    int offlineIconWidth = offlineIconBounds.right - offlineIconBounds.left;

                    if (layoutWidth > offlineStartsAt + offlineIconWidth * 2) {
                      cameraLayout.showOfflineIconAsFloat = false;
                    } else {
                      cameraLayout.showOfflineIconAsFloat = true;
                    }
                  }
                },
                200);
      }

      if (refresh != null) refresh.setActionView(null);

      return true;
    } catch (Exception e) {
      Log.e(TAG, e.toString(), e);

      sendToMint(e);

      EvercamPlayApplication.sendCaughtException(this, e);
      CustomedDialog.showUnexpectedErrorDialog(CamerasActivity.this);
    }
    return false;
  }
  public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder2 holder;
    WindowManager mWinMgr = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    deviceHeight = mWinMgr.getDefaultDisplay().getHeight();
    deviceWidth = mWinMgr.getDefaultDisplay().getWidth();

    if (convertView == null) {
      holder = new ViewHolder2();

      convertView = mInflater.inflate(R.layout.picturecategory, null);
      try {
        int buttonwidth = (int) (deviceWidth * .48);
        int imagewidth = (int) (deviceWidth * .48);
        int imageHeight = (int) (deviceWidth * .48f * .75f);

        holder.ButtonGrid = (FrameLayout) convertView.findViewById(R.id.ButtonGrid);
        LinearLayout.LayoutParams params_ButtonGrid =
            (LinearLayout.LayoutParams) holder.ButtonGrid.getLayoutParams();
        params_ButtonGrid =
            new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                Gravity.TOP | Gravity.LEFT);
        params_ButtonGrid.width = buttonwidth;
        params_ButtonGrid.height = (int) (.9f * buttonwidth);
        params_ButtonGrid.leftMargin = (int) (0.02 * deviceWidth);
        params_ButtonGrid.rightMargin = (int) (0.02 * deviceWidth);
        holder.ButtonGrid.setLayoutParams(params_ButtonGrid);

        LinearLayout.LayoutParams marginparam_ButtonGrid =
            (LinearLayout.LayoutParams) holder.ButtonGrid.getLayoutParams();
        marginparam_ButtonGrid.topMargin = (int) (.02f * deviceHeight);

        holder.ButtonGV = (ImageView) convertView.findViewById(R.id.ButtonGV);
        ViewGroup.LayoutParams params_ButtonGV = holder.ButtonGV.getLayoutParams();
        params_ButtonGV.width = buttonwidth;
        params_ButtonGV.height = (int) (.9f * buttonwidth);
        holder.ButtonGV.setLayoutParams(params_ButtonGV);

        holder.THImage = (ImageView) convertView.findViewById(R.id.THImage);
        FrameLayout.LayoutParams params_THImage =
            (FrameLayout.LayoutParams) holder.THImage.getLayoutParams();
        params_THImage.width = imagewidth;
        params_THImage.height = (int) (.65 * .9f * buttonwidth);
        params_THImage.topMargin = (int) (deviceHeight * .025f);
        holder.THImage.setLayoutParams(params_THImage);

        holder.GridButtonTV = (TextView) convertView.findViewById(R.id.GridButtonTV);
        ViewGroup.LayoutParams params_GridButtonTV = holder.GridButtonTV.getLayoutParams();
        params_GridButtonTV.height = (int) (.3 * .9f * buttonwidth);
        holder.GridButtonTV.setPadding(0, (int) (.05 * .9f * buttonwidth), 0, 0);
        holder.GridButtonTV.setLayoutParams(params_GridButtonTV);
      } catch (Exception e) {
        System.out.println("Exception in Grid Item's Width Please Define the Width" + e);

        holder.ButtonGrid = (FrameLayout) convertView.findViewById(R.id.ButtonGrid);
        ViewGroup.LayoutParams params_ButtonGrid = holder.ButtonGrid.getLayoutParams();
        int buttonwidth = (int) (.2f * deviceWidth);
        params_ButtonGrid.width = buttonwidth;
        params_ButtonGrid.height = (int) (1.07f * buttonwidth);
        holder.ButtonGrid.setLayoutParams(params_ButtonGrid);

        LinearLayout.LayoutParams marginparam_ButtonGrid =
            (LinearLayout.LayoutParams) holder.ButtonGrid.getLayoutParams();
        //				marginparam_ButtonGrid.leftMargin = (int)(.025f*deviceWidth);
        marginparam_ButtonGrid.topMargin = (int) (.025f * deviceHeight);

        holder.ButtonGV = (ImageView) convertView.findViewById(R.id.ButtonGV);
        ViewGroup.LayoutParams params_ButtonGV = holder.ButtonGV.getLayoutParams();
        params_ButtonGV.width = buttonwidth;
        params_ButtonGV.height = (int) (.6f * buttonwidth);
        holder.ButtonGV.setLayoutParams(params_ButtonGV);

        holder.GridButtonTV = (TextView) convertView.findViewById(R.id.GridButtonTV);
        ViewGroup.LayoutParams params_GridButtonTV = holder.GridButtonTV.getLayoutParams();
        params_GridButtonTV.height = (int) (.0725f * deviceHeight);
        holder.GridButtonTV.setLayoutParams(params_GridButtonTV);
      }

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder2) convertView.getTag();
    }

    holder.ButtonGrid.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                //					holder.THImage.getBackground().setAlpha(150);
                try {
                  holder.THImage.setAlpha(100);
                } catch (Exception e) {
                  // TODO: handle exception
                }
                //		        	holder.GridButtonTV.getBackground().setAlpha(150);
                //					return false;
                return true;
              case MotionEvent.ACTION_UP:
                //					holder.THImage.getBackground().setAlpha(255);
                try {
                  holder.THImage.setAlpha(255);
                } catch (Exception e) {
                  // TODO: handle exception
                }
                //					String
                // screenNumber=MyUIApplication._objEWList.get(position).OnClick.substring(12);
                //					String mailto=MyUIApplication._objEWList.get(position).mailto;
                //					String body=MyUIApplication._objEWList.get(position).body;
                //					String subject=MyUIApplication._objEWList.get(position).subject;

                //					if(screenNumber.equals("1"))   //  "1" For Mail
                //					{
                //						UtilMail mail = new UtilMail();
                //						mail.OpenMail(mContext ,mailto ,body,subject);
                //					}
                //					else
                //					{
                //					if(((Home)mContext).LLLayout.getVisibility()==View.VISIBLE)
                //					{
                //
                //	((Home)mContext).LLLayoutCopy.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.slide_in_left));
                //
                //	((Home)mContext).LLLayout.startAnimation(AnimationUtils.loadAnimation(mContext,
                // R.anim.slide_out_left));
                //					}
                //					if(((Home)mContext).LLLayoutCopy.getVisibility()==View.VISIBLE)
                //					{
                //
                //	((Home)mContext).LLLayout.startAnimation(AnimationUtils.loadAnimation(mContext,
                // R.anim.slide_in_left));
                //
                //	((Home)mContext).LLLayoutCopy.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.slide_out_left));
                //					}

                try {
                  ((Home) mContext).inLayoutAnim();
                } catch (Exception e) {
                  // TODO: handle exception
                }

                MyUIApplication.CatagoryCode =
                    MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryCode;
                MyUIApplication.CatagoryName =
                    MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryName;

                //					if(ScreenNumberr.equals("100"))
                //					{
                //
                //	((Home)mContext).OpenHtmlPage("11",MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryCode);
                //						MyUIApplication.StateMachine.add("11");
                //					}
                //					else if(ScreenNumberr.equals("101"))
                //					{
                //
                //	((Home)mContext).OpenHtmlPage("115",MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryCode);
                //						MyUIApplication.StateMachine.add("115");
                //					}

                ((Home) mContext)
                    .OpenHtmlPage(
                        ScreenNumberr,
                        MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryName);
                MyUIApplication.StateMachine.add(ScreenNumberr);

                int i = MyUIApplication.StateMachine.size();
                System.out.println("State Machine Size >>>" + i);
                //					}

                break;
              case MotionEvent.ACTION_CANCEL:
                //					holder.THImage.getBackground().setAlpha(255);
                try {
                  holder.THImage.setAlpha(255);
                } catch (Exception e) {
                  // TODO: handle exception
                }
                break;
            }

            return false;
          }
        });
    try {

      int buttonwidth = (int) (.48f * deviceWidth);
      int imagewidth = (int) (.48f * deviceWidth);
      //			int imagewidth=(int)(deviceWidth* .25f);
      int imageHeight = (int) (deviceWidth * .48f * .65f);

      try {

        String root = Environment.getExternalStorageDirectory().toString();
        String imagepath =
            MyUIApplication.mainDirectoryName
                + "/"
                + MyUIApplication.ClientCode
                + "/"
                + MyUIApplication.EventCode
                + "/PictureGalleryCategory/"
                + MyUIApplication.PictureGaleryCategoryList.get(position).Image;
        File myDir = new File(root + "/" + imagepath);
        if (myDir.exists()) {
          Bitmap bmp =
              ImageUtil.setBgFromSDCardForOtherDirectoy(
                  holder.THImage,
                  (Home) mContext,
                  imagepath,
                  (int) (imageHeight),
                  (int) (imagewidth));
          if (bmp != null) {
            holder.THImage.setImageBitmap(bmp);
            holder.THImage.setBackgroundDrawable(null);
          }
        }
      } catch (Exception e) {
        // TODO: handle exception
        String filePath = "images/folder.png";
        ImageUtil.setBackgroundBgFromAssetsNotCache(
            holder.ButtonGV,
            (Home) mContext,
            filePath,
            (int) (buttonwidth * .6f),
            (int) (buttonwidth));
      }

      String s = MyUIApplication.PictureGaleryCategoryList.get(position).ImageCount.trim();
      holder.GridButtonTV.setText(
          MyUIApplication.PictureGaleryCategoryList.get(position).CatagoryName.trim()
              + " ("
              + s
              + ")");

    } catch (Exception e) {

    }

    try {
      Typeface tf = MyUIApplication.fontmap.get(_objElement.fontStyle);
      holder.GridButtonTV.setTypeface(tf);
    } catch (Exception e) {
      // TODO: handle exception
    }

    try {
      holder.GridButtonTV.setTextColor(Color.parseColor(_objElement.fontColor));
      int i = Integer.parseInt(_objElement.fontSize);
      float testsizepercent = i / 960f;
      holder.GridButtonTV.setTextSize(
          TypedValue.COMPLEX_UNIT_PX,
          MyUIApplication.determineTextSize(
              holder.GridButtonTV.getTypeface(), (testsizepercent * deviceHeight)));
    } catch (Exception e) {
      // TODO: handle exception
      holder.GridButtonTV.setTextSize(
          TypedValue.COMPLEX_UNIT_PX,
          MyUIApplication.determineTextSize(
              holder.GridButtonTV.getTypeface(), (0.1f) * (.4f * deviceHeight)));
    }

    try {
      if (_objElement.TitleGravity.equalsIgnoreCase("center"))
        holder.GridButtonTV.setGravity(Gravity.CENTER);
      if (_objElement.TitleGravity.equalsIgnoreCase("right"))
        holder.GridButtonTV.setGravity(Gravity.RIGHT);
      if (_objElement.TitleGravity.equalsIgnoreCase("left"))
        holder.GridButtonTV.setGravity(Gravity.LEFT);
    } catch (Exception e) {
      // TODO: handle exception
      holder.GridButtonTV.setGravity(Gravity.CENTER);
    }

    try {
      holder.ButtonGV.setBackgroundColor(Color.parseColor(_objElement.bgcolor));
    } catch (Exception e) {
      // TODO: handle exception
      holder.ButtonGV.setBackgroundColor(Color.WHITE);
    }

    // Display planet data
    holder.id = position;
    return convertView;
  }
  @Override
  public View createView(Context context) {
    if (!receiverRegistered) {
      receiverRegistered = true;
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
      filter.addAction(Intent.ACTION_MEDIA_CHECKING);
      filter.addAction(Intent.ACTION_MEDIA_EJECT);
      filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
      filter.addAction(Intent.ACTION_MEDIA_NOFS);
      filter.addAction(Intent.ACTION_MEDIA_REMOVED);
      filter.addAction(Intent.ACTION_MEDIA_SHARED);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
      filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
      filter.addDataScheme("file");
      ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
    }

    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            } else if (id == -2) {
              selectedFiles.clear();
              actionBar.hideActionMode();
              listView.invalidateViews();
            } else if (id == done) {
              if (delegate != null) {
                ArrayList<String> files = new ArrayList<>();
                files.addAll(selectedFiles.keySet());
                delegate.didSelectFiles(DocumentSelectActivity.this, files);
              }
            }
          }
        });
    selectedFiles.clear();
    actionModeViews.clear();

    final ActionBarMenu actionMode = actionBar.createActionMode();
    actionModeViews.add(
        actionMode.addItem(
            -2,
            R.drawable.ic_ab_back_grey,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    selectedMessagesCountTextView = new TextView(actionMode.getContext());
    selectedMessagesCountTextView.setTextSize(18);
    selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    selectedMessagesCountTextView.setTextColor(0xff737373);
    selectedMessagesCountTextView.setSingleLine(true);
    selectedMessagesCountTextView.setLines(1);
    selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
    selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
    selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
    selectedMessagesCountTextView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    actionMode.addView(selectedMessagesCountTextView);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
    layoutParams.weight = 1;
    layoutParams.width = 0;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    selectedMessagesCountTextView.setLayoutParams(layoutParams);

    actionModeViews.add(
        actionMode.addItem(
            done,
            R.drawable.ic_ab_done_gray,
            R.drawable.bar_selector_mode,
            null,
            AndroidUtilities.dp(54)));

    fragmentView =
        getParentActivity()
            .getLayoutInflater()
            .inflate(R.layout.document_select_layout, null, false);
    listAdapter = new ListAdapter(context);
    emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    listView = (ListView) fragmentView.findViewById(R.id.listView);
    listView.setEmptyView(emptyView);
    listView.setAdapter(listAdapter);

    listView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            scrolling = scrollState != SCROLL_STATE_IDLE;
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int i, long id) {
            if (actionBar.isActionModeShowed() || i < 0 || i >= items.size()) {
              return false;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file != null && !file.isDirectory()) {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                return false;
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return false;
                }
              }
              if (file.length() == 0) {
                return false;
              }
              selectedFiles.put(file.toString(), item);
              selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
              if (Build.VERSION.SDK_INT >= 11) {
                AnimatorSetProxy animatorSet = new AnimatorSetProxy();
                ArrayList<Object> animators = new ArrayList<>();
                for (int a = 0; a < actionModeViews.size(); a++) {
                  View view2 = actionModeViews.get(a);
                  AndroidUtilities.clearDrawableAnimation(view2);
                  if (a < 1) {
                    animators.add(
                        ObjectAnimatorProxy.ofFloat(
                            view2, "translationX", -AndroidUtilities.dp(56), 0));
                  } else {
                    animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f));
                  }
                }
                animatorSet.playTogether(animators);
                animatorSet.setDuration(250);
                animatorSet.start();
              }
              scrolling = false;
              if (view instanceof SharedDocumentCell) {
                ((SharedDocumentCell) view).setChecked(true, true);
              }
              actionBar.showActionMode();
            }
            return true;
          }
        });

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i < 0 || i >= items.size()) {
              return;
            }
            ListItem item = items.get(i);
            File file = item.file;
            if (file == null) {
              if (item.icon == R.drawable.ic_storage_gallery) {
                if (delegate != null) {
                  delegate.startDocumentSelectActivity();
                }
                finishFragment(false);
              } else {
                HistoryEntry he = history.remove(history.size() - 1);
                actionBar.setTitle(he.title);
                if (he.dir != null) {
                  listFiles(he.dir);
                } else {
                  listRoots();
                }
                listView.setSelectionFromTop(he.scrollItem, he.scrollOffset);
              }
            } else if (file.isDirectory()) {
              HistoryEntry he = new HistoryEntry();
              he.scrollItem = listView.getFirstVisiblePosition();
              he.scrollOffset = listView.getChildAt(0).getTop();
              he.dir = currentDir;
              he.title = actionBar.getTitle();
              history.add(he);
              if (!listFiles(file)) {
                history.remove(he);
                return;
              }
              actionBar.setTitle(item.title);
              listView.setSelection(0);
            } else {
              if (!file.canRead()) {
                showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
                file = new File("/mnt/sdcard");
              }
              if (sizeLimit != 0) {
                if (file.length() > sizeLimit) {
                  showErrorBox(
                      LocaleController.formatString(
                          "FileUploadLimit",
                          R.string.FileUploadLimit,
                          AndroidUtilities.formatFileSize(sizeLimit)));
                  return;
                }
              }
              if (file.length() == 0) {
                return;
              }
              if (actionBar.isActionModeShowed()) {
                if (selectedFiles.containsKey(file.toString())) {
                  selectedFiles.remove(file.toString());
                } else {
                  selectedFiles.put(file.toString(), item);
                }
                if (selectedFiles.isEmpty()) {
                  actionBar.hideActionMode();
                } else {
                  selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
                }
                scrolling = false;
                if (view instanceof SharedDocumentCell) {
                  ((SharedDocumentCell) view)
                      .setChecked(selectedFiles.containsKey(item.file.toString()), true);
                }
              } else {
                if (delegate != null) {
                  ArrayList<String> files = new ArrayList<>();
                  files.add(file.getAbsolutePath());
                  delegate.didSelectFiles(DocumentSelectActivity.this, files);
                }
              }
            }
          }
        });

    listRoots();

    return fragmentView;
  }
 private void updateButtonLayoutWidth() {
   // use our context to set a valid button width
   BUTTON_LAYOUT_PARAMS.width =
       mContext.getResources().getDisplayMetrics().widthPixels / LAYOUT_SCROLL_BUTTON_THRESHOLD;
 }