Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

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

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.example.nikhil.wikipediasearch.ImageAdapter.java

private void zoomImageFromThumb(final View thumbView, int imageId) {
    // If there's an animation in progress, cancel it immediately and
    // proceed with this one.
    int startIndex = 0;
    int lastIndex = 0;

    // Load the high-resolution "zoomed-in" image.
    final ImageView expandedImageView = (ImageView) ((Activity) thumbView.getContext())
            .findViewById(R.id.expanded_image);

    expandedImageView.setBackgroundColor(ContextCompat.getColor(thumbView.getContext(), R.color.Color_1));
    String newURL = URLS[imageId].replace("/thumb", "");

    lastIndex = newURL.lastIndexOf("/");

    String newURLSubString = newURL.substring(lastIndex);

    newURL = newURL.replace(newURLSubString, "");

    int width = thumbView.getContext().getResources().getDisplayMetrics().widthPixels;
    int height = thumbView.getContext().getResources().getDisplayMetrics().heightPixels;

    Picasso.with(thumbView.getContext()).load(newURL).noFade().resize(width, height / 2).centerCrop()
            .error(R.drawable.no_image).placeholder(R.drawable.progress_animation)
            .into((ImageView) expandedImageView);

    Log.d(TAG, "setOnClickListener" + newURL);

    expandedImageView.setVisibility(View.VISIBLE);

    // Set the pivot point for SCALE_X and SCALE_Y transformations to the
    // top-left corner of
    // the zoomed-in view (the default is the center of the view).
    expandedImageView.setPivotX(0f);/*from ww  w .  ja  v a2s. com*/
    expandedImageView.setPivotY(0f);

    // Upon clicking the zoomed-in image, it should zoom back down to the
    // original bounds
    // and show the thumbnail instead of the expanded image.
    //final float startScaleFinal = startScale;
    expandedImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            expandedImageView.setVisibility(View.GONE);
        }
    });
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java

