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:co.nerdart.ourss.adapter.FeedsCursorAdapter.java

@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
    ImageView indicatorImage = (ImageView) view.findViewById(R.id.indicator);

    if (cursor.getInt(isGroupPosition) == 1) {
        long feedId = cursor.getLong(idPosition);
        if (feedId == mSelectedFeedId) {
            view.setBackgroundResource(android.R.color.holo_blue_dark);
        } else {//from  ww w  .j  a v a2 s . co  m
            view.setBackgroundResource(android.R.color.transparent);
        }

        indicatorImage.setVisibility(View.VISIBLE);

        TextView textView = ((TextView) view.findViewById(android.R.id.text1));
        textView.setEnabled(true);
        textView.setText(cursor.getString(namePosition));
        textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);

        int unreadCount;
        synchronized (mUnreadItemsByFeed) {
            unreadCount = mUnreadItemsByFeed.get(feedId);
        }

        textView.setText(cursor.getString(namePosition) + (unreadCount > 0 ? " (" + unreadCount + ")" : ""));

        view.findViewById(android.R.id.text2).setVisibility(View.GONE);

        View sortView = view.findViewById(R.id.sortitem);
        if (!sortViews.contains(sortView)) { // as we are reusing views, this is fine
            sortViews.add(sortView);
        }
        sortView.setVisibility(feedSort ? View.VISIBLE : View.GONE);

        final int groupPosition = cursor.getPosition();
        if (!mGroupInitDone.get(groupPosition)) {
            mGroupInitDone.put(groupPosition, true);

            boolean savedExpandedState = cursor.getInt(isGroupCollapsedPosition) != 1;
            if (savedExpandedState && !isExpanded) {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mListView.expandGroup(groupPosition);
                    }
                });
            }

            if (savedExpandedState)
                indicatorImage.setImageResource(R.drawable.group_expanded);
            else
                indicatorImage.setImageResource(R.drawable.group_collapsed);
        } else {
            if (isExpanded)
                indicatorImage.setImageResource(R.drawable.group_expanded);
            else
                indicatorImage.setImageResource(R.drawable.group_collapsed);
        }
    } else {
        bindChildView(view, context, cursor);
        indicatorImage.setVisibility(View.GONE);
    }
}

From source file:com.aware.ui.Plugins_Manager.java

private void drawUI() {
    //Clear previous states
    store_grid.removeAllViews();//  w  w  w .j a v a  2s.c  o m

    //Build UI
    Cursor installed_plugins = getContentResolver().query(Aware_Plugins.CONTENT_URI, null, null, null,
            Aware_Plugins.PLUGIN_NAME + " ASC");
    if (installed_plugins != null && installed_plugins.moveToFirst()) {
        do {
            final String package_name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_PACKAGE_NAME));
            final String name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME));
            final String description = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_DESCRIPTION));
            final String developer = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_AUTHOR));
            final String version = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_VERSION));
            final int status = installed_plugins
                    .getInt(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_STATUS));

            final View pkg_view = inflater.inflate(R.layout.plugins_store_pkg_list_item, null, false);
            pkg_view.setTag(package_name); //each view has the package name as a tag for easier references

            try {
                ImageView pkg_icon = (ImageView) pkg_view.findViewById(R.id.pkg_icon);
                if (status != PLUGIN_NOT_INSTALLED) {
                    ApplicationInfo appInfo = getPackageManager().getApplicationInfo(package_name,
                            PackageManager.GET_META_DATA);
                    pkg_icon.setImageDrawable(appInfo.loadIcon(getPackageManager()));
                } else {
                    byte[] img = installed_plugins
                            .getBlob(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_ICON));
                    if (img != null)
                        pkg_icon.setImageBitmap(BitmapFactory.decodeByteArray(img, 0, img.length));
                }

                TextView pkg_title = (TextView) pkg_view.findViewById(R.id.pkg_title);
                pkg_title.setText(installed_plugins
                        .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME)));

                ImageView pkg_state = (ImageView) pkg_view.findViewById(R.id.pkg_state);

                switch (status) {
                case PLUGIN_DISABLED:
                    pkg_state.setVisibility(View.INVISIBLE);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Activate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.startPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_ACTIVE:
                    pkg_state.setImageResource(R.drawable.ic_pkg_active);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_UPDATED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_updated);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setNeutralButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, true);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_NOT_INSTALLED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_download);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                            builder.setPositiveButton("Install", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, false);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                }
                store_grid.addView(pkg_view);
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        } while (installed_plugins.moveToNext());
    }
    if (installed_plugins != null && !installed_plugins.isClosed())
        installed_plugins.close();
}

