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:org.videolan.vlc.gui.helpers.SearchSuggestionsAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    final String location = cursor.getString(cursor.getColumnIndex(MediaDatabase.MEDIA_LOCATION));
    final MediaWrapper mw = mMediaLibrary.getMediaItem(location);
    view.findViewById(R.id.item_more).setVisibility(View.GONE);
    TextView tv1 = (TextView) view.findViewById(R.id.title);
    tv1.setText(cursor.getString(cursor.getColumnIndex(MediaDatabase.MEDIA_TITLE)));
    view.setBackgroundColor(backgroundColor);

    if (mw == null)
        return;//from w  ww. java  2  s  .  c  o m
    String artist = mw.getAlbumArtist();
    if (artist == null)
        artist = mw.getArtist();
    if (artist != null) {
        TextView tv2 = (TextView) view.findViewById(R.id.subtitle);
        tv2.setText(artist);
    } else
        view.findViewById(R.id.subtitle).setVisibility(View.GONE);

    Bitmap artwork;
    ImageView coverView = (ImageView) view.findViewById(R.id.media_cover);
    if (mw.getType() == MediaWrapper.TYPE_AUDIO)
        artwork = AudioUtil.getCover(context, mw,
                context.getResources().getDimensionPixelSize(R.dimen.audio_browser_item_size));
    else if (mw.getType() == MediaWrapper.TYPE_VIDEO)
        artwork = BitmapUtil.getPicture(mw);
    else
        artwork = null;
    if (artwork != null) {
        coverView.setVisibility(View.VISIBLE);
        coverView.setImageBitmap(artwork);
    } else
        coverView.setVisibility(View.INVISIBLE);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MediaUtils.openMedia(context, mw);
        }
    });
    view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN)
                UiTools.setKeyboardVisibility(v, false);
            return false;
        }
    });
}

From source file:com.layer.messenger.makemoji.MakeMojiAtlasComposer.java

private void addAttachmentMenuItem(AttachmentSender sender) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    LinearLayout menuLayout = (LinearLayout) mAttachmentMenu.getContentView();

    View menuItem = inflater.inflate(com.layer.atlas.R.layout.atlas_message_composer_attachment_menu_item,
            menuLayout, false);/*from w w w  .ja v a  2s. c  o m*/
    ((TextView) menuItem.findViewById(com.layer.atlas.R.id.title)).setText(sender.getTitle());
    menuItem.setTag(sender);
    menuItem.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mAttachmentMenu.dismiss();
            ((AttachmentSender) v.getTag()).requestSend();
        }
    });
    if (sender.getIcon() != null) {
        ImageView iconView = ((ImageView) menuItem.findViewById(com.layer.atlas.R.id.icon));
        iconView.setImageResource(sender.getIcon());
        iconView.setVisibility(VISIBLE);
        Drawable d = DrawableCompat.wrap(iconView.getDrawable());
        DrawableCompat.setTint(d, getResources().getColor(com.layer.atlas.R.color.atlas_icon_enabled));
    }
    menuLayout.addView(menuItem);
}

From source file:org.sickstache.fragments.ShowsFragment.java

@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    if (actionMode == null) {
        actionMode = getSherlockActivity().startActionMode(new ActionMode.Callback() {

            @Override//  ww w  . j  av  a 2s.com
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                showAdapter.notifyDataSetChanged();
                selected.clear();
                actionMode = null;
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                MenuInflater inflate = getSherlockActivity().getSupportMenuInflater();
                inflate.inflate(R.menu.shows_cab_menu, menu);
                return true;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                switch (item.getItemId()) {
                case R.id.pauseMenuItem:
                    final PauseDialog pDialog = new PauseDialog();
                    pDialog.setTitle("Set Pause");
                    pDialog.setOnOkClick(new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface arg0, int arg1) {
                            final ProgressDialog dialog = ProgressDialog.show(
                                    ShowsFragment.this.getSherlockActivity(), "",
                                    "Pausing Shows. Please wait...", true);
                            dialog.setCancelable(true);
                            dialog.show();
                            String[] tvdbids = new String[selected.size()];
                            for (int i = 0; i < selected.size(); i++) {
                                tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                            }
                            Preferences pref = Preferences
                                    .getSingleton(ShowsFragment.this.getSherlockActivity());
                            PauseTask pause = new PauseTask(pref, tvdbids, pDialog.getPause()) {
                                @Override
                                protected void onPostExecute(Boolean result) {
                                    if (dialog != null && dialog.isShowing())
                                        dialog.dismiss();
                                    if (error != null && getFragmentManager() != null) {
                                        ErrorDialog dialog = new ErrorDialog();
                                        dialog.setMessage("Error pausing show.\nERROR: " + error.getMessage());
                                        dialog.show(getFragmentManager(), "pauseError");
                                    }
                                }
                            };
                            pause.execute();
                        }
                    });
                    pDialog.show(getFragmentManager(), "update");
                    return true;
                case R.id.refreshMenuItem: {
                    final ProgressDialog dialog = ProgressDialog.show(ShowsFragment.this.getSherlockActivity(),
                            "", "Refreshing Shows. Please wait...", true);
                    dialog.setCancelable(true);
                    dialog.show();
                    String[] tvdbids = new String[selected.size()];
                    for (int i = 0; i < selected.size(); i++) {
                        tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                    }
                    Preferences pref = Preferences.getSingleton(ShowsFragment.this.getSherlockActivity());
                    RefreshTask refresh = new RefreshTask(pref, tvdbids) {
                        @Override
                        protected void onPostExecute(Boolean result) {
                            if (dialog != null && dialog.isShowing())
                                dialog.dismiss();
                            if (error != null && getFragmentManager() != null) {
                                ErrorDialog dialog = new ErrorDialog();
                                dialog.setMessage("Error refreshing show.\nERROR: " + error.getMessage());
                                dialog.show(getFragmentManager(), "refreshError");
                            }
                        }
                    };
                    refresh.execute();
                }
                    return true;
                case R.id.updateMenuItem: {
                    final ProgressDialog dialog = ProgressDialog.show(ShowsFragment.this.getSherlockActivity(),
                            "", "Updating Shows. Please wait...", true);
                    dialog.setCancelable(true);
                    dialog.show();
                    String[] tvdbids = new String[selected.size()];
                    for (int i = 0; i < selected.size(); i++) {
                        tvdbids[i] = showAdapter.getItem(selected.get(i)).id;
                    }
                    Preferences pref = Preferences.getSingleton(ShowsFragment.this.getSherlockActivity());
                    UpdateTask update = new UpdateTask(pref, tvdbids) {
                        @Override
                        protected void onPostExecute(Boolean result) {
                            if (dialog != null && dialog.isShowing())
                                dialog.dismiss();
                            if (error != null && getFragmentManager() != null) {
                                ErrorDialog dialog = new ErrorDialog();
                                dialog.setMessage("Error updating show.\nERROR: " + error.getMessage());
                                dialog.show(getFragmentManager(), "updateError");
                            }
                        }
                    };
                    update.execute();
                }
                    return true;
                //               case R.id.editMenuItem:
                //                  // get all selected items and create the edit show activity passing all of them
                //                  actionMode.finish();
                //                  return true;
                }
                return false;
            }
        });
    }
    ImageView overlay = (ImageView) arg1.findViewById(R.id.showSelectedOverlay);
    int i = selected.indexOf(arg2);
    if (i >= 0) {
        selected.remove(i);
        overlay.setVisibility(View.INVISIBLE);
    } else {
        selected.add(arg2);
        overlay.setVisibility(View.VISIBLE);
    }
    actionMode.setTitle(selected.size() + " Items Selected");
    if (selected.size() == 0) {
        actionMode.finish();
    }
    return true;
}

From source file:nl.basvanmarwijk.mylocations.viewcontroller.LocationItemDetailFragment.java

/**
 * Gets Bitmap from mItem and updates into the ImageView
 *//*ww w .j  a  va2s .co  m*/
private void updateImageView() {

    if (mItem != null) {
        final Uri picLocation;
        try {
            itemReadLock.lock();

            final List<Location_picture> pictures = mItem.getFk_location_picture();
            if (pictures.isEmpty()) {
                return;
            }
            picLocation = Uri.parse(pictures.get(pictures.size() - 1).getPicture_path());
        } finally {
            itemReadLock.unlock();
        }

        if (picLocation != null) {
            new AsyncTask<Void, Void, Bitmap>() {
                @Override
                protected void onPreExecute() {
                    // progress bar on
                    progressBar.setVisibility(View.VISIBLE);
                }

                @Override
                protected Bitmap doInBackground(Void... params) {

                    Bitmap b = null;
                    try {
                        // get bitmap
                        b = ExternalStorageHelper.readBitmap(picLocation);
                        // get preferred width
                        int width = ImageHelper.getScreenDimension(getActivity()).x;
                        // scale bitmap
                        b = ImageHelper.scaleBitmap(b, width);
                    } catch (IllegalStateException e) {
                        getActivity().runOnUiThread(new ToastRunnable(R.string.sd_card_in_use));
                    }

                    return b;
                }

                @Override
                protected void onPostExecute(Bitmap result) {
                    ImageView iv = (ImageView) rootView.findViewById(R.id.iv_photoView);

                    iv.setImageBitmap(result);
                    iv.setVisibility(View.VISIBLE);

                    // progress bar off
                    progressBar.setVisibility(View.GONE);
                }
            }.execute();

        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    //Check if this version of Android allows to use custom title bars
    boolean feature = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    /** Set layout **/
    //Base layout
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_excursion_info);
    //set title bar
    if (feature) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_title_bar);
        TextView myTitleText = (TextView) findViewById(R.id.textView0);
        myTitleText.setText(getString(R.string.title_activity_excursion_info));
    }//from   ww w.  j av a2s .c om

    //Get excursion ID
    int id = getIntent().getIntExtra(ExcursionListActivity.EXCURSION_ID, 0);
    if (id > 0) {
        //Set listener
        listener = new ExcursionInfoListener(this);
        //Set tabs

        TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
        tabHost.setup();

        TabSpec spec1 = tabHost.newTabSpec("Info");
        spec1.setContent(R.id.tab1);
        spec1.setIndicator("", getResources().getDrawable(R.drawable.description_tab));
        spec1.setContent(R.id.tab1);

        TabSpec spec2 = tabHost.newTabSpec("POI");
        spec2.setIndicator("", getResources().getDrawable(R.drawable.pois_tab));
        spec2.setContent(R.id.tab2);

        TabSpec spec3 = tabHost.newTabSpec("Instructions");
        spec3.setIndicator("", getResources().getDrawable(R.drawable.instruction_tab));
        spec3.setContent(R.id.tab3);

        TabSpec spec4 = tabHost.newTabSpec("Photos");
        spec4.setIndicator("", getResources().getDrawable(R.drawable.photos_tab));
        spec4.setContent(R.id.tab4);

        tabHost.addTab(spec1);
        tabHost.addTab(spec2);
        tabHost.addTab(spec3);
        tabHost.addTab(spec4);

        //set the info tab
        try {
            Excursion exc = MapController.getInstance(this).getCurrentLocation().getExcursions(this).get(id);
            //Display locomotions
            Locomotion[] locomotionsItems = exc.getLocomotions();
            LinearLayout locomotionsLayout = (LinearLayout) findViewById(R.id.locomotionsLayout);
            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            for (int i = 0; i < locomotionsItems.length; i++) {
                if (locomotionsItems[i].getIcon() == null) {
                    //Define icon if undefined
                    int imageResource = getResources().getIdentifier(
                            "locomotion_" + locomotionsItems[i].getKey(), "drawable", getPackageName());
                    if (imageResource != 0) {
                        Drawable ic = getResources().getDrawable(imageResource);
                        locomotionsItems[i].setIcon(ic);
                    }
                }
                ImageView img = (ImageView) inflater.inflate(R.layout.locomotion_item, null);
                img.setImageDrawable(locomotionsItems[i].getIcon());
                locomotionsLayout.addView(img);
            }

            int value = exc.getDifficulty();
            if (value == Excursion.DIFFICULTY_NONE) {
                ImageView view = (ImageView) findViewById(R.id.ImageView2);
                view.setImageResource(R.drawable.difficulte1);
            } else if (value == Excursion.DIFFICULTY_EASY) {
                ImageView view = (ImageView) findViewById(R.id.ImageView2);
                view.setImageResource(R.drawable.difficulte2);

            } else if (value == Excursion.DIFFICULTY_MEDIUM) {
                ImageView view = (ImageView) findViewById(R.id.ImageView2);
                view.setImageResource(R.drawable.difficulte3);

            } else if (value == Excursion.DIFFICULTY_HARD) {
                ImageView view = (ImageView) findViewById(R.id.ImageView2);
                view.setImageResource(R.drawable.difficulte4);

            } else if (value == Excursion.DIFFICULTY_EXPERT) {
                ImageView view = (ImageView) findViewById(R.id.ImageView2);
                view.setImageResource(R.drawable.difficulte5);

            }
            String time = ExcursionAdapter.convertTime(exc.getTime());

            TextView view = (TextView) findViewById(R.id.textView1);
            view.setText(time);

            Double length = Double.valueOf(exc.getLength() / 1000);
            String lengthString = length.toString().substring(0, length.toString().lastIndexOf(".") + 2)
                    + " km";
            view = (TextView) findViewById(R.id.textView2);
            view.setText(lengthString);

            view = (TextView) findViewById(R.id.textView3);
            view.setText(exc.getDescription());

        } catch (Exception e) {
            e.printStackTrace();
            onBackPressed();
            displayInfo(getString(R.string.message_excursion_not_found));
        }
        MapController exc = MapController.getInstance(this);

        //set the POI tab
        try {
            PointOfInterest[] pois = exc.getCurrentLocation().getExcursions(this).get(id)
                    .getSurroundingPois(this);
            List<NamedPoint> itemsList = Arrays.asList(((NamedPoint[]) pois));
            Collections.sort(itemsList, new NamedPointComparator());
            pois = itemsList.toArray(new PointOfInterest[itemsList.size()]);
            if (pois.length > 0) {
                ListView listPoi = (ListView) findViewById(R.id.listView2);
                listPoi.setAdapter(new FavoriteAdapter(getLayoutInflater(), pois, this));
                listPoi.setOnItemClickListener(listener);
                listPoi.setVisibility(View.VISIBLE);
                findViewById(R.id.NoPOIs).setVisibility(View.GONE);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("Couldn't fill POI tab");
        }

        //set the instruction tab
        ListView list = (ListView) findViewById(R.id.listView1);
        if (list != null) {
            try {
                NavigationInstruction[] instructions = exc.getCurrentLocation().getExcursions(this).get(id)
                        .getInstructions();
                if (instructions.length != 0) {
                    ((TextView) findViewById(R.id.NoInstructions)).setVisibility(View.GONE);
                }
                list.setAdapter(new ExcursionInfoInstructionAdapter(this, instructions));
                list.setOnItemClickListener(listener);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        //Set the picture tab
        String imagePath = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android"
                + File.separator + "data" + File.separator + "net.line2soft.preambul" + File.separator + "files"
                + File.separator + MapController.getInstance(this).getCurrentLocation().getId() + File.separator
                + "excursions" + File.separator
                + getIntent().getIntExtra(ExcursionListActivity.EXCURSION_ID, 0);
        FileFilter filter = new FileFilter() {
            @Override
            public boolean accept(File file) {
                return file.getAbsolutePath().matches(".*\\.jpg");
            }
        };
        imagesFile = new File(imagePath).listFiles(filter);
        ((TextView) findViewById(R.id.NoPhotos)).setVisibility(View.VISIBLE);
        if (imagesFile != null) {
            if (imagesFile.length > 0) {
                ((TextView) findViewById(R.id.NoPhotos)).setVisibility(View.GONE);
                ImagePagerAdapter adapter = new ImagePagerAdapter(getSupportFragmentManager(), imagesFile,
                        this);
                ViewPager myPager = (ViewPager) findViewById(R.id.pager_images);
                myPager.setAdapter(adapter);
                myPager.setOnPageChangeListener(listener);

                //Set listener on right and left buttons in picture tab
                (findViewById(R.id.imageRight)).setOnClickListener(listener);
                (findViewById(R.id.imageLeft)).setOnClickListener(listener);
                //Change visibility of these buttons
                ImageView right = (ImageView) findViewById(R.id.imageRight);
                ImageView left = (ImageView) findViewById(R.id.imageLeft);
                left.setVisibility(View.INVISIBLE);
                right.setVisibility(View.INVISIBLE);
                int idPhoto = ((ViewPager) findViewById(R.id.pager_images)).getCurrentItem();
                int nbPhotos = getImagesFile().length;
                if (idPhoto != nbPhotos - 1) {
                    right.setVisibility(View.VISIBLE);
                }
            }
        }

        //Set listener on launch button
        Button launch = (Button) findViewById(R.id.button_load_excursion);
        launch.setOnClickListener(listener);

    } else {
        onBackPressed();
        displayInfo(getString(R.string.message_excursion_not_found));
    }
}

From source file:com.almalence.opencam.ui.AlmalenceStore.java

public void showStore() {
    LayoutInflater inflater = LayoutInflater.from(MainScreen.getInstance());
    List<RelativeLayout> pages = new ArrayList<RelativeLayout>();

    // <!-- -+-
    final boolean unlocked = false;
    //-+- -->/*w w w  .j ava 2s. c  o m*/
    /* <!-- +++
    final boolean unlocked = true; 
     +++ --> */

    // page 1
    RelativeLayout page = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_pager_fragment, null);
    initStoreList();

    RelativeLayout store = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_store, null);
    final ImageView imgStoreNext = (ImageView) store.findViewById(R.id.storeWhatsNew);
    GridView gridview = (GridView) store.findViewById(R.id.storeGrid);
    gridview.setAdapter(storeAdapter);

    if (!unlocked) {
        page.addView(store);
        pages.add(page);
    }

    // page 2
    page = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_pager_fragment, null);
    RelativeLayout features = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_features, null);
    final ImageView imgFeaturesPrev = (ImageView) features.findViewById(R.id.storeWhatsNew);
    imgFeaturesPrev.setVisibility(View.INVISIBLE);
    WebView wv = (WebView) features.findViewById(R.id.text_features);
    wv.loadUrl("file:///android_asset/www/features.html");

    page.addView(features);
    pages.add(page);

    SamplePagerAdapter pagerAdapter = new SamplePagerAdapter(pages);
    final ViewPager viewPager = new ViewPager(MainScreen.getInstance());
    viewPager.setAdapter(pagerAdapter);
    if (!unlocked)
        viewPager.setCurrentItem(0);
    else
        viewPager.setCurrentItem(1);
    viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            switch (position) {
            case 0:
                // 0
                imgStoreNext.setVisibility(View.VISIBLE);
                // 1
                imgFeaturesPrev.setVisibility(View.INVISIBLE);
                break;
            case 1:
                // 0
                imgStoreNext.setVisibility(View.INVISIBLE);
                // 1
                if (!unlocked)
                    imgFeaturesPrev.setVisibility(View.VISIBLE);
                else
                    imgFeaturesPrev.setVisibility(View.INVISIBLE);
                break;
            default:
                break;
            }
        }
    });

    imgStoreNext.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            viewPager.setCurrentItem(1);
        }
    });

    imgFeaturesPrev.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            viewPager.setCurrentItem(0);
        }
    });

    guiView.findViewById(R.id.buttonGallery).setEnabled(false);
    guiView.findViewById(R.id.buttonShutter).setEnabled(false);
    guiView.findViewById(R.id.buttonSelectMode).setEnabled(false);

    PluginManager.getInstance().sendMessage(ApplicationInterface.MSG_BROADCAST,
            ApplicationInterface.MSG_CONTROL_LOCKED);

    MainScreen.getGUIManager().lockControls = true;

    // <!-- -+-
    if (MainScreen.getInstance().showPromoRedeemed) {
        Toast.makeText(MainScreen.getInstance(),
                "The promo code has been successfully redeemed. All PRO-Features are unlocked",
                Toast.LENGTH_LONG).show();
        MainScreen.getInstance().showPromoRedeemed = false;
    }
    if (MainScreen.getInstance().showPromoRedeemedJulius) {
        Toast.makeText(MainScreen.getInstance(),
                MainScreen.getInstance().getResources().getString(R.string.promoRedeemedJulius),
                Toast.LENGTH_LONG).show();
        MainScreen.getInstance().showPromoRedeemedJulius = false;
    }
    //-+- -->

    final RelativeLayout pagerLayout = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout));
    pagerLayout.addView(viewPager);

    final RelativeLayout pagerLayoutMain = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain));
    pagerLayoutMain.setVisibility(View.VISIBLE);
    pagerLayoutMain.bringToFront();

    // We need this timer, to show store on top, after we return from google
    // play.
    // In MainScreen there is timer, which brings main buttons on top,
    // after MainScreen activity resumed.
    // So this timer "blocks" timer from MainScreen if we want to show
    // store.
    new CountDownTimer(600, 10) {
        public void onTick(long millisUntilFinished) {
            pagerLayoutMain.bringToFront();
        }

        public void onFinish() {
            pagerLayoutMain.bringToFront();
        }
    }.start();
}

From source file:org.videolan.vlc.gui.SearchSuggestionsAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    final String location = cursor.getString(cursor.getColumnIndex(MediaDatabase.MEDIA_LOCATION));
    final MediaWrapper mw = mMediaLibrary.getMediaItem(location);
    view.findViewById(R.id.item_more).setVisibility(View.GONE);
    TextView tv1 = (TextView) view.findViewById(R.id.title);
    tv1.setText(cursor.getString(cursor.getColumnIndex(MediaDatabase.MEDIA_TITLE)));
    view.setBackgroundColor(backgroundColor);

    if (mw == null)
        return;/* ww w.  ja v  a  2 s  . c  o  m*/
    String artist = mw.getAlbumArtist();
    if (artist == null)
        artist = mw.getArtist();
    if (artist != null) {
        TextView tv2 = (TextView) view.findViewById(R.id.subtitle);
        tv2.setText(artist);
    } else
        view.findViewById(R.id.subtitle).setVisibility(View.GONE);

    Bitmap artwork;
    ImageView coverView = (ImageView) view.findViewById(R.id.cover);
    if (mw.getType() == MediaWrapper.TYPE_AUDIO)
        artwork = AudioUtil.getCover(context, mw,
                context.getResources().getDimensionPixelSize(R.dimen.audio_browser_item_size));
    else if (mw.getType() == MediaWrapper.TYPE_VIDEO)
        artwork = BitmapUtil.getPictureFromCache(mw);
    else
        artwork = null;
    if (artwork != null) {
        coverView.setVisibility(View.VISIBLE);
        coverView.setImageBitmap(artwork);
    } else
        coverView.setVisibility(View.INVISIBLE);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Util.openMedia(context, mw);
        }
    });
    view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN)
                activity.hideKeyboard();
            return false;
        }
    });
}

From source file:com.chalmers.feedlr.activity.FeedActivity.java

private void updateOverlay() {
    if (feedAdapter.getCount() > 0) {
        LinearLayout overlayLayout = (LinearLayout) mainViewFlipper.findViewById(R.id.main_layout);
        ImageView overlay = (ImageView) overlayLayout.findViewById(R.id.no_feed_image);
        overlay.setVisibility(View.INVISIBLE);
    }//from   ww  w .j  av  a  2 s .c o  m
}

From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java

private void setButtonItemView(final View view, CannedButton item) {
    TextView captionTextView = (TextView) view.findViewById(R.id.caption);
    TextView actionTextView = (TextView) view.findViewById(R.id.action);
    captionTextView.setTextColor(ContextCompat.getColor(mService, android.R.color.primary_text_light));
    actionTextView.setTextColor(ContextCompat.getColor(mService, android.R.color.secondary_text_light));

    ImageView statusImageView = (ImageView) view.findViewById(R.id.status);
    UIUtils.setBackgroundColor(statusImageView, LookAndFeelConstants.getPrimaryColor(this));
    statusImageView.setVisibility(item.isSelected() ? View.VISIBLE : View.GONE);

    captionTextView.setText(item.getCaption());
    String action = item.getAction();
    if (action == null) {
        actionTextView.setVisibility(View.GONE);
        captionTextView.setPadding(0, 13, 0, 13);
    } else {/*from w w  w. j a  v a  2 s .c  o  m*/
        actionTextView.setVisibility(View.VISIBLE);
        actionTextView.setText(action);
        captionTextView.setPadding(0, 0, 0, 0);
    }
    view.setTag(item);
}

