Example usage for android.widget TextView setVisibility

List of usage examples for android.widget TextView setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.bhb27.isu.Checks.java

public void checkSafety() {
    cancheckSafety = false;//from  ww  w.j  a  v  a 2s.  co m
    boolean adbRoot = Tools.AndroidDebugRoot() && Tools.AndroidDebugState(getActivity()), su = Tools.SuBinary(),
            selinux, system;

    ViewGroup base_parent = (ViewGroup) getActivity().findViewById(R.id.base_parent);
    View alertLayout = LayoutInflater.from(getActivity()).inflate(R.layout.safety_check_dialog, base_parent,
            false);

    final TextView SU_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_su);
    final TextView Selinux_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_Selinux);
    final TextView adb_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_adb);
    final TextView system_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_system);
    final TextView props_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_props);

    if (isCMSU && rootAccess) {
        SU_textView.setText(getString(R.string.su_state) + ": "
                + (su ? getString(R.string.activated) : getString(R.string.deactivated)));
        if (su)
            SU_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
    }

    if (rootAccess) {
        selinux = Tools.isSELinuxActive(getActivity());

        Selinux_textView.setText(getString(R.string.selinux_state) + ": "
                + (selinux ? getString(R.string.enforcing) : getString(R.string.permissive)));
        if (!selinux)
            Selinux_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));

    } else {
        SU_textView.setText(getString(R.string.su_state) + ": " + getString(R.string.device_not_root));

        selinux = Tools.isSELinuxActiveNoROOT();

        Selinux_textView.setText(getString(R.string.selinux_state) + ": "
                + (selinux ? getString(R.string.enforcing) : getString(R.string.permissive)));
        if (!selinux)
            Selinux_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
    }

    adb_textView.setText(getString(R.string.adb_state_root) + ": "
            + (adbRoot ? getString(R.string.running) : getString(R.string.not_running)));
    if (adbRoot)
        adb_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));

    if (rootAccess) {
        system = Tools.runCommand("cat /proc/mounts | grep system", su, getActivity()).contains("rw");

        system_textView.setText(getString(R.string.system_mouted) + ": "
                + (system ? getString(R.string.system_mouted_rw) : getString(R.string.system_mouted_ro)));
        if (system)
            system_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
    } else
        system_textView.setVisibility(View.GONE);

    String redprops = Tools.redProps();

    props_textView.setText(getString(R.string.props) + ": "
            + (!redprops.isEmpty() ? redprops : getString(R.string.props_status_good)));
    if (!redprops.isEmpty())
        props_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));

    new AlertDialog.Builder(getActivity(), R.style.AlertDialogStyle).setTitle(getString(R.string.safety_net))
            .setView(alertLayout).setPositiveButton(getString(R.string.dismiss), null).show();

    Tools.logStatus(getActivity());
    cancheckSafety = true;
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);
    StringBuilder sb;/*from   w  w  w  .  ja  v a2 s.c  o m*/

    switch (id) {
    case Constants.DIALOG_LOGIN:
        if (mSettings.getUsername() != null) {
            final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input);
            loginUsernameInput.setText(mSettings.getUsername());
        }
        final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input);
        loginPasswordInput.setText("");
        break;

    case Constants.DIALOG_COMMENT_CLICK:
        if (mVoteTargetThing == null)
            break;
        Boolean likes;
        final TextView titleView = (TextView) dialog.findViewById(R.id.title);
        final TextView urlView = (TextView) dialog.findViewById(R.id.url);
        final TextView submissionStuffView = (TextView) dialog
                .findViewById(R.id.submissionTime_submitter_subreddit);
        final Button linkButton = (Button) dialog.findViewById(R.id.thread_link_button);

        if (mVoteTargetThing == getOpThingInfo()) {
            likes = mVoteTargetThing.getLikes();
            titleView.setVisibility(View.VISIBLE);
            titleView.setText(getOpThingInfo().getTitle());
            urlView.setVisibility(View.VISIBLE);
            urlView.setText(getOpThingInfo().getUrl());
            submissionStuffView.setVisibility(View.VISIBLE);
            sb = new StringBuilder(Util.getTimeAgo(getOpThingInfo().getCreated_utc())).append(" by ")
                    .append(getOpThingInfo().getAuthor());
            submissionStuffView.setText(sb);
            // For self posts, you're already there!
            if (getOpThingInfo().getDomain().toLowerCase().startsWith("self.")) {
                linkButton.setText(R.string.comment_links_button);
                linkToEmbeddedURLs(linkButton);
            } else {
                final String url = getOpThingInfo().getUrl();
                linkButton.setText(R.string.thread_link_button);
                linkButton.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        removeDialog(Constants.DIALOG_COMMENT_CLICK);
                        setLinkClicked(getOpThingInfo());
                        Common.launchBrowser(CommentsListActivity.this, url,
                                Util.createThreadUri(getOpThingInfo()).toString(), false, false,
                                mSettings.isUseExternalBrowser(), mSettings.isSaveHistory());
                    }
                });
                linkButton.setEnabled(true);
            }
        } else {
            titleView.setText("Comment by " + mVoteTargetThing.getAuthor());
            likes = mVoteTargetThing.getLikes();
            urlView.setVisibility(View.INVISIBLE);
            submissionStuffView.setVisibility(View.INVISIBLE);

            // Get embedded URLs
            linkButton.setText(R.string.comment_links_button);
            linkToEmbeddedURLs(linkButton);
        }
        final CheckBox voteUpButton = (CheckBox) dialog.findViewById(R.id.vote_up_button);
        final CheckBox voteDownButton = (CheckBox) dialog.findViewById(R.id.vote_down_button);
        final Button replyButton = (Button) dialog.findViewById(R.id.reply_button);
        final Button loginButton = (Button) dialog.findViewById(R.id.login_button);

        // Only show upvote/downvote if user is logged in
        if (mSettings.isLoggedIn()) {
            loginButton.setVisibility(View.GONE);
            voteUpButton.setVisibility(View.VISIBLE);
            voteDownButton.setVisibility(View.VISIBLE);
            replyButton.setEnabled(true);

            // Make sure the setChecked() actions don't actually vote just yet.
            voteUpButton.setOnCheckedChangeListener(null);
            voteDownButton.setOnCheckedChangeListener(null);

            // Set initial states of the vote buttons based on user's past actions
            if (likes == null) {
                // User is currently neutral
                voteUpButton.setChecked(false);
                voteDownButton.setChecked(false);
            } else if (likes == true) {
                // User currenty likes it
                voteUpButton.setChecked(true);
                voteDownButton.setChecked(false);
            } else {
                // User currently dislikes it
                voteUpButton.setChecked(false);
                voteDownButton.setChecked(true);
            }
            // Now we want the user to be able to vote.
            voteUpButton.setOnCheckedChangeListener(voteUpOnCheckedChangeListener);
            voteDownButton.setOnCheckedChangeListener(voteDownOnCheckedChangeListener);

            // The "reply" button
            replyButton.setOnClickListener(replyOnClickListener);
        } else {
            replyButton.setEnabled(false);

            voteUpButton.setVisibility(View.GONE);
            voteDownButton.setVisibility(View.GONE);
            loginButton.setVisibility(View.VISIBLE);
            loginButton.setOnClickListener(loginOnClickListener);
        }
        break;

    case Constants.DIALOG_REPLY:
        if (mVoteTargetThing != null) {
            if (mVoteTargetThing.getReplyDraft() != null && !mShouldClearReply) {
                EditText replyBodyView = (EditText) dialog.findViewById(R.id.body);
                replyBodyView.setText(mVoteTargetThing.getReplyDraft());
            } else {
                EditText replyBodyView = (EditText) dialog.findViewById(R.id.body);
                replyBodyView.setText("");
                mShouldClearReply = false;
            }
        }
        break;

    case Constants.DIALOG_EDIT:
        EditText replyBodyView = (EditText) dialog.findViewById(R.id.body);
        replyBodyView.setText(mEditTargetBody);
        break;

    default:
        // No preparation based on app state is required.
        break;
    }
}

