use of android.widget.ExpandableListView in project ETSMobile-Android2 by ApplETS.
the class MoodleCourseDetailsFragment method onRequestSuccess.
@Override
public void onRequestSuccess(Object o) {
if (o instanceof MoodleCoreCourses) {
MoodleCoreCourses moodleCoreCourses = (MoodleCoreCourses) o;
// create empty data
listDataSectionName = new HashMap<HeaderText, Object[]>();
listDataHeader = new ArrayList<HeaderText>();
int positionSection = 0;
for (MoodleCoreCourse coreCourse : moodleCoreCourses) {
listMoodleLinkModules = new ArrayList<MoodleCoreModule>();
listMoodleResourceContents = new ArrayList<MoodleModuleContent>();
for (MoodleCoreModule coreModule : coreCourse.getModules()) {
if (coreModule.getModname().equals("folder")) {
if (coreModule.getContents() != null)
listMoodleResourceContents.addAll(coreModule.getContents());
} else if (coreModule.getModname().equals("url") || coreModule.getModname().equals("forum")) {
listMoodleLinkModules.add(coreModule);
} else if (coreModule.getModname().equals("resource")) {
listMoodleResourceContents.addAll(coreModule.getContents());
}
}
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, new Comparator<HeaderText>() {
@Override
public int compare(HeaderText headerText1, HeaderText headerText2) {
if (headerText1.getPosition() < headerText2.getPosition()) {
return -1;
} else if (headerText1.getPosition() == headerText2.getPosition()) {
return 0;
} else {
return 1;
}
}
});
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) {
MoodleModuleContent item = (MoodleModuleContent) object;
String url = item.getFileurl() + "&token=" + ApplicationManager.userCredentials.getMoodleToken();
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, item.getFilename());
// r.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
MimeTypeMap mimetype = MimeTypeMap.getSingleton();
String extension = FilenameUtils.getExtension(item.getFilename());
request.setMimeType(mimetype.getMimeTypeFromExtension(extension));
dm = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
enqueue = dm.enqueue(request);
AnalyticsHelper.getInstance(getActivity()).sendActionEvent(getClass().getSimpleName(), TELECHARGE_FICHIER_MOODLE);
}
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();
}
AnalyticsHelper.getInstance(getActivity()).sendActionEvent(getClass().getSimpleName(), CONSULTE_PAGE_MOODLE);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
return true;
}
});
super.onRequestSuccess(null);
}
}
use of android.widget.ExpandableListView in project platform_frameworks_base by android.
the class RenderSessionImpl method postInflateProcess.
/**
* Post process on a view hierarchy that was just inflated.
* <p/>
* At the moment this only supports TabHost: If {@link TabHost} is detected, look for the
* {@link TabWidget}, and the corresponding {@link FrameLayout} and make new tabs automatically
* based on the content of the {@link FrameLayout}.
* @param view the root view to process.
* @param layoutlibCallback callback to the project.
* @param skip the view and it's children are not processed.
*/
// For the use of Pair
@SuppressWarnings("deprecation")
private void postInflateProcess(View view, LayoutlibCallback layoutlibCallback, View skip) throws PostInflateException {
if (view == skip) {
return;
}
if (view instanceof TabHost) {
setupTabHost((TabHost) view, layoutlibCallback);
} else if (view instanceof QuickContactBadge) {
QuickContactBadge badge = (QuickContactBadge) view;
badge.setImageToDefault();
} else if (view instanceof AdapterView<?>) {
// get the view ID.
int id = view.getId();
BridgeContext context = getContext();
// get a ResourceReference from the integer ID.
ResourceReference listRef = context.resolveId(id);
if (listRef != null) {
SessionParams params = getParams();
AdapterBinding binding = params.getAdapterBindings().get(listRef);
// if there was no adapter binding, trying to get it from the call back.
if (binding == null) {
binding = layoutlibCallback.getAdapterBinding(listRef, context.getViewKey(view), view);
}
if (binding != null) {
if (view instanceof AbsListView) {
if ((binding.getFooterCount() > 0 || binding.getHeaderCount() > 0) && view instanceof ListView) {
ListView list = (ListView) view;
boolean skipCallbackParser = false;
int count = binding.getHeaderCount();
for (int i = 0; i < count; i++) {
Pair<View, Boolean> pair = context.inflateView(binding.getHeaderAt(i), list, false, skipCallbackParser);
if (pair.getFirst() != null) {
list.addHeaderView(pair.getFirst());
}
skipCallbackParser |= pair.getSecond();
}
count = binding.getFooterCount();
for (int i = 0; i < count; i++) {
Pair<View, Boolean> pair = context.inflateView(binding.getFooterAt(i), list, false, skipCallbackParser);
if (pair.getFirst() != null) {
list.addFooterView(pair.getFirst());
}
skipCallbackParser |= pair.getSecond();
}
}
if (view instanceof ExpandableListView) {
((ExpandableListView) view).setAdapter(new FakeExpandableAdapter(listRef, binding, layoutlibCallback));
} else {
((AbsListView) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
}
} else if (view instanceof AbsSpinner) {
((AbsSpinner) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
}
}
}
} else if (view instanceof ViewGroup) {
mInflater.postInflateProcess(view);
ViewGroup group = (ViewGroup) view;
final int count = group.getChildCount();
for (int c = 0; c < count; c++) {
View child = group.getChildAt(c);
postInflateProcess(child, layoutlibCallback, skip);
}
}
}
use of android.widget.ExpandableListView in project PullToRefreshLibrary by harichen.
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 ExoPlayer by google.
the class SampleChooserActivity method onSampleGroups.
private void onSampleGroups(final List<SampleGroup> groups, boolean sawError) {
if (sawError) {
Toast.makeText(getApplicationContext(), R.string.sample_list_load_error, Toast.LENGTH_LONG).show();
}
ExpandableListView sampleList = (ExpandableListView) findViewById(R.id.sample_list);
sampleList.setAdapter(new SampleAdapter(this, groups));
sampleList.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View view, int groupPosition, int childPosition, long id) {
onSampleSelected(groups.get(groupPosition).samples.get(childPosition));
return true;
}
});
}
use of android.widget.ExpandableListView in project XobotOS by xamarin.
the class ExpandableListActivity method onContentChanged.
/**
* Updates the screen state (current list and other views) when the
* content changes.
*
* @see Activity#onContentChanged()
*/
@Override
public void onContentChanged() {
super.onContentChanged();
View emptyView = findViewById(com.android.internal.R.id.empty);
mList = (ExpandableListView) findViewById(com.android.internal.R.id.list);
if (mList == null) {
throw new RuntimeException("Your content must have a ExpandableListView whose id attribute is " + "'android.R.id.list'");
}
if (emptyView != null) {
mList.setEmptyView(emptyView);
}
mList.setOnChildClickListener(this);
mList.setOnGroupExpandListener(this);
mList.setOnGroupCollapseListener(this);
if (mFinishedStart) {
setListAdapter(mAdapter);
}
mFinishedStart = true;
}
Aggregations