private void addIndicatorViews() {
    final Mode mode = getMode();

    if (mode.canPullDown() && null == mIndicatorIvTop) {
      // If the mode can pull down, and we don't have one set already
      mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_DOWN_TO_REFRESH);
      final FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding);
      params.gravity = Gravity.TOP | Gravity.RIGHT;
      mRefreshableViewHolder.addView(mIndicatorIvTop, params);

    } else if (!mode.canPullDown() && null != mIndicatorIvTop) {
      // If we can't pull down, but have a View then remove it
      mRefreshableViewHolder.removeView(mIndicatorIvTop);
      mIndicatorIvTop = null;
    }

    if (mode.canPullUp() && null == mIndicatorIvBottom) {
      // If the mode can pull down, and we don't have one set already
      mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_UP_TO_REFRESH);
      final FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding);
      params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
      mRefreshableViewHolder.addView(mIndicatorIvBottom, params);

    } else if (!mode.canPullUp() && null != mIndicatorIvBottom) {
      // If we can't pull down, but have a View then remove it
      mRefreshableViewHolder.removeView(mIndicatorIvBottom);
      mIndicatorIvBottom = null;
    }
  }
Beispiel #2
0
 public void setBadgeMargin(
     int leftDipMargin, int topDipMargin, int rightDipMargin, int bottomDipMargin) {
   FrameLayout.LayoutParams params = (LayoutParams) getLayoutParams();
   params.leftMargin = dip2Px(leftDipMargin);
   params.topMargin = dip2Px(topDipMargin);
   params.rightMargin = dip2Px(rightDipMargin);
   params.bottomMargin = dip2Px(bottomDipMargin);
   setLayoutParams(params);
 }
  private void addIndicatorViews() {
    Mode mode = getMode();
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();

    if (mode.showHeaderLoadingLayout() && null == mIndicatorIvTop) {
      // If the mode can pull down, and we don't have one set already
      mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_FROM_START);
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.rightMargin =
          getResources().getDimensionPixelSize(com.android.common.R.dimen.indicator_right_padding);
      params.gravity = Gravity.TOP | Gravity.RIGHT;
      refreshableViewWrapper.addView(mIndicatorIvTop, params);

    } else if (!mode.showHeaderLoadingLayout() && null != mIndicatorIvTop) {
      // If we can't pull down, but have a View then remove it
      refreshableViewWrapper.removeView(mIndicatorIvTop);
      mIndicatorIvTop = null;
    }

    if (mode.showFooterLoadingLayout() && null == mIndicatorIvBottom) {
      // If the mode can pull down, and we don't have one set already
      mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_FROM_END);
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.rightMargin =
          getResources().getDimensionPixelSize(com.android.common.R.dimen.indicator_right_padding);
      params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
      refreshableViewWrapper.addView(mIndicatorIvBottom, params);

    } else if (!mode.showFooterLoadingLayout() && null != mIndicatorIvBottom) {
      // If we can't pull down, but have a View then remove it
      refreshableViewWrapper.removeView(mIndicatorIvBottom);
      mIndicatorIvBottom = null;
    }
  }
 public static void resetFL(View... view) {
   float rote = Handler_System.getWidthRoate(ApplicationBean.getApplication().getMode_w());
   if (view == null || rote == 1) {
     return;
   }
   for (View view2 : view) {
     FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view2.getLayoutParams();
     layoutParams.leftMargin = (int) (layoutParams.leftMargin * rote);
     layoutParams.rightMargin = (int) (layoutParams.rightMargin * rote);
     layoutParams.topMargin = (int) (layoutParams.topMargin * rote);
     layoutParams.bottomMargin = (int) (layoutParams.bottomMargin * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
 private void init(Context context, AttributeSet attrs) {
   mListView = new ListView(context, attrs);
   mListView.setPadding(0, 0, 0, 0);
   FrameLayout.LayoutParams params =
       new FrameLayout.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
   params.bottomMargin = 0;
   params.topMargin = 0;
   params.leftMargin = 0;
   params.rightMargin = 0;
   mListView.setLayoutParams(params);
   mListView.setId(android.R.id.list);
   mListView.setOnScrollListener(mOnScrollListener);
   addView(mListView);
 }
  public void setVideoFullSize() {
    if (normalHeight == 0) return;
    FrameLayout.LayoutParams lp =
        (FrameLayout.LayoutParams)
            (nativeMode ? mVideoView.getLayoutParams() : mSurfaceView.getLayoutParams());
    lp.height = normalHeight;
    lp.width = normalWidth;
    if (nativeMode) {
      lp.rightMargin = 0;
      lp.bottomMargin = 0;
      mVideoView.setLayoutParams(lp);
      mVideoView.invalidate();
    } else mSurfaceView.setLayoutParams(lp);

    isContracted = false;
  }
  public void contractVideo(int height) {
    FrameLayout.LayoutParams lp =
        (FrameLayout.LayoutParams)
            (nativeMode ? mVideoView.getLayoutParams() : mSurfaceView.getLayoutParams());
    if (isContracted) return;

    Activity activity = TvApp.getApplication().getCurrentActivity();
    int sw = activity.getWindow().getDecorView().getWidth();
    int sh = activity.getWindow().getDecorView().getHeight();
    float ar = (float) sw / sh;
    lp.height = height;
    lp.width = (int) Math.ceil(height * ar);
    lp.rightMargin = ((lp.width - normalWidth) / 2) - 110;
    lp.bottomMargin = ((lp.height - normalHeight) / 2) - 50;

    if (nativeMode) {
      mVideoView.setLayoutParams(lp);
      mVideoView.invalidate();
    } else mSurfaceView.setLayoutParams(lp);

    isContracted = true;
  }
  public WebFrame(Activity context, boolean allowNavigation, boolean scroll, boolean showExit) {
    super(context);
    initCompatibility();
    mActivity = context;
    mWebView = new WebView(context);
    mWebView.setVerticalScrollBarEnabled(scroll);
    mWebView.setHorizontalScrollBarEnabled(scroll);
    mWebView.setBackgroundColor(Color.TRANSPARENT);
    setLayer(mWebView);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setPluginsEnabled(true);
    webSettings.setSupportZoom(enableZoom);
    webSettings.setBuiltInZoomControls(enableZoom);
    mWebViewClient = new WebViewClient(mActivity, allowNavigation);
    mWebView.setWebViewClient(mWebViewClient);

    final Activity localContext = context;
    if (showExit) {
      ImageView bg = new ImageView(context);
      bg.setBackgroundColor(Color.TRANSPARENT);
      addView(
          bg,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
      addView(
          mWebView,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
      mExitButton = new ImageView(context);
      mExitButton.setAdjustViewBounds(false);
      mExitButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              localContext.finish();
            }
          });
      int buttonSize =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
      mExitButton.setImageDrawable(
          ResourceManager.getStaticResource(
              context, ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID));
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(buttonSize, buttonSize, Gravity.TOP | Gravity.RIGHT);
      int margin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics());
      params.topMargin = margin;
      params.rightMargin = margin;
      addView(mExitButton, params);
    } else {
      addView(
          mWebView,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
    }
  }
Beispiel #9
0
  public DialogHolder(
      Context context, FrameLayout fl, final OnItemClickedListener<Dialog> onClickListener) {
    super(fl);

    this.context = context;

    final int paddingH = Screen.dp(11);
    final int paddingV = Screen.dp(9);

    pendingColor = context.getResources().getColor(R.color.chats_state_pending);
    sentColor = context.getResources().getColor(R.color.chats_state_sent);
    receivedColor = context.getResources().getColor(R.color.chats_state_delivered);
    readColor = context.getResources().getColor(R.color.chats_state_read);
    errorColor = context.getResources().getColor(R.color.chats_state_error);

    fl.setLayoutParams(
        new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(73)));
    fl.setBackgroundResource(R.drawable.selector_fill);

    avatar = new AvatarView(context);
    avatar.init(Screen.dp(52), 24);
    {
      FrameLayout.LayoutParams avatarLayoutParams =
          new FrameLayout.LayoutParams(Screen.dp(52), Screen.dp(52));
      avatarLayoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
      avatarLayoutParams.leftMargin = paddingH;
      avatar.setLayoutParams(avatarLayoutParams);
    }
    fl.addView(avatar);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.TOP);
    {
      FrameLayout.LayoutParams layoutParams =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      layoutParams.rightMargin = paddingH;
      layoutParams.leftMargin = Screen.dp(79);
      layoutParams.topMargin = paddingV;
      layoutParams.bottomMargin = paddingV;
      linearLayout.setLayoutParams(layoutParams);
    }

    LinearLayout firstRow = new LinearLayout(context);
    firstRow.setOrientation(LinearLayout.HORIZONTAL);
    {
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      firstRow.setLayoutParams(params);
    }

    title = new TextView(context);
    title.setTextColor(context.getResources().getColor(R.color.chats_title));
    title.setTypeface(Fonts.medium());
    title.setTextSize(17);
    title.setPadding(0, Screen.dp(1), 0, 0);
    title.setSingleLine();
    title.setCompoundDrawablePadding(Screen.dp(4));
    title.setEllipsize(TextUtils.TruncateAt.END);
    {
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.weight = 1;
      title.setLayoutParams(params);
    }
    firstRow.addView(title);

    time = new TextView(context);
    time.setTextColor(context.getResources().getColor(R.color.chats_time));
    time.setTypeface(Fonts.regular());
    time.setTextSize(13);
    time.setPadding(Screen.dp(6), 0, 0, 0);
    time.setSingleLine();
    firstRow.addView(time);

    linearLayout.addView(firstRow);

    text = new TextView(context);
    text.setTypeface(Fonts.regular());
    text.setTextColor(context.getResources().getColor(R.color.chats_text));
    text.setTextSize(15);
    text.setPadding(0, Screen.dp(5), Screen.dp(28), 0);
    text.setSingleLine();
    text.setEllipsize(TextUtils.TruncateAt.END);
    linearLayout.addView(text);

    fl.addView(linearLayout);

    separator = new View(context);
    separator.setBackgroundColor(context.getResources().getColor(R.color.chats_divider));
    FrameLayout.LayoutParams divLayoutParams =
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            context.getResources().getDimensionPixelSize(R.dimen.div_size));
    divLayoutParams.leftMargin = Screen.dp(76);
    divLayoutParams.gravity = Gravity.BOTTOM;
    fl.addView(separator, divLayoutParams);

    state = new TintImageView(context);
    {
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              Screen.dp(28), Screen.dp(12), Gravity.BOTTOM | Gravity.RIGHT);
      params.bottomMargin = Screen.dp(16);
      params.rightMargin = Screen.dp(9);
      state.setLayoutParams(params);
      fl.addView(state);
    }

    counter = new TextView(context);
    counter.setTextColor(context.getResources().getColor(R.color.chats_counter));
    counter.setBackgroundColor(context.getResources().getColor(R.color.chats_counter_bg));
    counter.setPadding(Screen.dp(4), 0, Screen.dp(4), 0);
    counter.setTextSize(10);
    counter.setTypeface(Fonts.regular());
    counter.setGravity(Gravity.CENTER);
    counter.setIncludeFontPadding(false);
    counter.setMinWidth(Screen.dp(14));
    {
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, Screen.dp(14), Gravity.BOTTOM | Gravity.RIGHT);
      params.bottomMargin = Screen.dp(12);
      params.rightMargin = Screen.dp(10);
      counter.setLayoutParams(params);
      fl.addView(counter);
    }

    fl.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (bindedItem != null) {
              onClickListener.onClicked(bindedItem);
            }
          }
        });
    fl.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (bindedItem != null) {
              return onClickListener.onLongClicked(bindedItem);
            }
            return false;
          }
        });
  }
Beispiel #10
0
  public void createControls() {
    // 1. Create view groups and controls
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));
    rightStack = new StackWidgetView(view.getContext());
    leftStack = new StackWidgetView(view.getContext());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);
    // for measurement
    statusBar.addView(backToLocation);
    STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
    statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Rect statusBarPadding = new Rect();
    statusBar.getBackground().getPadding(statusBarPadding);
    // 3. put into frame parent layout controls
    FrameLayout parent = (FrameLayout) view.getParent();
    // status bar hides own top part
    int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom;
    // we want that status bar lays over map stack controls
    topMargin -= topRectPadding.top;

    FrameLayout.LayoutParams flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    rightStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER_HORIZONTAL | Gravity.TOP);
    flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
    lanesControl.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    leftStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = -topRectPadding.top;
    statusBar.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            (int) (78 * scaleCoefficient),
            (int) (78 * scaleCoefficient),
            Gravity.RIGHT | Gravity.BOTTOM);
    flp.rightMargin = (int) (10 * scaleCoefficient);
    flp.bottomMargin = (int) (85 * scaleCoefficient);
    alarmControl.setLayoutParams(flp);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
    parent.addView(alarmControl);
    alarmControl.setVisibility(View.GONE);
    lanesControl.setVisibility(View.GONE);

    // update and create controls
    recreateControls();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    classGuid = ConnectionsManager.getInstance().generateClassGuid();
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    typingDotsDrawable = new TypingDotsDrawable();
    recordStatusDrawable = new RecordStatusDrawable();

    SizeNotifierRelativeLayout contentView = new SizeNotifierRelativeLayout(this);
    setContentView(contentView);
    contentView.setBackgroundColor(0x99000000);

    RelativeLayout relativeLayout = new RelativeLayout(this);
    contentView.addView(relativeLayout);
    RelativeLayout.LayoutParams layoutParams3 =
        (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.MATCH_PARENT;
    relativeLayout.setLayoutParams(layoutParams3);

    RelativeLayout popupContainer = new RelativeLayout(this);
    popupContainer.setBackgroundColor(0xffffffff);
    relativeLayout.addView(popupContainer);
    layoutParams3 = (RelativeLayout.LayoutParams) popupContainer.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = AndroidUtilities.dp(240);
    layoutParams3.leftMargin = AndroidUtilities.dp(12);
    layoutParams3.rightMargin = AndroidUtilities.dp(12);
    layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT);
    popupContainer.setLayoutParams(layoutParams3);

    if (chatActivityEnterView != null) {
      chatActivityEnterView.onDestroy();
    }
    chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
    popupContainer.addView(chatActivityEnterView);
    layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    chatActivityEnterView.setLayoutParams(layoutParams3);
    chatActivityEnterView.setDelegate(
        new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
          @Override
          public void onMessageSend(String message) {
            if (currentMessageObject == null) {
              return;
            }
            if (currentMessageNum >= 0
                && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
              NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
            }
            MessagesController.getInstance()
                .markDialogAsRead(
                    currentMessageObject.getDialogId(),
                    currentMessageObject.getId(),
                    Math.max(0, currentMessageObject.getId()),
                    0,
                    currentMessageObject.messageOwner.date,
                    true,
                    true);
            currentMessageObject = null;
            getNewMessage();
          }

          @Override
          public void onTextChanged(CharSequence text, boolean big) {}

          @Override
          public void needSendTyping() {
            if (currentMessageObject != null) {
              MessagesController.getInstance()
                  .sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
            }
          }

          @Override
          public void onAttachButtonHidden() {}

          @Override
          public void onAttachButtonShow() {}

          @Override
          public void onWindowSizeChanged(int size) {}
        });

    messageContainer = new FrameLayoutTouch(this);
    popupContainer.addView(messageContainer, 0);

    actionBar = new ActionBar(this);
    actionBar.setOccupyStatusBar(false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackgroundColor(0xff54759e);
    actionBar.setItemsBackground(R.drawable.bar_selector);
    popupContainer.addView(actionBar);
    ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    ActionBarMenu menu = actionBar.createMenu();
    View view = menu.addItemResource(2, R.layout.popup_count_layout);
    countText = (TextView) view.findViewById(R.id.count_text);

    avatarContainer = new FrameLayoutFixed(this);
    avatarContainer.setBackgroundResource(R.drawable.bar_selector);
    avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
    actionBar.addView(avatarContainer);
    FrameLayout.LayoutParams layoutParams2 =
        (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
    layoutParams2.height = LayoutHelper.MATCH_PARENT;
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.rightMargin = AndroidUtilities.dp(48);
    layoutParams2.leftMargin = AndroidUtilities.dp(60);
    layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
    avatarContainer.setLayoutParams(layoutParams2);

    avatarImageView = new BackupImageView(this);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    avatarContainer.addView(avatarImageView);
    layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
    layoutParams2.width = AndroidUtilities.dp(42);
    layoutParams2.height = AndroidUtilities.dp(42);
    layoutParams2.topMargin = AndroidUtilities.dp(3);
    avatarImageView.setLayoutParams(layoutParams2);

    nameTextView = new TextView(this);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    avatarContainer.addView(nameTextView);
    layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(22);
    layoutParams2.gravity = Gravity.BOTTOM;
    nameTextView.setLayoutParams(layoutParams2);

    onlineTextView = new TextView(this);
    onlineTextView.setTextColor(0xffd7e8f7);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setLines(1);
    onlineTextView.setMaxLines(1);
    onlineTextView.setSingleLine(true);
    onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
    onlineTextView.setGravity(Gravity.LEFT);
    avatarContainer.addView(onlineTextView);
    layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(4);
    layoutParams2.gravity = Gravity.BOTTOM;
    onlineTextView.setLayoutParams(layoutParams2);

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              onFinish();
              finish();
            } else if (id == 1) {
              openCurrentMessage();
            } else if (id == 2) {
              switchToNextMessage();
            }
          }
        });

    PowerManager pm =
        (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
    wakeLock =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
    wakeLock.setReferenceCounted(false);

    handleIntent(getIntent());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    classGuid = ConnectionsManager.getInstance().generateClassGuid();
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    typingDotsDrawable = new TypingDotsDrawable();
    recordStatusDrawable = new RecordStatusDrawable();

    SizeNotifierFrameLayout contentView =
        new SizeNotifierFrameLayout(this) {
          @Override
          protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthMode = MeasureSpec.getMode(widthMeasureSpec);
            int heightMode = MeasureSpec.getMode(heightMeasureSpec);
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);

            setMeasuredDimension(widthSize, heightSize);

            int keyboardSize = getKeyboardHeight();

            if (keyboardSize <= AndroidUtilities.dp(20)) {
              heightSize -= chatActivityEnterView.getEmojiPadding();
            }

            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
              View child = getChildAt(i);
              if (child.getVisibility() == GONE) {
                continue;
              }
              if (chatActivityEnterView.isPopupView(child)) {
                child.measure(
                    MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(
                        child.getLayoutParams().height, MeasureSpec.EXACTLY));
              } else {
                child.measure(
                    MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(
                        Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)),
                        MeasureSpec.EXACTLY));
              }
            }
          }

          @Override
          protected void onLayout(boolean changed, int l, int t, int r, int b) {
            final int count = getChildCount();

            int paddingBottom =
                getKeyboardHeight() <= AndroidUtilities.dp(20)
                    ? chatActivityEnterView.getEmojiPadding()
                    : 0;

            for (int i = 0; i < count; i++) {
              final View child = getChildAt(i);
              if (child.getVisibility() == GONE) {
                continue;
              }
              final LayoutParams lp = (LayoutParams) child.getLayoutParams();

              int width = child.getMeasuredWidth();
              int height = child.getMeasuredHeight();

              int childLeft;
              int childTop;

              int gravity = lp.gravity;
              if (gravity == -1) {
                gravity = Gravity.TOP | Gravity.LEFT;
              }

              final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
              final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

              switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.CENTER_HORIZONTAL:
                  childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
                  break;
                case Gravity.RIGHT:
                  childLeft = r - width - lp.rightMargin;
                  break;
                case Gravity.LEFT:
                default:
                  childLeft = lp.leftMargin;
              }

              switch (verticalGravity) {
                case Gravity.TOP:
                  childTop = lp.topMargin;
                  break;
                case Gravity.CENTER_VERTICAL:
                  childTop =
                      ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
                  break;
                case Gravity.BOTTOM:
                  childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
                  break;
                default:
                  childTop = lp.topMargin;
              }
              if (chatActivityEnterView.isPopupView(child)) {
                childTop =
                    paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight();
              }
              child.layout(childLeft, childTop, childLeft + width, childTop + height);
            }

            notifyHeightChanged();
          }
        };
    setContentView(contentView);
    contentView.setBackgroundColor(0x99000000);

    RelativeLayout relativeLayout = new RelativeLayout(this);
    contentView.addView(
        relativeLayout,
        LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    RelativeLayout popupContainer = new RelativeLayout(this);
    popupContainer.setBackgroundColor(0xffffffff);
    relativeLayout.addView(
        popupContainer,
        LayoutHelper.createRelative(
            LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT));

    if (chatActivityEnterView != null) {
      chatActivityEnterView.onDestroy();
    }
    chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
    popupContainer.addView(
        chatActivityEnterView,
        LayoutHelper.createRelative(
            LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT,
            RelativeLayout.ALIGN_PARENT_BOTTOM));
    chatActivityEnterView.setDelegate(
        new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
          @Override
          public void onMessageSend(String message) {
            if (currentMessageObject == null) {
              return;
            }
            if (currentMessageNum >= 0
                && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
              NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
            }
            MessagesController.getInstance()
                .markDialogAsRead(
                    currentMessageObject.getDialogId(),
                    currentMessageObject.getId(),
                    Math.max(0, currentMessageObject.getId()),
                    0,
                    currentMessageObject.messageOwner.date,
                    true,
                    true);
            currentMessageObject = null;
            getNewMessage();
          }

          @Override
          public void onTextChanged(CharSequence text, boolean big) {}

          @Override
          public void needSendTyping() {
            if (currentMessageObject != null) {
              MessagesController.getInstance()
                  .sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
            }
          }

          @Override
          public void onAttachButtonHidden() {}

          @Override
          public void onAttachButtonShow() {}

          @Override
          public void onWindowSizeChanged(int size) {}
        });

    messageContainer = new FrameLayoutTouch(this);
    popupContainer.addView(messageContainer, 0);

    actionBar = new ActionBar(this);
    actionBar.setOccupyStatusBar(false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackgroundColor(0xff54759e);
    actionBar.setItemsBackground(R.drawable.bar_selector);
    popupContainer.addView(actionBar);
    ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    ActionBarMenu menu = actionBar.createMenu();
    View view = menu.addItemResource(2, R.layout.popup_count_layout);
    countText = (TextView) view.findViewById(R.id.count_text);

    avatarContainer = new FrameLayoutFixed(this);
    avatarContainer.setBackgroundResource(R.drawable.bar_selector);
    avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
    actionBar.addView(avatarContainer);
    FrameLayout.LayoutParams layoutParams2 =
        (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
    layoutParams2.height = LayoutHelper.MATCH_PARENT;
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.rightMargin = AndroidUtilities.dp(48);
    layoutParams2.leftMargin = AndroidUtilities.dp(60);
    layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
    avatarContainer.setLayoutParams(layoutParams2);

    avatarImageView = new BackupImageView(this);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    avatarContainer.addView(avatarImageView);
    layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
    layoutParams2.width = AndroidUtilities.dp(42);
    layoutParams2.height = AndroidUtilities.dp(42);
    layoutParams2.topMargin = AndroidUtilities.dp(3);
    avatarImageView.setLayoutParams(layoutParams2);

    nameTextView = new TextView(this);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    avatarContainer.addView(nameTextView);
    layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(22);
    layoutParams2.gravity = Gravity.BOTTOM;
    nameTextView.setLayoutParams(layoutParams2);

    onlineTextView = new TextView(this);
    onlineTextView.setTextColor(0xffd7e8f7);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setLines(1);
    onlineTextView.setMaxLines(1);
    onlineTextView.setSingleLine(true);
    onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
    onlineTextView.setGravity(Gravity.LEFT);
    avatarContainer.addView(onlineTextView);
    layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(4);
    layoutParams2.gravity = Gravity.BOTTOM;
    onlineTextView.setLayoutParams(layoutParams2);

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              onFinish();
              finish();
            } else if (id == 1) {
              openCurrentMessage();
            } else if (id == 2) {
              switchToNextMessage();
            }
          }
        });

    PowerManager pm =
        (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
    wakeLock =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
    wakeLock.setReferenceCounted(false);

    handleIntent(getIntent());
  }
  private void updateContentOverlayVisibility(boolean show) {
    if (mView == null) return;

    sCachedCVCList.clear();
    if (mLayoutManager != null) {
      mLayoutManager.getActiveLayout().getAllContentViewCores(sCachedCVCList);
    }
    if (show) {
      if (mView.getParent() != this) {
        // Make sure the view isn't a child of something else before we attempt to add it.
        if (mView.getParent() != null && mView.getParent() instanceof ViewGroup) {
          ((ViewGroup) mView.getParent()).removeView(mView);
        }

        for (int i = 0; i < sCachedCVCList.size(); i++) {
          ContentViewCore content = sCachedCVCList.get(i);
          assert content.isAlive();
          content.getContainerView().setVisibility(View.VISIBLE);
          if (mFullscreenManager != null) {
            mFullscreenManager.updateContentViewViewportSize(content);
          }
        }

        FrameLayout.LayoutParams layoutParams =
            new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        if (mView.getLayoutParams() instanceof MarginLayoutParams) {
          MarginLayoutParams existingLayoutParams = (MarginLayoutParams) mView.getLayoutParams();
          layoutParams.leftMargin = existingLayoutParams.leftMargin;
          layoutParams.rightMargin = existingLayoutParams.rightMargin;
          layoutParams.topMargin = existingLayoutParams.topMargin;
          layoutParams.bottomMargin = existingLayoutParams.bottomMargin;
        }
        addView(mView, layoutParams);

        setFocusable(false);
        setFocusableInTouchMode(false);

        // Claim focus for the new view unless the user is currently using the URL bar.
        if (mUrlBar == null || !mUrlBar.hasFocus()) mView.requestFocus();
      }
    } else {
      if (mView.getParent() == this) {
        setFocusable(true);
        setFocusableInTouchMode(true);

        for (int i = 0; i < sCachedCVCList.size(); i++) {
          ContentViewCore content = sCachedCVCList.get(i);
          if (content.isAlive()) content.getContainerView().setVisibility(View.INVISIBLE);
        }

        if (hasFocus()) {
          InputMethodManager manager =
              (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
          if (manager.isActive(this)) {
            manager.hideSoftInputFromWindow(getWindowToken(), 0, null);
          }
        }
        removeView(mView);
      }
    }
    sCachedCVCList.clear();
  }
  @Override
  public View createView(LayoutInflater inflater) {
    if (fragmentView == null) {
      searching = false;
      searchWas = false;

      actionBar.setBackButtonImage(R.drawable.ic_ab_back);
      actionBar.setAllowOverlayTitle(true);
      if (isAlwaysShare) {
        actionBar.setTitle(
            LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
      } else if (isNeverShare) {
        actionBar.setTitle(
            LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
      } else {
        actionBar.setTitle(
            isBroadcast
                ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)
                : LocaleController.getString("NewGroup", R.string.NewGroup));
        actionBar.setSubtitle(
            LocaleController.formatString(
                "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
      }

      actionBar.setActionBarMenuOnItemClick(
          new ActionBar.ActionBarMenuOnItemClick() {
            @Override
            public void onItemClick(int id) {
              if (id == -1) {
                finishFragment();
              } else if (id == done_button) {
                if (selectedContacts.isEmpty()) {
                  return;
                }
                ArrayList<Integer> result = new ArrayList<>();
                result.addAll(selectedContacts.keySet());
                if (isAlwaysShare || isNeverShare) {
                  if (delegate != null) {
                    delegate.didSelectUsers(result);
                  }
                  finishFragment();
                } else {
                  Bundle args = new Bundle();
                  args.putIntegerArrayList("result", result);
                  args.putBoolean("broadcast", isBroadcast);
                  presentFragment(new GroupCreateFinalActivity(args));
                }
              }
            }
          });
      ActionBarMenu menu = actionBar.createMenu();
      menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

      searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
      searchListViewAdapter.setCheckedMap(selectedContacts);
      searchListViewAdapter.setUseUserCell(true);
      listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
      listViewAdapter.setCheckedMap(selectedContacts);

      fragmentView = new LinearLayout(getParentActivity());
      LinearLayout linearLayout = (LinearLayout) fragmentView;
      linearLayout.setOrientation(LinearLayout.VERTICAL);

      FrameLayout frameLayout = new FrameLayout(getParentActivity());
      linearLayout.addView(frameLayout);
      LinearLayout.LayoutParams layoutParams =
          (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
      layoutParams.gravity = Gravity.TOP;
      frameLayout.setLayoutParams(layoutParams);

      userSelectEditText = new EditText(getParentActivity());
      userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      userSelectEditText.setHintTextColor(0xff979797);
      userSelectEditText.setTextColor(0xff212121);
      userSelectEditText.setInputType(
          InputType.TYPE_TEXT_VARIATION_FILTER
              | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
              | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
      userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54));
      userSelectEditText.setSingleLine(false);
      userSelectEditText.setLines(2);
      userSelectEditText.setMaxLines(2);
      userSelectEditText.setVerticalScrollBarEnabled(true);
      userSelectEditText.setHorizontalScrollBarEnabled(false);
      userSelectEditText.setPadding(0, 0, 0, 0);
      userSelectEditText.setImeOptions(
          EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
      userSelectEditText.setGravity(
          (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
      AndroidUtilities.clearCursorDrawable(userSelectEditText);
      frameLayout.addView(userSelectEditText);
      FrameLayout.LayoutParams layoutParams1 =
          (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams();
      layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
      layoutParams1.leftMargin = AndroidUtilities.dp(10);
      layoutParams1.rightMargin = AndroidUtilities.dp(10);
      layoutParams1.gravity = Gravity.TOP;
      userSelectEditText.setLayoutParams(layoutParams1);

      if (isAlwaysShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "AlwaysShareWithPlaceholder", R.string.AlwaysShareWithPlaceholder));
      } else if (isNeverShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "NeverShareWithPlaceholder", R.string.NeverShareWithPlaceholder));
      } else {
        userSelectEditText.setHint(
            LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
      }
      if (Build.VERSION.SDK_INT >= 11) {
        userSelectEditText.setTextIsSelectable(false);
      }
      userSelectEditText.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(
                CharSequence charSequence, int start, int count, int after) {
              if (!ignoreChange) {
                beforeChangeIndex = userSelectEditText.getSelectionStart();
                changeString = new SpannableString(charSequence);
              }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (!ignoreChange) {
                boolean search = false;
                int afterChangeIndex = userSelectEditText.getSelectionEnd();
                if (editable.toString().length() < changeString.toString().length()) {
                  String deletedString = "";
                  try {
                    deletedString =
                        changeString.toString().substring(afterChangeIndex, beforeChangeIndex);
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  if (deletedString.length() > 0) {
                    if (searching && searchWas) {
                      search = true;
                    }
                    Spannable span = userSelectEditText.getText();
                    for (int a = 0; a < allSpans.size(); a++) {
                      XImageSpan sp = allSpans.get(a);
                      if (span.getSpanStart(sp) == -1) {
                        allSpans.remove(sp);
                        selectedContacts.remove(sp.uid);
                      }
                    }
                    if (!isAlwaysShare && !isNeverShare) {
                      actionBar.setSubtitle(
                          LocaleController.formatString(
                              "MembersCount",
                              R.string.MembersCount,
                              selectedContacts.size(),
                              maxCount));
                    }
                    listView.invalidateViews();
                  } else {
                    search = true;
                  }
                } else {
                  search = true;
                }
                if (search) {
                  String text = userSelectEditText.getText().toString().replace("<", "");
                  if (text.length() != 0) {
                    searching = true;
                    searchWas = true;
                    if (listView != null) {
                      listView.setAdapter(searchListViewAdapter);
                      searchListViewAdapter.notifyDataSetChanged();
                      if (android.os.Build.VERSION.SDK_INT >= 11) {
                        listView.setFastScrollAlwaysVisible(false);
                      }
                      listView.setFastScrollEnabled(false);
                      listView.setVerticalScrollBarEnabled(true);
                    }
                    if (emptyTextView != null) {
                      emptyTextView.setText(
                          LocaleController.getString("NoResult", R.string.NoResult));
                    }
                    searchListViewAdapter.searchDialogs(text);
                  } else {
                    searchListViewAdapter.searchDialogs(null);
                    searching = false;
                    searchWas = false;
                    listView.setAdapter(listViewAdapter);
                    listViewAdapter.notifyDataSetChanged();
                    if (android.os.Build.VERSION.SDK_INT >= 11) {
                      listView.setFastScrollAlwaysVisible(true);
                    }
                    listView.setFastScrollEnabled(true);
                    listView.setVerticalScrollBarEnabled(false);
                    emptyTextView.setText(
                        LocaleController.getString("NoContacts", R.string.NoContacts));
                  }
                }
              }
            }
          });

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

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

      FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
      emptyTextLayout.addView(frameLayout2);
      layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      frameLayout2.setLayoutParams(layoutParams);

      listView = new LetterSectionsListView(getParentActivity());
      listView.setEmptyView(emptyTextLayout);
      listView.setVerticalScrollBarEnabled(false);
      listView.setDivider(null);
      listView.setDividerHeight(0);
      listView.setFastScrollEnabled(true);
      listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
      listView.setAdapter(listViewAdapter);
      if (Build.VERSION.SDK_INT >= 11) {
        listView.setFastScrollAlwaysVisible(true);
        listView.setVerticalScrollbarPosition(
            LocaleController.isRTL
                ? ListView.SCROLLBAR_POSITION_LEFT
                : ListView.SCROLLBAR_POSITION_RIGHT);
      }
      linearLayout.addView(listView);
      layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      listView.setLayoutParams(layoutParams);
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
              TLRPC.User user = null;
              if (searching && searchWas) {
                user = searchListViewAdapter.getItem(i);
              } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (row < 0 || section < 0) {
                  return;
                }
                user = (TLRPC.User) listViewAdapter.getItem(section, row);
              }
              if (user == null) {
                return;
              }

              boolean check = true;
              if (selectedContacts.containsKey(user.id)) {
                check = false;
                try {
                  XImageSpan span = selectedContacts.get(user.id);
                  selectedContacts.remove(user.id);
                  SpannableStringBuilder text =
                      new SpannableStringBuilder(userSelectEditText.getText());
                  text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                  allSpans.remove(span);
                  ignoreChange = true;
                  userSelectEditText.setText(text);
                  userSelectEditText.setSelection(text.length());
                  ignoreChange = false;
                } catch (Exception e) {
                  FileLog.e("tmessages", e);
                }
              } else {
                if (selectedContacts.size() == maxCount) {
                  return;
                }
                ignoreChange = true;
                XImageSpan span = createAndPutChipForUser(user);
                span.uid = user.id;
                ignoreChange = false;
              }
              if (!isAlwaysShare && !isNeverShare) {
                actionBar.setSubtitle(
                    LocaleController.formatString(
                        "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
              }
              if (searching || searchWas) {
                ignoreChange = true;
                SpannableStringBuilder ssb = new SpannableStringBuilder("");
                for (ImageSpan sp : allSpans) {
                  ssb.append("<<");
                  ssb.setSpan(
                      sp,
                      ssb.length() - 2,
                      ssb.length(),
                      SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                userSelectEditText.setText(ssb);
                userSelectEditText.setSelection(ssb.length());
                ignoreChange = false;

                searchListViewAdapter.searchDialogs(null);
                searching = false;
                searchWas = false;
                listView.setAdapter(listViewAdapter);
                listViewAdapter.notifyDataSetChanged();
                if (android.os.Build.VERSION.SDK_INT >= 11) {
                  listView.setFastScrollAlwaysVisible(true);
                }
                listView.setFastScrollEnabled(true);
                listView.setVerticalScrollBarEnabled(false);
                emptyTextView.setText(
                    LocaleController.getString("NoContacts", R.string.NoContacts));
              } else {
                if (view instanceof UserCell) {
                  ((UserCell) view).setChecked(check, true);
                }
              }
            }
          });
      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(userSelectEditText);
              }
              if (listViewAdapter != null) {
                listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE);
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {
              if (absListView.isFastScrollEnabled()) {
                AndroidUtilities.clearDrawableAnimation(absListView);
              }
            }
          });
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
Beispiel #15
0
  private void initVideoView() {
    this.mVideoData = this.mAd.getVideo();
    if (this.mVideoData.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
      if (this.mWindowWidth < this.mWindowHeight) {
        final int size = this.mWindowWidth;
        this.mWindowWidth = this.mWindowHeight;
        this.mWindowHeight = size;
      }
    } else if (this.mWindowHeight < this.mWindowWidth) {
      final int size = this.mWindowHeight;
      this.mWindowHeight = this.mWindowWidth;
      this.mWindowWidth = size;
    }
    this.mVideoWidth = this.mVideoData.width;
    this.mVideoHeight = this.mVideoData.height;
    if (this.mVideoWidth <= 0) {
      this.mVideoWidth = this.mWindowWidth;
      this.mVideoHeight = this.mWindowHeight;
    }
    if (this.mVideoView != null) {
      this.mVideoLayout.removeView(this.mVideoView);
    }
    if (this.mInterstitialView != null) {
      this.mVideoLayout.removeView(this.mInterstitialView);
    }
    if (this.mInterstitialController != null) {
      this.mVideoLayout.removeView(this.mInterstitialController);
    }
    if (this.mMediaController != null) {
      this.mVideoLayout.removeView(this.mMediaController);
    }
    if (this.mLoadingView != null) {
      this.mVideoLayout.removeView(this.mLoadingView);
    }
    this.mVideoView =
        new SDKVideoView(mContext, this.mVideoWidth, this.mVideoHeight, this.mVideoData.display);
    this.mVideoLayout.addView(
        mVideoView,
        new FrameLayout.LayoutParams(this.mVideoWidth, this.mVideoHeight, Gravity.CENTER)); //

    this.mMediaController = new MediaController(mContext, mVideoData);
    this.mVideoView.setMediaController(this.mMediaController);
    if (this.mVideoData.showNavigationBars) mMediaController.toggle();
    if (!this.mVideoData.pauseEvents.isEmpty())
      this.mMediaController.setOnPauseListener(this.mOnVideoPauseListener);
    if (!this.mVideoData.unpauseEvents.isEmpty())
      this.mMediaController.setOnUnpauseListener(this.mOnVideoUnpauseListener);
    if (!this.mVideoData.replayEvents.isEmpty())
      this.mMediaController.setOnReplayListener(this.mOnVideoReplayListener);

    this.mVideoLayout.addView(
        this.mMediaController,
        new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT,
            Gravity.FILL_HORIZONTAL)); // fill_parent
    if (this.mVideoData.showSkipButton) {

      //			this.mSkipButton = new ImageView(this);
      this.mSkipButton.setAdjustViewBounds(false);
      FrameLayout.LayoutParams params = null;

      int buttonSize =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP,
                  this.skipButtonSizeLand,
                  this.getResources().getDisplayMetrics());

      int size =
          Math.min(
              this.getResources().getDisplayMetrics().widthPixels,
              this.getResources().getDisplayMetrics().heightPixels);
      buttonSize = (int) (size * 0.09);

      params = new FrameLayout.LayoutParams(buttonSize, buttonSize, Gravity.TOP | Gravity.RIGHT);
      if (this.mVideoData.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 8, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      } else {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 10, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      }

      //			if (this.mVideoData.skipButtonImage != null
      //					&& this.mVideoData.skipButtonImage.length() > 0)
      //				this.mResourceManager.fetchResource(this,
      //						this.mVideoData.skipButtonImage,
      //						ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID);
      //			else
      //				this.mSkipButton.setImageDrawable(mResourceManager.getResource(
      //						this, ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID));
      //			this.mSkipButton.setOnClickListener(this.mOnVideoSkipListener);
      if (this.mVideoData.showSkipButtonAfter > 0) {
        this.mCanClose = false;
        this.mSkipButton.setVisibility(View.GONE);
      } else {
        this.mCanClose = true;
        this.mSkipButton.setVisibility(View.VISIBLE);
      }
      this.mVideoLayout.addView(this.mSkipButton, params);
    } else this.mCanClose = false;
    //		if (this.mVideoData.showSkipButtonAfter > 0)
    //			this.mVideoView.setOnTimeEventListener(
    //					this.mVideoData.showSkipButtonAfter,
    //					this.mOnVideoCanCloseEventListener);
    final FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER);
    //		this.mLoadingView = new FrameLayout(mContext);
    //		final TextView loadingText = new TextView(mContext);
    //		loadingText.setText(Const.LOADING);
    //		this.mLoadingView.addView(loadingText, params);
    //		this.mVideoLayout.addView(this.mLoadingView,
    //				new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
    //						LayoutParams.MATCH_PARENT, Gravity.CENTER));// fill_parent

    this.mVideoView.setOnPreparedListener(this.mOnVideoPreparedListener);
    this.mVideoView.setOnCompletionListener(this.mOnVideoCompletionListener);
    this.mVideoView.setOnErrorListener(this.mOnVideoErrorListener);
    this.mVideoView.setOnInfoListener(this.mOnVideoInfoListener);
    if (!this.mVideoData.startEvents.isEmpty())
      this.mVideoView.setOnStartListener(this.mOnVideoStartListener);
    if (!this.mVideoData.timeTrackingEvents.isEmpty()) {
      final Set<Integer> keys = this.mVideoData.timeTrackingEvents.keySet();
      for (final Iterator<Integer> it = keys.iterator(); it.hasNext(); ) {
        final int key = it.next();
        this.mVideoView.setOnTimeEventListener(key, this.mOnVideoTimeEventListener);
      }
    }
    this.mVideoLastPosition = 0;
    mVideoLayout.setBackgroundColor(Color.BLACK);
    setAdvPathAndRequestNext();
  }
Beispiel #16
0
  private void initInterstitialView() {
    new Handler().postDelayed(RequestNextAdv, 5000);
    this.mInterstitialData = this.mAd.getInterstitial();
    this.mInterstitialAutocloseReset = false;
    this.mInterstitialView = new WebFrame((Activity) mContext, true, false, false);
    this.mInterstitialView.setBackgroundColor(Color.BLACK); //
    this.mInterstitialView.setOnPageLoadedListener(this.mOnInterstitialLoadedListener);
    if (this.mInterstitialController != null) {
      layout.removeView(this.mInterstitialController);
    }
    this.mInterstitialController = new InterstitialController(mContext, this.mInterstitialData);
    this.mInterstitialController.setBrowser(this.mInterstitialView);
    this.mInterstitialController.setBrowserView(this.mInterstitialView);
    this.mInterstitialController.setOnResetAutocloseListener(this.mOnResetAutocloseListener);
    layout.addView(
        this.mInterstitialController,
        new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER));
    if (this.mInterstitialData.showNavigationBars) this.mInterstitialController.show(0);
    if (this.mInterstitialData.showSkipButton) {

      this.mSkipButton = new ImageView(mContext);
      this.mSkipButton.setAdjustViewBounds(false);
      FrameLayout.LayoutParams params = null;

      int buttonSize =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP,
                  this.skipButtonSizeLand,
                  this.getResources().getDisplayMetrics());

      int size =
          Math.min(
              this.getResources().getDisplayMetrics().widthPixels,
              this.getResources().getDisplayMetrics().heightPixels);
      buttonSize = (int) (size * 0.1);

      params = new FrameLayout.LayoutParams(buttonSize, buttonSize, Gravity.TOP | Gravity.RIGHT);

      if (this.mInterstitialData.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 8, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      } else {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 10, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      }

      if (this.mInterstitialData.skipButtonImage != null
          && this.mInterstitialData.skipButtonImage.length() > 0) {
        this.mSkipButton.setBackgroundDrawable(null);
        this.mResourceManager.fetchResource(
            mContext,
            this.mInterstitialData.skipButtonImage,
            ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID);
      }
      //			else
      //				this.mSkipButton.setImageDrawable(mResourceManager.getResource(
      //						mContext, ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID));
      //			this.mSkipButton
      //					.setOnClickListener(this.mOnInterstitialSkipListener);
      if (this.mInterstitialData.showSkipButtonAfter > 0) {
        this.mCanClose = false;
        this.mSkipButton.setVisibility(View.GONE);
        if (this.mInterstitialLoadingTimer == null) {
          //					final InterstitialLoadingTimeoutTask loadingTimeoutTask = new
          // InterstitialLoadingTimeoutTask();
          //					this.mInterstitialLoadingTimer = new Timer();
          //					this.mInterstitialLoadingTimer.schedule(loadingTimeoutTask,
          //							Const.CONNECTION_TIMEOUT);
        }

      } else {
        this.mCanClose = true;
        this.mSkipButton.setVisibility(View.VISIBLE);
      }
      layout.addView(this.mSkipButton, params);
    } else this.mCanClose = false;
    this.mInterstitialView.setOnClickListener(this.mInterstitialClickListener);
    setAdvImgPathAndRequestNext();

    switch (this.mInterstitialData.interstitialType) {
      case InterstitialData.INTERSTITIAL_MARKUP:
        if (Util.isCacheLoaded()) {
          String textData = this.mInterstitialData.interstitialMarkup;
          if (textData != null) {
            int startInd = textData.indexOf("<img") + 10;
            int endInd = textData.indexOf(">", startInd) - 1;
            String thisImageText = textData.substring(startInd, endInd);
            URL url = null;
            try {
              url = new URL(thisImageText);
            } catch (MalformedURLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            if (url != null) {
              Util.ExternalName = "." + Util.getExtensionName(url.getPath());
            } else {
              Util.ExternalName = ".jpg";
            }
          }
          new ImpressionThread(
                  mContext,
                  mAd.getmImpressionUrl(),
                  Util.PublisherId,
                  Util.AD_TYPE.FULL_SCREEN_VIDEO)
              .start();

          // change by Jas
          if (mAd.getmTrackingUrl().size() > 0) {
            AdMonitorManager.getInstance(mContext).AddTRACKINGURL(mAd.getmTrackingUrl());
          }
          // end change by Jas

          this.mInterstitialView.setMarkup(this.mInterstitialData.interstitialMarkup);
        }
        break;
      case InterstitialData.INTERSTITIAL_URL:
        this.mInterstitialView.loadUrl(this.mInterstitialData.interstitialUrl);
        break;
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public View createView(Context context) {
    actionBar.setBackgroundColor(0xff333333);
    actionBar.setItemsBackground(R.drawable.bar_selector_picker);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              if (Build.VERSION.SDK_INT < 11) {
                listView.setAdapter(null);
                listView = null;
                listAdapter = null;
              }
              finishFragment();
            } else if (id == 1) {
              if (delegate != null) {
                finishFragment(false);
                delegate.startPhotoSelectActivity();
              }
            } else if (id == item_photos) {
              if (selectedMode == 0) {
                return;
              }
              selectedMode = 0;
              dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
              emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
              listAdapter.notifyDataSetChanged();
            } else if (id == item_video) {
              if (selectedMode == 1) {
                return;
              }
              selectedMode = 1;
              dropDown.setText(LocaleController.getString("PickerVideo", R.string.PickerVideo));
              emptyView.setText(LocaleController.getString("NoVideo", R.string.NoVideo));
              listAdapter.notifyDataSetChanged();
            }
          }
        });

    ActionBarMenu menu = actionBar.createMenu();
    menu.addItem(1, R.drawable.ic_ab_other);

    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(0xff000000);

    if (!singlePhoto) {
      selectedMode = 0;

      dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector_picker);
      dropDownContainer.setSubMenuOpenSide(1);
      dropDownContainer.addSubItem(
          item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0);
      dropDownContainer.addSubItem(
          item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0);
      actionBar.addView(dropDownContainer);
      FrameLayout.LayoutParams layoutParams =
          (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
      layoutParams.height = LayoutHelper.MATCH_PARENT;
      layoutParams.width = LayoutHelper.WRAP_CONTENT;
      layoutParams.rightMargin = AndroidUtilities.dp(40);
      layoutParams.leftMargin =
          AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
      layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
      dropDownContainer.setLayoutParams(layoutParams);
      dropDownContainer.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              dropDownContainer.toggleSubMenu();
            }
          });

      dropDown = new TextView(context);
      dropDown.setGravity(Gravity.LEFT);
      dropDown.setSingleLine(true);
      dropDown.setLines(1);
      dropDown.setMaxLines(1);
      dropDown.setEllipsize(TextUtils.TruncateAt.END);
      dropDown.setTextColor(0xffffffff);
      dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
      dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
      dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
      dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
      dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos));
      dropDownContainer.addView(dropDown);
      layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
      layoutParams.width = LayoutHelper.WRAP_CONTENT;
      layoutParams.height = LayoutHelper.WRAP_CONTENT;
      layoutParams.leftMargin = AndroidUtilities.dp(16);
      layoutParams.gravity = Gravity.CENTER_VERTICAL;
      dropDown.setLayoutParams(layoutParams);
    } else {
      actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
    }

    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);

    pickerBottomLayout = new PickerBottomLayout(context);
    frameLayout.addView(pickerBottomLayout);
    layoutParams = (FrameLayout.LayoutParams) pickerBottomLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    layoutParams.gravity = Gravity.BOTTOM;
    pickerBottomLayout.setLayoutParams(layoutParams);
    pickerBottomLayout.cancelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            finishFragment();
          }
        });
    pickerBottomLayout.doneButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            sendSelectedPhotos();
            finishFragment();
          }
        });

    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
      progressView.setVisibility(View.VISIBLE);
      listView.setEmptyView(null);
    } else {
      progressView.setVisibility(View.GONE);
      listView.setEmptyView(emptyView);
    }
    pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);

    return fragmentView;
  }