From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java

@Override
protected void onServiceBound() {
    T.UI();/*from w  w w  .  j  av  a  2 s . com*/
    if (mNotYetProcessedIntent != null) {
        processIntent(mNotYetProcessedIntent);
        mNotYetProcessedIntent = null;
    }

    setContentView(R.layout.registration2);

    //Apply Fonts
    TextUtils.overrideFonts(this, findViewById(android.R.id.content));

    final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf");
    final int[] visibleLogos;
    final int[] goneLogos;
    if (AppConstants.FULL_WIDTH_HEADERS) {
        visibleLogos = FULL_WIDTH_ROGERTHAT_LOGOS;
        goneLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS;
        View viewFlipper = findViewById(R.id.registration_viewFlipper);
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) viewFlipper.getLayoutParams();
        params.setMargins(0, 0, 0, 0);
    } else {
        visibleLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS;
        goneLogos = FULL_WIDTH_ROGERTHAT_LOGOS;
    }

    for (int id : visibleLogos)
        findViewById(id).setVisibility(View.VISIBLE);
    for (int id : goneLogos)
        findViewById(id).setVisibility(View.GONE);

    handleScreenOrientation(getResources().getConfiguration().orientation);

    ScrollView rc = (ScrollView) findViewById(R.id.registration_container);
    Resources resources = getResources();
    if (CloudConstants.isRogerthatApp()) {
        rc.setBackgroundColor(resources.getColor(R.color.mc_page_dark));
    } else {
        rc.setBackgroundColor(resources.getColor(R.color.mc_homescreen_background));
    }

    TextView rogerthatWelcomeTextView = (TextView) findViewById(R.id.rogerthat_welcome);

    TextView tosTextView = (TextView) findViewById(R.id.registration_tos);
    Typeface FONT_THIN_ITALIC = Typeface.createFromAsset(getAssets(), "fonts/lato_light_italic.ttf");
    tosTextView.setTypeface(FONT_THIN_ITALIC);
    tosTextView.setTextColor(ContextCompat.getColor(RegistrationActivity2.this, R.color.mc_words_color));

    Button agreeBtn = (Button) findViewById(R.id.registration_agree_tos);

    TextView tvRegistration = (TextView) findViewById(R.id.registration);
    tvRegistration.setText(getString(R.string.registration_city_app_sign_up, getString(R.string.app_name)));

    mEnterEmailAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.registration_enter_email);

    if (CloudConstants.isEnterpriseApp()) {
        rogerthatWelcomeTextView
                .setText(getString(R.string.rogerthat_welcome_enterprise, getString(R.string.app_name)));
        tosTextView.setVisibility(View.GONE);
        agreeBtn.setText(R.string.start_registration);
        mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint_enterprise);
    } else {
        rogerthatWelcomeTextView
                .setText(getString(R.string.registration_welcome_text, getString(R.string.app_name)));

        tosTextView.setText(Html.fromHtml(
                "<a href=\"" + CloudConstants.TERMS_OF_SERVICE_URL + "\">" + tosTextView.getText() + "</a>"));
        tosTextView.setMovementMethod(LinkMovementMethod.getInstance());

        agreeBtn.setText(R.string.registration_btn_agree_tos);

        mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint);
    }

    agreeBtn.getBackground().setColorFilter(Message.GREEN_BUTTON_COLOR, PorterDuff.Mode.MULTIPLY);
    agreeBtn.setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_AGREED_TOS);
            mWiz.proceedToNextPage();

        }
    });

    initLocationUsageStep(faTypeFace);

    View.OnClickListener emailLoginListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_EMAIL_LOGIN);
            mWiz.proceedToNextPage();
        }
    };

    findViewById(R.id.login_via_email).setOnClickListener(emailLoginListener);

    Button facebookButton = (Button) findViewById(R.id.login_via_fb);

    View.OnClickListener facebookLoginListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check network connectivity
            if (!mService.getNetworkConnectivityManager().isConnected()) {
                UIUtils.showNoNetworkDialog(RegistrationActivity2.this);
                return;
            }

            sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_FACEBOOK_LOGIN);

            FacebookUtils.ensureOpenSession(RegistrationActivity2.this,
                    AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE
                            ? Arrays.asList("email", "user_friends", "user_birthday")
                            : Arrays.asList("email", "user_friends"),
                    PermissionType.READ, new Session.StatusCallback() {
                        @Override
                        public void call(Session session, SessionState state, Exception exception) {
                            if (session != Session.getActiveSession()) {
                                session.removeCallback(this);
                                return;
                            }

                            if (exception != null) {
                                session.removeCallback(this);
                                if (!(exception instanceof FacebookOperationCanceledException)) {
                                    L.bug("Facebook SDK error during registration", exception);
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            RegistrationActivity2.this);
                                    builder.setMessage(R.string.error_please_try_again);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();
                                }
                            } else if (session.isOpened()) {
                                session.removeCallback(this);
                                if (session.getPermissions().contains("email")) {
                                    registerWithAccessToken(session.getAccessToken());
                                } else {
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            RegistrationActivity2.this);
                                    builder.setMessage(R.string.facebook_registration_email_missing);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();
                                }
                            }
                        }
                    }, false);
        }

        ;
    };

    facebookButton.setOnClickListener(facebookLoginListener);

    final Button getAccountsButton = (Button) findViewById(R.id.get_accounts);
    if (configureEmailAutoComplete()) {
        // GET_ACCOUNTS permission is granted
        getAccountsButton.setVisibility(View.GONE);
    } else {
        getAccountsButton.setTypeface(faTypeFace);
        getAccountsButton.setOnClickListener(new SafeViewOnClickListener() {
            @Override
            public void safeOnClick(View v) {
                ActivityCompat.requestPermissions(RegistrationActivity2.this,
                        new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS);
            }
        });
    }

    mEnterPinEditText = (EditText) findViewById(R.id.registration_enter_pin);

    mEnterPinEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() == PIN_LENGTH)
                onPinEntered();
        }
    });

    Button requestNewPinButton = (Button) findViewById(R.id.registration_request_new_pin);
    requestNewPinButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mWiz.setEmail(null);
            hideNotification();
            mWiz.reInit();
            mWiz.goBackToPrevious();
            mEnterEmailAutoCompleteTextView.setText("");
        }
    });

    mWiz = RegistrationWizard2.getWizard(mService);
    mWiz.setFlipper((ViewFlipper) findViewById(R.id.registration_viewFlipper));
    setFinishHandler();
    addAgreeTOSHandler();
    addIBeaconUsageHandler();
    addChooseLoginMethodHandler();
    addEnterPinHandler();
    mWiz.run();
    mWiz.setDeviceId(Installation.id(this));

    handleEnterEmail();

    if (mWiz.getBeaconRegions() != null && mBeaconManager == null) {
        bindBeaconManager();
    }

    if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) {
        GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() {
            @Override
            public void idFound(String registrationId) {
                mGCMRegistrationId = registrationId;
            }
        });
    }
}

From source file:biz.bokhorst.xprivacy.ActivityMain.java

@SuppressLint("DefaultLocale")
private void optionAbout() {
    // About/*from  w  w w. ja v a 2s .co m*/
    Dialog dlgAbout = new Dialog(this);
    dlgAbout.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dlgAbout.setTitle(R.string.menu_about);
    dlgAbout.setContentView(R.layout.about);
    dlgAbout.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));

    // Show version
    try {
        int userId = Util.getUserId(Process.myUid());
        Version currentVersion = new Version(Util.getSelfVersionName(this));
        Version storedVersion = new Version(
                PrivacyManager.getSetting(userId, PrivacyManager.cSettingVersion, "0.0"));
        boolean migrated = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingMigrated, false);
        String versionName = currentVersion.toString();
        if (currentVersion.compareTo(storedVersion) != 0)
            versionName += "/" + storedVersion.toString();
        if (!migrated)
            versionName += "!";
        int versionCode = Util.getSelfVersionCode(this);
        TextView tvVersion = (TextView) dlgAbout.findViewById(R.id.tvVersion);
        tvVersion.setText(String.format(getString(R.string.app_version), versionName, versionCode));
    } catch (Throwable ex) {
        Util.bug(null, ex);
    }

    if (!PrivacyManager.cVersion3 || Hook.isAOSP(19))
        ((TextView) dlgAbout.findViewById(R.id.tvCompatibility)).setVisibility(View.GONE);

    // Show license
    String licensed = Util.hasProLicense(this);
    TextView tvLicensed1 = (TextView) dlgAbout.findViewById(R.id.tvLicensed);
    TextView tvLicensed2 = (TextView) dlgAbout.findViewById(R.id.tvLicensedAlt);
    if (licensed == null) {
        tvLicensed1.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
        tvLicensed2.setText(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
                .getAbsolutePath());
    } else {
        tvLicensed1.setText(String.format(getString(R.string.app_licensed), licensed));
        tvLicensed2.setVisibility(View.GONE);
    }

    // Show some build properties
    String android = String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT);
    ((TextView) dlgAbout.findViewById(R.id.tvAndroid)).setText(android);
    ((TextView) dlgAbout.findViewById(R.id.build_brand)).setText(Build.BRAND);
    ((TextView) dlgAbout.findViewById(R.id.build_manufacturer)).setText(Build.MANUFACTURER);
    ((TextView) dlgAbout.findViewById(R.id.build_model)).setText(Build.MODEL);
    ((TextView) dlgAbout.findViewById(R.id.build_product)).setText(Build.PRODUCT);
    ((TextView) dlgAbout.findViewById(R.id.build_device)).setText(Build.DEVICE);
    ((TextView) dlgAbout.findViewById(R.id.build_host)).setText(Build.HOST);
    ((TextView) dlgAbout.findViewById(R.id.build_display)).setText(Build.DISPLAY);
    ((TextView) dlgAbout.findViewById(R.id.build_id)).setText(Build.ID);

    dlgAbout.setCancelable(true);

    final int userId = Util.getUserId(Process.myUid());
    if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true))
        dlgAbout.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                Dialog dlgUsage = new Dialog(ActivityMain.this);
                dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
                dlgUsage.setTitle(R.string.app_name);
                dlgUsage.setContentView(R.layout.usage);
                dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
                dlgUsage.setCancelable(true);
                dlgUsage.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        PrivacyManager.setSetting(userId, PrivacyManager.cSettingFirstRun,
                                Boolean.FALSE.toString());
                        optionLegend();
                    }
                });
                dlgUsage.show();
            }
        });

    dlgAbout.show();
}

From source file:com.android.mtkex.chips.BaseRecipientAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    /// M: add view holder to improve performance.
    DropDownListViewHolder viewHolder;/* ww  w  .  j ava 2  s.com*/

    /// M: get view holder from convert view. @{
    if (convertView == null) {
        convertView = mInflater.inflate(getItemLayout(), parent, false);

        viewHolder = new DropDownListViewHolder();
        if (convertView != null) {
            viewHolder.name = (TextView) convertView.findViewById(getDisplayNameId());
            viewHolder.dest = (TextView) convertView.findViewById(getDestinationId());
            viewHolder.destType = (TextView) convertView.findViewById(getDestinationTypeId());
            viewHolder.img = (ImageView) convertView.findViewById(getPhotoId());
            convertView.setTag(viewHolder);
        }
    } else {
        viewHolder = (DropDownListViewHolder) convertView.getTag();
    }
    /// @}

    final RecipientEntry entry = getEntries().get(position);
    String displayName = entry.getDisplayName();
    String destination = entry.getDestination();
    if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, destination)) {
        displayName = destination;

        // We only show the destination for secondary entries, so clear it
        // only for the first level.
        if (entry.isFirstLevel()) {
            destination = null;
        }
    }

    /// M: get properties from view holder. @{
    final View itemView = convertView;
    final TextView displayNameView = viewHolder.name;
    final TextView destinationView = viewHolder.dest;
    final TextView destinationTypeView = viewHolder.destType;
    final ImageView imageView = viewHolder.img;
    /// @}

    displayNameView.setText(displayName);
    if (!TextUtils.isEmpty(destination)) {
        destinationView.setText(destination);
    } else {
        destinationView.setText(null);
    }
    if (destinationTypeView != null) {
        CharSequence destinationType = null;
        if (mShowPhoneAndEmail) {
            /// M: Current query is phone query, but there may exist email results as well.
            ///    Hence, we need to get destinationType of email results by Queries.EMAIL. @{
            if (entry.getDestinationKind() == RecipientEntry.ENTRY_KIND_EMAIL) {
                destinationType = Queries.EMAIL.getTypeLabel(mContext.getResources(),
                        entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase();
            } else {
                destinationType = Queries.PHONE.getTypeLabel(mContext.getResources(),
                        entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase();
            }
            /// @}
        } else {
            destinationType = mQuery.getTypeLabel(mContext.getResources(), entry.getDestinationType(),
                    entry.getDestinationLabel()).toString().toUpperCase();
        }
        destinationTypeView.setText(destinationType);
    }

    if (entry.isFirstLevel()) {
        displayNameView.setVisibility(View.VISIBLE);
        if (imageView != null) {
            imageView.setVisibility(View.VISIBLE);
            final byte[] photoBytes = entry.getPhotoBytes();
            if (photoBytes != null) {
                /// M: get bitmap from recipient entry
                Bitmap photo = entry.getBitmap();
                /// M: cache bitmap if unavailable. @{
                if (photo == null) {
                    photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length);
                    entry.setBitmap(photo);
                }
                /// @}
                imageView.setImageBitmap(photo);
            } else {
                imageView.setImageResource(getDefaultPhotoResource());
            }
        }
    } else {
        displayNameView.setVisibility(View.GONE);
        if (imageView != null) {
            imageView.setVisibility(View.INVISIBLE);
        }
    }
    return itemView;
}

From source file:at.alladin.rmbt.android.views.ResultQoSDetailView.java

@SuppressWarnings("unchecked")
@Override//  w w  w. j a  v  a2s.com
public void taskEnded(JSONArray result) {
    System.out.println("ResultQoSDetail taskEnded");
    this.testResult = result;

    if (resultFetchEndTaskListener != null) {
        resultFetchEndTaskListener.taskEnded(result);
    }

    ProgressBar resultProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    TextView resultTextView = (TextView) view.findViewById(R.id.info_text);

    try {
        results = new QoSServerResultCollection(result);

        View successList = view.findViewById(R.id.qos_success_list);

        List<HashMap<String, String>> itemList = new ArrayList<HashMap<String, String>>();
        int index = 0;
        for (QoSTestResultEnum type : QoSTestResultEnum.values()) {
            if (results.getQoSStatistics().getTestCounter(type) > 0) {
                HashMap<String, String> listItem = new HashMap<String, String>();
                listItem.put("name", ConfigHelper.getCachedQoSNameByTestType(type, activity));
                listItem.put("type_name", type.toString());
                listItem.put("index", String.valueOf(index++));
                itemList.add(listItem);
            }
        }

        ListAdapter valueList = new SimpleAdapter(activity, itemList, R.layout.qos_category_list_item,
                new String[] { "name" }, new int[] { R.id.name });

        resultProgressBar.setVisibility(View.GONE);

        if (valueList.getCount() > 0) {

            //in case the view will change again:
            if (ListView.class.isAssignableFrom(successList.getClass())) {
                ((ListView) successList).setAdapter(valueList);
                ((ListView) successList).setOnItemClickListener(this);
            } else {
                ViewGroup vgList = (ViewGroup) successList;
                for (int i = 0; i < valueList.getCount(); i++) {
                    View v = valueList.getView(i, null, null);

                    QoSTestResultEnum key = QoSTestResultEnum
                            .valueOf(((HashMap<String, String>) valueList.getItem(i)).get("type_name"));
                    if (results.getQoSStatistics().getFailureCounter(key) > 0) {
                        ImageView img = (ImageView) v.findViewById(R.id.status);
                        img.setImageResource(R.drawable.traffic_lights_red);
                    }

                    TextView status = (TextView) v.findViewById(R.id.qos_type_status);
                    status.setText((results.getQoSStatistics().getTestCounter(key)
                            - results.getQoSStatistics().getFailedTestsCounter(key)) + "/"
                            + results.getQoSStatistics().getTestCounter(key));

                    v.setOnClickListener(this);
                    v.setTag(valueList.getItem(i));
                    vgList.addView(v);
                }
            }

            successList.invalidate();

            resultTextView.setVisibility(View.GONE);
            successList.setVisibility(View.VISIBLE);
        } else {
            resultTextView.setText(R.string.result_qos_error_no_data_available);
        }

    } catch (Throwable t) {
        resultTextView.setText(R.string.result_qos_error_no_data_available);
        resultProgressBar.setVisibility(View.GONE);
        t.printStackTrace();
    }
}