From source file:net.line2soft.preambul.views.SlippyMapActivity.java

/**
 * Change the navigation instruction to display.
 * It updates the current path segment and set zoom and location.
 * @param id The ID of the instruction//  ww w  .jav  a  2  s .c  o m
 */
public void setNavigationInstructionToDisplay(int id) {
    try {
        //Display the segment on map
        MapView mv = (MapView) findViewById(R.id.mapView);
        //Get and set segment
        Paint color = createPaint(getResources().getColor(R.color.Green), 170);
        OverlayWay path = MapController.getInstance(this).getCurrentLocation().getExcursions(this)
                .get(MapController.getInstance().getPathToDisplay()).getInstructions()[id].getSegment();
        Paint haloColor = createPaint(getResources().getColor(R.color.Blue), 100);
        haloColor.setStrokeWidth(17);
        path.setPaint(color, haloColor);
        if (segment != null) {
            overlayPaths.removeWay(segment);
        }
        segment = new OverlayWayText(path, "");
        overlayPaths.addWay(segment);
        //Set zoom and center
        GeoPoint start = path.getWayNodes()[0][0];
        boolean positionValid = mv.getMapViewLimits().getBottomLimit() <= start.getLatitude()
                && mv.getMapViewLimits().getTopLimit() >= start.getLatitude()
                && mv.getMapViewLimits().getLeftLimit() <= start.getLongitude()
                && mv.getMapViewLimits().getRightLimit() >= start.getLongitude();
        if (positionValid) {
            mv.zoomToPoint(start);
            //Show destination on map
            removeMarker("NAV");
            addMarkerOnMap(start, "NAV", getResources().getDrawable(R.drawable.marker_location_nav));
        } else {
            displayInfo(getString(R.string.message_map_position_out_of_bounds));
        }

        //Change the instruction
        ViewPager myPager = (ViewPager) findViewById(R.id.pager_nav);
        myPager.setCurrentItem(id);

        //Change images
        ImageView right = (ImageView) findViewById(R.id.imageRight);
        ImageView left = (ImageView) findViewById(R.id.imageLeft);
        left.setVisibility(View.VISIBLE);
        right.setVisibility(View.VISIBLE);
        int nbInstructions = MapController.getInstance(this).getCurrentLocation().getExcursions(this)
                .get(MapController.getInstance().getPathToDisplay()).getInstructions().length;
        if (id == 0) {
            left.setVisibility(View.INVISIBLE);
        } else if (id == nbInstructions - 1) {
            right.setVisibility(View.INVISIBLE);
        }

        //MapController.getInstance(this).setInstructionToDisplay(id);
    } catch (Exception e) {
        displayInfo(getString(R.string.message_map_navigation_error));
        e.printStackTrace();
    }
}

From source file:com.aapbd.utils.image.CacheImageDownloader.java

/**
 * Same as {@link #download(String, ImageView)}, with the possibility to
 * provide an additional cookie that will be used when the image will be
 * retrieved.//from  www.  ja va 2 s. co  m
 *
 * @param url
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 * @param cookie
 *            A cookie String that will be used by the http connection.
 */
public void download(final String url, final ImageView imageView, final String cookie) {
    resetPurgeTimer();
    final Bitmap bitmap = getBitmapFromCache(url);

    if (bitmap == null) {
        forceDownload(url, imageView, cookie);
    } else {
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
        imageView.setVisibility(View.VISIBLE);

        if (isScale) {
            scaleImage1(imageView);
        }

    }
}

From source file:com.frostwire.android.gui.adapters.menu.FileListAdapter.java

private void populateSDState(View v, FileDescriptorItem item) {
    ImageView img = findView(v, R.id.view_browse_peer_list_item_sd);

    if (item.inSD) {
        if (item.mounted) {
            v.setBackgroundResource(R.drawable.listview_item_background_selector);
            setNormalTextColors(v);//from w w w.j a va2  s .co  m
            img.setVisibility(View.GONE);
        } else {
            v.setBackgroundResource(R.drawable.browse_peer_listview_item_inactive_background);
            setInactiveTextColors(v);
            img.setVisibility(View.VISIBLE);
        }
    } else {
        v.setBackgroundResource(R.drawable.listview_item_background_selector);
        setNormalTextColors(v);
        img.setVisibility(View.GONE);
    }
}

From source file:com.mydatingapp.ui.base.SkBaseInnerActivity.java

public void setActionBarLogoCounter(int count) {
    ImageView logo = (ImageView) findViewById(android.R.id.home);

    if (count < 1) {
        currentLogoCounter = 0;/* w w  w.  j  av a  2  s.c o  m*/
        logo.setVisibility(View.GONE);
        return;
    } else {
        logo.setVisibility(View.VISIBLE);
    }

    currentLogoCounter = count;

    TextView v = new TextView(getApp());
    v.setText(new Integer(count).toString());
    v.setBackgroundResource(R.drawable.sidebar_menu_counterbg);
    v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    v.setDrawingCacheEnabled(true);
    v.setTextColor(Color.WHITE);
    v.setPadding(SKDimensions.convertDpToPixel(6, getApp()), 0, SKDimensions.convertDpToPixel(6, getApp()), 0);

    ActionBar.LayoutParams paramsExample = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, 1);
    paramsExample.setMargins(0, 0, 0, 0);
    v.setHeight(SKDimensions.convertDpToPixel(20, getApp()));
    v.setLayoutParams(paramsExample);

    // this is the important code :)
    // Without it the view will have a dimension of 0,0 and the bitmap will be null
    v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());

    v.buildDrawingCache(true);
    Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false);

    logo.setImageDrawable(new BitmapDrawable(getApp().getResources(), b));
    logo.setPadding(SKDimensions.convertDpToPixel(3, getApp()), 0, 0, 0);
}

From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java

private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) {
      FrameLayout tabfl = new FrameLayout(getContext());
      ImageView tabi = new ImageView(getContext());
      tabi.setContentDescription(title);
      tabi.setImageResource(resId);/*from  w ww . j  a v  a 2s  .c o m*/
      tabi.setVisibility(View.INVISIBLE);
      TextView tabt = new TextView(getContext());
      tabt.setText(title);
      tabt.setTypeface(App.skrift_gibson);
      tabt.setGravity(Gravity.CENTER);
      tabt.setSingleLine();

      tabfl.addView(tabi);
      tabfl.addView(tabt);

      LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
      lp.gravity = Gravity.CENTER;
      lp = (LayoutParams) tabt.getLayoutParams();
      lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
      lp.gravity = Gravity.CENTER;

      addTab(position, tabfl);
  }

From source file:orbin.deskclock.timer.TimerFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }/*from  w  w w.  j  a  va  2  s.c om*/

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            fab.setImageResource(R.drawable.ic_pause_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        case RESET:
        case PAUSED:
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            break;
        case EXPIRED:
            fab.setImageResource(R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        }

    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setVisibility(INVISIBLE);
        }
    }
}

From source file:me.fireant.photoselect.ui.PhotoPreviewActivity.java

@Override
protected void initData() {
    Intent intent = getIntent();/*from w  ww  .j a  v a2s.  co  m*/
    if (intent != null) {
        mPhotos = intent.getParcelableArrayListExtra(BUNDLE_PHOTOS);
        mSelectIndex = intent.getIntExtra(BUNDLE_SELECT_INDEX, 0);
        mSelectedPhotos = intent.getParcelableArrayListExtra(BUNDLE_SELECTED_PHOTOS);
        mMaxSelectPhotoCount = intent.getIntExtra(BUNDLE_MAX_SELECT_COUNT, 1);
    }

    if (mSelectedPhotos == null) {
        mSelectedPhotos = new ArrayList<>();
    }

    mPagerAdapter = new PagerAdapter() {
        @Override
        public int getCount() {
            return mPhotos.size();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            View rootView = LayoutInflater.from(PhotoPreviewActivity.this)
                    .inflate(R.layout.list_cell_photo_preview, null);
            final ImageView photoView = (ImageView) rootView.findViewById(R.id.iv_photo);
            final ProgressBar pbLoading = (ProgressBar) rootView.findViewById(R.id.pb_loading);
            final Photo photo = mPhotos.get(position);

            Picasso.with(PhotoPreviewActivity.this).load(new File(photo.getPath()))
                    .error(R.drawable.ic_photo_error).into(photoView, new Callback() {
                        @Override
                        public void onSuccess() {
                            photoView.setVisibility(View.VISIBLE);
                            pbLoading.setVisibility(View.GONE);
                        }

                        @Override
                        public void onError() {

                        }
                    });

            container.addView(rootView);

            return rootView;
        }
    };

    mViewPager.setAdapter(mPagerAdapter);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            checkChecked(position);
            mSelectIndex = position + 1;
            setActionTitle();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    if (mSelectIndex == 0) {
        checkChecked(mSelectIndex);
        mSelectIndex = mSelectIndex + 1;
        setActionTitle();
    } else {
        mViewPager.setCurrentItem(mSelectIndex, false);
    }
}

From source file:com.netease.nim.chatroom.demo.im.ui.tab.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);

    if (item == null || indicatorView == null) {
        return;//from   w  ww  .ja  v a 2  s.c  om
    }
    boolean indicator = item.indicator();
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
}