This kit enables you to display a list of groups, a list of group classes, the list of members of a group, and to have the user join or leave a certain group.
To include the Groups kit, open the Gradle Scripts | build.gradle (Module: app)
and add the following to the
dependencies section:
implementation 'com.cheetahdigital.android:groups:<version>'
On this page:
Overview
The Groups kit displays a list of all the groups in the server, a list of all groups the user is a member of, and a list of all group classes (which is basically a group of groups). Clicking on a group class will bring up a list containing the groups belonging to that group class.
Clicking on a group will bring up its page. Here, the list of its members, upto six, is displayed. Joining or leaving a group is done by clicking the corresponding button in this page.
If a member in the list is clicked, it will open up their details page from the Members Kit. If the container of the list of members is clicked, a page displaying the list of all the members of the group will be shown.
Launching the Groups Activities
Assuming that the Groups kit will be launched
from a MainActivity
, you can follow these steps to launch the Activities from a Button’s OnClickListener
:
-
Add the Activities to your
AndroidManifest.xml
:<activity android:name="com.cheetahdigital.sdk.pager.GroupsActivity" android:label="@string/groups_title" /> <activity android:name="com.cheetahdigital.groups.ui.list.GroupsListActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="${applicationId}.GROUPS_LIST" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.cheetahdigital.groups.ui.members.GroupMembersListActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="${applicationId}.GROUP_MEMBERS_LIST" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.cheetahdigital.groups.ui.detail.GroupDetailsActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="${applicationId}.GROUP_DETAILS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
-
On your activity, add a Button to launch the Starting Activity -
GroupsActivity
mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Actions.getIntentAction(parent.getContext(), Actions.GROUPS_LIST)); view.getContext().startActivity(intent); } });
-
Add Intent extras to include specific class name or class label
intent.putExtra(IntentKey.PRIMARY_ID, groupClass.getName()); intent.putExtra(GroupsListActivity.CLASS_LABEL_KEY, groupClass.getLabel());
List of Activities and Fragments
JoinedGroupsListActivity
andStellarJoinedGroupsListFragment
for displaying the list of joined groups.GroupClassesListActivity
andStellarGroupClassesListFragment
for displaying the list of group classes.GroupsListActivity
andGroupsListFragment
for displaying the list of groups. Add an integer extra equal to a group class ID to the intent, usingIntentKey.CLASS_ID_KEY
as the key, to show only groups belonging to a certain group class. A String extra using keyIntentKey.CLASS_NAME_KEY
will dictate the title to be used for the Activity.GroupMembersListActivity
,GroupMembersListFragment
for displaying the list of members of a certain group. Add an integer extra equal to a group’s ID usingIntentKey.GROUP_ID_KEY
when calling the Activity. A String extra using keyIntentKey.GROUP_NAME_KEY
will dictate the title to be used for the Activity.GroupDetailsActivity
for displaying the details of a group. A String extra with keyIntentKey.GROUP_NAME_KEY
will be used as the group name. A String extra with keyIntentKey.GROUP_DESCRIPTION_KEY
will be used as the group description. A String extra with keyIntentKey.GROUP_AVATAR_KEY
will be used as the group avatar. And, an integer extra with keyIntentKey.GROUP_ID_KEY
will be used to query the members as the group’s ID.
Theme Customization
The Kits leverage on Android’s built-in support for Styles and Themes. Overriding the Styles and Themes of the app will also change the corresponding Views used in this kit.
Layout Customization
Customizing Layouts via XML
You can customize the layouts of the different screens in the Groups kit by copying the layout XML’s and overriding as desired. To read more about this, please visit the Layout Customization via XML document. The XML’s used are:
activity_group_classes_list
- used to display the list of group classeslist_item_group_class
- layout used for every group class item in a listactivity_group_details
- used to display the details of a groupactivity_group_members_list
- used to display the list of members of a grouplist_item_group_member
- layout used for every member item in a listactivity_groups_list
- used to display a list of groupslist_item_groups
- layout used for every group item in a listactivity_groups_pager
- used to display the list of groups and group classes in a ViewPager
Customizing Layouts via Code
There are certain cases that you may want to use a highly-customized layout for an Activity. To read more about this, please visit the Layout Customization via Code document. The classes used by the Groups kit are indicated in List of Activities and Fragments.
Customizing Handlers
There are certain cases that you may want to change the default behavior of an Activity. You can achieve this by extending the Fragment that you want to customize and overriding as necessary.
Handlers may occur in different places:
- Adapters - for Lists
- Member Variables inside Activities or Fragments
- Member Variables inside Custom Widgets - for stand-alone Custom Widgets
Just follow the steps mentioned in Customizing Layouts via Code, and override the methods related to the handling that you want to customize.
Fully Custom UI
Groups
The GroupsAPI
class contains different GET
methods for querying all the group classes, all the groups in the server, all the groups the user has joined, and all the members of a group. The class also contains POST
methods for the user joining or leaving a group.
Retrieving List of Group Classes
getGroupClasses(GroupsParams groupsParams, boolean clearCache, ListenerModel<BaseModel<GroupClasses>, GroupClasses> listener)
Retrieving List of Groups
getGroups(GroupsParams groupsParams, boolean clearCache, ListenerModel<BaseModel<Groups>, Groups> listener)
Retrieving List of Joined Groups
getJoinedGroups(GroupsParams groupsParams, boolean clearCache, ListenerModel<BaseModel<Groups>, Groups> listener)
Retrieving List of Members in a Group
getJoinedGroups(GroupsParams groupsParams, boolean clearCache, ListenerModel<BaseModel<Groups>, Groups> listener)
Joining a Group
joinGroup(GroupsParams groupsParams, ListenerModel<BaseModel<GroupJoinLeaveResponse>, GroupJoinLeaveResponse> listener)
Leaving a Group
leaveGroup(GroupsParams groupsParams, ListenerModel<BaseModel<GroupJoinLeaveResponse>, GroupJoinLeaveResponse> listener)
Fetching Group Members
getGroupMembers(GroupsParams groupsParams, boolean clearCache, ListenerModel<BaseModel<GroupMembers>, GroupMembers> listener)