disply',' if title is empty?

Moderators: dwp, devin

Post Reply
oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

disply',' if title is empty?

Post by oldman1881 » Tue Oct 29, 2013 1:40 am

checked title field i am sure it is empty and no space.
suggest to trim the title filed before put ','

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Tue Oct 29, 2013 2:40 am

Code: Select all

if (TextUtils.isEmpty(company)) {
        combined = displayNameIsOrganization ? null : title;
} else {
        if (TextUtils.isEmpty(title)) {
                combined = displayNameIsOrganization ? null : company;
        } else {
                if (displayNameIsOrganization) {
                        combined = title;
                } else {
                        combined = context.getString(
                                R.string.organization_company_and_title, company, title);
                }
        }
}
Hello, this is the code, which title has been determined is empty. Only when the title contains a space will cause you mentioned. Maybe your contacts is a merge contacts. In one account he was not edited in the phone. But it contains spaces.

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Tue Oct 29, 2013 5:53 am

呵呵,n多年没有做coding了。不知道android里有没有trim这样的功能,就是如果有一个string :space+space+ABC+space+space,trim以后就只有ABC了,可以把space弄掉。 这样就不会遗留一个空白的space的问题。

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Thu Oct 31, 2013 1:39 am

这里没有使用trim。只是判断String是否为空。因此有空格会导致“,”出现。我之前是这样回答的。

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Thu Oct 31, 2013 5:36 am

建议使用trim,以前做coding的时候,我们判断string都是先trim一下,再判断的,不然A和A+space会不一样。

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Fri Nov 01, 2013 1:30 am

恩谢谢!有较多联系人出现这个情况吗?如果是个别建议修改一下联系人。因为是手机我想减少不必要的代码。

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Sat Nov 02, 2013 7:07 am

devin wrote:恩谢谢!有较多联系人出现这个情况吗?如果是个别建议修改一下联系人。因为是手机我想减少不必要的代码。
不是很多,是大多联系人有这个问题,因为大多都联络人是只有公司,没有职位。
所以至少这段码用trim处理一下。

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Mon Nov 04, 2013 2:05 am

好的,但是在我的手机没有这个问题。因为当联系人没有职位,相关的字段将是空,而不是空格。

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Tue Nov 05, 2013 11:14 am

devin wrote:好的,但是在我的手机没有这个问题。因为当联系人没有职位,相关的字段将是空,而不是空格。
其实应该是空的,不知道为什么会是空格。

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Thu Nov 07, 2013 7:33 am

恩,我已经修改它。并做一些优化在t9搜索,如果有时间,请试试它。
http://www.dw-p.net/dl/DW-Contacts-Phone-test.apk

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Sun Nov 10, 2013 4:11 am

devin wrote:恩,我已经修改它。并做一些优化在t9搜索,如果有时间,请试试它。
http://www.dw-p.net/dl/DW-Contacts-Phone-test.apk
ok了,谢谢。
不过backup和restore还是要手改文件路径,可否像settting restore一样有file browser功能,可以自己选。

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Mon Nov 11, 2013 2:53 am

好的,我试试

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Thu Nov 21, 2013 12:02 pm

using test version now, not sure why it has 'system not responding' problem very often.
do you know why?

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Fri Nov 22, 2013 1:11 am

What is the function you are using?
Please try this final version.
http://www.dw-p.net/dl/DW-Contacts-Phone.apk

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Sat Nov 23, 2013 12:13 pm

I donot use any complicate function, just start dialer, then the system show me unresponding and it is very often.

oldman1881
Posts: 47
Joined: Sat Sep 28, 2013 1:29 am

Re: disply',' if title is empty?

Post by oldman1881 » Sat Nov 23, 2013 12:14 pm

I donot use any complicate function, just start dialer, then the system show me unresponding and it is very often.

devin
Posts: 1160
Joined: Fri Oct 11, 2013 10:16 am

Re: disply',' if title is empty?

Post by devin » Mon Nov 25, 2013 2:04 am

Please try this final version
http://www.dw-p.net/dl/DW-Contacts-Phone.apk

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest