List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:de.enlightened.peris.SettingsFragment.java
private void setupUserCard() { if (this.getActivity() == null) { return;/*from w w w .j ava2s. c o m*/ } final LinearLayout userLayout = (LinearLayout) getActivity().findViewById(R.id.settings_user_box); if (this.application.getSession().getServer().serverUserId == null) { userLayout.setVisibility(View.GONE); } else { final ImageView ivAvatar = (ImageView) getActivity().findViewById(R.id.settings_user_avatar); final TextView tvUsername = (TextView) getActivity().findViewById(R.id.settings_user_name); final ImageView ivLogout = (ImageView) getActivity().findViewById(R.id.settings_user_logout); tvUsername.setText(this.application.getSession().getServer().serverUserName); if (this.application.getSession().getServer().serverAvatar.contains("http")) { ImageLoader.getInstance().displayImage(this.application.getSession().getServer().serverAvatar, ivAvatar); } else { ivAvatar.setImageResource(R.drawable.no_avatar); } ivLogout.setOnClickListener(new View.OnClickListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { logOut(); } }); userLayout.setOnClickListener(new View.OnClickListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { loadMyWall(); } }); } }
From source file:fm.krui.kruifm.StreamActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stream_layout); // Instantiate class members prefManager = new PreferenceManager(this); favTrackManager = new FavoriteTrackManager(this); stationTag = getIntent().getIntExtra(KEY_STATION_TAG, -1); // Set ActionBar Title ActionBar actionBar = getActionBar(); actionBar.setTitle(getString(R.string.listen_sidebar)); actionBar.setSubtitle(getActivitySubtitle(getIntent())); // FIXME: Move these to PreferenceManager after expanding its scope for cleaner code trackPrefs = this.getSharedPreferences(StreamService.PREFS_NAME, 0); // Instantiate broadcast receiver broadcastReceiver = new BroadcastReceiver() { @Override/*w w w . ja v a 2 s. c o m*/ public void onReceive(Context context, Intent intent) { processBroadcastCommand(intent); } }; // Retrieve player state to determine how to build this activity boolean playerState = prefManager.getPlayerState(); // If audio is playing in StreamService, we don't want to rebuffer, and we want to restore the UI state from the cache. if (playerState) { restoreUIState(); } // If audio is NOT playing, buffer and treat this launch like a clean startup. else { // Determine the URL we need to use to stream based on the station tag and quality preferences streamUrl = getStreamUrl(stationTag); Log.v(TAG, "streamUrl is now set to: " + streamUrl); // Perform initial configuration of audio server changeUrl(stationTag); // Begin buffering the audio startAudio((ImageView) this.findViewById(R.id.play_audio_imageview)); } // Build play button listener final ImageView playButton = (ImageView) this.findViewById(R.id.play_audio_imageview); playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleAudio(playButton); } }); // Build volume seek bar listener // ** DISABLED FOR NOW -- This might be completely thrown out. ** /*final SeekBar volumeSeekBar = (SeekBar)this.findViewById(R.id.volume_seekbar); volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // When seek bar progress is changed, change the audio of the media player appropriately. @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // Send new volume via intent? Will this be slow? } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); */ // Build settings button listener and apply it to settings icon and submit button View.OnClickListener flipListener = new View.OnClickListener() { @Override public void onClick(View v) { // Card flip animation which toggles between stream controls and settings views flipCard(); } }; final ImageView settingsButton = (ImageView) this.findViewById(R.id.stream_settings_imageview); final Button saveSettingsButton = (Button) this.findViewById(R.id.set_stream_settings_button); settingsButton.setOnClickListener(flipListener); saveSettingsButton.setOnClickListener(flipListener); // Build favorite button listener final ImageView favoriteButton = (ImageView) this.findViewById(R.id.stream_favorite_imageview); favoriteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (trackIsFavorite) { favoriteButton.setImageResource(R.drawable.star_unfilled_white); trackIsFavorite = false; removeTrackFromFavorites(); } else { favoriteButton.setImageResource(R.drawable.star_filled_white); trackIsFavorite = true; addTrackToFavorites(); } } }); // Build settings switches final Switch streamQualitySwitch = (Switch) this.findViewById(R.id.stream_quality_switch); final Switch albumArtSwitch = (Switch) this.findViewById(R.id.stream_album_art_switch); // Set initial state of switches albumArtSwitch.setChecked(prefManager.getAlbumArtDownloadPreference()); if (prefManager.getStreamQuality() == prefManager.HIGH_QUALITY) { streamQualitySwitch.setChecked(true); } else { streamQualitySwitch.setChecked(false); } // Assign listeners to switches streamQualitySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setStreamQuality(prefManager.HIGH_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } else { prefManager.setStreamQuality(prefManager.LOW_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } changeUrl(stationSpinnerPosition); } }); albumArtSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setAlbumArtDownloadPreference(true); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } else { prefManager.setAlbumArtDownloadPreference(false); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } } }); // ***** Old onCreate function starts here! // Initialize screen lock/wake receiver IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver screenReceiver = new ScreenReceiver(); // Attach it to this activity this.getApplicationContext().registerReceiver(screenReceiver, filter); }
From source file:com.nanostuffs.yurdriver.fragment.RegisterFragment.java
private void actionBarDetails() { getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); final View addView = getActivity().getLayoutInflater().inflate(R.layout.my_custom_navigation, null); TextView title = (TextView) addView.findViewById(R.id.title); title.setText("REGISTRATION"); ImageView back = (ImageView) addView.findViewById(R.id.back); back.setOnClickListener(new OnClickListener() { @Override// w w w .ja va 2s . c om public void onClick(View v) { // TODO Auto-generated method stub FragmentManager manager = getActivity().getSupportFragmentManager(); manager.popBackStack(); } }); getActivity().getActionBar().setCustomView(addView); }
From source file:com.userhook.view.UHMessageView.java
protected void loadMessage(Map<String, Object> params) { if (meta.getDisplayType().equals(UHMessageMeta.TYPE_IMAGE)) { if (meta.getButton1() != null && meta.getButton1().getImage() != null && meta.getButton1().getImage().getUrl() != null) { AsyncTask task = new AsyncTask<Object, Void, Drawable>() { @Override//from w w w. j a va 2 s .c om protected Drawable doInBackground(Object... params) { Drawable drawable = null; try { URL url = new URL((String) params[0]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream is = conn.getInputStream(); drawable = Drawable.createFromStream(is, "src"); int height = drawable.getIntrinsicHeight(); int width = drawable.getIntrinsicWidth(); drawable.setBounds(0, 0, width, height); } catch (Exception e) { Log.e(UserHook.TAG, "error download message image", e); } return drawable; } @Override protected void onPostExecute(Drawable result) { if (result != null) { // size image to fit inside the view int screenHeight = getResources().getDisplayMetrics().heightPixels; int screenWidth = getResources().getDisplayMetrics().widthPixels; int heightGutter = 40; int widthGutter = 40; int screenSpaceHeight = screenHeight - heightGutter * 2; int screenSpaceWidth = screenWidth - widthGutter * 2; float height = result.getIntrinsicHeight(); float width = result.getIntrinsicWidth(); float aspect = height / width; if (height > screenSpaceHeight) { height = screenHeight; width = height / aspect; } if (width > screenSpaceWidth) { width = screenSpaceWidth; height = width * aspect; } ImageView imageView = new ImageView(getContext()); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageDrawable(result); LayoutParams layoutParams = new LayoutParams((int) width, (int) height); layoutParams.addRule(CENTER_IN_PARENT); addView(imageView, layoutParams); // add click handler to image imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (meta.getButton1() != null) { clickedButton(meta.getButton1()); } } }); contentLoaded = true; if (showAfterLoad) { showDialog(); } } } }; task.execute(meta.getButton1().getImage().getUrl()); } } else if (UHMessageTemplate.getInstance().hasTemplate(meta.getDisplayType())) { String html = UHMessageTemplate.getInstance().renderTemplate(meta); loadWebViewContent(html); if (showAfterLoad) { showDialog(); } } else { UHPostAsyncTask asyncTask = new UHPostAsyncTask(params, new UHAsyncTask.UHAsyncTaskListener() { @Override public void onSuccess(String result) { if (result != null) { loadWebViewContent(result); } if (showAfterLoad) { showDialog(); } } }); asyncTask.execute(UserHook.UH_HOST_URL + UH_MESSAGE_PATH); } }
From source file:kr.baggum.awesomemusic.UI.View.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();/* ww w . j a v a2 s.c o m*/ IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); // attach click event to tab indicator // view.setOnLongClickListener(new OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // int index = ((ViewGroup) v.getParent()).indexOfChild(v); // // Log.d("aaa", index + " indicator selected : long click"); // // //TODO show alternative tab list to change tab // return false; // } // }); view.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int index = ((ViewGroup) v.getParent()).indexOfChild(v); onPageSelected(index); //Log.d("aaa", index + " indicator selected : long click"); //TODO show alternative tab list to change tab } }); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.mobicage.rogerthat.FriendDetailActivity.java
@Override protected void onServiceBound() { T.UI();/*from ww w . j a va 2 s .co m*/ mFriendsPlugin = mService.getPlugin(FriendsPlugin.class); mFriend = showFriend(getIntent()); if (mFriend == null) { if (!isFinishing()) { L.d("Finishing FriendDetailActivity - friend not found"); finish(); } return; } setTitle(mFriend.getDisplayName()); if (getPassportVisibility() != View.GONE) { GetFriendIdentityQRCodeResponseHandler rh = new GetFriendIdentityQRCodeResponseHandler(); rh.setFriendEmail(mFriend.email); GetIdentityQRCodeRequestTO request = new GetIdentityQRCodeRequestTO(); request.email = mFriend.email; try { com.mobicage.api.system.Rpc.getIdentityQRCode(rh, request); } catch (Exception e) { L.bug(e); } } ImageView location = (ImageView) findViewById(R.id.location); location.setImageDrawable(new IconicsDrawable(FriendDetailActivity.this, FontAwesome.Icon.faw_map_marker) .color(LookAndFeelConstants.getPrimaryIconColor(FriendDetailActivity.this)).sizeDp(35)); location.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { T.UI(); if (mFriend.sharesLocation) { String title = getString(R.string.friend_location_requested_title); String message = getString(R.string.friend_location_requested_body, mFriend.name); UIUtils.showDialog(FriendDetailActivity.this, title, message, null); mFriendsPlugin.scheduleSingleFriendLocationRetrieval(mFriend.email); } else { SafeDialogClick onPositiveClickListener = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { dialog.dismiss(); mFriendsPlugin.requestFriendShareLocation(mFriend.email, null); UIUtils.showLongToast(FriendDetailActivity.this, getString(R.string.friend_request_share_location_invitation_sent, mFriendName)); } }; SafeDialogClick onNegativeClickListener = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { dialog.dismiss(); } }; String message = getString(R.string.dialog_request_location_sharing, mFriendName); mRequestFriendToShareLocationDialog = UIUtils.showDialog(FriendDetailActivity.this, null, message, R.string.yes, onPositiveClickListener, R.string.no, onNegativeClickListener); } } }); ImageView newMessage = (ImageView) findViewById(R.id.send); newMessage.setImageDrawable(new IconicsDrawable(FriendDetailActivity.this, FontAwesome.Icon.faw_envelope) .color(LookAndFeelConstants.getPrimaryIconColor(FriendDetailActivity.this)).sizeDp(35)); newMessage.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { final Intent sendMessage = new Intent(FriendDetailActivity.this, SendMessageMessageActivity.class); sendMessage.putExtra(SendMessageMessageActivity.RECIPIENTS, new String[] { mFriend.email }); startActivity(sendMessage); } }); ImageView history = (ImageView) findViewById(R.id.history); history.setImageDrawable(new IconicsDrawable(FriendDetailActivity.this, FontAwesome.Icon.faw_history) .color(LookAndFeelConstants.getPrimaryIconColor(FriendDetailActivity.this)).sizeDp(35)); history.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { final Intent viewMessages = new Intent(FriendDetailActivity.this, MessagingFilterActivity.class); viewMessages.putExtra(MessagingPlugin.MEMBER_FILTER, mFriend.email); startActivity(viewMessages); } }); CheckBox iShareLocationCheckBox = (CheckBox) findViewById(R.id.share_location); // Increase space between checkbox and text iShareLocationCheckBox.setPadding( iShareLocationCheckBox.getPaddingLeft() + UIUtils.convertDipToPixels(this, 10), iShareLocationCheckBox.getPaddingTop(), iShareLocationCheckBox.getPaddingRight(), iShareLocationCheckBox.getPaddingBottom()); IntentFilter filter = getIntentFilter(); if (filter != null) initBroadcastReceiver(filter); }
From source file:com.android.inputmethod.keyboard.EmojiPalettesView.java
@Override protected void onFinishInflate() { mTabHost = (TabHost) findViewById(R.id.emoji_category_tabhost); mTabHost.setup();/* w w w .j a v a2 s. c om*/ for (final CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); mTabHost.getTabWidget().setStripEnabled(true); mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, mLayoutSet, this); mEmojiPager = (ViewPager) findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(ViewPager.PERSISTENT_NO_CACHE); final Resources res = getResources(); final EmojiLayoutParams emojiLp = new EmojiLayoutParams(res); emojiLp.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView) findViewById( R.id.emoji_category_page_id_view); emojiLp.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout) findViewById(R.id.emoji_action_bar); emojiLp.setActionBarProperties(actionBar); final ImageView deleteKey = (ImageView) findViewById(R.id.emoji_keyboard_delete); deleteKey.setTag(Constants.CODE_DELETE); deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); final ImageView alphabetKey = (ImageView) findViewById(R.id.emoji_keyboard_alphabet); alphabetKey.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); alphabetKey.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL); alphabetKey.setOnClickListener(this); final ImageView spaceKey = (ImageView) findViewById(R.id.emoji_keyboard_space); spaceKey.setBackgroundResource(mKeyBackgroundId); spaceKey.setTag(Constants.CODE_SPACE); spaceKey.setOnClickListener(this); emojiLp.setKeyProperties(spaceKey); final ImageView alphabetKey2 = (ImageView) findViewById(R.id.emoji_keyboard_alphabet2); alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); alphabetKey2.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL); alphabetKey2.setOnClickListener(this); }
From source file:com.trukr.shipper.fragment.RequestStatus.java
private void process() { more_Icon.setOnClickListener(new View.OnClickListener() { @Override/*ww w . j av a2 s . c om*/ public void onClick(View v) { showImageAlert(); } }); driverProfile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View popUpView = getLayoutInflater().inflate(R.layout.activity_map_popup, null); // inflating popup layout mpopup = new PopupWindow(popUpView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); //Creation of popup mpopup.setAnimationStyle(android.R.style.Animation_Dialog); mpopup.showAtLocation(popUpView, Gravity.BOTTOM, 0, 0); // Displaying popup RoundedImageView pop_up_driverimage = (RoundedImageView) popUpView.findViewById(R.id.pop_up_image); TextView driverName = (TextView) popUpView.findViewById(R.id.tv_drivername); TextView licenseNumber = (TextView) popUpView.findViewById(R.id.tv_driverlicenseno); TextView usDotnumber = (TextView) popUpView.findViewById(R.id.tv_usdotno); TextView mcNumber = (TextView) popUpView.findViewById(R.id.tv_mcno); TextView licensePlates = (TextView) popUpView.findViewById(R.id.tv_licenseplates); TextView checkSafetyRating = (TextView) popUpView.findViewById(R.id.tv_checksafetyrating); TextView insuranceDocument = (TextView) popUpView.findViewById(R.id.tv_insurancedocument); ImageView moreIcon = (ImageView) popUpView.findViewById(R.id.fragment_btn_currentjobs); moreIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showImageAlert(); } }); checkSafetyRating.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(mContext, WebViewDisplay.class); i.putExtra("insurancedocument", 1); startActivity(i); } }); insuranceDocument.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(mContext, WebViewDisplay.class); i.putExtra("insuranceValue", insuranceValue); startActivity(i); } }); driverName.setText(driversname); System.out.println("driversimage--->" + driverImage); try { Picasso.with(getApplicationContext()).load(driverImage).into(pop_up_driverimage); } catch (Exception e) { e.printStackTrace(); } licenseNumber.setText(": " + driverLicenseValue); usDotnumber.setText(": " + driverUsDotNumberValue); mcNumber.setText(": " + driverMcNumberValue); licensePlates.setText(": " + driverLicensePlatesValue); popup = (LinearLayout) popUpView.findViewById(R.id.map_activity_popup); RoundedImageView view = (RoundedImageView) popUpView.findViewById(R.id.pop_up_image); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mpopup.dismiss(); } }); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, SlidingDrawer.class); intent.putExtra("OrderStatus", 1); startActivity(intent); } }); notification.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RequestStatus.this, Notification.class); startActivity(intent); } }); }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
void init() { // img=(ImageView)findViewById(R.id.logo); TextView build = (TextView) findViewById(R.id.checkfornew); build.setOnClickListener(new View.OnClickListener() { @Override// w w w . j a v a2 s . c om public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } CommonUtilities.logMe("about to check for version "); try { WebServiceHandler wsb = new WebServiceHandler(); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php", postParameters); JSONObject jsonObject = new JSONObject(result); String version = jsonObject.getString("version"); String features = jsonObject.getString("features"); System.err.println("version is : " + version); if (!LoginActivity.myversion.equals(version)) { MyToast.popmessagelong( "There is a new build available. Please download for these features: " + features, TabsActivity.this); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp")); browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(browserIntent); } else { MyToast.popmessagelong("You have the most current version!", TabsActivity.this); } } catch (Exception exc) { exc.printStackTrace(); } } }); TextView maillog = (TextView) findViewById(R.id.maillog); maillog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); TextView question = (TextView) dialog.findViewById(R.id.question); question.setText("Are you sure you want to email the log?"); TextView extra = (TextView) dialog.findViewById(R.id.extratext); extra.setText(""); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" }); i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log"); i.putExtra(Intent.EXTRA_TEXT, "body of email"); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(TabsActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); listops listops = new listops(TabsActivity.this); CommonUtilities.logMe("logging in as: " + listops.getString("firstname")); TextView name = (TextView) findViewById(R.id.welcome); name.setText("Welcome, " + listops.getString("firstname")); TextView logoutname = (TextView) findViewById(R.id.logoutname); logoutname.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); dialog.setContentView(R.layout.dialog_logout); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyToast.popmessagelong("Logging out... ", TabsActivity.this); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.loginkey, ""); editor.commit(); listops listops = new listops(TabsActivity.this); //make sure to remove the downloaded schools Intent intent = new Intent(TabsActivity.this, LoginActivity.class); startActivity(intent); ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>(); listops.putdrilllist(ls); listops.putservicelist(ls); listops.putinstallllist(ls); ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>(); listops.putpendinglist(l); finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); ll1 = (LinearLayout) findViewById(R.id.ll1); ll2 = (LinearLayout) findViewById(R.id.ll2); ll3 = (LinearLayout) findViewById(R.id.ll3); ll4 = (LinearLayout) findViewById(R.id.ll4); ll5 = (LinearLayout) findViewById(R.id.ll5); ll6 = (LinearLayout) findViewById(R.id.ll6); ll1.setBackgroundColor(getResources().getColor(R.color.White)); llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool); llDrills = (LinearLayout) findViewById(R.id.llDrills); llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls); llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls); llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads); frameLayout = (FrameLayout) findViewById(R.id.frame); }
From source file:de.baumann.hhsmoodle.data_count.Count_Fragment.java
public void setCountList() { if (isFABOpen) { closeFABMenu();// ww w .j a v a 2 s .co m } //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "count_title", "count_content", "count_creation" }; final Cursor row = db.fetchAllData(getActivity()); adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title")); final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content")); final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon")); final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment")); final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation")); View v = super.getView(position, convertView, parent); final TextView tv = (TextView) v.findViewById(R.id.text); if (count_attachment.isEmpty()) { tv.setText(count_content); new Handler().postDelayed(new Runnable() { public void run() { int n = tv.getLineCount(); StringBuilder sb = new StringBuilder(n); for (int i = 0; i < n; ++i) { sb.append("0" + '\n'); } String result = sb.toString(); db.update(Integer.parseInt(_id), count_title, count_content, count_icon, result, count_creation); setCountList(); } }, 500); } ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); helper_main.switchIcon(getActivity(), count_icon, "count_icon", iv_icon); iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final helper_main.Item[] items = { new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green), new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), count_title, count_content, "3", count_attachment, count_creation); setCountList(); } else if (item == 1) { db.update(Integer.parseInt(_id), count_title, count_content, "2", count_attachment, count_creation); setCountList(); } else if (item == 2) { db.update(Integer.parseInt(_id), count_title, count_content, "1", count_attachment, count_creation); setCountList(); } } }).show(); } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_countBY", "note_title"); sharedPref.edit().putString("filter_countBY", "note_title").apply(); filter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title")); final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content")); final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon")); final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment")); final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation")); sharedPref.edit().putString("count_title", count_title).apply(); sharedPref.edit().putString("count_content", count_content).apply(); sharedPref.edit().putString("count_seqno", _id).apply(); sharedPref.edit().putString("count_icon", count_icon).apply(); sharedPref.edit().putString("count_create", count_creation).apply(); sharedPref.edit().putString("count_attachment", count_attachment).apply(); helper_main.switchToActivity(getActivity(), Activity_count.class, false); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title")); final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content")); final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon")); final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment")); final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation")); final CharSequence[] options = { getString(R.string.number_edit_entry), getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share), getString(R.string.bookmark_createNote), getString(R.string.bookmark_createEvent) }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.number_edit_entry))) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(count_title); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTag, count_content, count_icon, count_attachment, count_creation); setCountList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(getActivity(), edit_title); } if (options[item].equals(getString(R.string.todo_share))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, count_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, count_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { helper_main.createCalendarEvent(getActivity(), count_title, count_content); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setCountList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { Notes_helper.newNote(getActivity(), count_title, count_content, "", "", "", ""); } } }).show(); return true; } }); }