Skip to content

Commit

Permalink
1.add pinyinsearch for c plus plus
Browse files Browse the repository at this point in the history
  • Loading branch information
handsomezhou committed Feb 1, 2016
1 parent 48e0d81 commit 7d36194
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 144 deletions.
Binary file modified AppSearch/libs/pinyinsearch.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public void onPageScrollStateChanged(int state) {
public void onAppInfoLoadSuccess() {
getBaseProgressDialog().hide();

AppInfoHelper.getInstance().getQwertySearchAppInfo(null);
AppInfoHelper.getInstance().getT9SearchAppInfo(null);
AppInfoHelper.getInstance().qwertySearch(null);
AppInfoHelper.getInstance().t9Search(null);

refreshView();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ private void updateSearch(String search) {
}

if (TextUtils.isEmpty(curCharacter)) {
AppInfoHelper.getInstance().getQwertySearchAppInfo(null);
AppInfoHelper.getInstance().qwertySearch(null);
} else {
AppInfoHelper.getInstance().getQwertySearchAppInfo(curCharacter);
AppInfoHelper.getInstance().qwertySearch(curCharacter);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ private void updateSearch(String search) {
}

if (TextUtils.isEmpty(curCharacter)) {
AppInfoHelper.getInstance().getT9SearchAppInfo(null);
AppInfoHelper.getInstance().t9Search(null);
} else {
AppInfoHelper.getInstance().getT9SearchAppInfo(curCharacter);
AppInfoHelper.getInstance().t9Search(curCharacter);
}
}

Expand Down
48 changes: 24 additions & 24 deletions AppSearch/src/com/handsomezhou/appsearch/helper/AppInfoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ public List<AppInfo> loadAppInfo(Context context){
return appInfos;
}

public void getQwertySearchAppInfo(String search){
public void qwertySearch(String keyword){
List<AppInfo> baseAppInfos=getBaseAppInfo();
if(null!=mQwertySearchAppInfos){
mQwertySearchAppInfos.clear();
}else{
mQwertySearchAppInfos=new ArrayList<AppInfo>();
}

if(TextUtils.isEmpty(search)){
if(TextUtils.isEmpty(keyword)){
for(AppInfo ai:baseAppInfos){
ai.setSearchByType(SearchByType.SearchByNull);
ai.clearMatchKeywords();
Expand All @@ -272,13 +272,13 @@ public void getQwertySearchAppInfo(String search){
}

if (mFirstNoQwertySearchResultInput.length() > 0) {
if (search.contains(mFirstNoQwertySearchResultInput.toString())) {
if (keyword.contains(mFirstNoQwertySearchResultInput.toString())) {
Log.i(TAG,
"no need to search,null!=search,mFirstNoQwertySearchResultInput.length()="
+ mFirstNoQwertySearchResultInput.length() + "["
+ mFirstNoQwertySearchResultInput.toString() + "]"
+ ";searchlen=" + search.length() + "["
+ search + "]");
+ ";searchlen=" + keyword.length() + "["
+ keyword + "]");
return;
} else {
Log.i(TAG,
Expand All @@ -288,9 +288,9 @@ public void getQwertySearchAppInfo(String search){
+ mFirstNoQwertySearchResultInput.toString()
+ "]"
+ ";searchlen="
+ search.length()
+ keyword.length()
+ "["
+ search + "]");
+ keyword + "]");
mFirstNoQwertySearchResultInput.delete(0,mFirstNoQwertySearchResultInput.length());
}
}
Expand All @@ -299,13 +299,13 @@ public void getQwertySearchAppInfo(String search){
int baseAppInfosCount=baseAppInfos.size();
for(int i=0; i<baseAppInfosCount; i++){
PinyinSearchUnit labelPinyinSearchUnit=baseAppInfos.get(i).getLabelPinyinSearchUnit();
boolean match=QwertyUtil.match(labelPinyinSearchUnit,search);
boolean match=QwertyUtil.match(labelPinyinSearchUnit,keyword);


if (true == match) {// search by LabelPinyinUnits;
AppInfo appInfo = baseAppInfos.get(i);
appInfo.setSearchByType(SearchByType.SearchByLabel);
appInfo.setMatchKeywords(labelPinyinSearchUnit.getMatchKeyWord().toString());
appInfo.setMatchKeywords(labelPinyinSearchUnit.getMatchKeyword().toString());
appInfo.setMatchStartIndex(appInfo.getLabel().indexOf(appInfo.getMatchKeywords().toString()));
appInfo.setMatchLength(appInfo.getMatchKeywords().length());

Expand All @@ -317,13 +317,13 @@ public void getQwertySearchAppInfo(String search){

if (mQwertySearchAppInfos.size() <= 0) {
if (mFirstNoQwertySearchResultInput.length() <= 0) {
mFirstNoQwertySearchResultInput.append(search);
mFirstNoQwertySearchResultInput.append(keyword);
Log.i(TAG,
"no search result,null!=search,mFirstNoQwertySearchResultInput.length()="
+ mFirstNoQwertySearchResultInput.length() + "["
+ mFirstNoQwertySearchResultInput.toString() + "]"
+ ";searchlen=" + search.length() + "["
+ search + "]");
+ ";searchlen=" + keyword.length() + "["
+ keyword + "]");
} else {

}
Expand All @@ -333,7 +333,7 @@ public void getQwertySearchAppInfo(String search){
return;
}

public void getT9SearchAppInfo(String search){
public void t9Search(String keyword){
List<AppInfo> baseAppInfos=getBaseAppInfo();
Log.i(TAG, "baseAppInfos["+baseAppInfos.size()+"]");
if(null!=mT9SearchAppInfos){
Expand All @@ -342,7 +342,7 @@ public void getT9SearchAppInfo(String search){
mT9SearchAppInfos=new ArrayList<AppInfo>();
}

if(TextUtils.isEmpty(search)){
if(TextUtils.isEmpty(keyword)){
for(AppInfo ai:baseAppInfos){
ai.setSearchByType(SearchByType.SearchByNull);
ai.clearMatchKeywords();
Expand All @@ -358,13 +358,13 @@ public void getT9SearchAppInfo(String search){
}

if (mFirstNoT9SearchResultInput.length() > 0) {
if (search.contains(mFirstNoT9SearchResultInput.toString())) {
if (keyword.contains(mFirstNoT9SearchResultInput.toString())) {
Log.i(TAG,
"no need to search,null!=search,mFirstNoT9SearchResultInput.length()="
+ mFirstNoT9SearchResultInput.length() + "["
+ mFirstNoT9SearchResultInput.toString() + "]"
+ ";searchlen=" + search.length() + "["
+ search + "]");
+ ";searchlen=" + keyword.length() + "["
+ keyword + "]");
return;
} else {
Log.i(TAG,
Expand All @@ -374,9 +374,9 @@ public void getT9SearchAppInfo(String search){
+ mFirstNoT9SearchResultInput.toString()
+ "]"
+ ";searchlen="
+ search.length()
+ keyword.length()
+ "["
+ search + "]");
+ keyword + "]");
mFirstNoT9SearchResultInput.delete(0,mFirstNoT9SearchResultInput.length());
}
}
Expand All @@ -386,12 +386,12 @@ public void getT9SearchAppInfo(String search){
for(int i=0; i<baseAppInfosCount; i++){
PinyinSearchUnit labelPinyinSearchUnit=baseAppInfos.get(i).getLabelPinyinSearchUnit();

boolean match=T9Util.match(labelPinyinSearchUnit,search);
boolean match=T9Util.match(labelPinyinSearchUnit,keyword);

if (true == match) {// search by LabelPinyinUnits;
AppInfo appInfo = baseAppInfos.get(i);
appInfo.setSearchByType(SearchByType.SearchByLabel);
appInfo.setMatchKeywords(labelPinyinSearchUnit.getMatchKeyWord().toString());
appInfo.setMatchKeywords(labelPinyinSearchUnit.getMatchKeyword().toString());
appInfo.setMatchStartIndex(appInfo.getLabel().indexOf(appInfo.getMatchKeywords().toString()));
appInfo.setMatchLength(appInfo.getMatchKeywords().length());
mT9SearchAppInfos.add(appInfo);
Expand All @@ -402,13 +402,13 @@ public void getT9SearchAppInfo(String search){

if (mT9SearchAppInfos.size() <= 0) {
if (mFirstNoT9SearchResultInput.length() <= 0) {
mFirstNoT9SearchResultInput.append(search);
mFirstNoT9SearchResultInput.append(keyword);
Log.i(TAG,
"no search result,null!=search,mFirstNoT9SearchResultInput.length()="
+ mFirstNoT9SearchResultInput.length() + "["
+ mFirstNoT9SearchResultInput.toString() + "]"
+ ";searchlen=" + search.length() + "["
+ search + "]");
+ ";searchlen=" + keyword.length() + "["
+ keyword + "]");
} else {

}
Expand Down
Binary file modified ContactsSearch/libs/pinyinsearch.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onResume() {
@Override
public void onDestroy() {
mSearchBox.getSearchEt().setText("");
ContactsHelper.getInstance().parseQwertyInputSearchContacts(null);
ContactsHelper.getInstance().qwertySearch(null);

List<Contacts> selectedContactsList=new ArrayList<Contacts>();
selectedContactsList.addAll(ContactsHelper.getInstance().getSelectedContacts().values());
Expand Down Expand Up @@ -90,7 +90,7 @@ protected void initListener() {
/*Start: OnContactsLoad*/
@Override
public void onContactsLoadSuccess() {
ContactsHelper.getInstance().parseQwertyInputSearchContacts(null);
ContactsHelper.getInstance().qwertySearch(null);
mContactsOperationView.contactsLoadSuccess();

ContactsIndexHelper.getInstance().praseContacts(ContactsHelper.getInstance().getBaseContacts());
Expand All @@ -115,7 +115,7 @@ public void onSearchTextChanged(String curCharacter) {
/*Start: OnContactsOperationView*/
@Override
public void onListItemClick(Contacts contacts,int position){
ContactsHelper.getInstance().parseQwertyInputSearchContacts(null);
ContactsHelper.getInstance().qwertySearch(null);
mContactsOperationView.updateContactsList(true);
}

Expand Down Expand Up @@ -175,9 +175,9 @@ private void updateSearch(String search) {
}

if(TextUtils.isEmpty(curCharacter)){
ContactsHelper.getInstance().parseQwertyInputSearchContacts(null);
ContactsHelper.getInstance().qwertySearch(null);
}else{
ContactsHelper.getInstance().parseQwertyInputSearchContacts(curCharacter);
ContactsHelper.getInstance().qwertySearch(curCharacter);
}
mContactsOperationView.updateContactsList(TextUtils.isEmpty(curCharacter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onResume() {
@Override
public void onDestroy() {
mT9TelephoneDialpadView.clearT9Input();
ContactsHelper.getInstance().parseT9InputSearchContacts(null);
ContactsHelper.getInstance().t9InputSearch(null);

List<Contacts> selectedContactsList=new ArrayList<Contacts>();
selectedContactsList.addAll(ContactsHelper.getInstance().getSelectedContacts().values());
Expand Down Expand Up @@ -125,9 +125,9 @@ public void onDeleteDialCharacter(String deleteCharacter) {
public void onDialInputTextChanged(String curCharacter) {

if(TextUtils.isEmpty(curCharacter)){
ContactsHelper.getInstance().parseT9InputSearchContacts(null);
ContactsHelper.getInstance().t9InputSearch(null);
}else{
ContactsHelper.getInstance().parseT9InputSearchContacts(curCharacter);
ContactsHelper.getInstance().t9InputSearch(curCharacter);
}
mContactsOperationView.updateContactsList(TextUtils.isEmpty(curCharacter));
}
Expand All @@ -141,7 +141,7 @@ public void onHideT9TelephoneDialpadView() {
/*start:OnContactsLoad*/
@Override
public void onContactsLoadSuccess() {
ContactsHelper.getInstance().parseT9InputSearchContacts(null);
ContactsHelper.getInstance().t9InputSearch(null);
mContactsOperationView.contactsLoadSuccess();

//just background printing contacts information
Expand All @@ -161,7 +161,7 @@ public void onContactsLoadFailed() {
/*start:OnContactsOperationView*/
@Override
public void onListItemClick(Contacts contacts,int position){
ContactsHelper.getInstance().parseT9InputSearchContacts(null);
ContactsHelper.getInstance().t9InputSearch(null);
mContactsOperationView.updateContactsList(true);
}

Expand Down
Loading

0 comments on commit 7d36194

Please sign in to comment.