List of usage examples for android.widget FrameLayout FrameLayout
public FrameLayout(@NonNull Context context)
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
@Override public synchronized void showProgressIndicatorInTool() { MBToolDefinition refreshToolDef = getRefreshToolDef(); Menu menu = _menu;/*from ww w . j av a2 s . com*/ if (refreshToolDef != null && menu != null) { final MenuItem item = menu.findItem(refreshToolDef.getName().hashCode()); ImageView rotationImage = getRotationImage(); float imageWidth = rotationImage.getDrawable().getIntrinsicWidth(); int framePadding = (int) ((ScreenUtil.convertDimensionPixelsToPixels(_context, 80) - imageWidth) / 2); final FrameLayout frameLayout = new FrameLayout(_context); frameLayout.setLayoutParams( new FrameLayout.LayoutParams(ScreenUtil.convertDimensionPixelsToPixels(_context, 80), LayoutParams.WRAP_CONTENT, Gravity.CENTER)); frameLayout.setPadding(framePadding, 0, framePadding, 0); frameLayout.addView(rotationImage); MBViewManager.getInstance().runOnUiThread(new MBThread() { @Override public void runMethod() { //item.setIcon(null); MenuItemCompat.setActionView(item, frameLayout); getRotationImage().getAnimation().startNow(); } }); } }
From source file:com.taobao.weex.ui.component.WXSliderNeighbor.java
@Override protected FrameLayout initComponentHostView(@NonNull Context context) { FrameLayout view = new FrameLayout(context); // init view pager FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); pagerParams.gravity = Gravity.CENTER; mViewPager = new WXCircleViewPager(getContext()); mViewPager.setLayoutParams(pagerParams); // init adapter mAdapter = new WXCirclePageAdapter(); mViewPager.setAdapter(mAdapter);/*w w w . ja v a2 s .c o m*/ // add to parent view.addView(mViewPager); mViewPager.addOnPageChangeListener(mPageChangeListener); mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER); registerActivityStateListener(); mViewPager.setPageTransformer(false, createTransformer()); return view; }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww . jav a 2 s. c o m //size of screen screenWidth = size.x; screenHeight = size.y; FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); topLayout = new FrameLayout(this); setContentView(topLayout); mGLView = overlay.getGLView(); // OpenGLview int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); Log.d("CameraDebug", "InitLayout acquired camera"); if (CAMERA_PREVIEW) { cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); }
From source file:com.taobao.weex.ui.component.WXSlider.java
@Override protected FrameLayout initComponentHostView(@NonNull Context context) { FrameLayout view = new FrameLayout(context); // init view pager FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);//from w w w . j a v a 2 s .c o m mViewPager = new WXCircleViewPager(context); mViewPager.setLayoutParams(pagerParams); // init adapter mAdapter = new WXCirclePageAdapter(); mViewPager.setAdapter(mAdapter); // add to parent view.addView(mViewPager); mViewPager.addOnPageChangeListener(mPageChangeListener); registerActivityStateListener(); return view; }
From source file:cz.maresmar.sfm.view.menu.MenuDetailsFragment.java
private void showPickerDialog(@StringRes int title, int min, int max, int value, IntConsumer newValueConsumer) { // Prepare number picker NumberPicker picker = new NumberPicker(getContext()); picker.setMinValue(min);/*from w w w .j ava2s . c o m*/ picker.setMaxValue(max); picker.setValue(value); picker.setWrapSelectorWheel(false); FrameLayout layout = new FrameLayout(getContext()); layout.addView(picker, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // Show alert new AlertDialog.Builder(getContext()).setTitle(title).setMessage(R.string.menu_detail_pick_new_value) .setView(layout).setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { // do something with picker.getValue() newValueConsumer.accept(picker.getValue()); }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
private void resize(final int width, final int height) { final FrameLayout content = (FrameLayout) getRootView().findViewById(android.R.id.content); final FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams(width, height); final View placeholderView = new View(getContext()); placeholderView.setLayoutParams(getLayoutParams()); mExpandLayout = new FrameLayout(getContext()); final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; mExpandLayout.setLayoutParams(layoutParams); mOriginalParent = (ViewGroup) getParent(); int index = 0; if (mOriginalParent != null) { int count = mOriginalParent.getChildCount(); for (index = 0; index < count; index++) { if (mOriginalParent.getChildAt(index) == this) break; }//from w w w .ja v a2 s. co m mIndex = index; this.setLayoutParams(adParams); mOriginalParent.removeView(this); mExpandLayout.addView(this); mCloseButton = addCloseButtonToViewGroup(((ViewGroup) getParent())); mCloseButton.setId(43); if (!mExpandProperties.useCustomClose) { mCloseButton.setImageResource(android.R.drawable.ic_menu_close_clear_cancel); } content.addView(mExpandLayout); mOriginalParent.addView(placeholderView, mIndex); mOriginalParent.setVisibility(View.GONE); mState = STATE_EXPANDED; } }
From source file:com.todoroo.astrid.activity.FilterListFragment.java
public static void showCreateShortcutDialog(final Activity activity, final Intent shortcutIntent, final Filter filter) { FrameLayout frameLayout = new FrameLayout(activity); frameLayout.setPadding(10, 0, 10, 0); final EditText editText = new EditText(activity); if (filter.listingTitle == null) filter.listingTitle = ""; //$NON-NLS-1$ editText.setText(filter.listingTitle.replaceAll("\\(\\d+\\)$", "").trim()); //$NON-NLS-1$ //$NON-NLS-2$ frameLayout.addView(editText, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); final Runnable createShortcut = new Runnable() { @Override// w w w. j av a 2 s. c om public void run() { String label = editText.getText().toString(); createShortcut(activity, filter, shortcutIntent, label); } }; editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL) { createShortcut.run(); return true; } return false; } }); new AlertDialog.Builder(activity).setTitle(R.string.FLA_shortcut_dialog_title) .setMessage(R.string.FLA_shortcut_dialog).setView(frameLayout) .setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createShortcut.run(); } }).setNegativeButton(android.R.string.cancel, null).show().setOwnerActivity(activity); }
From source file:org.telegram.ui.ActionBar.ActionBarMenuItem.java
public ActionBarMenuItem setIsSearchField(boolean value) { if (parentMenu == null) { return this; }//from w w w .j av a 2 s . co m if (value && searchContainer == null) { searchContainer = new FrameLayout(getContext()); parentMenu.addView(searchContainer, 0); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) searchContainer.getLayoutParams(); layoutParams.weight = 1; layoutParams.width = 0; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(6); searchContainer.setLayoutParams(layoutParams); searchContainer.setVisibility(GONE); searchField = new EditText(getContext()); searchField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); searchField.setHintTextColor(0x88ffffff); searchField.setTextColor(0xffffffff); searchField.setSingleLine(true); searchField.setBackgroundResource(0); searchField.setPadding(0, 0, 0, 0); int inputType = searchField.getInputType() | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS; searchField.setInputType(inputType); searchField.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (/*actionId == EditorInfo.IME_ACTION_SEARCH || */event != null && (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { AndroidUtilities.hideKeyboard(searchField); if (listener != null) { listener.onSearchPressed(searchField); } } return false; } }); searchField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (listener != null) { listener.onTextChanged(searchField); } if (clearButton != null) { clearButton.setAlpha(s == null || s.length() == 0 ? 0.6f : 1.0f); } } @Override public void afterTextChanged(Editable s) { } }); try { Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes"); mCursorDrawableRes.setAccessible(true); mCursorDrawableRes.set(searchField, R.drawable.search_carret); } catch (Exception e) { //nothing to do } searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH); searchField.setTextIsSelectable(false); searchContainer.addView(searchField); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) searchField.getLayoutParams(); layoutParams2.width = LayoutHelper.MATCH_PARENT; layoutParams2.gravity = Gravity.CENTER_VERTICAL; layoutParams2.height = AndroidUtilities.dp(36); layoutParams2.rightMargin = AndroidUtilities.dp(48); searchField.setLayoutParams(layoutParams2); clearButton = new ImageView(getContext()); clearButton.setImageResource(R.drawable.ic_close_white); clearButton.setScaleType(ImageView.ScaleType.CENTER); clearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { searchField.setText(""); searchField.requestFocus(); AndroidUtilities.showKeyboard(searchField); } }); searchContainer.addView(clearButton); layoutParams2 = (FrameLayout.LayoutParams) clearButton.getLayoutParams(); layoutParams2.width = AndroidUtilities.dp(48); layoutParams2.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT; layoutParams2.height = LayoutHelper.MATCH_PARENT; clearButton.setLayoutParams(layoutParams2); } isSearchField = value; return this; }
From source file:com.taobao.weex.ui.component.WXSliderNeighbor.java
@Override protected void addSubView(View view, final int index) { if (view == null || mAdapter == null) { return;// ww w .ja v a 2s. c o m } if (view instanceof WXCircleIndicator) { return; } FrameLayout wrapper = new FrameLayout(getContext()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; view.setLayoutParams(params); wrapper.addView(view); super.addSubView(wrapper, index); updateAdapterScaleAndAlpha(mNeighborAlpha, mNeighborScale); // we need to set neighbor view status when added. mViewPager.postDelayed(WXThread.secure(new Runnable() { @Override public void run() { try { if (mViewPager.getRealCount() > 0 && index > 2) { // index > 2 mean more than two times, then need a fake drag // prevent a bug of init status. ZoomTransformer no called as excepted. mViewPager.beginFakeDrag(); mViewPager.fakeDragBy(1); // must be 1 } } catch (IndexOutOfBoundsException e) { // do nothing } finally { try { mViewPager.endFakeDrag(); } catch (Exception e) { // do nothing } } } }), 50); }
From source file:org.telegraph.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, Context context) { super(context); showStickers = needStickers;//from w w w.j a v a 2 s .co m for (int i = 0; i < Emoji.data.length + 1; i++) { GridView gridView = new GridView(context); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else { gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(i - 1); gridView.setAdapter(emojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); adapters.add(emojiGridAdapter); } if (showStickers) { StickersQuery.checkStickers(); stickersGridView = new GridView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); int count = stickersGridView.getChildCount(); for (int a = 0; a < count; a++) { View view = stickersGridView.getChildAt(a); int top = view.getTop(); int bottom = view.getBottom(); int left = view.getLeft(); int right = view.getRight(); if (top > y || bottom < y || left > x || right < x) { continue; } if (!(view instanceof StickerEmojiCell) || !((StickerEmojiCell) view).showingBitmap()) { return super.onInterceptTouchEvent(event); } startX = x; startY = y; currentStickerPreviewCell = (StickerEmojiCell) view; openStickerPreviewRunnable = new Runnable() { @Override public void run() { if (openStickerPreviewRunnable == null) { return; } stickersGridView.setOnItemClickListener(null); stickersGridView.requestDisallowInterceptTouchEvent(true); openStickerPreviewRunnable = null; StickerPreviewViewer.getInstance().setParentActivity((Activity) getContext()); StickerPreviewViewer.getInstance() .setKeyboardHeight(EmojiView.this.getMeasuredHeight()); StickerPreviewViewer.getInstance().open(currentStickerPreviewCell.getSticker()); currentStickerPreviewCell.setScaled(true); } }; AndroidUtilities.runOnUIThread(openStickerPreviewRunnable, 200); return true; } } return false; } }; stickersGridView.setSelector(R.drawable.transparent); stickersGridView.setColumnWidth(AndroidUtilities.dp(72)); stickersGridView.setNumColumns(-1); stickersGridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); stickersGridView.setClipToPadding(false); views.add(stickersGridView); stickersGridAdapter = new StickersGridAdapter(context); stickersGridView.setAdapter(stickersGridAdapter); stickersGridView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (openStickerPreviewRunnable != null || StickerPreviewViewer.getInstance().isVisible()) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stickersGridView.setOnItemClickListener(stickersOnItemClickListener); } }, 150); if (openStickerPreviewRunnable != null) { AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable); openStickerPreviewRunnable = null; } else if (StickerPreviewViewer.getInstance().isVisible()) { StickerPreviewViewer.getInstance().close(); if (currentStickerPreviewCell != null) { currentStickerPreviewCell.setScaled(false); currentStickerPreviewCell = null; } } } else if (event.getAction() != MotionEvent.ACTION_DOWN) { if (StickerPreviewViewer.getInstance().isVisible()) { if (event.getAction() == MotionEvent.ACTION_MOVE) { int x = (int) event.getX(); int y = (int) event.getY(); int count = stickersGridView.getChildCount(); for (int a = 0; a < count; a++) { View view = stickersGridView.getChildAt(a); int top = view.getTop(); int bottom = view.getBottom(); int left = view.getLeft(); int right = view.getRight(); if (top > y || bottom < y || left > x || right < x) { continue; } if (!(view instanceof StickerEmojiCell) || view == currentStickerPreviewCell) { break; } if (currentStickerPreviewCell != null) { currentStickerPreviewCell.setScaled(false); } currentStickerPreviewCell = (StickerEmojiCell) view; StickerPreviewViewer.getInstance() .setKeyboardHeight(EmojiView.this.getMeasuredHeight()); StickerPreviewViewer.getInstance() .open(currentStickerPreviewCell.getSticker()); currentStickerPreviewCell.setScaled(true); return true; } } return true; } else if (openStickerPreviewRunnable != null) { if (event.getAction() == MotionEvent.ACTION_MOVE) { if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities .dp(10)) { AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable); openStickerPreviewRunnable = null; } } else { AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable); openStickerPreviewRunnable = null; } } } } return false; } }); stickersOnItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long i) { if (!(view instanceof StickerEmojiCell)) { return; } if (openStickerPreviewRunnable != null) { AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable); openStickerPreviewRunnable = null; } if (currentStickerPreviewCell != null) { currentStickerPreviewCell.setScaled(false); currentStickerPreviewCell = null; } StickerEmojiCell cell = (StickerEmojiCell) view; if (cell.isDisabled()) { return; } cell.disable(); TLRPC.Document document = cell.getSticker(); Integer count = stickersUseHistory.get(document.id); if (count == null) { count = 0; } if (count == 0 && stickersUseHistory.size() > 19) { for (int a = recentStickers.size() - 1; a >= 0; a--) { TLRPC.Document sticker = recentStickers.get(a); stickersUseHistory.remove(sticker.id); recentStickers.remove(a); if (stickersUseHistory.size() <= 19) { break; } } } stickersUseHistory.put(document.id, ++count); long id = StickersQuery.getStickerSetId(document); if (id != -1) { count = stickerSetsUseCount.get(id); if (count == null) { count = 0; } stickerSetsUseCount.put(id, ++count); } saveRecentStickers(); if (listener != null) { listener.onStickerSelected(document); } } }; stickersGridView.setOnItemClickListener(stickersOnItemClickListener); AndroidUtilities.setListViewEdgeEffectColor(stickersGridView, 0xfff5f6f7); stickersWrap = new FrameLayout(context); stickersWrap.addView(stickersGridView); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoStickers", R.string.NoStickers)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setTextColor(0xff888888); stickersWrap.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); stickersGridView.setEmptyView(textView); scrollSlidingTabStrip = new ScrollSlidingTabStrip(context) { boolean startedScroll; float lastX; float lastTranslateX; boolean first = true; @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { if (Build.VERSION.SDK_INT >= 11) { if (first) { first = false; lastX = ev.getX(); } float newTranslationX = ViewProxy.getTranslationX(scrollSlidingTabStrip); if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) { if (!startedScroll && lastX - ev.getX() < 0) { if (pager.beginFakeDrag()) { startedScroll = true; lastTranslateX = ViewProxy.getTranslationX(scrollSlidingTabStrip); } } else if (startedScroll && lastX - ev.getX() > 0) { if (pager.isFakeDragging()) { pager.endFakeDrag(); startedScroll = false; } } } if (startedScroll) { int dx = (int) (ev.getX() - lastX + newTranslationX - lastTranslateX); try { pager.fakeDragBy(dx); lastTranslateX = newTranslationX; } catch (Exception e) { try { pager.endFakeDrag(); } catch (Exception e2) { //don't promt } startedScroll = false; FileLog.e("tmessages", e); } } lastX = ev.getX(); if (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP) { first = true; if (startedScroll) { pager.endFakeDrag(); startedScroll = false; } } return startedScroll || super.onTouchEvent(ev); } return super.onTouchEvent(ev); } }; scrollSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); scrollSlidingTabStrip.setIndicatorColor(0xffe2e5e7); scrollSlidingTabStrip.setUnderlineColor(0xffe2e5e7); scrollSlidingTabStrip.setVisibility(INVISIBLE); addView(scrollSlidingTabStrip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP)); ViewProxy.setTranslationX(scrollSlidingTabStrip, AndroidUtilities.displaySize.x); updateStickerTabs(); scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() { @Override public void onPageSelected(int page) { if (page == 0) { pager.setCurrentItem(0); return; } else if (page == 1 && !recentStickers.isEmpty()) { views.get(6).setSelection(0); return; } int index = page - (recentStickers.isEmpty() ? 1 : 2); if (index >= stickerSets.size()) { index = stickerSets.size() - 1; } views.get(6).setSelection(stickersGridAdapter.getPositionForPack(stickerSets.get(index))); } }); stickersGridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int count = view.getChildCount(); for (int a = 0; a < count; a++) { View child = view.getChildAt(a); if (child.getHeight() + child.getTop() < AndroidUtilities.dp(5)) { firstVisibleItem++; } else { break; } } scrollSlidingTabStrip .onPageScrolled(stickersGridAdapter.getTabForPosition(firstVisibleItem) + 1, 0); } }); } setBackgroundColor(0xfff5f6f7); pager = new ViewPager(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pager.setAdapter(new EmojiPagesAdapter()); pagerSlidingTabStripContainer = new LinearLayout(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL); pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7); addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48)); PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context); pagerSlidingTabStrip.setViewPager(pager); pagerSlidingTabStrip.setShouldExpand(true); pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2)); pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2); pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7); pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f)); pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { EmojiView.this.onPageScrolled(position, getMeasuredWidth(), positionOffsetPixels); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); FrameLayout frameLayout = new FrameLayout(context); pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48)); backspaceButton = new ImageView(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { backspacePressed = true; backspaceOnce = false; postBackspaceRunnable(350); } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { backspacePressed = false; if (!backspaceOnce) { if (listener != null && listener.onBackspace()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } } super.onTouchEvent(event); return true; } }; backspaceButton.setImageResource(R.drawable.ic_smiles_backspace); backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace); backspaceButton.setScaleType(ImageView.ScaleType.CENTER); frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48)); View view = new View(context); view.setBackgroundColor(0xffe2e5e7); frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.LEFT | Gravity.BOTTOM)); recentsWrap = new FrameLayout(context); recentsWrap.addView(views.get(0)); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); textView.setTextSize(18); textView.setTextColor(0xff888888); textView.setGravity(Gravity.CENTER); recentsWrap.addView(textView); views.get(0).setEmptyView(textView); addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0)); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }