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:dk.nordfalk.aktivitetsliste.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);/* w w  w .  j a v  a  2 s .c  o m*/
    tabi.setImageResource(resId);
    tabi.setVisibility(View.INVISIBLE);
    TextView tabt = new TextView(getContext());
    tabt.setText(title);
    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:org.safegees.safegees.gui.fragment.ProfileContactFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_profile_contact, container, false);

    ArrayList<Friend> friends = SafegeesDAO.getInstance(view.getContext()).getMutualFriends();

    Friend friend = friends.get(position);

    //this.getActivity().onBackPressed();

    //ImageButton closeContact = (ImageButton) view.findViewById(R.id.close_contact);
    //closeContact.setOnClickListener(this);

    imageView = (ImageView) view.findViewById(R.id.result);
    editName = (EditText) view.findViewById(R.id.editName);
    editSurname = (EditText) view.findViewById(R.id.editSurname);
    editEmail = (EditText) view.findViewById(R.id.editEmail);
    editPhone = (EditText) view.findViewById(R.id.editPhone);
    editTopic = (TextView) view.findViewById(R.id.editTopic);

    LinearLayout llName = (LinearLayout) view.findViewById(R.id.lay_name);
    LinearLayout llSurname = (LinearLayout) view.findViewById(R.id.lay_surname);
    LinearLayout llMail = (LinearLayout) view.findViewById(R.id.lay_mail);
    LinearLayout llPhone = (LinearLayout) view.findViewById(R.id.lay_phone);
    //LinearLayout llBio = (LinearLayout) view.findViewById(R.id.lay_topic);

    //Show arrows to reveal user if there are more contacts
    ImageView arrowLeft = (ImageView) view.findViewById(R.id.contact_left);
    ImageView arrowRight = (ImageView) view.findViewById(R.id.contact_right);

    //Change arrows if Language is LTR (Ar or FA)
    //And reveal the accurate arrow
    if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
        arrowLeft.setBackgroundResource(R.drawable.ic_chevron_right_black_24dp);
        arrowRight.setBackgroundResource(R.drawable.ic_chevron_left_black_24dp);
        if (position == 0)
            arrowRight.setVisibility(View.INVISIBLE);
        if (position == friends.size() - 1)
            arrowLeft.setVisibility(View.INVISIBLE);
    } else {//from  w  w w.  ja  va  2  s. c  o  m
        if (position == 0)
            arrowLeft.setVisibility(View.INVISIBLE);
        if (position == friends.size() - 1)
            arrowRight.setVisibility(View.INVISIBLE);
    }

    if (friend != null) {
        this.editName.setText(friend.getName() != null ? friend.getName() : "");
        this.editSurname.setText(friend.getSurname() != null ? friend.getSurname() : "");
        this.editEmail.setText(friend.getPublicEmail() != null ? friend.getPublicEmail() : "");
        this.editPhone.setText(friend.getPhoneNumber() != null ? friend.getPhoneNumber() : "");
        this.editTopic.setText(friend.getBio() != null ? "\"" + friend.getBio() + "\"" : "");
        ViewGroup.LayoutParams params = editTopic.getLayoutParams();
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        editTopic.setLayoutParams(params);
    }

    if (friend.getName() == null || friend.getName().equals(""))
        llName.setVisibility(View.GONE);
    if (friend.getSurname() == null || friend.getSurname().equals(""))
        llSurname.setVisibility(View.GONE);
    if (friend.getPublicEmail() == null || friend.getPublicEmail().equals(""))
        llMail.setVisibility(View.GONE);
    if (friend.getPhoneNumber() == null || friend.getPhoneNumber().equals(""))
        llPhone.setVisibility(View.GONE);
    if (friend.getBio() == null || friend.getBio().equals(""))
        editTopic.setVisibility(View.GONE);

    //Add image from friend
    if (friend.getPublicEmail() != null) {
        Bitmap bitmap = ImageController.getContactImageBitmap(getContext(), friend.getPublicEmail());
        if (bitmap != null)
            this.imageView.setImageBitmap(bitmap);
    }

    // Inflate the layout for this fragment
    return view;
}

From source file:org.mozilla.focus.fragment.BrowserFragment.java

private void initialiseCustomTabUi(final @NonNull View view) {
    final CustomTabConfig customTabConfig = BrowsingSession.getInstance().getCustomTabConfig();
    if (customTabConfig == null) {
        throw new IllegalStateException("Can't initialise custom tab UI for non custom-tab session");
    }/*from   w ww .j av a 2 s. c om*/

    // Unfortunately there's no simpler way to have the FAB only in normal-browser mode.
    // - ViewStub: requires splitting attributes for the FAB between the ViewStub, and actual FAB layout file.
    //             Moreover, the layout behaviour just doesn't work unless you set it programatically.
    // - View.GONE: doesn't work because the layout-behaviour makes the FAB visible again when scrolling.
    // - Adding at runtime: works, but then we need to use a separate layout file (and you need
    //   to set some attributes programatically, same as ViewStub).
    final View erase = view.findViewById(R.id.erase);
    final ViewGroup eraseContainer = (ViewGroup) erase.getParent();
    eraseContainer.removeView(erase);

    final View toolbar = view.findViewById(R.id.urlbar);
    if (customTabConfig.toolbarColor != null) {
        toolbar.setBackgroundColor(customTabConfig.toolbarColor);
    }

    final ImageView closeButton = (ImageView) view.findViewById(R.id.customtab_close);

    closeButton.setVisibility(View.VISIBLE);
    closeButton.setOnClickListener(this);

    if (customTabConfig.closeButtonIcon != null) {
        closeButton.setImageBitmap(customTabConfig.closeButtonIcon);
    } else {
        // Always set the icon in case it's been overridden by a previous CT invocation
        closeButton.setImageResource(R.drawable.ic_close);
    }

    if (customTabConfig.disableUrlbarHiding) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
        params.setScrollFlags(0);
    }

    if (customTabConfig.actionButtonConfig != null) {
        final ImageButton actionButton = (ImageButton) view.findViewById(R.id.customtab_actionbutton);
        actionButton.setVisibility(View.VISIBLE);

        actionButton.setImageBitmap(customTabConfig.actionButtonConfig.icon);
        actionButton.setContentDescription(customTabConfig.actionButtonConfig.description);

        final PendingIntent pendingIntent = customTabConfig.actionButtonConfig.pendingIntent;

        actionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    pendingIntent.send();
                } catch (PendingIntent.CanceledException e) {
                    // There's really nothing we can do here...
                }
            }
        });
    }
}

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

/**
 * Updates the state of the page indicators so they reflect the selected page in the context of
 * all pages./*from  w  w  w. j a v a2 s .c  o  m*/
 */
private void updatePageIndicators() {
    final int page = mViewPager.getCurrentItem();
    final int pageIndicatorCount = mPageIndicators.length;
    final int pageCount = mAdapter.getCount();

    final int[] states = computePageIndicatorStates(page, pageIndicatorCount, pageCount);
    for (int i = 0; i < states.length; i++) {
        final int state = states[i];
        final ImageView pageIndicator = mPageIndicators[i];
        if (state == 0) {
            pageIndicator.setVisibility(GONE);
        } else {
            pageIndicator.setVisibility(VISIBLE);
            pageIndicator.setImageResource(state);
        }
    }
}

From source file:com.facebook.samples.loginsample.accountkit.ReverbBodyFragment.java

private void updateIcon(final View view) {

    final View progressSpinner = view.findViewById(R.id.reverb_progress_spinner);
    if (progressSpinner != null) {
        progressSpinner.setVisibility(showProgressSpinner ? View.VISIBLE : View.GONE);
    }/*from w ww.  ja  v a 2s  . com*/

    final ImageView iconView = (ImageView) view.findViewById(R.id.reverb_icon);
    if (iconView != null) {
        if (iconResourceId > 0) {

            /*
             * Api levels lower than 21 do not support android:tint in xml drawables. Tint can
             * be applied with DrawableCompat
             */
            Drawable icon = getResources().getDrawable(iconResourceId);
            if (iconTintResourceId > 0) {
                icon = DrawableCompat.wrap(icon);
                DrawableCompat.setTint(icon, ContextCompat.getColor(view.getContext(), R.color.reverb_dark));
            }

            iconView.setImageDrawable(icon);
            iconView.setVisibility(View.VISIBLE);
        } else {
            iconView.setVisibility(View.GONE);
        }
    }
}

From source file:de.enlightened.peris.ThemeEditor.java

private void updatePreview() {
    final SharedPreferences appPreferences = getSharedPreferences("prefs", 0);

    final boolean useShading = appPreferences.getBoolean("use_shading", false);
    final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false);
    final int fontSize = appPreferences.getInt("font_size", 16);
    final boolean currentAvatarSetting = appPreferences.getBoolean("show_images", true);

    final TextView themeEditorPreviewAppbar = (TextView) findViewById(R.id.theme_editor_preview_appbar);
    themeEditorPreviewAppbar/*www  .j  a v  a2 s  . c o  m*/
            .setBackgroundColor(Color.parseColor(this.application.getSession().getServer().serverColor));

    if (ThemeSetter.getForegroundDark(this.application.getSession().getServer().serverColor)) {
        themeEditorPreviewAppbar.setTextColor(Color.BLACK);
    } else {
        themeEditorPreviewAppbar.setTextColor(Color.WHITE);
    }

    final FrameLayout themeEditorPreview = (FrameLayout) findViewById(R.id.theme_editor_preview);
    final ImageView themeEditorPreviewWallpaper = (ImageView) findViewById(R.id.theme_editor_preview_wallpaper);

    final String forumWallpaper = this.application.getSession().getServer().serverWallpaper;
    final String forumBackground = this.application.getSession().getServer().serverBackground;

    if (forumWallpaper != null && forumWallpaper.contains("http")) {
        final String imageUrl = forumWallpaper;
        themeEditorPreviewWallpaper.setVisibility(View.VISIBLE);
        ImageLoader.getInstance().displayImage(imageUrl, themeEditorPreviewWallpaper);
    } else {
        themeEditorPreviewWallpaper.setVisibility(View.GONE);
    }

    if (forumBackground != null && forumBackground.contains("#") && forumBackground.length() == 7) {
        themeEditorPreview.setBackgroundColor(Color.parseColor(forumBackground));
    } else {
        themeEditorPreview.setBackgroundColor(Color.parseColor(getString(R.string.default_background)));
    }

    final boolean useDivider = true;
    /*
    if (!(this.application.getSession().getServer().serverBackground.contentEquals(this.application.getSession().getServer().serverBoxColor)
        && this.application.getSession().getServer().serverBoxBorder.contentEquals("0"))) {
      useDivider = false;
    }
    */

    final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.theme_editor_preview_holder);
    previewHolder.removeAllViews();

    final Category sampleCategory = Category.builder().name("Sample Category").build();

    final Topic sampleTopic = Topic.builder().title("Thread Title").type(Topic.Type.Sticky).replyCount(2)
            .viewCount(7).authorName("Author Name").hasNewPosts(true)
            .authorIcon("http://localhost/author_icon.jpg").build();

    final Post po = new Post();
    po.author = "nezkeeeze";
    po.body = "Hey guys I'm new.  How do I get colored text?  Can I be an admin?  How do I start a new topic?<br /><br />"
            + this.application.getSession().getServer().serverTagline;
    po.avatar = "http://localhost/nezkeys.png";

    final LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View vC = vi.inflate(R.layout.category, null);
    final View vT = vi.inflate(R.layout.thread, null);
    final View vP = vi.inflate(R.layout.post, null);

    ElementRenderer.renderCategory(vC, this.application, this, useOpenSans, useShading, sampleCategory,
            currentAvatarSetting);
    ElementRenderer.renderCategory(vT, this.application, this, useOpenSans, useShading, sampleTopic,
            currentAvatarSetting);
    ElementRenderer.renderPost(vP, this.application, 1, this, 0, useOpenSans, useShading, po, fontSize,
            currentAvatarSetting);

    previewHolder.addView(vC);

    if (useDivider) {
        final View d1 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d1);
    }

    previewHolder.addView(vT);

    if (useDivider) {
        final View d2 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d2);
    }

    previewHolder.addView(vP);

    if (useDivider) {
        final View d3 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d3);
    }
}

