List of usage examples for android.widget GridView setOnScrollListener
public void setOnScrollListener(OnScrollListener l)
From source file:com.fbbackup.TagMeImageGridFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.album_photo_grid, container, false); final GridView mGridView = (GridView) v.findViewById(R.id.gridView); TextView tx_user_name = (TextView) v.findViewById(R.id.tx_album_name); tx_user_name.setText(albumName);/*from w w w. j av a 2 s. c o m*/ btn_tag_me = (ImageButton) v.findViewById(R.id.btn_tag_me); btn_photo = (ImageButton) v.findViewById(R.id.btn_photo); btn_tag_me.setVisibility(View.VISIBLE); btn_photo.setVisibility(View.VISIBLE); tx_user_name.setVisibility(View.GONE); btn_tag_me.setBackgroundResource(R.drawable.tagme); btn_photo.setOnClickListener(new ImageButton.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub getFragmentManager().popBackStack(); MyFriendFragmentActivity.controlPanelHandler .sendEmptyMessage(MyFriendFragmentActivity.SHOW_CONTROL_PANEL); } }); cb_all = (CheckBox) v.findViewById(R.id.cb_all_photo); cb_all.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton v, boolean choose) { // TODO Auto-generated method stub if (choose) { // Toast.makeText(getActivity(), "choose:" + choose, // Toast.LENGTH_SHORT).show(); } else { // Toast.makeText(getActivity(), "choose:" + choose, // Toast.LENGTH_SHORT).show(); } setSelectedData(choose); mAdapter.notifyDataSetChanged(); } }); btn_download_photo = (ImageButton) v.findViewById(R.id.btn_download_photo); btn_download_photo.setOnClickListener(new ImageButton.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String dir = Utils.getDirName(albumName); int select = 0; // QarrayU for (int i = 0; i < isSelected.size(); i++) { if (isSelected.get(i)) { DownloadList.downloadPhotoAlbumQueue.add(dir); DownloadList.downloadPhotoQueue.add(tagMePicture[i]); DownloadList.downloadUserNameQueue.add(name); select++; } } DownloadList.setAddNumber(select); DownloadList.setUserName(name); MyFriendFragmentActivity.downloadHandler.sendMessage(MyFriendFragmentActivity.downloadHandler .obtainMessage(MyFriendFragmentActivity.DOWNLOAD_PRB, 0, 0)); } }); isSelected = new HashMap<Integer, Boolean>(); initSelectedData(); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(this); mGridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause fetcher to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { mImageFetcher.setPauseWork(true); } else { mImageFetcher.setPauseWork(false); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); // This listener is used to get the final width of the GridView and then // calculate the // number of columns and the width of each column. The width of each // column is variable // as the GridView has stretchMode=columnWidth. The column width is used // to set the height // of each view so we get nice square thumbnails. mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing; mAdapter.setNumColumns(numColumns); mAdapter.setItemHeight(columnWidth); if (BuildConfig.DEBUG) { Log.d(TAG, "onCreateView - numColumns set to " + numColumns); } } } } }); return v; }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
@SuppressLint("InlinedApi") private void openGridGallery() { final int tnSize = resources.getDimensionPixelSize(R.dimen.post_thumbnail_size); class GridGalleryAdapter extends ArrayAdapter<Triple<AttachmentModel, String, String>> implements View.OnClickListener, AbsListView.OnScrollListener { private final GridView view; private boolean selectingMode = false; private boolean[] isSelected = null; private volatile boolean isBusy = false; public GridGalleryAdapter(GridView view, List<Triple<AttachmentModel, String, String>> list) { super(activity, 0, list); this.view = view; this.isSelected = new boolean[list.size()]; }/*from w ww . j a v a 2s . co m*/ @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { if (isBusy) setNonBusy(); isBusy = false; } else isBusy = true; } private void setNonBusy() { if (!downloadThumbnails()) return; for (int i = 0; i < view.getChildCount(); ++i) { View v = view.getChildAt(i); Object tnTag = v.findViewById(R.id.post_thumbnail_image).getTag(); if (tnTag == null || tnTag == Boolean.FALSE) fill(view.getPositionForView(v), v, false); } } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = new FrameLayout(activity); convertView.setLayoutParams(new AbsListView.LayoutParams(tnSize, tnSize)); ImageView tnImage = new ImageView(activity); tnImage.setLayoutParams(new FrameLayout.LayoutParams(tnSize, tnSize, Gravity.CENTER)); tnImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); tnImage.setId(R.id.post_thumbnail_image); ((FrameLayout) convertView).addView(tnImage); } convertView.setTag(getItem(position).getLeft()); safeRegisterForContextMenu(convertView); convertView.setOnClickListener(this); fill(position, convertView, isBusy); if (isSelected[position]) { /*ImageView overlay = new ImageView(activity); overlay.setImageResource(android.R.drawable.checkbox_on_background);*/ FrameLayout overlay = new FrameLayout(activity); overlay.setBackgroundColor(Color.argb(128, 0, 255, 0)); if (((FrameLayout) convertView).getChildCount() < 2) ((FrameLayout) convertView).addView(overlay); } else { if (((FrameLayout) convertView).getChildCount() > 1) ((FrameLayout) convertView).removeViewAt(1); } return convertView; } private void safeRegisterForContextMenu(View view) { try { view.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (presentationModel == null) { Fragment currentFragment = MainApplication .getInstance().tabsSwitcher.currentFragment; if (currentFragment instanceof BoardFragment) { currentFragment.onCreateContextMenu(menu, v, menuInfo); } } else { BoardFragment.this.onCreateContextMenu(menu, v, menuInfo); } } }); } catch (Exception e) { Logger.e(TAG, e); } } @Override public void onClick(View v) { if (selectingMode) { int position = view.getPositionForView(v); isSelected[position] = !isSelected[position]; notifyDataSetChanged(); } else { BoardFragment fragment = BoardFragment.this; if (presentationModel == null) { Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment; if (currentFragment instanceof BoardFragment) fragment = (BoardFragment) currentFragment; } fragment.openAttachment((AttachmentModel) v.getTag()); } } private void fill(int position, View view, boolean isBusy) { AttachmentModel attachment = getItem(position).getLeft(); String attachmentHash = getItem(position).getMiddle(); ImageView tnImage = (ImageView) view.findViewById(R.id.post_thumbnail_image); if (attachment.thumbnail == null || attachment.thumbnail.length() == 0) { tnImage.setTag(Boolean.TRUE); tnImage.setImageResource(Attachments.getDefaultThumbnailResId(attachment.type)); return; } tnImage.setTag(Boolean.FALSE); CancellableTask imagesDownloadTask = BoardFragment.this.imagesDownloadTask; ExecutorService imagesDownloadExecutor = BoardFragment.this.imagesDownloadExecutor; if (presentationModel == null) { Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment; if (currentFragment instanceof BoardFragment) { imagesDownloadTask = ((BoardFragment) currentFragment).imagesDownloadTask; imagesDownloadExecutor = ((BoardFragment) currentFragment).imagesDownloadExecutor; } } bitmapCache.asyncGet(attachmentHash, attachment.thumbnail, tnSize, chan, localFile, imagesDownloadTask, tnImage, imagesDownloadExecutor, Async.UI_HANDLER, downloadThumbnails() && !isBusy, downloadThumbnails() ? (isBusy ? 0 : R.drawable.thumbnail_error) : Attachments.getDefaultThumbnailResId(attachment.type)); } public void setSelectingMode(boolean selectingMode) { this.selectingMode = selectingMode; if (!selectingMode) { Arrays.fill(isSelected, false); notifyDataSetChanged(); } } public void selectAll() { if (selectingMode) { Arrays.fill(isSelected, true); notifyDataSetChanged(); } } public void downloadSelected(final Runnable onFinish) { final Dialog progressDialog = ProgressDialog.show(activity, resources.getString(R.string.grid_gallery_dlg_title), resources.getString(R.string.grid_gallery_dlg_message), true, false); Async.runAsync(new Runnable() { @Override public void run() { BoardFragment fragment = BoardFragment.this; if (fragment.presentationModel == null) { Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment; if (currentFragment instanceof BoardFragment) fragment = (BoardFragment) currentFragment; } boolean flag = false; for (int i = 0; i < isSelected.length; ++i) if (isSelected[i]) if (!fragment.downloadFile(getItem(i).getLeft(), true)) flag = true; final boolean toast = flag; activity.runOnUiThread(new Runnable() { @Override public void run() { if (toast) Toast.makeText(activity, R.string.notification_download_exists_or_in_queue, Toast.LENGTH_LONG).show(); progressDialog.dismiss(); onFinish.run(); } }); } }); } } try { List<Triple<AttachmentModel, String, String>> list = presentationModel.getAttachments(); if (list == null) { Toast.makeText(activity, R.string.notifacation_updating_now, Toast.LENGTH_LONG).show(); return; } GridView grid = new GridView(activity); final GridGalleryAdapter gridAdapter = new GridGalleryAdapter(grid, list); grid.setNumColumns(GridView.AUTO_FIT); grid.setColumnWidth(tnSize); int spacing = (int) (resources.getDisplayMetrics().density * 5 + 0.5f); grid.setVerticalSpacing(spacing); grid.setHorizontalSpacing(spacing); grid.setPadding(spacing, spacing, spacing, spacing); grid.setAdapter(gridAdapter); grid.setOnScrollListener(gridAdapter); grid.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); final Button btnToSelecting = new Button(activity); btnToSelecting.setText(R.string.grid_gallery_select); CompatibilityUtils.setTextAppearance(btnToSelecting, android.R.style.TextAppearance_Small); btnToSelecting.setSingleLine(); btnToSelecting.setVisibility(View.VISIBLE); btnToSelecting.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final LinearLayout layoutSelectingButtons = new LinearLayout(activity); layoutSelectingButtons.setOrientation(LinearLayout.HORIZONTAL); layoutSelectingButtons.setWeightSum(10f); Button btnDownload = new Button(activity); btnDownload.setLayoutParams( new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.25f)); btnDownload.setText(R.string.grid_gallery_download); CompatibilityUtils.setTextAppearance(btnDownload, android.R.style.TextAppearance_Small); btnDownload.setSingleLine(); Button btnSelectAll = new Button(activity); btnSelectAll.setLayoutParams( new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.75f)); btnSelectAll.setText(android.R.string.selectAll); CompatibilityUtils.setTextAppearance(btnSelectAll, android.R.style.TextAppearance_Small); btnSelectAll.setSingleLine(); Button btnCancel = new Button(activity); btnCancel.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3f)); btnCancel.setText(android.R.string.cancel); CompatibilityUtils.setTextAppearance(btnCancel, android.R.style.TextAppearance_Small); btnCancel.setSingleLine(); layoutSelectingButtons.addView(btnDownload); layoutSelectingButtons.addView(btnSelectAll); layoutSelectingButtons.addView(btnCancel); layoutSelectingButtons.setVisibility(View.GONE); layoutSelectingButtons.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); btnToSelecting.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { btnToSelecting.setVisibility(View.GONE); layoutSelectingButtons.setVisibility(View.VISIBLE); gridAdapter.setSelectingMode(true); } }); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { btnToSelecting.setVisibility(View.VISIBLE); layoutSelectingButtons.setVisibility(View.GONE); gridAdapter.setSelectingMode(false); } }); btnSelectAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gridAdapter.selectAll(); } }); btnDownload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gridAdapter.downloadSelected(new Runnable() { @Override public void run() { btnToSelecting.setVisibility(View.VISIBLE); layoutSelectingButtons.setVisibility(View.GONE); gridAdapter.setSelectingMode(false); } }); } }); LinearLayout dlgLayout = new LinearLayout(activity); dlgLayout.setOrientation(LinearLayout.VERTICAL); dlgLayout.addView(btnToSelecting); dlgLayout.addView(layoutSelectingButtons); dlgLayout.addView(grid); Dialog gridDialog = new Dialog(activity); gridDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); gridDialog.setContentView(dlgLayout); gridDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); gridDialog.show(); } catch (OutOfMemoryError oom) { MainApplication.freeMemory(); Logger.e(TAG, oom); Toast.makeText(activity, R.string.error_out_of_memory, Toast.LENGTH_LONG).show(); } }
From source file:org.telegramsecureplus.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, Context context) { super(context); showStickers = needStickers;/* ww w. ja v a 2s .c o m*/ for (int i = 0; i < Emoji.data.length; 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(Emoji.data[i]); gridView.setAdapter(emojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); adapters.add(emojiGridAdapter); } if (showStickers) { StickersQuery.checkStickers(); GridView gridView = new GridView(context); gridView.setColumnWidth(AndroidUtilities.dp(72)); gridView.setNumColumns(-1); gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); gridView.setClipToPadding(false); views.add(gridView); stickersGridAdapter = new StickersGridAdapter(context); gridView.setAdapter(stickersGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); stickersWrap = new FrameLayout(context); stickersWrap.addView(gridView); 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)); gridView.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); 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))); } }); gridView.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 (EmojiView.this.listener != null && EmojiView.this.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); } }