List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:com.granita.tasks.groupings.BaseTaskViewDescriptor.java
protected void setDueDate(TextView view, ImageView dueIcon, Time dueDate, boolean isClosed) { if (view != null && dueDate != null) { Time now = mNow;// w w w . j av a 2 s . com if (now == null) { now = mNow = new Time(); } if (!now.timezone.equals(TimeZone.getDefault().getID())) { now.clear(TimeZone.getDefault().getID()); } if (Math.abs(now.toMillis(false) - System.currentTimeMillis()) > 5000) { now.setToNow(); now.normalize(true); } dueDate.normalize(true); view.setText(new DateFormatter(view.getContext()).format(dueDate, now, DateFormatContext.LIST_VIEW)); if (dueIcon != null) { dueIcon.setVisibility(View.VISIBLE); } // highlight overdue dates & times, handle allDay tasks separately if ((!dueDate.allDay && dueDate.before(now) || dueDate.allDay && (dueDate.year < now.year || dueDate.yearDay <= now.yearDay && dueDate.year == now.year)) && !isClosed) { view.setTextAppearance(view.getContext(), R.style.task_list_overdue_text); } else { view.setTextAppearance(view.getContext(), R.style.task_list_due_text); } } else if (view != null) { view.setText(""); if (dueIcon != null) { dueIcon.setVisibility(View.GONE); } } }
From source file:com.newshiqi.yushi.ProfileActivity.java
/** * ??/*w w w . j ava2s .c o m*/ * */ private View initItem(int viewId, CharSequence label, String value, boolean showLine) { View view = findViewById(viewId); if (view != null) { view.setVisibility(View.VISIBLE); TextView labelView = (TextView) view.findViewById(R.id.label_tv); if (labelView != null) { labelView.setText(label); } TextView valueView = (TextView) view.findViewById(R.id.value_tv); if (valueView != null) { if (!TextUtils.isEmpty(value)) { if (value.length() > 11) { value = value.substring(0, 10) + ".."; } } valueView.setText(value); } ImageView lineView = (ImageView) view.findViewById(R.id.bottom_line); if (lineView != null) { if (showLine) { lineView.setVisibility(View.VISIBLE); } else { lineView.setVisibility(View.GONE); } } initOnClick(viewId); } return view; }
From source file:com.odoo.addons.notes.Notes.java
@Override public void onViewBind(View view, Cursor cursor, ODataRow row) { int color_number = row.getInt("color"); view.findViewById(R.id.note_bg_color).setBackgroundColor(NoteUtil.getBackgroundColor(color_number)); OControls.setText(view, R.id.note_memo, StringUtils.htmlToString(row.getString("short_memo"))); OControls.setTextColor(view, R.id.note_memo, NoteUtil.getTextColor(color_number)); OControls.setTextColor(view, R.id.note_reminder_status, NoteUtil.getTextColor(color_number)); ImageView attachment = (ImageView) view.findViewById(R.id.noteHasAttachment); attachment.setColorFilter(NoteUtil.getTextColor(color_number)); boolean showContainer = true; if (((NoteNote) db()).hasAttachment(row.getInt(OColumn.ROW_ID))) { attachment.setVisibility(View.VISIBLE); } else {/*from www.ja va2 s . co m*/ showContainer = false; attachment.setVisibility(View.GONE); } ImageView reminderClock = (ImageView) view.findViewById(R.id.reminderClock); reminderClock.setColorFilter(NoteUtil.getTextColor(color_number)); if (!row.getString("reminder").equals("0")) { view.findViewById(R.id.reminderClock).setVisibility(View.VISIBLE); OControls.setText(view, R.id.note_reminder_status, row.getString("reminder")); } else { if (!showContainer) showContainer = false; view.findViewById(R.id.reminderClock).setVisibility(View.GONE); OControls.setText(view, R.id.note_reminder_status, ""); } view.findViewById(R.id.note_info_container).setVisibility((!showContainer) ? View.GONE : View.VISIBLE); bindRowControls(view, row); }
From source file:com.jihao.imtest.viewpager.PagerSlidingTabStrip.java
public void updateTab(int index, int unread) { LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index); ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator); TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label); if (unreadLbl == null || indicatorView == null) { unreadLbl.setVisibility(View.GONE); indicatorView.setVisibility(View.GONE); return;/*from w w w. ja v a 2 s . c o m*/ } unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE); // indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE); if (unread > 0) { unreadLbl.setText(String.valueOf(unread)); } }
From source file:file_manager.Activity_files.java
private void setFilesList() { deleteDatabase("files_DB_v01.db"); String folder = sharedPref.getString("folder", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()); File f = new File(sharedPref.getString("files_startFolder", folder)); final File[] files = f.listFiles(); if (files == null || files.length == 0) { Snackbar.make(listView, R.string.toast_files, Snackbar.LENGTH_LONG).show(); } else {/*from w w w . j a v a 2 s . c o m*/ // looping through all items <item> for (File file : files) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); String file_Name = file.getName(); String file_Size = getReadableFileSize(file.length()); String file_date = formatter.format(new Date(file.lastModified())); String file_path = file.getAbsolutePath(); String file_ext; if (file.isDirectory()) { file_ext = "."; } else { file_ext = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(".")); } db.open(); if (file_ext.equals(".") || file_ext.equals(".pdf") || file_ext.equals(".") || file_ext.equals(".jpg") || file_ext.equals(".JPG") || file_ext.equals(".jpeg") || file_ext.equals(".png")) { if (db.isExist(file_Name)) { Log.i(TAG, "Entry exists" + file_Name); } else { db.insert(file_Name, file_Size, file_ext, file_path, file_date); } } } } try { db.insert("...", "", "", "", ""); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "files_title", "files_content", "files_creation" }; final Cursor row = db.fetchAllData(this); adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_icon = row2.getString(row2.getColumnIndexOrThrow("files_icon")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final String files_title = row2.getString(row2.getColumnIndexOrThrow("files_title")); final File pathFile = new File(files_attachment); View v = super.getView(position, convertView, parent); final ImageView iv = (ImageView) v.findViewById(R.id.icon_notes); iv.setVisibility(View.VISIBLE); if (pathFile.isDirectory()) { iv.setImageResource(R.drawable.folder); } else { switch (files_icon) { case ".gif": case ".bmp": case ".tiff": case ".svg": case ".png": case ".jpg": case ".JPG": case ".jpeg": try { Uri uri = Uri.fromFile(pathFile); Picasso.with(Activity_files.this).load(uri).resize(76, 76).centerCrop().into(iv); } catch (Exception e) { Log.w("HHS_Moodle", "Error Load image", e); } break; case ".pdf": iv.setImageResource(R.drawable.file_pdf); break; default: iv.setImageResource(R.drawable.arrow_up_dark); break; } } if (files_title.equals("...")) { new Handler().postDelayed(new Runnable() { public void run() { iv.setImageResource(R.drawable.arrow_up_dark); } }, 200); } return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_filesBY", "files_title"); sharedPref.edit().putString("filter_filesBY", "files_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); } }); listView.setAdapter(adapter); //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_icon = row2.getString(row2.getColumnIndexOrThrow("files_icon")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final File pathFile = new File(files_attachment); if (pathFile.isDirectory()) { try { sharedPref.edit().putString("files_startFolder", files_attachment).apply(); setFilesList(); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } } else if (files_attachment.equals("")) { try { final File pathActual = new File(sharedPref.getString("files_startFolder", Environment.getExternalStorageDirectory().getPath())); sharedPref.edit().putString("files_startFolder", pathActual.getParent()).apply(); setFilesList(); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } } else if (files_icon.equals(".pdf")) { Uri uri = Uri.fromFile(pathFile); Intent intent = new Intent(Activity_files.this, MuPDFActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); } else { helper_main.open(files_icon, Activity_files.this, pathFile, listView); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_title = row2.getString(row2.getColumnIndexOrThrow("files_title")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final File pathFile = new File(files_attachment); if (pathFile.isDirectory()) { Snackbar snackbar = Snackbar .make(listView, R.string.toast_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { deleteRecursive(pathFile); setFilesList(); } }); snackbar.show(); } else { final CharSequence[] options = { getString(R.string.choose_menu_2), getString(R.string.choose_menu_3), getString(R.string.choose_menu_4) }; final AlertDialog.Builder dialog = new AlertDialog.Builder(Activity_files.this); dialog.setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); dialog.setItems(options, new DialogInterface.OnClickListener() { @SuppressWarnings("ResultOfMethodCallIgnored") @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.choose_menu_2))) { if (pathFile.exists()) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, files_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, files_title); Uri bmpUri = Uri.fromFile(pathFile); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_file)))); } } if (options[item].equals(getString(R.string.choose_menu_4))) { Snackbar snackbar = Snackbar .make(listView, R.string.toast_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { pathFile.delete(); setFilesList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.choose_menu_3))) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity_files.this); View dialogView = View.inflate(Activity_files.this, R.layout.dialog_edit_file, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setText(files_title); builder.setView(dialogView); builder.setTitle(R.string.choose_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); File dir = pathFile.getParentFile(); File to = new File(dir, inputTag); pathFile.renameTo(to); pathFile.delete(); setFilesList(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Activity_files.this, edit_title); } } }); dialog.show(); } return true; } }); }
From source file:org.getlantern.firetweet.activity.support.CustomTabEditorActivity.java
public void setExtraFieldView(final View view, final Object value) { final TextView text1 = (TextView) view.findViewById(android.R.id.text1); final TextView text2 = (TextView) view.findViewById(android.R.id.text2); final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); final boolean displayProfileImage = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true); final boolean displayName = mPreferences.getBoolean(KEY_NAME_FIRST, true); text1.setVisibility(View.VISIBLE); text2.setVisibility(View.VISIBLE); icon.setVisibility(displayProfileImage ? View.VISIBLE : View.GONE); if (value instanceof ParcelableUser) { final ParcelableUser user = (ParcelableUser) value; text1.setText(getUserNickname(this, user.id, user.name)); text2.setText("@" + user.screen_name); if (displayProfileImage) { mImageLoader.displayProfileImage(icon, user.profile_image_url); }/* w w w. j a v a2 s .c o m*/ } else if (value instanceof ParcelableUserList) { final ParcelableUserList user_list = (ParcelableUserList) value; final String created_by; if (displayName) { created_by = "@" + user_list.user_screen_name; } else { created_by = getUserNickname(this, user_list.user_id, user_list.user_name); } text1.setText(user_list.name); text2.setText(getString(R.string.created_by, created_by)); if (displayProfileImage) { mImageLoader.displayProfileImage(icon, user_list.user_profile_image_url); } } else if (value instanceof CharSequence) { text2.setVisibility(View.GONE); icon.setVisibility(View.GONE); text1.setText((CharSequence) value); } }
From source file:pl.bcichecki.rms.client.android.fragments.listAdapters.EventsListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View view;/* w w w. j a va 2 s . c om*/ if (convertView == null) { view = getLayoutInflater().inflate(FRAGMENT_EVENTS_LIST_ITEM, parent, false); } else { view = convertView; } TextView eventTitle = (TextView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_TITLE); TextView eventFrom = (TextView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_FROM); TextView eventTill = (TextView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_TILL); ImageView archivedIndicator = (ImageView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_INDICATORS_ARCHIVED); ImageView signedUpIndicator = (ImageView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_INDICATORS_SIGNED_UP); ImageView lockedIndicator = (ImageView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_INDICATORS_LOCKED); ImageView ownerIndicator = (ImageView) view.findViewById(FRAGMENT_EVENTS_LIST_ITEM_INDICATORS_OWNER); Locale locale = getContext().getResources().getConfiguration().locale; Event event = getItem(position); eventTitle.setText(event.getTitle()); eventFrom.setText(AppUtils.getFormattedDateAsString(event.getStartDate(), locale)); eventTill.setText(AppUtils.getFormattedDateAsString(event.getEndDate(), locale)); archivedIndicator.setVisibility(event.isArchived() ? View.VISIBLE : View.INVISIBLE); signedUpIndicator.setVisibility( event.isUserSignedUp(UserProfileHolder.getUserProfile()) ? View.VISIBLE : View.INVISIBLE); lockedIndicator.setVisibility(event.isLocked() ? View.VISIBLE : View.INVISIBLE); ownerIndicator.setVisibility(UserProfileHolder.getUserProfile().getId() .equals(StringUtils.defaultString(event.getCreationUserId())) ? View.VISIBLE : View.INVISIBLE); return view; }
From source file:com.tarot.sdfnash.tarot.common.ui.viewpager.PagerSlidingTabStrip.java
public void updateTab(int index, ReminderItem item) { LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index); ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator); TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label); if (item == null || unreadLbl == null || indicatorView == null) { unreadLbl.setVisibility(View.GONE); indicatorView.setVisibility(View.GONE); return;//ww w . j a v a 2 s. com } int unread = item.unread(); boolean indicator = item.indicator(); // unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE); indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE); if (unread > 0) { unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread))); } }
From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java
public void updateTab(int index, ReminderItem item) { LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index); ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator); TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label); if (item == null || unreadLbl == null || indicatorView == null) { unreadLbl.setVisibility(View.GONE); indicatorView.setVisibility(View.GONE); return;/*from www .j a v a2s .c om*/ } int unread = item.unread(); boolean indicator = item.indicator(); unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE); indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE); if (unread > 0) { unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread))); } }
From source file:org.mariotaku.twidere.activity.CustomTabEditorActivity.java
public void setExtraFieldView(final View view, final Object value) { final TextView text1 = (TextView) view.findViewById(android.R.id.text1); final TextView text2 = (TextView) view.findViewById(android.R.id.text2); final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); final boolean displayProfileImage = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true); final boolean displayName = mPreferences.getBoolean(KEY_NAME_FIRST, true); text1.setVisibility(View.VISIBLE); text2.setVisibility(View.VISIBLE); icon.setVisibility(displayProfileImage ? View.VISIBLE : View.GONE); if (value instanceof ParcelableUser) { final ParcelableUser user = (ParcelableUser) value; text1.setText(userColorNameManager.getUserNickname(user.key, user.name)); text2.setText(String.format("@%s", user.screen_name)); if (displayProfileImage) { mediaLoader.displayProfileImage(icon, user); }//from w w w. j a va2 s . co m } else if (value instanceof ParcelableUserList) { final ParcelableUserList userList = (ParcelableUserList) value; final String createdBy = userColorNameManager.getDisplayName(userList, displayName); text1.setText(userList.name); text2.setText(getString(R.string.created_by, createdBy)); if (displayProfileImage) { mediaLoader.displayProfileImage(icon, userList.user_profile_image_url); } } else if (value instanceof CharSequence) { text2.setVisibility(View.GONE); icon.setVisibility(View.GONE); text1.setText((CharSequence) value); } }