From source file:nuclei.ui.view.media.PlayerControlsView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setClickable(true);/*  w  w  w .  j  a  va 2s .  c o  m*/
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PlayerControlsView, defStyleAttr,
            defStyleRes);

    mAutoHide = a.getBoolean(R.styleable.PlayerControlsView_auto_hide, false);
    boolean bottom = a.getBoolean(R.styleable.PlayerControlsView_bottom, false);

    int layout = a.getResourceId(R.styleable.PlayerControlsView_control_layout,
            bottom ? R.layout.cyto_view_player_controls_bottom : R.layout.cyto_view_player_controls);

    boolean hasPrevious = a.getBoolean(R.styleable.PlayerControlsView_has_previous, true);
    boolean hasNext = a.getBoolean(R.styleable.PlayerControlsView_has_next, true);

    boolean hasRewind = a.getBoolean(R.styleable.PlayerControlsView_has_rewind, false);
    boolean hasFastforward = a.getBoolean(R.styleable.PlayerControlsView_has_fastforward, false);

    a.recycle();

    View view = LayoutInflater.from(context).inflate(layout, this, false);
    addView(view);

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMediaInterface != null) {
                if (v.getId() == R.id.btn_play) {
                    if (mMediaInterface.getPlayerController() != null) {
                        v.setActivated(!v.isActivated());
                        if (v.isActivated())
                            mMediaInterface.getPlayerController().start();
                        else
                            mMediaInterface.getPlayerController().pause();
                    }
                } else if (v.getId() == R.id.btn_speed) {
                    onSpeedSelected(v);
                } else if (v.getId() == R.id.btn_timer) {
                    onTimerSelected(v);
                } else if (mMediaInterface.getMediaController() != null) {
                    if (mMediaInterface.getPlayerController() != null) {
                        if (v.getId() == R.id.btn_previous)
                            mMediaInterface.getPlayerController().skipToPrevious();
                        else if (v.getId() == R.id.btn_next)
                            mMediaInterface.getPlayerController().skipToNext();
                        else if (v.getId() == R.id.btn_rewind)
                            mMediaInterface.getPlayerController().rewind();
                        else if (v.getId() == R.id.btn_fastforward)
                            mMediaInterface.getPlayerController().fastForward();
                    }
                }
            }
        }
    };

    view.findViewById(R.id.btn_play).setOnClickListener(listener);

    ImageView previous = (ImageView) view.findViewById(R.id.btn_previous);
    ImageView next = (ImageView) view.findViewById(R.id.btn_next);
    ImageView rewind = (ImageView) view.findViewById(R.id.btn_rewind);
    ImageView fastforward = (ImageView) view.findViewById(R.id.btn_fastforward);

    if (previous != null) {
        previous.setOnClickListener(listener);
        previous.setVisibility(hasPrevious ? VISIBLE : GONE);
    }

    if (next != null) {
        next.setOnClickListener(listener);
        next.setVisibility(hasNext ? VISIBLE : GONE);
    }

    if (rewind != null) {
        rewind.setOnClickListener(listener);
        rewind.setVisibility(hasRewind ? VISIBLE : GONE);
    }

    if (fastforward != null) {
        fastforward.setOnClickListener(listener);
        fastforward.setVisibility(hasFastforward ? VISIBLE : GONE);
    }

    DefaultCallback.onHandleState(this, fastforward, rewind, next, previous, null);

    TextView speed = ((TextView) view.findViewById(R.id.btn_speed));
    if (speed != null) {
        speed.setText(ResourceProvider.getInstance().getSelectedSpeed());
        speed.setOnClickListener(listener);
        speed.setVisibility(View.VISIBLE);
    }

    TextView timer = (TextView) view.findViewById(R.id.btn_timer);
    if (timer != null) {
        timer.setText(ResourceProvider.getInstance().getString(ResourceProvider.TIMER));
        timer.setOnClickListener(listener);
    }
}