@Override
public void create() {
    try {//from w w w  .j  av a  2s .c om
        setContentView(R.layout.grouped_contacts_details);

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        person = (Person) store.getSerializable("person");
        if (person == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }
        setTopBarTitle(widget.getTitle());

        Boolean single = currentIntent.getBooleanExtra("single", true);

        setTopBarLeftButtonTextAndColor(
                single ? getResources().getString(R.string.common_home_upper)
                        : getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) {

            ImageView shareButton = (ImageView) getLayoutInflater()
                    .inflate(R.layout.grouped_contacts_share_button, null);
            shareButton.setLayoutParams(
                    new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density),
                            (int) (39 * getResources().getDisplayMetrics().density)));
            shareButton.setColorFilter(Color.BLACK);
            setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share),
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder();

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                                sharingDialogBuilder
                                        .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();
                                                Intent email = new Intent(Intent.ACTION_SEND);
                                                email.putExtra(Intent.EXTRA_TEXT, message);
                                                email.setType("message/rfc822");
                                                startActivity(Intent.createChooser(email,
                                                        getString(R.string.choose_email_client)));
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                                sharingDialogBuilder
                                        .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();

                                                try {
                                                    Utils.sendSms(ContactDetailsActivity.this, message);
                                                } catch (ActivityNotFoundException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT)))
                                sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook,
                                        R.drawable.gc_add_to_contacts, true,
                                        new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                createNewContact(person.getName(), person.getPhone(),
                                                        person.getEmail());
                                            }
                                        });

                            showDialogSharing(sharingDialogBuilder.build());
                        }
                    });

        }

        boolean hasSchema = store.getBoolean("hasschema");
        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        contacts = person.getContacts();

        if (widget.getTitle().length() > 0) {
            setTitle(widget.getTitle());
        }

        root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root);

        if (hasSchema) {
            root.setBackgroundColor(Statics.color1);
        } else if (widget.isBackgroundURL()) {
            cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL());
            File backgroundFile = new File(cacheBackgroundFile);
            if (backgroundFile.exists()) {
                root.setBackgroundDrawable(
                        new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile))));
            } else {
                BackgroundDownloadTask dt = new BackgroundDownloadTask();
                dt.execute(widget.getBackgroundURL());
            }
        } else if (widget.isBackgroundInAssets()) {
            AssetManager am = this.getAssets();
            root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL())));
        }

        if (contacts != null) {
            ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar);

            avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            if (person.hasAvatar() && NetworkUtils.isOnline(this)) {
                avatarImage.setVisibility(View.VISIBLE);
                Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar)
                        .dontAnimate().into(avatarImage);
            } else {
                avatarImage.setVisibility(View.VISIBLE);
                avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            }

            String name = "";
            neededContacts = new ArrayList<>();
            for (Contact con : contacts) {
                if ((con.getType() == 5) || (con.getDescription().length() == 0)) {
                } else {
                    if (con.getType() == 0) {
                        name = con.getDescription();
                    } else
                        neededContacts.add(con);
                }
            }

            if (neededContacts.isEmpty()) {
                handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA);
                return;
            }

            headSeparator = findViewById(R.id.gc_head_separator);
            bottomSeparator = findViewById(R.id.gc_bottom_separator);
            imageBottom = findViewById(R.id.gc_image_bottom_layout);
            personName = (TextView) findViewById(R.id.gc_details_description);

            if ("".equals(name))
                personName.setVisibility(View.GONE);
            else {
                personName.setVisibility(View.VISIBLE);
                personName.setText(name);
                personName.setTextColor(Statics.color3);
            }
            if (Statics.isLight) {
                headSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
            } else {
                headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
            }

            ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1);

            ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view);
            list.setDivider(null);

            ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this,
                    R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1));
            list.setAdapter(adapter);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
                    listViewItemClick(position);
                }
            });
        }

        if (widget.hasParameter("add_contact")) {
            HashMap<String, String> hm = new HashMap<>();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    hm.put("contactName", contacts.get(i).getDescription());
                }
                    break;
                case 1: {
                    hm.put("contactNumber", contacts.get(i).getDescription());
                }
                    break;
                case 2: {
                    hm.put("contactEmail", contacts.get(i).getDescription());
                }
                    break;
                case 3: {
                    hm.put("contactSite", contacts.get(i).getDescription());
                }
                    break;
                }
            }
            addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm);
        }
        if (widget.hasParameter("send_sms")) {
            HashMap<String, String> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                sb.append(contacts.get(i).getDescription());
                if (i < contacts.size() - 1) {
                    sb.append(", ");
                }
            }
            hm.put("text", sb.toString());
            addNativeFeature(NATIVE_FEATURES.SMS, null, hm);
        }
        if (widget.hasParameter("send_mail")) {
            HashMap<String, CharSequence> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    sb.append("Name: ");
                }
                    break;
                case 1: {
                    sb.append("Phone: ");
                }
                    break;
                case 2: {
                    sb.append("Email: ");
                }
                    break;
                case 3: {
                    sb.append("Site: ");
                }
                    break;
                case 4: {
                    sb.append("Address: ");
                }
                    break;
                }
                sb.append(contacts.get(i).getDescription());
                sb.append("<br/>");
            }

            if (widget.isHaveAdvertisement()) {
                sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)");
            }

            hm.put("text", sb.toString());
            hm.put("subject", "Contacts");
            addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm);
        }

    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.moki.touch.fragments.views.WebContent.java

private void configureNavigationBar() {

    Button back = (Button) rootView.findViewById(R.id.backButton);
    back.setOnClickListener(new View.OnClickListener() {
        @Override//  w  w w . j av  a2 s  .  c o  m
        public void onClick(View v) {
            webView.goBack();
        }
    });
    back.setBackgroundDrawable(createButtonStateList(R.drawable.mt_btn_touch_prev, R.drawable.mt_btn_prev));
    Button forward = (Button) rootView.findViewById(R.id.forwardButton);
    forward.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            webView.goForward();
        }
    });
    forward.setBackgroundDrawable(createButtonStateList(R.drawable.mt_btn_touch_next, R.drawable.mt_btn_next));
    Button home = (Button) rootView.findViewById(R.id.homeButton);
    home.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            endSession();
        }
    });
    home.setBackgroundDrawable(createButtonStateList(R.drawable.mt_btn_touch_home, R.drawable.mt_btn_home));
    Button refresh = (Button) rootView.findViewById(R.id.refreshButton);
    refresh.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            webView.reload();
        }
    });
    refresh.setBackgroundDrawable(
            createButtonStateList(R.drawable.mt_btn_touch_refresh, R.drawable.mt_btn_refresh));
    Button endSession = (Button) rootView.findViewById(R.id.endSession);
    endSession.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setupEndSessionAlertDialog();
            endSession();
        }
    });
    endSession.setBackgroundDrawable(createButtonStateList(R.drawable.mt_btn_end, R.drawable.mt_btn_end));
    addressBar = (EditText) rootView.findViewById(R.id.urlBar);
    addressBar.setText(homeUrl);
    addressBar.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String url = addressBar.getText().toString();
            url = UrlUtil.addHttp(url);
            webView.loadUrl(url);
            return true;
        }
    });
    addressBar.setLongClickable(false);
    if (!isHomeMode) {
        addressBar.setClickable(false);
        addressBar.setFocusable(false);
        addressBar.setFocusableInTouchMode(false);
        back.setClickable(false);
        forward.setClickable(false);
        home.setClickable(false);
        refresh.setClickable(false);
        endSession.setClickable(false);
    }
    ImageView logo = (ImageView) rootView.findViewById(R.id.logo);

    boolean allNavigationItemsDisabled = true;

    if (!showNavigationButtons) {
        back.setVisibility(View.GONE);
        forward.setVisibility(View.GONE);
        refresh.setVisibility(View.GONE);
        home.setVisibility(View.GONE);
    } else {
        allNavigationItemsDisabled = false;
    }

    if (!showLogo) {
        logo.setVisibility(View.GONE);
    } else {
        allNavigationItemsDisabled = false;
    }

    if (!showEndSessionButton) {
        endSession.setVisibility(View.GONE);
    } else {
        allNavigationItemsDisabled = false;
    }

    if (!showNavigationBar) {
        addressBar.setVisibility(View.GONE);
    } else {
        allNavigationItemsDisabled = false;
    }

    if (allNavigationItemsDisabled) {
        browserBar.setVisibility(View.GONE);
    }
}

From source file:com.roamprocess1.roaming4world.ui.favorites.FavAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(cursor, cv);

    int type = ContactsWrapper.TYPE_CONTACT;
    if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) {
        type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE);
    }/*ww  w  .  j  a va  2s.com*/

    showViewForType(view, type);

    if (type == ContactsWrapper.TYPE_GROUP) {
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.header_text);
        ImageView icon = (ImageView) view.findViewById(R.id.header_icon);
        //   PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view.findViewById(R.id.header_presence_spinner);

        // Get datas
        SipProfile acc = new SipProfile(cursor);

        final Long profileId = cv.getAsLong(BaseColumns._ID);
        final String groupName = acc.android_group;
        final String displayName = acc.display_name;
        final String wizard = acc.wizard;
        final boolean publishedEnabled = (acc.publish_enabled == 1);
        final String domain = acc.getDefaultDomain();

        // Bind datas to view
        //tv.setText(displayName);  //Commented by Esstel Softwares
        tv.setText("Starred Android Contacts");

        icon.setImageResource(WizardUtils.getWizardIconRes(wizard));
        //  presSpinner.setProfileId(profileId);

        // Extra menu view if not already set
        ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner);

        MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled);
        MenuBuilder menuBuilder;
        if (menuViewWrapper.getTag() == null) {

            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);

            ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext);
            mActionMenuPresenter.setReserveOverflow(true);
            menuBuilder = new MenuBuilder(context);
            menuBuilder.setCallback(newMcb);
            MenuInflater inflater = new MenuInflater(context);
            inflater.inflate(R.menu.fav_menu_new, menuBuilder);
            menuBuilder.addMenuPresenter(mActionMenuPresenter);
            ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper);
            UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null);
            menuViewWrapper.addView(menuView, layoutParams);
            menuViewWrapper.setTag(menuBuilder);
        } else {
            menuBuilder = (MenuBuilder) menuViewWrapper.getTag();
            menuBuilder.setCallback(newMcb);
        }
        //  menuBuilder.findItem(R.id.share_presence).setTitle(publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing);
        // menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName));

    } else if (type == ContactsWrapper.TYPE_CONTACT) {
        ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor);
        ci.userData = cursor.getPosition();
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.contact_name);
        QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
        TextView statusText = (TextView) view.findViewById(R.id.status_text);
        ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon);

        // Bind
        if (ci.contactId != null) {
            tv.setText(ci.displayName);
            badge.assignContactUri(ci.callerInfo.contactContentUri);
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(),
                    ci.callerInfo, R.drawable.ic_contact_picture_holo_dark);

            statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusText.setText(ci.status);
            statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence));
        }
        View v;
        v = view.findViewById(R.id.contact_view);
        v.setTag(ci);
        v.setOnClickListener(mPrimaryActionListener);
        v = view.findViewById(R.id.secondary_action_icon);
        v.setTag(ci);
        v.setOnClickListener(mSecondaryActionListener);
    } else if (type == ContactsWrapper.TYPE_CONFIGURE) {
        // We only bind if it's the correct type
        // View v = view.findViewById(R.id.configure_view);
        //v.setOnClickListener(this);
        //ConfigureObj cfg = new ConfigureObj();
        // cfg.profileId = cv.getAsLong(BaseColumns._ID);
        // v.setTag(cfg);
    }
}

From source file:org.schabi.newpipe.VideoItemDetailFragment.java

private void updateInfo(final StreamInfo info) {
    try {// www  . java2  s .  c  o  m
        Context c = getContext();
        VideoInfoItemViewCreator videoItemViewCreator = new VideoInfoItemViewCreator(
                LayoutInflater.from(getActivity()));

        RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detailTextContentLayout);
        final TextView videoTitleView = (TextView) activity.findViewById(R.id.detailVideoTitleView);
        TextView uploaderView = (TextView) activity.findViewById(R.id.detailUploaderView);
        TextView viewCountView = (TextView) activity.findViewById(R.id.detailViewCountView);
        TextView thumbsUpView = (TextView) activity.findViewById(R.id.detailThumbsUpCountView);
        TextView thumbsDownView = (TextView) activity.findViewById(R.id.detailThumbsDownCountView);
        TextView uploadDateView = (TextView) activity.findViewById(R.id.detailUploadDateView);
        TextView descriptionView = (TextView) activity.findViewById(R.id.detailDescriptionView);
        FrameLayout nextVideoFrame = (FrameLayout) activity.findViewById(R.id.detailNextVideoFrame);
        RelativeLayout nextVideoRootFrame = (RelativeLayout) activity
                .findViewById(R.id.detailNextVideoRootLayout);
        Button nextVideoButton = (Button) activity.findViewById(R.id.detailNextVideoButton);
        TextView similarTitle = (TextView) activity.findViewById(R.id.detailSimilarTitle);
        Button backgroundButton = (Button) activity
                .findViewById(R.id.detailVideoThumbnailWindowBackgroundButton);
        View topView = activity.findViewById(R.id.detailTopView);
        View nextVideoView = null;
        if (info.next_video != null) {
            nextVideoView = videoItemViewCreator.getViewFromVideoInfoItem(null, nextVideoFrame,
                    info.next_video);
        } else {
            activity.findViewById(R.id.detailNextVidButtonAndContentLayout).setVisibility(View.GONE);
            activity.findViewById(R.id.detailNextVideoTitle).setVisibility(View.GONE);
            activity.findViewById(R.id.detailNextVideoButton).setVisibility(View.GONE);
        }

        progressBar.setVisibility(View.GONE);
        if (nextVideoView != null) {
            nextVideoFrame.addView(nextVideoView);
        }

        initThumbnailViews(info, nextVideoFrame);

        textContentLayout.setVisibility(View.VISIBLE);
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setVisibility(View.VISIBLE);
        } else {
            ImageView playArrowView = (ImageView) activity.findViewById(R.id.playArrowView);
            playArrowView.setVisibility(View.VISIBLE);
        }

        if (!showNextVideoItem) {
            nextVideoRootFrame.setVisibility(View.GONE);
            similarTitle.setVisibility(View.GONE);
        }

        videoTitleView.setText(info.title);

        topView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
                    ImageView arrow = (ImageView) activity.findViewById(R.id.toggleDescriptionView);
                    View extra = activity.findViewById(R.id.detailExtraView);
                    if (extra.getVisibility() == View.VISIBLE) {
                        extra.setVisibility(View.GONE);
                        arrow.setImageResource(R.drawable.arrow_down);
                    } else {
                        extra.setVisibility(View.VISIBLE);
                        arrow.setImageResource(R.drawable.arrow_up);
                    }
                }
                return true;
            }
        });

        // Since newpipe is designed to work even if certain information is not available,
        // the UI has to react on missing information.
        videoTitleView.setText(info.title);
        if (!info.uploader.isEmpty()) {
            uploaderView.setText(info.uploader);
        } else {
            activity.findViewById(R.id.detailUploaderWrapView).setVisibility(View.GONE);
        }
        if (info.view_count >= 0) {
            viewCountView.setText(Localization.localizeViewCount(info.view_count, c));
        } else {
            viewCountView.setVisibility(View.GONE);
        }
        if (info.dislike_count >= 0) {
            thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, c));
        } else {
            thumbsDownView.setVisibility(View.INVISIBLE);
            activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE);
        }
        if (info.like_count >= 0) {
            thumbsUpView.setText(Localization.localizeNumber(info.like_count, c));
        } else {
            thumbsUpView.setVisibility(View.GONE);
            activity.findViewById(R.id.detailThumbsUpImgView).setVisibility(View.GONE);
            thumbsDownView.setVisibility(View.GONE);
            activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE);
        }
        if (!info.upload_date.isEmpty()) {
            uploadDateView.setText(Localization.localizeDate(info.upload_date, c));
        } else {
            uploadDateView.setVisibility(View.GONE);
        }
        if (!info.description.isEmpty()) {
            descriptionView.setText(Html.fromHtml(info.description));
        } else {
            descriptionView.setVisibility(View.GONE);
        }

        descriptionView.setMovementMethod(LinkMovementMethod.getInstance());

        // parse streams
        Vector<VideoStream> streamsToUse = new Vector<>();
        for (VideoStream i : info.video_streams) {
            if (useStream(i, streamsToUse)) {
                streamsToUse.add(i);
            }
        }

        nextVideoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent detailIntent = new Intent(getActivity(), VideoItemDetailActivity.class);
                /*detailIntent.putExtra(
                        VideoItemDetailFragment.ARG_ITEM_ID, currentVideoInfo.nextVideo.id); */
                detailIntent.putExtra(VideoItemDetailFragment.VIDEO_URL, info.next_video.webpage_url);
                detailIntent.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
                startActivity(detailIntent);
            }
        });
        textContentLayout.setVisibility(View.VISIBLE);

        if (info.related_videos != null && !info.related_videos.isEmpty()) {
            initSimilarVideos(info, videoItemViewCreator);
        } else {
            activity.findViewById(R.id.detailSimilarTitle).setVisibility(View.GONE);
            activity.findViewById(R.id.similarVideosView).setVisibility(View.GONE);
        }

        setupActionBarHandler(info);

        if (autoPlayEnabled) {
            playVideo(info);
        }

        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    playVideo(info);
                }
            });
        }

        backgroundButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });

    } catch (java.lang.NullPointerException e) {
        Log.w(TAG, "updateInfo(): Fragment closed before thread ended work... or else");
        e.printStackTrace();
    }
}

