Search in sources :

Example 41 with ExpandableListView

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleExpandableListAdapter(android.widget.SimpleExpandableListAdapter) Map(java.util.Map) HashMap(java.util.HashMap) PullToRefreshExpandableListView(com.handmark.pulltorefresh.library.PullToRefreshExpandableListView) ExpandableListView(android.widget.ExpandableListView)

Example 42 with ExpandableListView

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);
}
Also used : MoodleCoreModule(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreModule) HashMap(java.util.HashMap) MoodleCoreCourse(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreCourse) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) ExpandableListView(android.widget.ExpandableListView) MoodleModuleContent(ca.etsmtl.applets.etsmobile.model.moodle.MoodleModuleContent) ExpandableListMoodleSectionAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListMoodleSectionAdapter) ExpandableListView(android.widget.ExpandableListView)

Example 43 with ExpandableListView

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;
}
Also used : ExpandableListView(android.widget.ExpandableListView)

Example 44 with ExpandableListView

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;
}
Also used : ExpandableListView(android.widget.ExpandableListView)

Example 45 with ExpandableListView

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!");
                }
            }
        }
    }
}
Also used : ExpandableListAdapter(android.widget.ExpandableListAdapter) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ExpandableListView(android.widget.ExpandableListView)

Aggregations

ExpandableListView (android.widget.ExpandableListView)86 View (android.view.View)59 TextView (android.widget.TextView)30 AdapterView (android.widget.AdapterView)18 Intent (android.content.Intent)16 ListView (android.widget.ListView)16 ArrayList (java.util.ArrayList)16 AbsListView (android.widget.AbsListView)14 DialogInterface (android.content.DialogInterface)11 ImageView (android.widget.ImageView)11 List (java.util.List)11 Builder (android.app.AlertDialog.Builder)9 ViewGroup (android.view.ViewGroup)9 ExpandableListAdapter (android.widget.ExpandableListAdapter)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6 TabHost (android.widget.TabHost)6 AdapterBinding (com.android.ide.common.rendering.api.AdapterBinding)6 ResourceReference (com.android.ide.common.rendering.api.ResourceReference)6 SessionParams (com.android.ide.common.rendering.api.SessionParams)6