List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:im.vector.adapters.VectorRoomSummaryAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (null == convertView) { convertView = this.mLayoutInflater.inflate(this.mHeaderLayoutResourceId, null); }/*ww w . jav a 2 s . c o m*/ TextView sectionNameTxtView = convertView.findViewById(R.id.heading); if (null != sectionNameTxtView) { sectionNameTxtView.setText(getGroupTitle(groupPosition)); } ImageView imageView = convertView.findViewById(R.id.heading_image); if (mIsSearchMode) { imageView.setVisibility(View.GONE); } else { if (isExpanded) { imageView.setImageResource(R.drawable.ic_material_expand_less_black); } else { imageView.setImageResource(R.drawable.ic_material_expand_more_black); } } return convertView; }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Attaches the alarmIcon to all Finds in ListView that currently have an * associated Reminder, which is indicated by the Find's * is_adhoc field being set to REMINDER_SET or REMINDER_NOTIFIED. * /*from w ww. j av a 2s . co m*/ * @param context -- the context from which this method is called * @param find -- the current Find * @param view -- the calling activity's contentView, which is needed * to access the UI's sub-views. * */ public void listFindCallback(Context context, Find find, View view) { Log.i(TAG, "listFindCallback"); if (find.getIs_adhoc() == REMINDER_SET || find.getIs_adhoc() == this.REMINDER_NOTIFIED) { ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.list_row_rl); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(25, 25); lp.addRule(RelativeLayout.BELOW, R.id.status); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lp.setMargins(0, 6, 0, 0); rl.addView(alarmIcon, lp); alarmIcon.setVisibility(ImageView.VISIBLE); } }
From source file:de.blinkt.openvpn.ActivityServerList.java
private void makeFavoriteServer() { linearFavorites.removeAllViews();/*from w ww . ja v a2s . c o m*/ for (int i = 0; i < mServerList.size(); i++) { final String server = mServerList.get(i); if (spGlobal.getBoolean(server, false)) { final View viewItem = LayoutInflater.from(this).inflate(R.layout.itemserver, linearSelectedServer, false); ImageView imgViewFlag = (ImageView) viewItem.findViewById(R.id.imgViewFlag); TextView txtCountry = (TextView) viewItem.findViewById(R.id.txtViewCountryName); ImageView imgFavorite = (ImageView) viewItem.findViewById(R.id.imgFavorite); imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_favorite", null, getPackageName())); imgViewFlag.setVisibility(View.GONE); for (int j = 0; j < countryList.length; j++) { String country = countryList[j]; if (server.toLowerCase().contains(country.toLowerCase())) { String resourceName = country.toLowerCase().replace(" ", "_"); int checkExistence = getResources().getIdentifier(resourceName, "drawable", getPackageName()); if (checkExistence != 0) { // the resouce exists... imgViewFlag.setVisibility(View.VISIBLE); imgViewFlag.setImageResource(getResources().getIdentifier("drawable/" + resourceName, null, getPackageName())); } break; } } txtCountry.setText(server); imgFavorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { edGlobal.putBoolean(server, false); edGlobal.commit(); linearFavorites.removeView(viewItem); makeAvaiableServer(); } }); txtCountry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connected) || (ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { if (ActivityDashboard.lolstring.equals(server)) { } else { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; if (VpnStatus.isVPNActive()) { if (ActivityDashboard.mService != null) { try { ActivityDashboard.mService.stopVPN(false); } catch (RemoteException e) { VpnStatus.logException(e); } } } ActivityDashboard.DISCONNECT_VPN_SERVERLIST = 1; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { builder.setMessage( "Currently connecting to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } else { builder.setMessage( "Currently connected to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } } } else { ActivityDashboard.lolstring = server; finish(); } /* if(VpnStatus.isVPNActive() && ActivityDashboard.m_status.equals(Status.Connected) ) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); builder.setMessage("Currently connected to another VPN server. Are you sure you want to change the server?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); }else{ ActivityDashboard.lolstring = server; finish(); }*/ } }); linearFavorites.addView(viewItem); } } }
From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java
@Override public void onUpdateFab(@NonNull ImageView fab) { if (getStopwatch().isRunning()) { fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_pause_white_24dp); fab.setContentDescription(/*from w ww . ja v a 2s.c om*/ fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_pause_button)); } else { fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_start_button)); } fab.setVisibility(VISIBLE); }
From source file:org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView keyId = (TextView) view.findViewById(R.id.keyId); TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails); TextView keyExpiry = (TextView) view.findViewById(R.id.keyExpiry); ImageView masterKeyIcon = (ImageView) view.findViewById(R.id.ic_masterKey); ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey); ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey); ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey); ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(context, cursor.getInt(mIndexAlgorithm), cursor.getInt(mIndexKeySize)); keyId.setText(keyIdStr);/*w w w . j a v a 2 s. c o m*/ // may be set with additional "stripped" later on if (hasAnySecret && cursor.getInt(mIndexHasSecret) == 0) { keyDetails.setText(algorithmStr + ", " + context.getString(R.string.key_stripped)); } else { keyDetails.setText(algorithmStr); } // Set icons according to properties masterKeyIcon.setVisibility(cursor.getInt(mIndexRank) == 0 ? View.VISIBLE : View.INVISIBLE); certifyIcon.setVisibility(cursor.getInt(mIndexCanCertify) != 0 ? View.VISIBLE : View.GONE); encryptIcon.setVisibility(cursor.getInt(mIndexCanEncrypt) != 0 ? View.VISIBLE : View.GONE); signIcon.setVisibility(cursor.getInt(mIndexCanSign) != 0 ? View.VISIBLE : View.GONE); boolean valid = true; if (cursor.getInt(mIndexRevokedKey) > 0) { revokedKeyIcon.setVisibility(View.VISIBLE); valid = false; } else { keyId.setTextColor(mDefaultTextColor); keyDetails.setTextColor(mDefaultTextColor); keyExpiry.setTextColor(mDefaultTextColor); revokedKeyIcon.setVisibility(View.GONE); } if (!cursor.isNull(mIndexExpiry)) { Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000); valid = valid && expiryDate.after(new Date()); keyExpiry.setText(context.getString(R.string.label_expiry) + ": " + DateFormat.getDateFormat(context).format(expiryDate)); } else { keyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none)); } // if key is expired or revoked, strike through text if (!valid) { keyId.setText(OtherHelper.strikeOutText(keyId.getText())); keyDetails.setText(OtherHelper.strikeOutText(keyDetails.getText())); keyExpiry.setText(OtherHelper.strikeOutText(keyExpiry.getText())); } keyId.setEnabled(valid); keyDetails.setEnabled(valid); keyExpiry.setEnabled(valid); }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
/** * Override methods / listeners// ww w. j a v a2s . c o m */ @Override public Object instantiateItem(ViewGroup container, int position) { SwipeItem slideItem = mItems.get(position); LinearLayout layout = null; switch (slideItem.iconGravity) { case CENTER: case DEFAULT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_item, null); break; case LEFT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_left_item, null); break; case RIGHT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_right_item, null); break; } // GET VIEW ImageView icon = (ImageView) layout.findViewById(R.id.swipeselector_content_icon); TextView title = (TextView) layout.findViewById(R.id.swipeselector_content_title); TextView description = (TextView) layout.findViewById(R.id.swipeselector_content_description); // SET VIEW title.setText(slideItem.title); if (slideItem.description == null) { description.setVisibility(View.GONE); } else { description.setVisibility(View.VISIBLE); description.setText(slideItem.description); } if (slideItem.icon == null) { icon.setVisibility(View.GONE); } else { icon.setImageDrawable(slideItem.icon); icon.setVisibility(View.VISIBLE); } // We shouldn't get here if the typeface didn't exist. // But just in case, because we're paranoid. if (mCustomTypeFace != null) { title.setTypeface(mCustomTypeFace); description.setTypeface(mCustomTypeFace); } if (mTitleTextAppearance != -1) { setTextAppearanceCompat(title, mTitleTextAppearance); } if (mDescriptionTextAppearance != -1) { setTextAppearanceCompat(description, mDescriptionTextAppearance); } switch (slideItem.titleGravity) { case DEFAULT: case CENTER: title.setGravity(Gravity.CENTER); break; case LEFT: title.setGravity(Gravity.START); break; case RIGHT: title.setGravity(Gravity.END); break; } switch (slideItem.descriptionGravity) { case DEFAULT: if (mDescriptionGravity != -1) { description.setGravity(mDescriptionGravity); } else { description.setGravity(Gravity.CENTER); } break; case CENTER: description.setGravity(Gravity.CENTER); break; case LEFT: description.setGravity(Gravity.START); break; case RIGHT: description.setGravity(Gravity.END); break; } layout.setPadding(mContentLeftPadding, mSweetSixteen, mContentRightPadding, mSweetSixteen); container.addView(layout); return layout; }
From source file:de.baumann.hhsmoodle.data_notes.Notes_Fragment.java
public void setNotesList() { if (isFABOpen) { closeFABMenu();/*from www . j a v a2 s. c o 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[] { "note_title", "note_content", "note_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 note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); helper_main.switchIcon(getActivity(), note_icon, "note_icon", iv_icon); switch (note_attachment) { case "": iv_attachment.setVisibility(View.GONE); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.ic_attachment); break; } File file = new File(note_attachment); if (!file.exists()) { iv_attachment.setVisibility(View.GONE); } 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), note_title, note_content, "3", note_attachment, note_creation); setNotesList(); } else if (item == 1) { db.update(Integer.parseInt(_id), note_title, note_content, "2", note_attachment, note_creation); setNotesList(); } else if (item == 2) { db.update(Integer.parseInt(_id), note_title, note_content, "1", note_attachment, note_creation); setNotesList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(getActivity(), lv, note_attachment); } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_noteBY", "note_title"); sharedPref.edit().putString("filter_noteBY", "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 note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final Button attachment; final TextView textInput; LayoutInflater inflater = getActivity().getLayoutInflater(); final ViewGroup nullParent = null; final View dialogView = inflater.inflate(R.layout.dialog_note_show, nullParent); final String attName = note_attachment.substring(note_attachment.lastIndexOf("/") + 1); final String att = getString(R.string.app_att) + ": " + attName; attachment = (Button) dialogView.findViewById(R.id.button_att); if (attName.equals("")) { attachment.setVisibility(View.GONE); } else { attachment.setText(att); } textInput = (TextView) dialogView.findViewById(R.id.note_text_input); if (note_content.isEmpty()) { textInput.setVisibility(View.GONE); } else { textInput.setText(note_content); Linkify.addLinks(textInput, Linkify.WEB_URLS); } attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(getActivity(), textInput, note_attachment); } }); final ImageView be = (ImageView) dialogView.findViewById(R.id.imageButtonPri); final ImageView attImage = (ImageView) dialogView.findViewById(R.id.attImage); File file2 = new File(note_attachment); if (!file2.exists()) { attachment.setVisibility(View.GONE); attImage.setVisibility(View.GONE); } else if (note_attachment.contains(".gif") || note_attachment.contains(".bmp") || note_attachment.contains(".tiff") || note_attachment.contains(".png") || note_attachment.contains(".jpg") || note_attachment.contains(".JPG") || note_attachment.contains(".jpeg") || note_attachment.contains(".mpeg") || note_attachment.contains(".mp4") || note_attachment.contains(".3gp") || note_attachment.contains(".3g2") || note_attachment.contains(".avi") || note_attachment.contains(".flv") || note_attachment.contains(".h261") || note_attachment.contains(".h263") || note_attachment.contains(".h264") || note_attachment.contains(".asf") || note_attachment.contains(".wmv")) { attImage.setVisibility(View.VISIBLE); try { Glide.with(getActivity()).load(note_attachment) // or URI/path .diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(attImage); //imageView to set thumbnail to } catch (Exception e) { Log.w("HHS_Moodle", "Error load thumbnail", e); attImage.setVisibility(View.GONE); } attImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(getActivity(), attImage, note_attachment); } }); } switch (note_icon) { case "3": be.setImageResource(R.drawable.circle_green); break; case "2": be.setImageResource(R.drawable.circle_yellow); break; case "1": be.setImageResource(R.drawable.circle_red); break; } android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(getActivity()) .setTitle(note_title).setView(dialogView) .setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setNegativeButton(R.string.note_edit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon).putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(getActivity(), Activity_EditNote.class, false); } }); dialog.show(); } }); 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 note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final CharSequence[] options = { getString(R.string.number_edit_entry), getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share), getString(R.string.todo_menu), getString(R.string.count_create), 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))) { Notes_helper.newNote(getActivity(), note_title, note_content, note_icon, note_attachment, note_creation, _id); } if (options[item].equals(getString(R.string.todo_share))) { File attachment = new File(note_attachment); Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, note_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, note_content); if (attachment.exists()) { Uri bmpUri = Uri.fromFile(attachment); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); } startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.todo_menu))) { Todo_helper.newTodo(getActivity(), note_title, note_content, getActivity().getString(R.string.note_content)); } if (options[item].equals(getString(R.string.count_create))) { Count_helper.newCount(getActivity(), note_title, note_content, getActivity().getString(R.string.note_content), false); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { helper_main.createCalendarEvent(getActivity(), note_title, note_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)); setNotesList(); } }); snackbar.show(); } } }).show(); return true; } }); }
From source file:de.baumann.hhsmoodle.popup.Popup_todo.java
private void setTodoList() { PreferenceManager.setDefaultValues(Popup_todo.this, R.xml.user_settings, false); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Popup_todo.this); NotificationManager nMgr = (NotificationManager) Popup_todo.this .getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll();/*from w w w . j a va 2s .c om*/ //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[] { "todo_title", "todo_content", "todo_creation" }; final String search = sharedPref.getString("filter_todo_subject", ""); final Cursor row = db.fetchDataByFilter(search, "todo_title"); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo.this, 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 todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (todo_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (todo_attachment) { case "true": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle_red); int n = Integer.valueOf(_id); android.content.Intent iMain = new android.content.Intent(); iMain.setAction("shortcutToDo"); iMain.setClassName(Popup_todo.this, "de.baumann.hhsmoodle.activities.Activity_splash"); PendingIntent piMain = PendingIntent.getActivity(Popup_todo.this, n, iMain, 0); NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(Popup_todo.this) .setSmallIcon(R.drawable.school) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain); Notification notification = new NotificationCompat.Builder(Popup_todo.this) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setSmallIcon(R.drawable.school).setContentTitle(todo_title) .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true) .setGroup("HHS_Moodle") .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content)) .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) Popup_todo.this .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); break; } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_todo.this, 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(Popup_todo.this) .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), todo_title, todo_content, "3", todo_attachment, todo_creation); setTodoList(); } else if (item == 1) { db.update(Integer.parseInt(_id), todo_title, todo_content, "2", todo_attachment, todo_creation); setTodoList(); } else if (item == 2) { db.update(Integer.parseInt(_id), todo_title, todo_content, "1", todo_attachment, todo_creation); setTodoList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { switch (todo_attachment) { case "true": db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "", todo_creation); setTodoList(); break; default: db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true", todo_creation); setTodoList(); break; } } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); sharedPref.edit().putString("toDo_title", todo_title).apply(); sharedPref.edit().putString("toDo_text", todo_content).apply(); sharedPref.edit().putString("toDo_seqno", _id).apply(); sharedPref.edit().putString("toDo_icon", todo_icon).apply(); sharedPref.edit().putString("toDo_create", todo_creation).apply(); sharedPref.edit().putString("toDo_attachment", todo_attachment).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_todo.class, false); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); final CharSequence[] options = { getString(R.string.bookmark_edit_title), getString(R.string.todo_share), getString(R.string.bookmark_createNote), getString(R.string.bookmark_createEvent), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_todo.this) .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.bookmark_edit_title))) { AlertDialog.Builder builder = new AlertDialog.Builder(Popup_todo.this); View dialogView = View.inflate(Popup_todo.this, 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(todo_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, todo_content, todo_icon, todo_attachment, todo_creation); setTodoList(); 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(Popup_todo.this, 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, todo_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, todo_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, todo_content); startActivity(calIntent); } 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)); setTodoList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { sharedPref.edit().putString("handleTextTitle", todo_title) .putString("handleTextText", todo_content).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_EditNote.class, false); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { FrameLayout vCustomPart = (FrameLayout) view.findViewById(R.id.part_custom); ImageView vAppIcon = (ImageView) view.findViewById(R.id.part_app_icon); TextView vVersion = (TextView) view.findViewById(R.id.part_version); TextView vOpensource = (TextView) view.findViewById(R.id.part_opensource); TextView vAppName = (TextView) view.findViewById(R.id.part_app_name); if (isVisible(PART_CUSTOM)) { View customView = getCustomPart(); if (customView != null) { vCustomPart.setVisibility(View.VISIBLE); vCustomPart.addView(customView); }// www . ja va 2 s . co m } else { vCustomPart.setVisibility(View.GONE); } if (isVisible(PART_APP_NAME)) { vAppName.setText( getActivity().getApplicationInfo().loadLabel(getActivity().getPackageManager()).toString()); } else { vAppName.setVisibility(View.GONE); } if (isVisible(PART_APP_ICON)) { if (getAppIcon() != 0) { vAppIcon.setImageResource(getAppIcon()); } vAppIcon.setVisibility(View.VISIBLE); vAppIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { IntentUtils.openBrowser(getActivity(), "http://www.avast.com"); } }); } else { vAppIcon.setVisibility(View.GONE); } if (isVisible(PART_VERSION)) { vVersion.setVisibility(View.VISIBLE); setupVersion(vVersion); } else { vVersion.setVisibility(View.GONE); } if (isVisible(PART_OPENSOURCE)) { vOpensource.setVisibility(View.VISIBLE); setupLink(vOpensource, new View.OnClickListener() { @Override public void onClick(View view) { openOpenSourceDialog(); } }); } else { vOpensource.setVisibility(View.GONE); } }
From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceQrCodeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Show activity as popup //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest // requestWindowFeature(Window.FEATURE_ACTION_BAR); // getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,WindowManager.LayoutParams.FLAG_DIM_BEHIND); // final WindowManager.LayoutParams params = getWindow().getAttributes(); // params.height = WindowManager.LayoutParams.WRAP_CONTENT; //fixed height // params.width = WindowManager.LayoutParams.WRAP_CONTENT; //fixed width // params.alpha = 1.0f; // params.dimAmount = 0.5f; // getWindow().setAttributes(params); setContentView(R.layout.tile_status_wireless_iface_qrcode); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }/* ww w.j a va 2 s . c o m*/ final Intent intent = getIntent(); mRouterUuid = intent.getStringExtra(RouterManagementActivity.ROUTER_SELECTED); mSsid = intent.getStringExtra(SSID); mWifiQrCodeString = intent.getStringExtra(WIFI_QR_CODE); final ImageView qrCodeImageView = (ImageView) findViewById(R.id.tile_status_wireless_iface_qrcode_image); final View loadingView = findViewById(R.id.tile_status_wireless_iface_qrcode_image_loading_view); loadingView.setVisibility(View.VISIBLE); new Handler().post(new Runnable() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { try { final Point outSize = new Point(); getWindowManager().getDefaultDisplay().getSize(outSize); mBitmap = encodeAsBitmap(mWifiQrCodeString, BarcodeFormat.QR_CODE, outSize.x, outSize.y / 2); qrCodeImageView.setImageBitmap(mBitmap); qrCodeImageView.setVisibility(View.VISIBLE); loadingView.setVisibility(View.GONE); if (optionsMenu != null) { optionsMenu.findItem(R.id.tile_status_wireless_iface_qrcode_share).setEnabled(true); } } catch (final Exception e) { e.printStackTrace(); mException = e; Utils.reportException(e); findViewById(R.id.tile_status_wireless_iface_qrcode_image_error) .setVisibility(View.VISIBLE); qrCodeImageView.setVisibility(View.GONE); loadingView.setVisibility(View.GONE); qrCodeImageView.setVisibility(View.GONE); if (optionsMenu != null) { optionsMenu.findItem(R.id.tile_status_wireless_iface_qrcode_share) .setEnabled(false); } } } }); } }); ((TextView) findViewById(R.id.tile_status_wireless_iface_qrcode_ssid)).setText(mSsid); }