Beispiel #18
0
  public void createTopBarElements() {
    // 1. Create view groups and controls
    statusBar = createStatusBar();
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));

    lanesControl = createLanesControl();
    lanesControl.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));

    rightStack = new MapStackControl(view.getContext());
    rightStack.addStackView(createAltitudeControl());
    rightStack.addStackView(createDistanceControl());
    rightStack.addCollapsedView(createSpeedControl());
    rightStack.addCollapsedView(createTimeControl());

    leftStack = new MapStackControl(view.getContext());
    leftStack.addStackView(createNextInfoControl());
    leftStack.addStackView(createMiniMapControl());
    leftStack.addStackView(createNextNextInfoControl());
    //		leftStack.addStackView(createAlarmInfoControl());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);

    STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
    statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Rect statusBarPadding = new Rect();
    statusBar.getBackground().getPadding(statusBarPadding);
    // 3. put into frame parent layout controls
    FrameLayout parent = (FrameLayout) view.getParent();
    // status bar hides own top part
    int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom;
    // we want that status bar lays over map stack controls
    topMargin -= topRectPadding.top;

    FrameLayout.LayoutParams flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    rightStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER_HORIZONTAL | Gravity.TOP);
    flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
    lanesControl.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    leftStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = -topRectPadding.top;
    statusBar.setLayoutParams(flp);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
  }