From source file:de.mdxdave.materialbreadcrumbsnavigation.MaterialBreadcrumbsNavigation.java

private void addItem(final NavigationItem item, int position, boolean isRoot, boolean setActive) {
    LayoutInflater vi = (LayoutInflater) context.getApplicationContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = vi.inflate(R.layout.item_view, null);

    int last;/*from  ww  w .  j  a v  a2s  . co m*/
    if (isRoot) {
        last = 0;
        list.add(item);
    } else if (position == -1) {
        last = viewGroup.getChildCount();
        last = (last < 0) ? 0 : last;
        list.add(item);
    } else {
        last = position;
        list.set(position, item);
    }

    final TextView textView = (TextView) v.findViewById(R.id.breadcrumbnav_textView);
    textView.setTextColor(darkenColor(textColor));
    textView.setText(item.getTitle().toUpperCase());

    item.setId(last);

    final int finalLast = last;
    textView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setActive(finalLast, false, true);
        }
    });

    ImageView imageView = (ImageView) v.findViewById(R.id.breadcrumbnav_imageView);
    imageView.setColorFilter(indicatorColor, PorterDuff.Mode.MULTIPLY);

    // Padding and root item
    if (isRoot) {
        imageView.setVisibility(View.GONE);
        int padding_left = 48;
        int padding_right = 12;
        int padding = 18;
        final float scale = getResources().getDisplayMetrics().density;
        int padding_left_px = (int) (padding_left * scale + 0.5f);
        int padding_right_px = (int) (padding_right * scale + 0.5f);
        int padding_px = (int) (padding * scale + 0.5f);
        textView.setPadding(padding_left_px, padding_px, padding_right_px, padding_px);
    }

    // Scroll to end

    final int finalLast1 = last;
    horizontalScrollView.post(new Runnable() {
        @Override
        public void run() {
            if (finalLast1 == viewGroup.getChildCount())
                horizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
        }
    });

    viewGroup.addView(v, last, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    if (setActive || getCurrent() == position || list.size() == 0)
        setActive(last, true);
}