From source file:de.baumann.hhsmoodle.data_todo.Todo_Fragment.java

public void setTodoList() {

    if (isFABOpen) {
        closeFABMenu();//from  ww w  .  j  a  va2s .co m
    }

    NotificationManager nMgr = (NotificationManager) getActivity()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "todo_title", "todo_content", "todo_creation" };
    final Cursor row = db.fetchAllData(getActivity());
    adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            View v = super.getView(position, convertView, parent);
            ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes);
            ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);
            helper_main.switchIcon(getActivity(), todo_icon, "todo_icon", iv_icon);

            switch (todo_attachment) {
            case "true":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle_red);

                int n = Integer.valueOf(_id);

                android.content.Intent iMain = new android.content.Intent();
                iMain.setAction("shortcutToDo");
                iMain.setClassName(getActivity(), "de.baumann.hhsmoodle.activities.Activity_splash");
                PendingIntent piMain = PendingIntent.getActivity(getActivity(), n, iMain, 0);

                NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(getActivity())
                        .setSmallIcon(R.drawable.school)
                        .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary))
                        .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain);

                Notification notification = new NotificationCompat.Builder(getActivity())
                        .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary))
                        .setSmallIcon(R.drawable.school).setContentTitle(todo_title)
                        .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true)
                        .setGroup("HHS_Moodle")
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content))
                        .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build();

                NotificationManager notificationManager = (NotificationManager) getActivity()
                        .getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(n, notification);
                notificationManager.notify(0, builderSummary.build());
                break;
            }

            iv_icon.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    final helper_main.Item[] items = {
                            new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green),
                            new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow),
                            new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), };

                    ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(),
                            android.R.layout.select_dialog_item, android.R.id.text1, items) {
                        @NonNull
                        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                            //Use super class to create the View
                            View v = super.getView(position, convertView, parent);
                            TextView tv = (TextView) v.findViewById(android.R.id.text1);
                            tv.setTextSize(18);
                            tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                            //Add margin between image and text (support various screen densities)
                            int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f);
                            tv.setCompoundDrawablePadding(dp5);

                            return v;
                        }
                    };

                    new AlertDialog.Builder(getActivity())
                            .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    dialog.cancel();
                                }
                            }).setAdapter(adapter, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int item) {
                                    if (item == 0) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "3",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 1) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "2",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 2) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "1",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    }
                                }
                            }).show();
                }
            });
            iv_attachment.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    switch (todo_attachment) {
                    case "true":
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "",
                                todo_creation);
                        setTodoList();
                        break;
                    default:
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true",
                                todo_creation);
                        setTodoList();
                        break;
                    }
                }
            });
            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_todoBY", "note_title");
    sharedPref.edit().putString("filter_todoBY", "note_title").apply();
    filter.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchDataByFilter(constraint.toString(), note_search);
        }
    });

    lv.setAdapter(adapter);
    //onClick function
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            sharedPref.edit().putString("toDo_title", todo_title).apply();
            sharedPref.edit().putString("toDo_text", todo_content).apply();
            sharedPref.edit().putString("toDo_seqno", _id).apply();
            sharedPref.edit().putString("toDo_icon", todo_icon).apply();
            sharedPref.edit().putString("toDo_create", todo_creation).apply();
            sharedPref.edit().putString("toDo_attachment", todo_attachment).apply();

            helper_main.switchToActivity(getActivity(), Activity_todo.class, false);
        }
    });

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

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            final CharSequence[] options = { getString(R.string.number_edit_entry),
                    getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share),
                    getString(R.string.bookmark_createNote), getString(R.string.count_create),
                    getString(R.string.bookmark_createEvent) };
            new AlertDialog.Builder(getActivity())
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.number_edit_entry))) {

                                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                                View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null);

                                final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title);
                                edit_title.setHint(R.string.bookmark_edit_title);
                                edit_title.setText(todo_title);

                                builder.setView(dialogView);
                                builder.setTitle(R.string.bookmark_edit_title);
                                builder.setPositiveButton(R.string.toast_yes,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {

                                                String inputTag = edit_title.getText().toString().trim();
                                                db.update(Integer.parseInt(_id), inputTag, todo_content,
                                                        todo_icon, todo_attachment, todo_creation);
                                                setTodoList();
                                                Snackbar.make(lv, R.string.bookmark_added,
                                                        Snackbar.LENGTH_SHORT).show();
                                            }
                                        });
                                builder.setNegativeButton(R.string.toast_cancel,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                dialog.cancel();
                                            }
                                        });

                                final AlertDialog dialog2 = builder.create();
                                // Display the custom alert dialog on interface
                                dialog2.show();
                                helper_main.showKeyboard(getActivity(), edit_title);
                            }

                            if (options[item].equals(getString(R.string.todo_share))) {
                                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                sharingIntent.setType("text/plain");
                                sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title);
                                sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content);
                                startActivity(Intent.createChooser(sharingIntent,
                                        (getString(R.string.note_share_2))));
                            }

                            if (options[item].equals(getString(R.string.bookmark_createEvent))) {
                                helper_main.createCalendarEvent(getActivity(), todo_title, todo_content);
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setTodoList();
                                            }
                                        });
                                snackbar.show();
                            }

                            if (options[item].equals(getString(R.string.bookmark_createNote))) {
                                Notes_helper.newNote(getActivity(), todo_title, todo_content, "", "", "", "");
                            }

                            if (options[item].equals(getString(R.string.count_create))) {
                                Count_helper.newCount(getActivity(), todo_title, todo_content,
                                        getActivity().getString(R.string.note_content), false);
                            }

                        }
                    }).show();

            return true;
        }
    });
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

