Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
dac0f641
Commit
dac0f641
authored
Dec 11, 2015
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
contacts: group by upper-case first char
Tuleap: #178 Change-Id: I117e7f6c891e8d3d9e19e56634a8d021483eda83
parent
c1c5b865
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/adapters/ContactsAdapter.java
+10
-30
10 additions, 30 deletions
...d/app/src/main/java/cx/ring/adapters/ContactsAdapter.java
with
10 additions
and
30 deletions
ring-android/app/src/main/java/cx/ring/adapters/ContactsAdapter.java
+
10
−
30
View file @
dac0f641
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
* Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
* Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
*
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
@@ -16,26 +17,13 @@
...
@@ -16,26 +17,13 @@
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
*/
package
cx.ring.adapters
;
package
cx.ring.adapters
;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
cx.ring.R
;
import
cx.ring.R
;
import
cx.ring.fragments.ContactListFragment
;
import
cx.ring.fragments.ContactListFragment
;
...
@@ -44,8 +32,6 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
...
@@ -44,8 +32,6 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.util.Log
;
import
android.util.LongSparseArray
;
import
android.util.LruCache
;
import
android.util.LruCache
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -83,18 +69,16 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
...
@@ -83,18 +69,16 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
infos_fetcher
=
pool
;
infos_fetcher
=
pool
;
}
}
public
static
final
int
TYPE_HEADER
=
0
;
public
static
final
int
TYPE_CONTACT
=
1
;
private
int
[]
getSectionIndices
()
{
private
int
[]
getSectionIndices
()
{
ArrayList
<
Integer
>
sectionIndices
=
new
ArrayList
<>();
ArrayList
<
Integer
>
sectionIndices
=
new
ArrayList
<>(
32
);
if
(
mContacts
.
isEmpty
())
if
(
mContacts
.
isEmpty
())
return
new
int
[
0
];
return
new
int
[
0
];
char
lastFirstChar
=
mContacts
.
get
(
0
).
getDisplayName
().
charAt
(
0
);
char
lastFirstChar
=
Character
.
toUpperCase
(
mContacts
.
get
(
0
).
getDisplayName
().
charAt
(
0
)
)
;
sectionIndices
.
add
(
0
);
sectionIndices
.
add
(
0
);
for
(
int
i
=
1
;
i
<
mContacts
.
size
();
i
++)
{
for
(
int
i
=
1
;
i
<
mContacts
.
size
();
i
++)
{
if
(
mContacts
.
get
(
i
).
getDisplayName
().
charAt
(
0
)
!=
lastFirstChar
)
{
char
c
=
Character
.
toUpperCase
(
mContacts
.
get
(
i
).
getDisplayName
().
charAt
(
0
));
lastFirstChar
=
mContacts
.
get
(
i
).
getDisplayName
().
charAt
(
0
);
if
(
c
!=
lastFirstChar
)
{
lastFirstChar
=
c
;
sectionIndices
.
add
(
i
);
sectionIndices
.
add
(
i
);
}
}
}
}
...
@@ -107,9 +91,8 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
...
@@ -107,9 +91,8 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
private
Character
[]
getSectionLetters
()
{
private
Character
[]
getSectionLetters
()
{
Character
[]
letters
=
new
Character
[
mSectionIndices
.
length
];
Character
[]
letters
=
new
Character
[
mSectionIndices
.
length
];
for
(
int
i
=
0
;
i
<
mSectionIndices
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
mSectionIndices
.
length
;
i
++)
letters
[
i
]
=
mContacts
.
get
(
mSectionIndices
[
i
]).
getDisplayName
().
charAt
(
0
);
letters
[
i
]
=
Character
.
toUpperCase
(
mContacts
.
get
(
mSectionIndices
[
i
]).
getDisplayName
().
charAt
(
0
));
}
return
letters
;
return
letters
;
}
}
...
@@ -234,12 +217,9 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
...
@@ -234,12 +217,9 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
}
}
// set header text as first char in name
// set header text as first char in name
char
headerChar
=
mContacts
.
get
(
position
).
getDisplayName
().
subSequence
(
0
,
1
).
charAt
(
0
);
holder
.
text
.
setText
(
String
.
valueOf
(
Character
.
toUpperCase
(
mContacts
.
get
(
position
).
getDisplayName
().
charAt
(
0
))));
holder
.
text
.
setText
(
""
+
headerChar
);
return
convertView
;
return
convertView
;
}
}
class
HeaderViewHolder
{
class
HeaderViewHolder
{
...
@@ -250,7 +230,7 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
...
@@ -250,7 +230,7 @@ public class ContactsAdapter extends BaseAdapter implements StickyListHeadersAda
public
long
getHeaderId
(
int
position
)
{
public
long
getHeaderId
(
int
position
)
{
// return the first character of the name as ID because this is what
// return the first character of the name as ID because this is what
// headers are based upon
// headers are based upon
return
mContacts
.
get
(
position
).
getDisplayName
().
subSequence
(
0
,
1
).
charAt
(
0
);
return
Character
.
toUpperCase
(
mContacts
.
get
(
position
).
getDisplayName
().
charAt
(
0
)
)
;
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment