List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:com.insthub.O2OMobile.Activity.C1_PublishOrderActivity.java
@Override public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException { // TODO Auto-generated method stub if (url.endsWith(ApiInterface.ORDER_PUBLISH)) { orderpublishResponse response = new orderpublishResponse(); response.fromJson(jo);/*from www . jav a 2 s. com*/ ToastView toast = new ToastView(C1_PublishOrderActivity.this, getString(R.string.public_success)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); File file = new File(newFileName()); if (file.exists()) { file.delete(); } if (mDefaultReceiverId == 0) { Intent it = new Intent(this, C2_PublishOrderDistributeActivity.class); it.putExtra(O2OMobileAppConst.ORDERINFO, response.order_info); startActivity(it); finish(); } else { finish(); } } else if (url.endsWith(ApiInterface.LOCATION_INFO)) { mLocation.setText(mLocationInfoModel.publicLocationName); } else if (url.endsWith(ApiInterface.SERVICETYPE_LIST)) { setServiceTypeAdater(); } }
From source file:com.b44t.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, boolean needGif, final Context context) { super(context); showStickers = needStickers;// ww w . j a v a2 s.c om showGifs = needGif; for (int i = 0; i < EmojiData.dataColored.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) { boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, stickersGridView, EmojiView.this.getMeasuredHeight()); return super.onInterceptTouchEvent(event) || result; } @Override public void setVisibility(int visibility) { if (gifsGridView != null && gifsGridView.getVisibility() == VISIBLE) { super.setVisibility(GONE); return; } super.setVisibility(visibility); } }; 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) { return StickerPreviewViewer.getInstance().onTouch(event, stickersGridView, EmojiView.this.getMeasuredHeight(), stickersOnItemClickListener); } }); stickersOnItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long i) { if (!(view instanceof StickerEmojiCell)) { return; } StickerPreviewViewer.getInstance().reset(); StickerEmojiCell cell = (StickerEmojiCell) view; if (cell.isDisabled()) { return; } cell.disable(); TLRPC.Document document = cell.getSticker(); addRecentSticker(document); if (listener != null) { listener.onStickerSelected(document); } } }; stickersGridView.setOnItemClickListener(stickersOnItemClickListener); AndroidUtilities.setListViewEdgeEffectColor(stickersGridView, 0xfff5f6f7); stickersWrap = new FrameLayout(context); stickersWrap.addView(stickersGridView); if (needGif) { gifsGridView = new RecyclerListView(context); gifsGridView.setTag(11); gifsGridView.setLayoutManager(flowLayoutManager = new ExtendedGridLayoutManager(context, 100) { private Size size = new Size(); @Override protected Size getSizeForItem(int i) { TLRPC.Document document = recentImages.get(i).document; size.width = document.thumb != null && document.thumb.w != 0 ? document.thumb.w : 100; size.height = document.thumb != null && document.thumb.h != 0 ? document.thumb.h : 100; for (int b = 0; b < document.attributes.size(); b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeImageSize || attribute instanceof TLRPC.TL_documentAttributeVideo) { size.width = attribute.w; size.height = attribute.h; break; } } return size; } }); flowLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return flowLayoutManager.getSpanSizeForItem(position); } }); gifsGridView.addItemDecoration(new RecyclerView.ItemDecoration() { @Override public void getItemOffsets(android.graphics.Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.left = 0; outRect.top = 0; outRect.bottom = 0; int position = parent.getChildAdapterPosition(view); if (!flowLayoutManager.isFirstRow(position)) { outRect.top = AndroidUtilities.dp(2); } outRect.right = flowLayoutManager.isLastInRow(position) ? 0 : AndroidUtilities.dp(2); } }); gifsGridView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER); gifsGridView.setAdapter(gifsAdapter = new GifsAdapter(context)); gifsGridView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (position < 0 || position >= recentImages.size() || listener == null) { return; } TLRPC.Document document = recentImages.get(position).document; listener.onGifSelected(document); } }); gifsGridView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { @Override public boolean onItemClick(View view, int position) { if (position < 0 || position >= recentImages.size()) { return false; } final MediaController.SearchImage searchImage = recentImages.get(position); AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setMessage(LocaleController.getString("DeleteGif", R.string.DeleteGif)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { recentImages.remove(searchImage); /*TLRPC.TL_messages_saveGif req = new TLRPC.TL_messages_saveGif(); req.id = new TLRPC.TL_inputDocument(); req.id.id = searchImage.document.id; req.id.access_hash = searchImage.document.access_hash; req.unsave = true; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { } });*/ //MessagesStorage.getInstance().removeWebRecent(searchImage); if (gifsAdapter != null) { gifsAdapter.notifyDataSetChanged(); } if (recentImages.isEmpty()) { updateStickerTabs(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.show().setCanceledOnTouchOutside(true); return true; } }); gifsGridView.setVisibility(GONE); stickersWrap.addView(gifsGridView); } stickersEmptyView = new TextView(context); stickersEmptyView.setText(LocaleController.getString("NoStickers", R.string.NoStickers)); stickersEmptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); stickersEmptyView.setTextColor(0xff888888); stickersWrap.addView(stickersEmptyView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); stickersGridView.setEmptyView(stickersEmptyView); 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 (first) { first = false; lastX = ev.getX(); } float newTranslationX = scrollSlidingTabStrip.getTranslationX(); if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) { if (!startedScroll && lastX - ev.getX() < 0) { if (pager.beginFakeDrag()) { startedScroll = true; lastTranslateX = scrollSlidingTabStrip.getTranslationX(); } } 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("messenger", 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); } }; 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)); scrollSlidingTabStrip.setTranslationX(AndroidUtilities.displaySize.x); updateStickerTabs(); scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() { @Override public void onPageSelected(int page) { if (gifsGridView != null) { if (page == gifTabBum + 1) { if (gifsGridView.getVisibility() != VISIBLE) { listener.onGifTab(true); showGifTab(); } } else { if (gifsGridView.getVisibility() == VISIBLE) { listener.onGifTab(false); gifsGridView.setVisibility(GONE); stickersGridView.setVisibility(VISIBLE); stickersEmptyView .setVisibility(stickersGridAdapter.getCount() != 0 ? GONE : VISIBLE); } } } if (page == 0) { pager.setCurrentItem(0); return; } else { if (page == gifTabBum + 1) { return; } else { if (page == recentTabBum + 1) { views.get(6).setSelection(0); return; } } } int index = page - 1 - stickersTabOffset; if (index == stickerSets.size()) { if (listener != null) { listener.onStickersSettingsClick(); } return; } 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) { checkStickersScroll(firstVisibleItem); } }); } 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)); emojiSize = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 40 : 32); pickerView = new EmojiColorPickerView(context); pickerViewPopup = new EmojiPopupWindow(pickerView, popupWidth = AndroidUtilities.dp((AndroidUtilities.isTablet() ? 40 : 32) * 6 + 10 + 4 * 5), popupHeight = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 64 : 56)); pickerViewPopup.setOutsideTouchable(true); pickerViewPopup.setClippingEnabled(true); pickerViewPopup.setInputMethodMode(EmojiPopupWindow.INPUT_METHOD_NOT_NEEDED); pickerViewPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); pickerViewPopup.getContentView().setFocusableInTouchMode(true); pickerViewPopup.getContentView().setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_UP && pickerViewPopup != null && pickerViewPopup.isShowing()) { pickerViewPopup.dismiss(); return true; } return false; } }); loadRecents(); }
From source file:edu.cens.loci.ui.PlaceViewActivity.java
private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) { ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>(); HashMap<String, APInfoMapItem> apMap = wifi.getAps(); Set<String> keys = apMap.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String bssid = iter.next(); APInfoMapItem ap = apMap.get(bssid); items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets)); }//from w w w . j a va 2s . co m Collections.sort(items); table.setColumnCollapsed(0, false); table.setColumnCollapsed(1, true); table.setColumnShrinkable(0, true); for (int i = 0; i < mAddedRows.size(); i++) { table.removeView(mAddedRows.get(i)); } mAddedRows.clear(); int totalCount = wifi.getScanCount(); for (WifiViewListItem item : items) { TableRow row = new TableRow(this); TextView ssidView = new TextView(this); ssidView.setText(item.ssid); //ssidView.setText("very very very veryvery very very very very very"); ssidView.setPadding(2, 2, 2, 2); ssidView.setTextColor(0xffffffff); TextView bssidView = new TextView(this); bssidView.setText(item.bssid); bssidView.setPadding(2, 2, 2, 2); bssidView.setTextColor(0xffffffff); TextView cntView = new TextView(this); cntView.setText("" + (item.count * 100) / totalCount); cntView.setPadding(2, 2, 2, 2); cntView.setGravity(Gravity.CENTER); cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); TextView rssView = new TextView(this); rssView.setText("" + item.rss); rssView.setPadding(2, 2, 6, 2); rssView.setGravity(Gravity.CENTER); rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); row.addView(ssidView, new TableRow.LayoutParams(0)); row.addView(bssidView, new TableRow.LayoutParams(1)); row.addView(cntView, new TableRow.LayoutParams(2)); row.addView(rssView, new TableRow.LayoutParams(3)); //Log.d(TAG, item.ssid); for (int i = 0; i < item.rssBuckets.length; i++) { TextView box = new TextView(this); box.setText(" "); box.setGravity(Gravity.RIGHT); box.setPadding(2, 2, 2, 2); box.setHeight(15); box.setGravity(Gravity.CENTER_VERTICAL); float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount()); //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]); int colorValInt = ((int) colorVal) - 1; if (colorValInt < 0) colorValInt = 0; box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan)); box.setTextColor(0xffffffff); row.addView(box, new TableRow.LayoutParams(4 + i)); } row.setGravity(Gravity.CENTER); table.addView(row, new TableLayout.LayoutParams()); table.setColumnStretchable(3, true); mAddedRows.add(row); } }
From source file:com.fullteem.yueba.app.ui.ChatActivity.java
/** * window/* w w w . j a va 2 s. co m*/ */ private void windowShow() { if (popupWindow == null) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); menuView = layoutInflater.inflate(R.layout.popwindow_msgmenu, null); listviewMsgMenus = (ListView) menuView.findViewById(R.id.listviewMsgPop); mma = new MessageMenuAdapter(this, menuTexts); listviewMsgMenus.setAdapter(mma); // PopuWidow popupWindow = new PopupWindow(menuView, 300, 500); } // ? popupWindow.setFocusable(true); // ? popupWindow.setOutsideTouchable(true); // Back??? popupWindow.setBackgroundDrawable(new BitmapDrawable()); WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); // ?:??-PopupWindow? int xPos = windowManager.getDefaultDisplay().getWidth() / 2 - popupWindow.getWidth() / 2; Log.i("coder", "windowManager.getDefaultDisplay().getWidth()/2:" + windowManager.getDefaultDisplay().getWidth() / 2); // Log.i("coder", "popupWindow.getWidth()/2:" + popupWindow.getWidth() / 2); Log.i("coder", "xPos:" + xPos); popupWindow.showAsDropDown(viewBtnMore, xPos, 0); listviewMsgMenus.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (popupWindow != null) { popupWindow.dismiss(); } // if (menuTexts[position].equals("")) { String strName = getString(R.string.add_firend); String msg = String.format(strName, userNickName); popMenu = new CommonPopWindow(ChatActivity.this, msg, new OnClickListener() { @Override public void onClick(View v) { addContact(); addFriendPop.dismiss(); } }, new OnClickListener() { @Override public void onClick(View v) { addFriendPop.dismiss(); } }); // ? popMenu.setIsEditText(false); // popMenu.preperShow(); addFriendPop = popMenu.getMenu(); addFriendPop.setOutsideTouchable(true); if (addFriendPop == null) { return; } if (addFriendPop.isShowing()) { addFriendPop.dismiss(); return; } addFriendPop.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0); } else if (menuTexts[position].equals("?")) { } // ? else if (menuTexts[position].equals("")) { // try { // EMContactManager.getInstance().deleteContact( // toChatUsername); // } catch (EaseMobException e) { // showToast(""); // } deleteFriends(); } else if (menuTexts[position].equals("?")) {// bill Intent intentDatePublish = new Intent(ChatActivity.this, DatePublishActivity.class); // TODO ????id,????????idname DBFriendListDao friendListDao = new DBFriendListDao(ChatActivity.this); UserCommonModel um = friendListDao.getContacter(toChatUsername); if (um == null) return; UmengUtil.onEvent(ChatActivity.this, "friend_chat_access_post_date_button_hits"); LogUtil.printUmengLog("friend_chat_access_post_date_button_hits"); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_ID, Integer.valueOf(TextUtils.isEmpty(um.getUserId()) ? "0" : um.getUserId())); // userIdint intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_NAME, um.getUserName()); // String intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_MOBILE, um.getUserMobile()); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_URL, um.getUserLogoUrl()); intentDatePublish.putExtra("isExist", true); startActivity(intentDatePublish); } else if (menuTexts[position].equals("")) { HttpRequest.getInstance(ChatActivity.this).getOutGroup(appContext.getUserInfo().getUserMobile(), toChatUsername, new CustomAsyncResponehandler() { @Override public void onSuccess(ResponeModel baseModel) { if (baseModel != null && baseModel.isStatus()) { showToast("?"); finish(); return; } showToast(getString(R.string.hint_operationError)); } @Override public void onFailure(Throwable error, String content) { showToast(getString(R.string.hint_operationError)); } }); } } }); }
From source file:com.ccxt.whl.activity.ChatActivity.java
/** * ?uri??//from w w w . j ava2 s . co m * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static void createViewRunnables() { viewRunnables = new HashMap<>(30); viewRunnables.put("scaleType", new ViewParamRunnable() { @Override// ww w . j av a 2 s. c om public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof ImageView) { ImageView.ScaleType scaleType = ((ImageView) view).getScaleType(); switch (value.toLowerCase()) { case "center": scaleType = ImageView.ScaleType.CENTER; break; case "center_crop": scaleType = ImageView.ScaleType.CENTER_CROP; break; case "center_inside": scaleType = ImageView.ScaleType.CENTER_INSIDE; break; case "fit_center": scaleType = ImageView.ScaleType.FIT_CENTER; break; case "fit_end": scaleType = ImageView.ScaleType.FIT_END; break; case "fit_start": scaleType = ImageView.ScaleType.FIT_START; break; case "fit_xy": scaleType = ImageView.ScaleType.FIT_XY; break; case "matrix": scaleType = ImageView.ScaleType.MATRIX; break; } ((ImageView) view).setScaleType(scaleType); } } }); viewRunnables.put("orientation", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof LinearLayout) { ((LinearLayout) view).setOrientation( value.equals("vertical") ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL); } } }); viewRunnables.put("text", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { ((TextView) view).setText(value); } } }); viewRunnables.put("textSize", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX, DimensionConverter.stringToDimension(value, view.getResources().getDisplayMetrics())); } } }); viewRunnables.put("textColor", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { ((TextView) view).setTextColor(parseColor(view, value)); } } }); viewRunnables.put("textStyle", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { int typeFace = Typeface.NORMAL; if (value.contains("bold")) typeFace |= Typeface.BOLD; else if (value.contains("italic")) typeFace |= Typeface.ITALIC; ((TextView) view).setTypeface(null, typeFace); } } }); viewRunnables.put("textAlignment", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { int alignment = View.TEXT_ALIGNMENT_TEXT_START; switch (value) { case "center": alignment = View.TEXT_ALIGNMENT_CENTER; break; case "left": case "textStart": break; case "right": case "textEnd": alignment = View.TEXT_ALIGNMENT_TEXT_END; break; } view.setTextAlignment(alignment); } else { int gravity = Gravity.LEFT; switch (value) { case "center": gravity = Gravity.CENTER; break; case "left": case "textStart": break; case "right": case "textEnd": gravity = Gravity.RIGHT; break; } ((TextView) view).setGravity(gravity); } } }); viewRunnables.put("ellipsize", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { TextUtils.TruncateAt where = TextUtils.TruncateAt.END; switch (value) { case "start": where = TextUtils.TruncateAt.START; break; case "middle": where = TextUtils.TruncateAt.MIDDLE; break; case "marquee": where = TextUtils.TruncateAt.MARQUEE; break; case "end": break; } ((TextView) view).setEllipsize(where); } } }); viewRunnables.put("singleLine", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { ((TextView) view).setSingleLine(); } } }); viewRunnables.put("hint", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof EditText) { ((EditText) view).setHint(value); } } }); viewRunnables.put("inputType", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof TextView) { int inputType = 0; switch (value) { case "textEmailAddress": inputType |= InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case "number": inputType |= InputType.TYPE_CLASS_NUMBER; break; case "phone": inputType |= InputType.TYPE_CLASS_PHONE; break; } if (inputType > 0) ((TextView) view).setInputType(inputType); } } }); viewRunnables.put("gravity", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { int gravity = parseGravity(value); if (view instanceof TextView) { ((TextView) view).setGravity(gravity); } else if (view instanceof LinearLayout) { ((LinearLayout) view).setGravity(gravity); } else if (view instanceof RelativeLayout) { ((RelativeLayout) view).setGravity(gravity); } } }); viewRunnables.put("src", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { if (view instanceof ImageView) { String imageName = value; if (imageName.startsWith("//")) imageName = "http:" + imageName; if (imageName.startsWith("http")) { if (imageLoader != null) { if (attrs.containsKey("cornerRadius")) { int radius = DimensionConverter.stringToDimensionPixelSize( attrs.get("cornerRadius"), view.getResources().getDisplayMetrics()); imageLoader.loadRoundedImage((ImageView) view, imageName, radius); } else { imageLoader.loadImage((ImageView) view, imageName); } } } else if (imageName.startsWith("@drawable/")) { imageName = imageName.substring("@drawable/".length()); ((ImageView) view).setImageDrawable(getDrawableByName(view, imageName)); } } } }); viewRunnables.put("visibility", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { int visibility = View.VISIBLE; String visValue = value.toLowerCase(); if (visValue.equals("gone")) visibility = View.GONE; else if (visValue.equals("invisible")) visibility = View.INVISIBLE; view.setVisibility(visibility); } }); viewRunnables.put("clickable", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { view.setClickable(value.equals("true")); } }); viewRunnables.put("tag", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { // Sigh, this is dangerous because we use tags for other purposes if (view.getTag() == null) view.setTag(value); } }); viewRunnables.put("onClick", new ViewParamRunnable() { @Override public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) { view.setOnClickListener(getClickListener(parent, value)); } }); }
From source file:com.ccxt.whl.activity.SettingsFragmentC_0815.java
/** * ?uri?/*from w w w . java2 s. com*/ * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getActivity().getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } //copyFile(picturePath,imageUri.getPath()); cropImageUri(selectedImage, 200, 200, USERPIC_REQUEST_CODE_CUT); //sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } //copyFile(selectedImage.getPath(),imageUri.getPath()); cropImageUri(selectedImage, 200, 200, USERPIC_REQUEST_CODE_CUT); //sendPicture(file.getAbsolutePath()); } /*if(getpathfromUri(uri)!=null&&getpathfromUri(imageUri)!=null){ copyFile(getpathfromUri(uri),getpathfromUri(imageUri)); }else{ return; }*/ //cropImageUri(selectedImage, 150, 150, USERPIC_REQUEST_CODE_CUT); }
From source file:android.support.v7.app.AppCompatDelegateImplV7.java
private boolean initializePanelDecor(PanelFeatureState st) { st.setStyle(getActionBarThemedContext()); st.decorView = new ListMenuDecorView(st.listPresenterContext); st.gravity = Gravity.CENTER | Gravity.BOTTOM; return true;/* w ww .j av a 2s. co m*/ }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
/** * app mcu'V' /*from w w w. j a va 2s . c o m*/ */ protected void isVapour() { State_Vapour = ""; mLogCabinInfo.setSTATE_VAPOUR(State_Vapour); toastDisplay(getApplicationContext(), "", Gravity.CENTER, R.drawable.icon_vapour_white, Toast.LENGTH_SHORT); vibratorSettings(1);// State_Vapour = ""; mLogCabinInfo.setSTATE_VAPOUR(State_Vapour); }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
/** * app mcu'I' /* ww w. j av a2s . com*/ */ protected void isIr() { State_Ir = ""; mLogCabinInfo.setSTATE_IR(State_Ir); toastDisplay(getApplicationContext(), "~~~", Gravity.CENTER, R.drawable.icon_ir_coming, Toast.LENGTH_SHORT); vibratorSettings(1);// State_Ir = ""; mLogCabinInfo.setSTATE_IR(State_Ir); }