private View makeNavDrawerItem(final int itemId, ViewGroup container) {
    int layout;/*w w w .java  2s . c  o m*/
    if (itemId == SEPARATOR) {
        layout = R.layout.navdrawer_separator;
    } else if (itemId == HEADER) {
        layout = R.layout.navdrawer_header;
    } else {
        layout = R.layout.navdrawer_item;
    }

    View view = getLayoutInflater().inflate(layout, container, false);

    if (itemId == SEPARATOR || itemId == HEADER) {
        // TODO: Header click
        // TODO: Accessibility?
        return view;
    }

    ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    TextView titleView = (TextView) view.findViewById(R.id.title);
    int iconId = itemId >= 0 && itemId < NAV_DRAWER_DRAWABLE_IDS.length ? NAV_DRAWER_DRAWABLE_IDS[itemId] : 0;
    int titleId = itemId >= 0 && itemId < NAV_DRAWER_STRING_IDS.length ? NAV_DRAWER_STRING_IDS[itemId] : 0;

    iconView.setVisibility(iconId == 0 ? View.GONE : View.VISIBLE);
    if (iconId > 0) {
        iconView.setImageResource(iconId);
    }
    titleView.setText(titleId);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onNavDrawerItemClick(itemId);
        }
    });

    return view;
}

From source file:com.android.ex.chips.RecipientAlternatesAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    int position = cursor.getPosition();

    TextView display = (TextView) view.findViewById(android.R.id.title);
    ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
    RecipientEntry entry = getRecipientEntry(position);
    if (position == 0) {
        display.setText(cursor.getString(Queries.Query.NAME));
        display.setVisibility(View.VISIBLE);

        byte[] photoBytes = mPhotoCacheMap.get(entry.getPhotoThumbnailUri());
        if (photoBytes != null && imageView != null) {
            Bitmap photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length);
            imageView.setImageBitmap(photo);
        } else {//from   www .  j  a  v a  2s.c o  m
            imageView.setImageResource(R.drawable.ic_contact_picture);
            if (entry.getPhotoThumbnailUri() != null)
                fetchPhotoAsync(entry, entry.getPhotoThumbnailUri());
        }
        imageView.setVisibility(View.VISIBLE);
    } else {
        display.setVisibility(View.GONE);
        imageView.setVisibility(View.GONE);
    }
    TextView destination = (TextView) view.findViewById(android.R.id.text1);
    destination.setText(cursor.getString(Queries.Query.DESTINATION));

    TextView destinationType = (TextView) view.findViewById(android.R.id.text2);
    if (destinationType != null) {
        destinationType.setText(
                mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE),
                        cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase());
    }
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