From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java

@Override
protected void onStart() {
    super.onStart();

    EquipmentListView elv;//from   w  w w. ja  va  2  s .  com

    elv = (EquipmentListView) findViewById(R.id.ListView);
    if (elv != null) {
        elv.setFilterByID(mFilterID);
        elv.setOrderByName(mOrderByName);
        elv.setFilterByType(mFilterByType);
        elv.setParam(getDAO(), mPart, mRace, mJob, mLevel);

        elv.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                Intent result = new Intent();

                result.putExtra("From", "EquipmentSelector");
                result.putExtra("Part", mPart);
                result.putExtra("Id", arg3);
                result.putExtra("AugId", -1);
                setResult(RESULT_OK, result);
                finish();
            }

        });

        elv.setOnItemLongClickListener(new OnItemLongClickListener() {
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                mLongClickingItemId = arg3;
                mLongClickingItemIsCurrent = false;
                EquipmentSelectorActivity.this.openContextMenu(arg0);
                return true;
            }
        });

        registerForContextMenu(elv);
    }

    {
        Equipment cur = getDAO().instantiateEquipment(mCurrent, mAugID);
        if (cur == null) {
            cur = new Equipment(-1, getString(R.string.EquipmentNotSelected), "", "", "", "", 0, 0, false,
                    false, "");
        }
        if (cur != null) {
            TextView tv;
            View.OnLongClickListener listener = new View.OnLongClickListener() {
                public boolean onLongClick(View v) {
                    mLongClickingItemId = mCurrent;
                    mLongClickingItemIsCurrent = true;
                    EquipmentSelectorActivity.this.openContextMenu(v);
                    return true;
                }
            };

            tv = (TextView) findViewById(R.id.Name);
            if (tv != null) {
                tv.setText(cur.getName());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Job);
            if (tv != null) {
                tv.setText(cur.getJob());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Description);
            if (tv != null) {
                tv.setText(cur.getDescription());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Augment);
            if (tv != null) {
                if (cur.getAugment().length() == 0) {
                    tv.setHeight(0);
                } else {
                    tv.setText(cur.getAugment());
                }
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Level);
            if (tv != null) {
                int lvl = cur.getLevel();
                if (lvl > 0)
                    tv.setText(((Integer) lvl).toString());
                else
                    tv.setText("");
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Race);
            if (tv != null) {
                tv.setText(cur.getRace());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Ex);
            if (tv != null) {
                if (cur.isEx())
                    tv.setVisibility(View.VISIBLE);
                else
                    tv.setVisibility(View.INVISIBLE);
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Rare);
            if (tv != null) {
                if (cur.isRare())
                    tv.setVisibility(View.VISIBLE);
                else
                    tv.setVisibility(View.INVISIBLE);
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }

        }
    }
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