From source file:ca.ualberta.cs.drivr.RequestsListAdapter.java

/**
 * Called when the view holder is wants to bind the request at a certain position in the list.
 * @param viewHolder/*w  ww .  j  av  a 2 s . c o  m*/
 * @param position
 */
@Override
public void onBindViewHolder(final RequestsListAdapter.ViewHolder viewHolder, final int position) {
    final Request request = requestsToDisplay.get(position);

    // Get the views to update
    final TextView otherUserNameTextView = viewHolder.otherUserNameTextView;
    final TextView descriptionTextView = viewHolder.descriptionTextView;
    final TextView fareTextView = viewHolder.fareTextView;
    final TextView routeTextView = viewHolder.routeTextView;
    final TextView statusTextView = viewHolder.statusTextView;
    final ImageView callImageView = viewHolder.callImageView;
    final ImageView emailImageView = viewHolder.emailImageView;
    final ImageView checkImageView = viewHolder.checkMarkImageView;
    final ImageView deleteImageView = viewHolder.xMarkImageView;

    // Todo Hide Image Views until correct Request State
    if (request.getRequestState() != RequestState.CONFIRMED) {
        checkImageView.setVisibility(View.INVISIBLE);
    }

    if (request.getRequestState() != RequestState.PENDING) {
        deleteImageView.setVisibility(View.INVISIBLE);
    }

    // Show the other person's name
    final DriversList drivers = request.getDrivers();

    // Get the username of the other user
    if (userManager.getUserMode() == UserMode.RIDER) {
        final String multipleDrivers = "Multiple Drivers Accepted";
        final String driverUsername = drivers.size() == 1 ? drivers.get(0).getUsername() : "No Driver Yet";
        otherUserNameTextView.setText(drivers.size() > 1 ? multipleDrivers : driverUsername);
    } else {
        otherUserNameTextView.setText(request.getRider().getUsername());
    }

    // If the request has a description, show it. Otherwise, hide te description
    if (Strings.isNullOrEmpty(request.getDescription()))
        descriptionTextView.setVisibility(View.GONE);
    else
        descriptionTextView.setText(request.getDescription());

    // Show the fare
    fareTextView.setText("$" + request.getFareString());

    // Show the route
    routeTextView.setText(request.getRoute());

    // Driver User
    otherUserNameTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String otherUsername = otherUserNameTextView.getText().toString();
            // there exists drivers
            if (otherUsername != "No Driver Yet") {
                if (otherUsername != "Multiple Drivers Accepted") {
                    Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create();

                    ElasticSearch elasticSearch = new ElasticSearch(
                            UserManager.getInstance().getConnectivityManager());
                    User user = elasticSearch.loadUser(otherUsername);

                    String driverString = gson.toJson(user, User.class);
                    Intent intent = new Intent(context, DriverProfileActivity.class);
                    intent.putExtra(DriverProfileActivity.DRIVER, driverString);
                    context.startActivity(intent);
                } else {
                    startMultipleDriverIntent(request);
                }
            }
        }
    });

    routeTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create();
            String requestString = gson.toJson(request, Request.class);
            Intent intent = new Intent(context, RequestActivity.class);
            intent.putExtra("UniqueID", "From_RequestListActivity");
            intent.putExtra(RequestActivity.EXTRA_REQUEST, requestString);
            context.startActivity(intent);
        }
    });

    // Show the status text
    statusTextView.setText(request.getRequestState().toString());

    // Add a listener to the call image
    callImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (drivers.size() == 0) {
                Toast.makeText(context, "No driver number available at this time", Toast.LENGTH_SHORT).show();

            }
            // Start Dialer
            else if (drivers.size() == 1) {
                Intent intent = new Intent(Intent.ACTION_CALL);
                String number;
                if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) {
                    number = drivers.get(0).getPhoneNumber();
                } else {
                    number = request.getRider().getPhoneNumber();
                }
                number = "tel:" + number;
                intent.setData(Uri.parse(number));
                if (ActivityCompat.checkSelfPermission(context,
                        Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

                    return;
                }
                context.startActivity(intent);

            } else {

                startMultipleDriverIntent(request);
            }
        }
    });

    // Add a listener to the email image
    emailImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (drivers.size() == 0) {
                Toast.makeText(context, "No driver email available at this time", Toast.LENGTH_SHORT).show();

            }
            //http://stackoverflow.com/questions/8701634/send-email-intent
            else if (drivers.size() == 1) {

                Intent intent = new Intent();
                ComponentName emailApp = intent.resolveActivity(context.getPackageManager());
                ComponentName unsupportedAction = ComponentName
                        .unflattenFromString("com.android.fallback/.Fallback");
                boolean hasEmailApp = emailApp != null && !emailApp.equals(unsupportedAction);
                String email;

                if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) {
                    email = drivers.get(0).getEmail();
                } else {
                    email = request.getRider().getEmail();
                }
                String subject = "Drivr Request: " + request.getId();
                String body = "Drivr user " + drivers.get(0).getUsername();

                if (hasEmailApp) {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
                    emailIntent.putExtra(Intent.EXTRA_TEXT, body);
                    context.startActivity(Intent.createChooser(emailIntent, "Chooser Title"));
                } else {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null));
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "");
                    emailIntent.putExtra(Intent.EXTRA_TEXT, "");
                    context.startActivity(Intent.createChooser(emailIntent, "Send email..."));
                }
            } else {
                startMultipleDriverIntent(request);

            }
        }
    });

    // Complete The Request
    checkImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, RequestCompletedActivity.class);
            intent.putExtra(RequestCompletedActivity.REQUEST_ID_EXTRA, request.getId());
            context.startActivity(intent);
        }
    });

    deleteImageView.setOnClickListener(new View.OnClickListener() {

        // Todo Delete the Request
        @Override
        public void onClick(View v) {
            v.getContext();
            ElasticSearch elasticSearch = new ElasticSearch(
                    (ConnectivityManager) v.getContext().getSystemService(Context.CONNECTIVITY_SERVICE));
            elasticSearch.deleteRequest(request.getId());
            UserManager userManager = UserManager.getInstance();
            userManager.getRequestsList().removeById(request);
            userManager.notifyObservers();
            requestsToDisplay.remove(request);
            notifyItemRemoved(viewHolder.getAdapterPosition());
        }
    });
}