@Override
protected void onActivityResult(final int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK)
        return;// w  ww  . ja  v a  2 s . c  o m
    switch (requestCode) {
    case REQUEST_CHOOSE_MERCHANT: {

        mAgentId = mMerchantId = data.getIntExtra(AGENT_ID, 0);
        mAgentName = data.getStringExtra(AGENT_NAME);
        setItemValue(mMerchantKeys[0], mAgentName);

        getAgentInfo();

        break;
    }
    case REQUEST_CHOOSE_BANK: {

        mBankName = data.getStringExtra("bank_name");
        mBankNo = data.getStringExtra("bank_no");
        setItemValue(customTag, mBankName);
        setItemValue(mBankKeys[0], mBankName);

        //FIXME no 
        //                setItemValue(mBankKeys[1], mBankNo);

        break;
    }
    case REQUEST_CHOOSE_CITY: {
        mMerchantProvince = (Province) data.getSerializableExtra(SELECTED_PROVINCE);
        mMerchantCity = (City) data.getSerializableExtra(SELECTED_CITY);
        mCityId = mMerchantCity.getId();
        setItemValue(mMerchantKeys[8], mMerchantCity.getName());
        break;
    }
    case REQUEST_CHOOSE_CHANNEL: {
        mChannelId = data.getIntExtra("channelId", 0);
        mBillingId = data.getIntExtra("billId", 0);
        String channelName = data.getStringExtra("channelName");
        String billName = data.getStringExtra("billName");

        setItemValue(getString(R.string.apply_detail_channel), channelName + " " + billName);
        break;
    }
    case REQUEST_UPLOAD_IMAGE:
    case REQUEST_TAKE_PHOTO: {

        final Handler handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == 1) {
                    //                     CommonUtil.toastShort(ApplyDetailActivity.this, (String) msg.obj);
                    if (null != uploadingTextView) {
                        final String url = (String) msg.obj;
                        LinearLayout item = (LinearLayout) uploadingTextView.getParent().getParent();

                        updateCustomerDetails(item.getTag(), url);
                        uploadingTextView.setVisibility(View.GONE);

                        ImageView iv_view = (ImageView) item.findViewById(R.id.apply_detail_view);
                        iv_view.setVisibility(View.VISIBLE);
                        iv_view.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class);
                                i.putExtra("url", url);
                                i.putExtra("justviewer", true);
                                startActivity(i);
                            }
                        });
                    }
                } else {
                    CommonUtil.toastShort(ApplyDetailActivity.this, getString(R.string.toast_upload_failed));
                    if (null != uploadingTextView) {
                        uploadingTextView.setText(getString(R.string.apply_upload_again));
                        uploadingTextView.setClickable(true);
                    }
                }

            }
        };
        if (null != uploadingTextView) {
            uploadingTextView.setText(getString(R.string.apply_uploading));
            uploadingTextView.setClickable(false);
        }
        new Thread() {
            @Override
            public void run() {
                String realPath = "";
                if (requestCode == REQUEST_TAKE_PHOTO) {
                    realPath = photoPath;
                } else {
                    Uri uri = data.getData();
                    if (uri != null) {
                        realPath = getRealPathFromURI(uri);
                    }
                }
                if (TextUtils.isEmpty(realPath)) {
                    handler.sendEmptyMessage(0);
                    return;
                }
                CommonUtil.uploadFile(realPath, "img", new CommonUtil.OnUploadListener() {
                    @Override
                    public void onSuccess(String result) {
                        try {
                            JSONObject jo = new JSONObject(result);
                            String url = jo.getString("result");
                            Message msg = new Message();
                            msg.what = 1;
                            msg.obj = url;
                            handler.sendMessage(msg);
                        } catch (JSONException e) {
                            handler.sendEmptyMessage(0);
                        }
                    }

                    @Override
                    public void onFailed(String message) {
                        handler.sendEmptyMessage(0);
                    }
                });
            }
        }.start();
        break;
    }
    }
}

From source file:hu.fnf.devel.atlas.Atlas.java

public void addCat(View view) {

    Spinner spinner = (Spinner) findViewById(R.id.taskSpinner);
    // In case of null add!
    if (spinner.getSelectedItem() == null) {
        Log.d("Atlas", "null selection");
        return;//  w  w w. ja  va  2 s .c om
    }
    String selected = (String) spinner.getSelectedItem();
    /*
     * add to list
     */
    Category sel = categories.get(selected);
    Log.d("Atlas", "selected: " + selected);
    Log.d("Atlas", "id: " + sel.getId());
    ListView cats = (ListView) findViewById(R.id.taskCats);
    CatAddAdapter catAddAdapter = (CatAddAdapter) cats.getAdapter();

    if (catAddAdapter.getSum() >= (int) (catAddAdapter.getAmount()) + Integer.valueOf(sel.getAmount())) {
        AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
        myAlertDialog.setTitle("--- Task ---");
        myAlertDialog.setMessage("Nothing left to categorize");
        myAlertDialog.setPositiveButton(getResources().getString(R.string.ok), AtlasData.ackClick);
        myAlertDialog.show();
        return;
    }
    catAddAdapter.add(new Category(sel.getId(), sel.getName(), sel.getAmount(), sel.getDepth(), sel.getColorr(),
            sel.getColorg(), sel.getColorb()));
    cats.setAdapter(catAddAdapter);

    //remove from spinner

    ArrayList<String> array_spinner = new ArrayList<String>();
    int spin_count = spinner.getAdapter().getCount();
    Log.d("Atlas", "spinner count: " + spin_count);
    if (spin_count == 1) {
        // no more category in spinner (ASANA: mi legyen ha elfogy a spinner)
        Log.d("Atlas", "no more category in spinner");
        ImageView add = (ImageView) findViewById(R.id.taskAdd);
        add.setVisibility(View.INVISIBLE);
        add.setEnabled(false);
        spinner.setVisibility(View.INVISIBLE);
        spinner.setEnabled(false);
    }
    for (int i = 0; i < spin_count; i++) {
        String s = (String) spinner.getAdapter().getItem(i);
        if (!s.equalsIgnoreCase(selected)) {
            array_spinner.add(s);
        }
    }
    ArrayAdapter<String> arrayadapter = new ArrayAdapter<String>(getApplicationContext(),
            R.layout.custom_simple_spinner, array_spinner);
    spinner.setAdapter(arrayadapter);

}