private View inflateSuggestionListView(final Suggestion suggestion) {
    final LayoutInflater layoutInflater = LayoutInflater.from(this);
    final View suggestionView = layoutInflater.inflate(R.layout.quickcontact_suggestion_contact_item, null);

    ContactPhotoManager.DefaultImageRequest request = new ContactPhotoManager.DefaultImageRequest(
            suggestion.name, suggestion.lookupKey, ContactPhotoManager.TYPE_DEFAULT, /*
                                                                                     isCircular */ true);
    final ImageView photo = (ImageView) suggestionView.findViewById(R.id.aggregation_suggestion_photo);
    if (suggestion.photo != null) {
        ContactPhotoManager.getInstance(this).loadThumbnail(photo, suggestion.photoId, /* darkTheme */ false,
                /* isCircular */ true, request);
    } else {//  ww w .  j  ava  2 s .  c o  m
        ContactPhotoManager.DEFAULT_AVATAR.applyDefaultImage(photo, -1, false, request);
    }

    final TextView name = (TextView) suggestionView.findViewById(R.id.aggregation_suggestion_name);
    name.setText(suggestion.name);

    final TextView accountNameView = (TextView) suggestionView
            .findViewById(R.id.aggregation_suggestion_account_name);
    final String accountName = suggestion.rawContacts.get(0).accountName;
    if (!TextUtils.isEmpty(accountName)) {
        accountNameView.setText(getResources().getString(R.string.contact_from_account_name, accountName));
    } else {
        accountNameView.setVisibility(View.INVISIBLE);
    }

    final CheckBox checkbox = (CheckBox) suggestionView.findViewById(R.id.suggestion_checkbox);
    final int[][] stateSet = new int[][] { new int[] { android.R.attr.state_checked },
            new int[] { -android.R.attr.state_checked } };
    final int[] colors = new int[] { mColorFilterColor, mColorFilterColor };
    if (suggestion != null && suggestion.name != null) {
        checkbox.setContentDescription(suggestion.name + " "
                + getResources().getString(R.string.contact_from_account_name, accountName));
    }
    checkbox.setButtonTintList(new ColorStateList(stateSet, colors));
    checkbox.setChecked(
            mSuggestionsShouldAutoSelected || mSelectedAggregationIds.contains(suggestion.contactId));
    if (checkbox.isChecked()) {
        mSelectedAggregationIds.add(suggestion.contactId);
    }
    checkbox.setTag(suggestion.contactId);
    checkbox.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            final CheckBox checkBox = (CheckBox) v;
            final Long contactId = (Long) checkBox.getTag();
            if (mSelectedAggregationIds.contains(mContactData.getId())) {
                mSelectedAggregationIds.remove(mContactData.getId());
            }
            if (checkBox.isChecked()) {
                mSelectedAggregationIds.add(contactId);
                if (mSelectedAggregationIds.size() >= 1) {
                    enableLinkButton();
                }
            } else {
                mSelectedAggregationIds.remove(contactId);
                mSuggestionsShouldAutoSelected = false;
                if (mSelectedAggregationIds.isEmpty()) {
                    disableLinkButton();
                }
            }
        }
    });

    return suggestionView;
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
protected void onStart() {
    super.onStart();

    AugmentListView lv;//from   www.j a v a  2  s.  co m

    lv = (AugmentListView) findViewById(R.id.ListView);
    if (lv != null) {
        lv.setFilterByID(mFilterID);
        lv.setOrderByName(mOrderByName);
        lv.setFilterByType(mFilterByType);
        lv.setParam(getDAO(), mPart, mRace, mJob, mLevel);

        lv.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                Intent result = new Intent();

                result.putExtra("From", "AugmentSelector");
                result.putExtra("Part", mPart);
                result.putExtra("Id", -1);
                result.putExtra("AugId", arg3);
                setResult(RESULT_OK, result);
                finish();
            }

        });

        lv.setOnItemLongClickListener(new OnItemLongClickListener() {
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                mLongClickingItemId = arg3;
                AugmentSelectorActivity.this.openContextMenu(arg0);
                return true;
            }
        });

        registerForContextMenu(lv);
    }

    {
        Equipment cur = getDAO().instantiateEquipment(mCurrent, mAugID);
        if (cur == null) {
            cur = new Equipment(-1, getString(R.string.EquipmentNotSelected), "", "", "", "", 0, 0, false,
                    false, "");
        }
        if (cur != null) {
            TextView tv;
            View.OnLongClickListener listener = new View.OnLongClickListener() {
                public boolean onLongClick(View v) {
                    mLongClickingItemId = mAugID;
                    AugmentSelectorActivity.this.openContextMenu(v);
                    return true;
                }
            };

            tv = (TextView) findViewById(R.id.Name);
            if (tv != null) {
                tv.setText(cur.getName());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Job);
            if (tv != null) {
                tv.setText(cur.getJob());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Description);
            if (tv != null) {
                tv.setText(cur.getDescription());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Augment);
            if (tv != null) {
                if (cur.getAugment().length() == 0) {
                    tv.setHeight(0);
                } else {
                    tv.setText(cur.getAugment());
                }
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Level);
            if (tv != null) {
                if (tv != null) {
                    int lvl = cur.getLevel();
                    if (lvl > 0)
                        tv.setText(((Integer) lvl).toString());
                    else
                        tv.setText("");
                }
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Race);
            if (tv != null) {
                tv.setText(cur.getRace());
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Ex);
            if (tv != null) {
                if (cur.isEx())
                    tv.setVisibility(View.VISIBLE);
                else
                    tv.setVisibility(View.INVISIBLE);
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }
            tv = (TextView) findViewById(R.id.Rare);
            if (tv != null) {
                if (cur.isRare())
                    tv.setVisibility(View.VISIBLE);
                else
                    tv.setVisibility(View.INVISIBLE);
                tv.setOnLongClickListener(listener);
                registerForContextMenu(tv);
            }

        }
    }
}