From source file:org.getlantern.firetweet.adapter.UserHashtagAutoCompleteAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    if (isCursorClosed())
        return;//  w  ww .  j  a v a  2  s .  c om
    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);

    // Clear images in prder to prevent images in recycled view shown.
    icon.setImageDrawable(null);

    if (mScreenNameIdx != -1 && mNameIdx != -1 && mUserIdIdx != -1) {
        text1.setText(getUserNickname(context, cursor.getLong(mUserIdIdx), cursor.getString(mNameIdx)));
        text2.setText("@" + cursor.getString(mScreenNameIdx));
    } else {
        text1.setText("#" + cursor.getString(mNameIdx));
        text2.setText(R.string.hashtag);
    }
    icon.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
    if (mProfileImageUrlIdx != -1) {
        if (mDisplayProfileImage) {
            final String profileImageUrl = cursor.getString(mProfileImageUrlIdx);
            mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
        } else {
            mProfileImageLoader.cancelDisplayTask(icon);
            //                icon.setImageResource(R.drawable.ic_profile_image_default);
        }
        icon.clearColorFilter();
    } else {
        icon.setImageResource(R.drawable.ic_action_hashtag);
        icon.setColorFilter(text1.getCurrentTextColor(), Mode.SRC_ATOP);
    }
    super.bindView(view, context, cursor);
}

