List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsFileTransferOutView(View view, Cursor cursor) { RcsFileTransferOutViewHolder holder = (RcsFileTransferOutViewHolder) view.getTag(); holder.getTimestampText()// ww w . j a v a2 s . co m .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String mimeType = cursor.getString(holder.getColumnMimetypeIdx()); StringBuilder sb = new StringBuilder(cursor.getString(holder.getColumnFilenameIdx())); long filesize = cursor.getLong(holder.getColumnFilesizeIdx()); long transferred = cursor.getLong(holder.getColumnTransferredIdx()); final ImageView imageView = holder.getFileImageView(); imageView.setOnClickListener(null); imageView.setLayoutParams(mImageParamsDefault); imageView.setImageResource(R.drawable.ri_filetransfer_on); if (filesize != transferred) { holder.getProgressText() .setText(sb.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); } else { holder.getProgressText().setText(sb.append(" (") .append(FileUtils.humanReadableByteCount(filesize, true)).append(")").toString()); } final Uri file = Uri.parse(cursor.getString(holder.getColumnContentIdx())); if (Utils.isImageType(mimeType)) { String filePath = FileUtils.getPath(mContext, file); Bitmap imageBitmap = null; if (filePath != null) { LruCache<String, BitmapCacheInfo> memoryCache = bitmapCache.getMemoryCache(); BitmapCacheInfo bitmapCacheInfo = memoryCache.get(filePath); if (bitmapCacheInfo == null) { ImageBitmapLoader loader = new ImageBitmapLoader(mContext, memoryCache, MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, new BitmapLoader.SetViewCallback() { @Override public void loadView(BitmapCacheInfo cacheInfo) { imageView.setImageBitmap(cacheInfo.getBitmap()); imageView.setLayoutParams(mImageParams); } }); loader.execute(filePath); } else { imageBitmap = bitmapCacheInfo.getBitmap(); } if (imageBitmap != null) { imageView.setImageBitmap(imageBitmap); imageView.setLayoutParams(mImageParams); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.showPicture(mActivity, file); } }); } } else if (Utils.isAudioType(mimeType)) { imageView.setImageResource(R.drawable.headphone); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.playAudio(mActivity, file); } }); } holder.getStatusText().setText(getRcsFileTransferStatus(cursor, holder)); boolean undeliveredExpiration = cursor.getInt(holder.getColumnExpiredDeliveryIdx()) == 1; holder.getStatusText().setCompoundDrawablesWithIntrinsicBounds( undeliveredExpiration ? R.drawable.chat_view_undelivered : 0, 0, 0, 0); }
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsFileTransferInView(View view, Cursor cursor) { final RcsFileTransferInViewHolder holder = (RcsFileTransferInViewHolder) view.getTag(); holder.getTimestampText()/* w w w . j ava2 s .c o m*/ .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String mimeType = cursor.getString(holder.getColumnMimetypeIdx()); StringBuilder sb = new StringBuilder(cursor.getString(holder.getColumnFilenameIdx())); long filesize = cursor.getLong(holder.getColumnFilesizeIdx()); long transferred = cursor.getLong(holder.getColumnTransferredIdx()); final ImageView imageView = holder.getFileImageView(); imageView.setOnClickListener(null); imageView.setLayoutParams(mImageParamsDefault); imageView.setImageResource(R.drawable.ri_filetransfer_off); if (filesize != transferred) { holder.getProgressText() .setText(sb.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); } else { imageView.setImageResource(R.drawable.ri_filetransfer_on); final Uri file = Uri.parse(cursor.getString(holder.getColumnContentIdx())); final RcsService.ReadStatus readStatus = RcsService.ReadStatus .valueOf(cursor.getInt(holder.getColumnReadStatusIdx())); final String id = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.ID)); if (Utils.isImageType(mimeType)) { final String filePath = FileUtils.getPath(mContext, file); if (filePath != null) { LruCache<String, BitmapCacheInfo> memoryCache = bitmapCache.getMemoryCache(); BitmapCacheInfo bitmapCacheInfo = memoryCache.get(filePath); if (bitmapCacheInfo == null) { ImageBitmapLoader loader = new ImageBitmapLoader(mContext, memoryCache, MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, new BitmapLoader.SetViewCallback() { @Override public void loadView(BitmapCacheInfo cacheInfo) { imageView.setImageBitmap(cacheInfo.getBitmap()); imageView.setLayoutParams(mImageParams); } }); loader.execute(filePath); } else { Bitmap imageBitmap = bitmapCacheInfo.getBitmap(); imageView.setImageBitmap(imageBitmap); imageView.setLayoutParams(mImageParams); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.showPicture(mActivity, file); markFileTransferAsRead(id, readStatus); } }); } } else if (Utils.isAudioType(mimeType)) { imageView.setImageResource(R.drawable.headphone); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.playAudio(mActivity, file); markFileTransferAsRead(id, readStatus); } }); } holder.getProgressText().setText(sb.append(" (") .append(FileUtils.humanReadableByteCount(filesize, true)).append(")").toString()); } holder.getStatusText().setText(getRcsFileTransferStatus(cursor, holder)); }
From source file:com.grass.caishi.cc.activity.main.FriendsListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w w w . ja v a 2s . c o m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); // listView.setFootRefresh(false); // listView.setPullLoadEnable(true); swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeLayout); // swipeRefreshLayout.setColorSchemeResources(R.color.swipe_color_1, // R.color.swipe_color_2, R.color.swipe_color_3, R.color.swipe_color_4); // swipeRefreshLayout.setSize(SwipeRefreshLayout.LARGE); // swipeRefreshLayout.setProgressBackgroundColor(R.color.swipe_background_color); swipeRefreshLayout.setProgressViewEndTarget(true, 100); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { ((MainActivity) getActivity()).refreshFriends(); } }); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); contactList = new ArrayList<User>(); // ?contactlist getContactList(); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = MyApplication.getInstance().getContactList(false) .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.KEFU.equals(username)) { // ?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", Constant.KEFU) .putExtra("chatType", 0)); } else { //todo Log.e("kevin", "adapter.getItem(position).getUsername():" + adapter.getItem(position).getUsername()); startActivity(new Intent(getActivity(), Userinfo.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); isInitDone = true; refresh(); // // ? // query = (EditText) getView().findViewById(R.id.query); // // ?button // clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); // query.addTextChangedListener(new TextWatcher() { // public void onTextChanged(CharSequence s, int start, int before, int count) { // adapter.getFilter().filter(s); // if (s.length() > 0) { // clearSearch.setVisibility(View.VISIBLE); // } else { // clearSearch.setVisibility(View.INVISIBLE); // } // } // // public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } // // public void afterTextChanged(Editable s) { // } // }); // clearSearch.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // query.getText().clear(); // } // }); }
From source file:com.yahala.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(OSUtilities.dpf(45.0f)); gridView.setNumColumns(-1);/*from www . j a v a 2 s. c o m*/ views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:hoahong.facebook.messenger.ui.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (Utils.isTablet()) { gridView.setColumnWidth(Utils.dp(60)); } else {/*from w ww.ja va 2s . c o m*/ gridView.setColumnWidth(Utils.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(Utils.dpf(2.0f)); tabs.setUnderlineHeight(Utils.dpf(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(Utils.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText("No recent"); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:cn.ucai.superwechat.ui.SettingsActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.em_fragment_conversation_settings); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/* w ww .j av a2s . co m*/ ImageView back = (ImageView) findViewById(R.id.img_back); back.setVisibility(View.VISIBLE); back.setOnClickListener(this); TextView title = (TextView) findViewById(R.id.txt_title); title.setVisibility(View.VISIBLE); title.setText(getString(R.string.set)); rl_switch_notification = (RelativeLayout) findViewById(R.id.rl_switch_notification); rl_switch_sound = (RelativeLayout) findViewById(R.id.rl_switch_sound); rl_switch_vibrate = (RelativeLayout) findViewById(R.id.rl_switch_vibrate); rl_switch_speaker = (RelativeLayout) findViewById(R.id.rl_switch_speaker); rl_switch_chatroom_leave = (RelativeLayout) findViewById(R.id.rl_switch_chatroom_owner_leave); rl_switch_delete_msg_when_exit_group = (RelativeLayout) findViewById( R.id.rl_switch_delete_msg_when_exit_group); rl_switch_auto_accept_group_invitation = (RelativeLayout) findViewById( R.id.rl_switch_auto_accept_group_invitation); rl_switch_adaptive_video_encode = (RelativeLayout) findViewById(R.id.rl_switch_adaptive_video_encode); rl_custom_server = (RelativeLayout) findViewById(R.id.rl_custom_server); notifiSwitch = (EaseSwitchButton) findViewById(R.id.switch_notification); soundSwitch = (EaseSwitchButton) findViewById(R.id.switch_sound); vibrateSwitch = (EaseSwitchButton) findViewById(R.id.switch_vibrate); speakerSwitch = (EaseSwitchButton) findViewById(R.id.switch_speaker); ownerLeaveSwitch = (EaseSwitchButton) findViewById(R.id.switch_owner_leave); switch_delete_msg_when_exit_group = (EaseSwitchButton) findViewById(R.id.switch_delete_msg_when_exit_group); switch_auto_accept_group_invitation = (EaseSwitchButton) findViewById( R.id.switch_auto_accept_group_invitation); switch_adaptive_video_encode = (EaseSwitchButton) findViewById(R.id.switch_adaptive_video_encode); logoutBtn = (Button) findViewById(R.id.btn_logout); if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) { logoutBtn.setText( getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")"); } customServerSwitch = (EaseSwitchButton) findViewById(R.id.switch_custom_server); textview1 = (TextView) findViewById(R.id.textview1); textview2 = (TextView) findViewById(R.id.textview2); blacklistContainer = (LinearLayout) findViewById(R.id.ll_black_list); // userProfileContainer = (LinearLayout) findViewById(R.id.ll_user_profile); llDiagnose = (LinearLayout) findViewById(R.id.ll_diagnose); pushNick = (LinearLayout) findViewById(R.id.ll_set_push_nick); settingsModel = SuperWeChatHelper.getInstance().getModel(); chatOptions = EMClient.getInstance().getOptions(); blacklistContainer.setOnClickListener(this); // userProfileContainer.setOnClickListener(this); rl_switch_notification.setOnClickListener(this); rl_switch_sound.setOnClickListener(this); rl_switch_vibrate.setOnClickListener(this); rl_switch_speaker.setOnClickListener(this); customServerSwitch.setOnClickListener(this); rl_custom_server.setOnClickListener(this); logoutBtn.setOnClickListener(this); llDiagnose.setOnClickListener(this); pushNick.setOnClickListener(this); rl_switch_chatroom_leave.setOnClickListener(this); rl_switch_delete_msg_when_exit_group.setOnClickListener(this); rl_switch_auto_accept_group_invitation.setOnClickListener(this); rl_switch_adaptive_video_encode.setOnClickListener(this); // the vibrate and sound notification are allowed or not? if (settingsModel.getSettingMsgNotification()) { notifiSwitch.openSwitch(); } else { notifiSwitch.closeSwitch(); } // sound notification is switched on or not? if (settingsModel.getSettingMsgSound()) { soundSwitch.openSwitch(); } else { soundSwitch.closeSwitch(); } // vibrate notification is switched on or not? if (settingsModel.getSettingMsgVibrate()) { vibrateSwitch.openSwitch(); } else { vibrateSwitch.closeSwitch(); } // the speaker is switched on or not? if (settingsModel.getSettingMsgSpeaker()) { speakerSwitch.openSwitch(); } else { speakerSwitch.closeSwitch(); } // if allow owner leave if (settingsModel.isChatroomOwnerLeaveAllowed()) { ownerLeaveSwitch.openSwitch(); } else { ownerLeaveSwitch.closeSwitch(); } // delete messages when exit group? if (settingsModel.isDeleteMessagesAsExitGroup()) { switch_delete_msg_when_exit_group.openSwitch(); } else { switch_delete_msg_when_exit_group.closeSwitch(); } if (settingsModel.isAutoAcceptGroupInvitation()) { switch_auto_accept_group_invitation.openSwitch(); } else { switch_auto_accept_group_invitation.closeSwitch(); } if (settingsModel.isAdaptiveVideoEncode()) { switch_adaptive_video_encode.openSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true); } else { switch_adaptive_video_encode.closeSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false); } if (settingsModel.isCustomServerEnable()) { customServerSwitch.openSwitch(); } else { customServerSwitch.closeSwitch(); } }
From source file:com.negaheno.ui.Components.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {//from ww w . ja va2 s. c o m gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999); adapters.add(localEmojiGridAdapter); } setBackgroundColor(0xff222222); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } updateColors(tabs); }
From source file:com.micabytes.app.BaseFragment.java
@NonNull protected ImageView setImageView(int resId) throws UIObjectNotFoundException { View root = getView();/*w w w . ja v a 2 s . c o m*/ if (root == null) throw new UIObjectNotFoundException(COULD_NOT_FIND_THE_ROOT_VIEW); ImageView v = (ImageView) root.findViewById(resId); if (v == null) throw new UIObjectNotFoundException(COULD_NOT_FIND_RES_ID + resId + IN_FIND_VIEW_BY_ID); v.setOnClickListener(this); return v; }
From source file:me.albinmathew.celluloid.ui.fragments.MovieDetailFragment.java
public void showTrailers(@NonNull List<VideoResponseBean> trailers) { if (trailers.isEmpty()) { mTrailerLabel.setVisibility(View.GONE); mTrailersView.setVisibility(View.GONE); mTrailersScrollView.setVisibility(View.GONE); } else {//from w w w . j a va2s .c o m mTrailerLabel.setVisibility(View.VISIBLE); mTrailersView.setVisibility(View.VISIBLE); mTrailersScrollView.setVisibility(View.VISIBLE); mTrailersView.removeAllViews(); if (mContext != null && isAdded()) { LayoutInflater inflater = getActivity().getLayoutInflater(); Picasso picasso = Picasso.with(getContext()); shareVideos(); for (VideoResponseBean trailer : trailers) { ViewGroup thumbContainer = (ViewGroup) inflater.inflate(R.layout.video, mTrailersView, false); ImageView thumbView = (ImageView) thumbContainer.findViewById(R.id.video_thumb); thumbView.setTag(CommonUtil.getUrl(trailer)); thumbView.requestLayout(); thumbView.setOnClickListener(this); picasso.load(CommonUtil.getThumbnailUrl(trailer)) .resizeDimen(R.dimen.video_width, R.dimen.video_height).centerCrop() .placeholder(R.color.cardview_shadow_start_color).into(thumbView); mTrailersView.addView(thumbContainer); } } } }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();//from w w w .ja v a 2 s .c o m conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }