use of android.widget.ExpandableListView in project Android-PullToRefresh by chrisbanes.
the class PullToRefreshExpandableListActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ptr_expandable_list);
mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list);
// Set a listener to be invoked when the list should be refreshed.
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {
@Override
public void onRefresh(PullToRefreshBase<ExpandableListView> refreshView) {
// Do work to refresh the list here.
new GetDataTask().execute();
}
});
for (String group : mGroupStrings) {
Map<String, String> groupMap1 = new HashMap<String, String>();
groupData.add(groupMap1);
groupMap1.put(KEY, group);
List<Map<String, String>> childList = new ArrayList<Map<String, String>>();
for (String string : mChildStrings) {
Map<String, String> childMap = new HashMap<String, String>();
childList.add(childMap);
childMap.put(KEY, string);
}
childData.add(childList);
}
mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1, new String[] { KEY }, new int[] { android.R.id.text1 }, childData, android.R.layout.simple_expandable_list_item_2, new String[] { KEY }, new int[] { android.R.id.text1 });
setListAdapter(mAdapter);
}
use of android.widget.ExpandableListView in project ETSMobile-Android2 by ApplETS.
the class MoodleCourseDetailsFragment method displayMoodleCourses.
/**
* Takes moodle courses for a given class and displays them in an {@link ExpandableListView}
*
* @param courses the list of courses for a given class
*/
private void displayMoodleCourses(List<MoodleCoreCourse> courses) {
// create empty data
HashMap<HeaderText, Object[]> listDataSectionName = new HashMap<>();
List<HeaderText> listDataHeader = new ArrayList<>();
int positionSection = 0;
for (MoodleCoreCourse coreCourse : courses) {
ArrayList<MoodleCoreModule> listMoodleLinkModules = new ArrayList<>();
ArrayList<MoodleModuleContent> listMoodleResourceContents = new ArrayList<>();
for (MoodleCoreModule coreModule : coreCourse.getModules()) {
ArrayList<MoodleModuleContent> contents = coreModule.getContents();
switch(coreModule.getModname()) {
case "folder":
if (contents != null)
listMoodleResourceContents.addAll(contents);
break;
case "url":
case "forum":
listMoodleLinkModules.add(coreModule);
break;
case "resource":
if (contents != null)
listMoodleResourceContents.addAll(contents);
break;
}
}
Object[] finalArray = ArrayUtils.addAll(listMoodleLinkModules.toArray(), listMoodleResourceContents.toArray());
if (finalArray.length != 0)
listDataSectionName.put(new HeaderText(coreCourse.getName(), positionSection), finalArray);
positionSection++;
}
listDataHeader.addAll(listDataSectionName.keySet());
Collections.sort(listDataHeader, (headerText1, headerText2) -> Integer.compare(headerText1.getPosition(), headerText2.getPosition()));
if (getActivity() == null)
return;
expandableListMoodleAdapter = new ExpandableListMoodleSectionAdapter(getActivity(), listDataHeader, listDataSectionName);
expListView.setAdapter(expandableListMoodleAdapter);
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Object object = expandableListMoodleAdapter.getChild(groupPosition, childPosition);
if (object instanceof MoodleModuleContent) {
MoodleCourseDetailsFragmentPermissionsDispatcher.downloadMoodleObjectWithPermissionCheck(MoodleCourseDetailsFragment.this, (MoodleModuleContent) object);
}
if (object instanceof MoodleCoreModule) {
MoodleCoreModule item = (MoodleCoreModule) object;
String url = "";
if (item.getModname().equals("url")) {
url = item.getContents().get(0).getFileurl();
} else {
url = item.getUrl();
}
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
return true;
}
});
onRequestSuccess(null);
}
use of android.widget.ExpandableListView in project PullToRefresh-PinnedSection-ListView by tongcpp.
the class PullToRefreshExpandableListView method createRefreshableView.
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
final ExpandableListView lv;
if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
lv = new InternalExpandableListViewSDK9(context, attrs);
} else {
lv = new InternalExpandableListView(context, attrs);
}
// Set it to this so it can be used in ListActivity/ListFragment
lv.setId(android.R.id.list);
return lv;
}
use of android.widget.ExpandableListView in project StaggeredGridView by bulletnoid.
the class PullToRefreshExpandableListView method createRefreshableView.
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
final ExpandableListView lv;
if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
lv = new InternalExpandableListViewSDK9(context, attrs);
} else {
lv = new InternalExpandableListView(context, attrs);
}
// Set it to this so it can be used in ListActivity/ListFragment
lv.setId(android.R.id.list);
return lv;
}
use of android.widget.ExpandableListView in project SmartAndroidSource by jaychou2012.
the class Common method onScrollStateChanged.
private void onScrollStateChanged(ExpandableListView elv, int scrollState) {
elv.setTag(AQuery.TAG_NUM, scrollState);
if (scrollState == SCROLL_STATE_IDLE) {
int first = elv.getFirstVisiblePosition();
int last = elv.getLastVisiblePosition();
int count = last - first;
ExpandableListAdapter ela = elv.getExpandableListAdapter();
for (int i = 0; i <= count; i++) {
long packed = elv.getExpandableListPosition(i + first);
int group = ExpandableListView.getPackedPositionGroup(packed);
int child = ExpandableListView.getPackedPositionChild(packed);
if (group >= 0) {
View convertView = elv.getChildAt(i);
Long targetPacked = (Long) convertView.getTag(AQuery.TAG_NUM);
if (targetPacked != null && targetPacked.longValue() == packed) {
if (child == -1) {
ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);
} else {
ela.getChildView(group, child, child == ela.getChildrenCount(group) - 1, convertView, elv);
}
convertView.setTag(AQuery.TAG_NUM, null);
} else {
// AQUtility.debug("skip!");
}
}
}
}
}
Aggregations