From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_page_virayesh);

    Fabric.with(this, new Crashlytics());

    TextView virayeshTextinToolbar = (TextView) findViewById(R.id.virayeshTextinToolbar);
    final TextView zaxireTextinToolbar = (TextView) findViewById(R.id.zaxireTextinToolbar);
    init();/*from   w  ww  .j  av a  2s .  co m*/
    ableall(false);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    ImageView imageView = (ImageView) findViewById(R.id.menuButton);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            drawer.openDrawer(Gravity.END);

        }
    });

    if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(true);
        nav_Menu.findItem(R.id.nav_login).setVisible(false);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(true);

    } else {

        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(false);
        nav_Menu.findItem(R.id.nav_login).setVisible(true);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(false);
    }

    final ImageView imageView1 = (ImageView) findViewById(R.id.onclickeasadinchimastanxanim);
    imageView1.setVisibility(View.GONE);

    if (isOnline()) {
        setAlage();

        if (GlobalVar.getUserType().equals("adviser")) {

            virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ableall(true);
                    sihhhhh1.setVisibility(View.VISIBLE);
                    sihhhhh2.setVisibility(View.VISIBLE);
                    imageView1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent pickPhoto = new Intent(Intent.ACTION_PICK,
                                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            startActivityForResult(pickPhoto, 1);//one can be replaced with any action code
                        }
                    });
                    zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            postgetData();
                        }
                    });
                }
            });

            imageView1.setVisibility(View.VISIBLE);
            barchasbEdit.setVisibility(View.VISIBLE);
            costperminEdit.setVisibility(View.VISIBLE);
            maxtimeEdit.setVisibility(View.VISIBLE);
            sexEdit.setVisibility(View.VISIBLE);
            dialtecEdit.setVisibility(View.VISIBLE);
            aboutmeEdit.setVisibility(View.VISIBLE);

        } else if (GlobalVar.getUserType().equals("user")) {

            virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    TextView textView = (TextView) findViewById(R.id.sihhhhh1);
                    TextView textView2 = (TextView) findViewById(R.id.sihhhhh2);
                    textView.setVisibility(View.GONE);
                    textView2.setVisibility(View.GONE);
                    imageView1.setVisibility(View.VISIBLE);
                    boolean b = false;
                    sihhhhh1.setVisibility(View.GONE);
                    sihhhhh2.setVisibility(View.GONE);
                    namexanivadeEdit.setEnabled(!b);
                    shomareteleEdit.setEnabled(!b);
                    emailEdit.setEnabled(!b);
                    barchasbEdit.setVisibility(View.GONE);
                    costperminEdit.setVisibility(View.GONE);
                    maxtimeEdit.setVisibility(View.GONE);
                    sexEdit.setVisibility(View.GONE);
                    dialtecEdit.setVisibility(View.GONE);
                    aboutmeEdit.setVisibility(View.GONE);

                    imageView1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent pickPhoto = new Intent(Intent.ACTION_PICK,
                                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            startActivityForResult(pickPhoto, 1);//one can be replaced with any action code
                        }
                    });
                    zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            postgetData();
                        }
                    });
                }
            });
        }
    } else {
        Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show();
    }
}