Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

private void updateFab(@NonNull ImageView fab, boolean animate) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }//from  w ww  . jav  a 2  s.com

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_play_pause_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_play_pause);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_stop));
            break;
        case RESET:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_stop_play_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            break;
        case PAUSED:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            break;
        case MISSED:
        case EXPIRED:
            fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_stop));
            break;
        }
    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_start_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setContentDescription(null);
            fab.setVisibility(INVISIBLE);
        }
    }
}

From source file:de.vanita5.twittnuker.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 display_profile_image = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
    final boolean nickname_only = mPreferences.getBoolean(KEY_NICKNAME_ONLY, false);
    final boolean display_name = mPreferences.getBoolean(KEY_NAME_FIRST, true);
    text1.setVisibility(View.VISIBLE);
    text2.setVisibility(View.VISIBLE);
    icon.setVisibility(display_profile_image ? View.VISIBLE : View.GONE);
    if (value instanceof ParcelableUser) {
        final ParcelableUser user = (ParcelableUser) value;
        final String nick = getUserNickname(this, user.id);
        text1.setText(TextUtils.isEmpty(nick) ? user.name
                : nickname_only ? nick : getString(R.string.name_with_nickname, user.name, nick));
        text2.setText("@" + user.screen_name);
        if (display_profile_image) {
            mImageLoader.displayProfileImage(icon, user.profile_image_url);
        }/*from   w  ww.  jav  a2 s  .com*/
    } else if (value instanceof ParcelableUserList) {
        final ParcelableUserList user_list = (ParcelableUserList) value;
        final String created_by;
        if (display_name) {
            created_by = "@" + user_list.user_screen_name;
        } else {
            final String nick = getUserNickname(this, user_list.user_id);
            created_by = TextUtils.isEmpty(nick) ? user_list.user_name
                    : nickname_only ? nick : getString(R.string.name_with_nickname, user_list.user_name, nick);
        }
        text1.setText(user_list.name);
        text2.setText(getString(R.string.created_by, created_by));
        if (display_profile_image) {
            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:fm.krui.kruifm.StreamActivity.java

/**
 * Enables and disables the loading indicator for UI views.
 * @param showLoadingIndicator True to enable, false to disable.
 *///  www .jav  a 2  s .  co  m
private void setLoadingIndicator(final boolean showLoadingIndicator) {
    Log.v(TAG, "setLoadingIndicator called!");
    Log.v(TAG, "Called with " + showLoadingIndicator + " parameter.");
    // Instantiate views
    ProgressBar progressBar = (ProgressBar) this.findViewById(R.id.album_art_progressbar);
    ImageView albumArtPaneImageView = (ImageView) this.findViewById(R.id.album_art_pane);
    ImageView albumArtLoadingPaneImageView = (ImageView) this.findViewById(R.id.album_art_loading_pane);
    if (showLoadingIndicator) {
        // Show loading indicators
        progressBar.setVisibility(View.VISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.VISIBLE);
        albumArtPaneImageView.setVisibility(View.INVISIBLE);

    } else {
        // Hide progressBar and placeholder image and re-show album art pane.
        progressBar.setVisibility(View.INVISIBLE);
        albumArtLoadingPaneImageView.setVisibility(View.INVISIBLE);
        albumArtPaneImageView.setVisibility(View.VISIBLE);
    }
}

From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java

private void setThumbnail() {
    // SET!// w w w.j a v a  2  s .c o m
    ImageView thumbView = (ImageView) findViewById(R.id.ThumbnailImage);

    if (mCurrentThumbnail != null) {
        // If we have a thumbnail, by all means, put it in!
        thumbView.setImageBitmap(mCurrentThumbnail);
        thumbView.setVisibility(View.VISIBLE);
    } else {
        // Otherwise, make it vanish entirely.  This is handy for, say,
        // clearing the thumbnail after an upload.
        thumbView.setVisibility(View.GONE);
    }
}

From source file:de.ub0r.android.wifibarcode.WifiBarcodeActivity.java

/**
 * Show barcode./*from   ww w .j a  v a  2  s.  c o m*/
 *
 * @param cacheOnly load only from cache
 */
private void showBarcode(final boolean cacheOnly) {
    final String url = getUrl();
    if (!cacheOnly && !this.barcodes.containsKey(url)) {
        Log.i(TAG, "barcode not available, load it...");
        BarcodeLoader loader = new BarcodeLoader();
        loader.execute(url);
    }
    ImageView iv = (ImageView) findViewById(R.id.barcode);
    Bitmap bc = barcodes.get(url);
    if (bc != null) {
        iv.setImageBitmap(bc);
        iv.setVisibility(View.VISIBLE);
        findViewById(R.id.c2e).setVisibility(View.VISIBLE);
        findViewById(R.id.progress).setVisibility(View.GONE);
    } else {
        iv.setVisibility(View.GONE);
        findViewById(R.id.c2e).setVisibility(View.GONE);
        if (!cacheOnly) {
            findViewById(R.id.progress).setVisibility(View.VISIBLE);
        }
    }
    if (cacheOnly) {
        findViewById(R.id.progress).setVisibility(View.GONE);
    }
}

From source file:de.baumann.hhsmoodle.data_files.Files_Fragment.java

public void setFilesList() {

    getActivity().deleteDatabase("files_DB_v01.db");

    File f = new File(sharedPref.getString("files_startFolder",
            Environment.getExternalStorageDirectory().getPath() + "/HHS_Moodle/"));
    final File[] files = f.listFiles();

    // looping through all items <item>
    if (files.length == 0) {
        Snackbar.make(lv, R.string.toast_files, Snackbar.LENGTH_LONG).show();
    }//from  w ww  .j a  v a  2  s .com

    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 (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(lv, R.string.toast_directory, Snackbar.LENGTH_LONG).show();
    }

    //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[] { "files_title", "files_content", "files_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 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);

            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 "":
                    new Handler().postDelayed(new Runnable() {
                        public void run() {
                            iv.setImageResource(R.drawable.arrow_up);
                        }
                    }, 200);
                    break;
                case ".gif":
                case ".bmp":
                case ".tiff":
                case ".svg":
                case ".png":
                case ".jpg":
                case ".JPG":
                case ".jpeg":
                    try {
                        Glide.with(getActivity()).load(files_attachment) // or URI/path
                                .override(76, 76).centerCrop().into(iv); //imageView to set thumbnail to
                    } catch (Exception e) {
                        Log.w("HHS_Moodle", "Error load thumbnail", e);
                        iv.setImageResource(R.drawable.file_image);
                    }
                    break;
                case ".m3u8":
                case ".mp3":
                case ".wma":
                case ".midi":
                case ".wav":
                case ".aac":
                case ".aif":
                case ".amp3":
                case ".weba":
                case ".ogg":
                    iv.setImageResource(R.drawable.file_music);
                    break;
                case ".mpeg":
                case ".mp4":
                case ".webm":
                case ".qt":
                case ".3gp":
                case ".3g2":
                case ".avi":
                case ".f4v":
                case ".flv":
                case ".h261":
                case ".h263":
                case ".h264":
                case ".asf":
                case ".wmv":
                    try {
                        Glide.with(getActivity()).load(files_attachment) // or URI/path
                                .override(76, 76).centerCrop().into(iv); //imageView to set thumbnail to
                    } catch (Exception e) {
                        Log.w("HHS_Moodle", "Error load thumbnail", e);
                        iv.setImageResource(R.drawable.file_video);
                    }
                    break;
                case ".vcs":
                case ".vcf":
                case ".css":
                case ".ics":
                case ".conf":
                case ".config":
                case ".java":
                case ".html":
                    iv.setImageResource(R.drawable.file_xml);
                    break;
                case ".apk":
                    iv.setImageResource(R.drawable.android);
                    break;
                case ".pdf":
                    iv.setImageResource(R.drawable.file_pdf);
                    break;
                case ".rtf":
                case ".csv":
                case ".txt":
                case ".doc":
                case ".xls":
                case ".ppt":
                case ".docx":
                case ".pptx":
                case ".xlsx":
                case ".odt":
                case ".ods":
                case ".odp":
                    iv.setImageResource(R.drawable.file_document);
                    break;
                case ".zip":
                case ".rar":
                    iv.setImageResource(R.drawable.zip_box);
                    break;
                default:
                    iv.setImageResource(R.drawable.file);
                    break;
                }
            }
            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);
        }
    });

    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 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(lv, 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(lv, R.string.toast_directory, Snackbar.LENGTH_LONG).show();
                }
            } else {
                helper_main.openAtt(getActivity(), lv, files_attachment);
            }
        }
    });

    lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) lv.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(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG)
                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                sharedPref.edit().putString("files_startFolder", pathFile.getParent()).apply();
                                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(getActivity());
                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(lv, R.string.note_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))) {

                            android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(
                                    getActivity());
                            View dialogView = View.inflate(getActivity(), 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(getActivity(), edit_title);
                        }
                    }
                });
                dialog.show();
            }

            return true;
        }
    });
}

From source file:com.tandong.sa.sherlock.widget.SuggestionsAdapter.java

/**
 * Sets the drawable in an image view, makes sure the view is only visible
 * if there is a drawable.//from  w ww . j  a v a 2  s.c  om
 */
private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) {
    // Set the icon even if the drawable is null, since we need to clear any
    // previous icon.
    v.setImageDrawable(drawable);

    if (drawable == null) {
        v.setVisibility(nullVisibility);
    } else {
        v.setVisibility(View.VISIBLE);

        // This is a hack to get any animated drawables (like a 'working'
        // spinner)
        // to animate. You have to setVisible true on an AnimationDrawable
        // to get
        // it to start animating, but it must first have been false or else
        // the
        // call to setVisible will be ineffective. We need to clear up the
        // story
        // about animated drawables in the future, see http://b/1878430.
        drawable.setVisible(false, false);
        drawable.setVisible(true, false);
    }
}

From source file:de.baumann.browser.popups.Popup_files.java

private void setFilesList() {

    deleteDatabase("files_DB_v01.db");

    File f = new File(sharedPref.getString("files_startFolder",
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()));
    final File[] files = f.listFiles();

    Arrays.sort(files, new Comparator<File>() {
        @Override/*  ww w .  j ava  2s . c  o m*/
        public int compare(File file1, File file2) {
            if (file1.isDirectory()) {
                if (file2.isDirectory()) {
                    return String.valueOf(file1.getName().toLowerCase())
                            .compareTo(file2.getName().toLowerCase());
                } else {
                    return -1;
                }
            } else {
                if (file2.isDirectory()) {
                    return 1;
                } else {
                    return String.valueOf(file1.getName().toLowerCase())
                            .compareTo(file2.getName().toLowerCase());
                }
            }
        }
    });

    // looping through all items <item>
    if (files.length == 0) {
        Snackbar.make(listView, R.string.toast_files, Snackbar.LENGTH_LONG).show();
    }

    for (File file : files) {

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());

        String file_Name = file.getName().substring(0, 1).toUpperCase() + file.getName().substring(1);
        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 (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 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 "":
                    iv.setImageResource(R.drawable.arrow_up_dark);
                    break;
                case ".m3u8":
                case ".mp3":
                case ".wma":
                case ".midi":
                case ".wav":
                case ".aac":
                case ".aif":
                case ".amp3":
                case ".weba":
                case ".ogg":
                    iv.setImageResource(R.drawable.file_music);
                    break;
                case ".mpeg":
                case ".mp4":
                case ".webm":
                case ".qt":
                case ".3gp":
                case ".3g2":
                case ".avi":
                case ".f4v":
                case ".flv":
                case ".h261":
                case ".h263":
                case ".h264":
                case ".asf":
                case ".wmv":
                    try {
                        Glide.with(Popup_files.this).load(files_attachment) // or URI/path
                                .override(76, 76).centerCrop().into(iv); //imageView to set thumbnail to
                    } catch (Exception e) {
                        Log.w("HHS_Moodle", "Error load thumbnail", e);
                        iv.setImageResource(R.drawable.file_video);
                    }
                    break;
                case ".vcs":
                case ".vcf":
                case ".css":
                case ".ics":
                case ".conf":
                case ".config":
                case ".java":
                case ".html":
                    iv.setImageResource(R.drawable.file_xml);
                    break;
                case ".apk":
                    iv.setImageResource(R.drawable.android);
                    break;
                case ".pdf":
                    iv.setImageResource(R.drawable.file_pdf);
                    break;
                case ".rtf":
                case ".csv":
                case ".txt":
                case ".doc":
                case ".xls":
                case ".ppt":
                case ".docx":
                case ".pptx":
                case ".xlsx":
                case ".odt":
                case ".ods":
                case ".odp":
                    iv.setImageResource(R.drawable.file_document);
                    break;
                case ".zip":
                case ".rar":
                    iv.setImageResource(R.drawable.zip_box);
                    break;
                case ".gif":
                case ".bmp":
                case ".tiff":
                case ".svg":
                case ".png":
                case ".jpg":
                case ".JPG":
                case ".jpeg":
                    try {
                        Glide.with(Popup_files.this).load(files_attachment) // or URI/path
                                .diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true)
                                .override(76, 76).centerCrop().into(iv); //imageView to set thumbnail to
                    } catch (Exception e) {
                        Log.w("HHS_Moodle", "Error load thumbnail", e);
                        iv.setImageResource(R.drawable.file_image);
                    }
                    break;
                default:
                    iv.setImageResource(R.drawable.file);
                    break;
                }
            }

            if (files_attachment.isEmpty()) {
                new Handler().postDelayed(new Runnable() {
                    public void run() {
                        iv.setImageResource(R.drawable.arrow_up_dark);
                    }
                }, 350);
            }

            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_filesBY", "files_title");
    sharedPref.edit().putString("filter_filesBY", "files_title").apply();
    editText.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 {
                helper_main.open(files_icon, Popup_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.bookmark_remove_confirmation, Snackbar.LENGTH_LONG)
                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                sharedPref.edit().putString("files_startFolder", pathFile.getParent()).apply();
                                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(Popup_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.bookmark_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))) {
                            sharedPref.edit().putString("pathFile", files_attachment).apply();
                            editText.setVisibility(View.VISIBLE);
                            helper_editText.showKeyboard(Popup_files.this, editText, 2, files_title,
                                    getString(R.string.bookmark_edit_title));
                        }
                    }
                });
                dialog.show();
            }

            return true;
        }
    });
}

From source file:com.mendhak.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java

private void showPreferencesSummary() {
    showCurrentFileName(Session.getCurrentFileName());

    ImageView imgGpx = (ImageView) rootView.findViewById(R.id.simpleview_imgGpx);
    ImageView imgKml = (ImageView) rootView.findViewById(R.id.simpleview_imgKml);
    ImageView imgCsv = (ImageView) rootView.findViewById(R.id.simpleview_imgCsv);
    ImageView imgNmea = (ImageView) rootView.findViewById(R.id.simpleview_imgNmea);
    ImageView imgLink = (ImageView) rootView.findViewById(R.id.simpleview_imgLink);

    if (preferenceHelper.shouldLogToGpx()) {

        imgGpx.setVisibility(View.VISIBLE);
    } else {// w  ww .j av a2  s .  c om
        imgGpx.setVisibility(View.GONE);
    }

    if (preferenceHelper.shouldLogToKml()) {

        imgKml.setVisibility(View.VISIBLE);
    } else {
        imgKml.setVisibility(View.GONE);
    }

    if (preferenceHelper.shouldLogToNmea()) {
        imgNmea.setVisibility(View.VISIBLE);
    } else {
        imgNmea.setVisibility(View.GONE);
    }

    if (preferenceHelper.shouldLogToPlainText()) {

        imgCsv.setVisibility(View.VISIBLE);
    } else {
        imgCsv.setVisibility(View.GONE);
    }

    if (preferenceHelper.shouldLogToCustomUrl()) {
        imgLink.setVisibility(View.VISIBLE);
    } else {
        imgLink.setVisibility(View.GONE);
    }

    if (!preferenceHelper.shouldLogToGpx() && !preferenceHelper.shouldLogToKml()
            && !preferenceHelper.shouldLogToPlainText()) {
        showCurrentFileName(null);
    }

}

From source file:com.arvention.lavish.activity.MainActivity.java

public void updateDetailPanel(Toilet toilet) {

    TextView nameView = (TextView) findViewById(R.id.toilet_name),
            openHours = (TextView) findViewById(R.id.opening_hours_label);

    ImageView bidet = (ImageView) findViewById(R.id.toilet_bidet_check),
            flush = (ImageView) findViewById(R.id.toilet_flush_check),
            soap = (ImageView) findViewById(R.id.toilet_soap_check),
            free = (ImageView) findViewById(R.id.toilet_free_check),
            pwd = (ImageView) findViewById(R.id.toilet_pwd_check);

    nameView.setText(toilet.getName());//from   w  w  w.ja  v a 2  s  .  com
    openHours.setText(toilet.getOpeningHours());
    if (toilet.isHasBidet())
        bidet.setVisibility(View.VISIBLE);
    else
        bidet.setVisibility(View.INVISIBLE);
    if (toilet.isHasFlush())
        flush.setVisibility(View.VISIBLE);
    else
        flush.setVisibility(View.INVISIBLE);
    if (toilet.isHasSoap())
        soap.setVisibility(View.VISIBLE);
    else
        soap.setVisibility(View.INVISIBLE);
    if (toilet.isFree())
        free.setVisibility(View.VISIBLE);
    else
        free.setVisibility(View.INVISIBLE);
    if (toilet.isPWDFriendly())
        pwd.setVisibility(View.VISIBLE);
    else
        pwd.setVisibility(View.INVISIBLE);
}