Java Code Examples for android.widget.ExpandableListView

The following examples show how to use android.widget.ExpandableListView. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AnyTime   Source File: DoingListFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View rootView = inflater.inflate(R.layout.fragment_main_doing_list,
			container, false);
	mDoingListData = new ArrayList<DoingListData>();
	expandableListView = (ExpandableListView) rootView
			.findViewById(R.id.expandableListView_doing_list);
	adapter = new AnytimeExpandableListAdapter(activity);
	expandableListView.setAdapter(adapter);
	expandableListView.setOnChildClickListener(listener);
	messageText = (TextView) rootView
			.findViewById(R.id.textView_loading_wait);
	LoadingData();
	return rootView;
}
 
Example 2
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                            int childPosition, long id) {
    if (mGattCharacteristics != null) {
        final BluetoothGattCharacteristic characteristic =
                mGattCharacteristics.get(groupPosition).get(childPosition);
        final int charaProp = characteristic.getProperties();
        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
            // If there is an active notification on a characteristic, clear
            // it first so it doesn't update the data field on the user interface.
            if (mNotifyCharacteristic != null) {
                mBluetoothLeService.setCharacteristicNotification(
                        mNotifyCharacteristic, false);
                mNotifyCharacteristic = null;
            }
            mBluetoothLeService.readCharacteristic(characteristic);
        }
        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
            mNotifyCharacteristic = characteristic;
            mBluetoothLeService.setCharacteristicNotification(
                    characteristic, true);
        }
        return true;
    }
    return false;
}
 
Example 3
public void setPinnedHeaderView(View view) {
	mHeaderView = view;
	if (mHeaderView != null) {
		setFadingEdgeLength(0);
		mHeaderView.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					final long flatPos = getExpandableListPosition(getFirstVisiblePosition());
					final int groupPos = ExpandableListView
							.getPackedPositionGroup(flatPos);
					collapseGroup(groupPos);
				}
				return true;
			}
		});
	}
	requestLayout();
}
 
Example 4
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_help);
    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 5
Source Project: AndroidChromium   Source File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 6
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
	super.onLayout(changed, l, t, r, b);
	final long flatPostion = getExpandableListPosition(getFirstVisiblePosition());
	final int groupPos = ExpandableListView
			.getPackedPositionGroup(flatPostion);
	final int childPos = ExpandableListView
			.getPackedPositionChild(flatPostion);
	int state = mAdapter.getPinnedHeaderState(groupPos, childPos);
	
	if (mHeaderView != null && mAdapter != null && state != mOldState) {
		mOldState = state;
		mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight);
	}

	configureHeaderView(groupPos, childPos);
}
 
Example 7
private void drawFloatingGroupIndicator(Canvas canvas) {
	final Drawable groupIndicator = (Drawable) ReflectionUtils.getFieldValue(ExpandableListView.class, "mGroupIndicator", FloatingGroupExpandableListView.this);
	if(groupIndicator != null) {
		final int stateSetIndex =
				(mAdapter.isGroupExpanded(mFloatingGroupPosition) ? 1 : 0) | // Expanded?
				(mAdapter.getChildrenCount(mFloatingGroupPosition) > 0 ? 2 : 0); // Empty?
		groupIndicator.setState(GROUP_STATE_SETS[stateSetIndex]);

		final int indicatorLeft = (Integer) ReflectionUtils.getFieldValue(ExpandableListView.class, "mIndicatorLeft", FloatingGroupExpandableListView.this);
		final int indicatorRight = (Integer) ReflectionUtils.getFieldValue(ExpandableListView.class, "mIndicatorRight", FloatingGroupExpandableListView.this);

		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			mIndicatorRect.set(indicatorLeft + getPaddingLeft(), mFloatingGroupView.getTop(), indicatorRight + getPaddingLeft(), mFloatingGroupView.getBottom());
		} else {
			mIndicatorRect.set(indicatorLeft, mFloatingGroupView.getTop(), indicatorRight, mFloatingGroupView.getBottom());
		}

		groupIndicator.setBounds(mIndicatorRect);
		groupIndicator.draw(canvas);
	}
}
 
Example 8
Source Project: buddycloud-android   Source File: GenericChannelAdapter.java    License: Apache License 2.0 6 votes vote down vote up
protected void showNoResultsFoundView(final String emptyMsg) {
	if (parentView == null || TextUtils.isEmpty(emptyMsg)) return;
	
	ExpandableListView lv = (ExpandableListView)parentView.findViewById(R.id.channelListView);
	View emptyView = parentView.findViewById(R.id.channelListEmpty);
	if (lv != null && emptyView != null) {
		TextView tv = (TextView)emptyView.findViewById(R.id.results_not_found);
		tv.setText(emptyMsg);
		
		lv.setEmptyView(emptyView);
	}
	
	View progressView = parentView.findViewById(R.id.channelListProgress);
	if (progressView != null) {
		progressView.setVisibility(View.GONE);
	}
	
}
 
Example 9
Source Project: TreeView   Source File: TreeView.java    License: Apache License 2.0 6 votes vote down vote up
private void onHeaderViewClick() {
    long packedPosition = getExpandableListPosition(getFirstVisiblePosition());

    int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);

    int status = mUpdater.getHeaderClickStatus(groupPosition);
    if (ITreeViewHeaderUpdater.STATE_VISIBLE_ALL == status) {
        collapseGroup(groupPosition);
        mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_GONE);
    } else {
        expandGroup(groupPosition);
        mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_VISIBLE_ALL);
    }

    setSelectedGroup(groupPosition);
}
 
Example 10
Source Project: ui   Source File: elvDemo1_Fragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo1_fragment, container, false);


	// get the listview
	expListView = (ExpandableListView) myView.findViewById(R.id.lvExp);

	// preparing list data
	prepareListData();

	listAdapter = new ExpandableListAdapter(myContext, listDataHeader, listDataChild);

	// setting list adapter
	expListView.setAdapter(listAdapter);
	
	return myView;
}
 
Example 11
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_generic_expandable_list, container, false);
    ExpandableListView elv = (ExpandableListView) v
            .findViewById(R.id.expandableListView);
    if (mHub.equals("Caravan")) {
        elv.setAdapter(new QuestListAdapter(caravan));
    } else if(mHub.equals("Guild")) {
        elv.setAdapter(new QuestListAdapter(guild));
    } else {
        elv.setAdapter(new QuestListAdapter(event));
    }

    return v;

}
 
Example 12
Source Project: letv   Source File: VipFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void setRootView(ChannelHomeBean result, boolean isFromNet) {
    if (result != null) {
        this.mChannelHomeBean = result;
        if (!BaseTypeUtils.isListEmpty(this.mChannelHomeBean.searchWords)) {
            initFooterSearchView(this.mChannelHomeBean.searchWords);
        }
        setFocusView(this.mChannelHomeBean.focus);
        if (this.mChannelHomeBean.isShowTextMark) {
            setVipTipsView();
        }
        initTabView(result);
        finishLoading();
        this.mPullView.setPullToRefreshEnabled(true);
        ((ExpandableListView) this.mPullView.getRefreshableView()).setAdapter(this.mListAdapter);
        this.mListAdapter.setDataList((ExpandableListView) this.mPullView.getRefreshableView(), this.mChannelHomeBean, isFromNet);
    }
}
 
Example 13
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    mDataField = (TextView) findViewById(R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
 
Example 14
Source Project: FireFiles   Source File: RootsFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void onCurrentRootChanged() {
    if (mAdapter == null || mList == null) return;

    final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
    for (int i = 0; i < mAdapter.getGroupCount(); i++) {
        for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
            final Object item = mAdapter.getChild(i,j);
            if (item instanceof RootItem) {
                final RootInfo testRoot = ((RootItem) item).root;
                if (Objects.equal(testRoot, root)) {
                    try {
                        long id = ExpandableListView.getPackedPositionForChild(i, j);
                        int index = mList.getFlatListPosition(id);
                        //mList.setSelection(index);
                        mList.setItemChecked(index, true);
                    } catch (Exception e){
                        Crashlytics.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
Example 15
@Override
protected void onCreate(Bundle savedInstance) {
  super.onCreate(savedInstance);
  setContentView(R.layout.results_expandable_list);

  // get intent from main activity
  Intent intent = getIntent();
  // get the HashMap created in MainActivity
  HashMap<String,ArrayList<String>> child = (HashMap<String,ArrayList<String>>) intent.getSerializableExtra("HashMap");
  ArrayList<String> header = new ArrayList<>();
  header.add("Point");
  header.add("Polyline");
  header.add("Polygon");

  // create an expandable list view and an adapter to display in new activity.
  ExpandableListView expandableListView = findViewById(R.id.expandableList);
  ExpandableListAdapter expandableListAdapter = new ExpandableListAdapter(this,header,child);
  expandableListView.setAdapter(expandableListAdapter);
}
 
Example 16
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 17
Source Project: ActivityLauncher   Source File: AllTasksListFragment.java    License: ISC License 6 votes vote down vote up
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v,
                                ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            menu.setHeaderIcon(activity.icon);
            menu.setHeaderTitle(activity.name);
            menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
            break;
        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            menu.setHeaderIcon(pack.icon);
            menu.setHeaderTitle(pack.name);
            break;
    }

    super.onCreateContextMenu(menu, v, menuInfo);
}
 
Example 18
Source Project: SkyTube   Source File: CommentsAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
public CommentsAdapter(Context context, String videoId, ExpandableListView expandableListView, View commentsProgressBar, View noVideoCommentsView) {
	this.context = context;
	this.videoId = videoId;
	this.expandableListView = expandableListView;
	this.expandableListView.setAdapter(this);
	this.expandableListView.setOnGroupClickListener((parent, v, groupPosition, id) -> true);
	this.commentsProgressBar = commentsProgressBar;
	this.noVideoCommentsView = noVideoCommentsView;
	this.layoutInflater = LayoutInflater.from(expandableListView.getContext());
	try {
		this.commentThreadPager = NewPipeService.isPreferred() ? NewPipeService.get().getCommentPager(videoId) : new GetCommentThreads(videoId);
		this.getCommentsTask = new GetCommentsTask();
		this.getCommentsTask.execute();
	} catch (Exception e) {
		SkyTubeApp.notifyUserOnError(context, e);
	}
}
 
Example 19
Source Project: delion   Source File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
Example 20
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    RunStore.setContext(this);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    HashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 21
Source Project: FireFiles   Source File: RootsFragment.java    License: Apache License 2.0 6 votes vote down vote up
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
Example 22
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 23
Source Project: ui   Source File: elvDemo2_Fragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo2_fragment, container, false);
	
    // get the listview
       expListView = (ExpandableListView) myView.findViewById(R.id.lvExp2);
       prepareListData();
       
       listAdapter =  new SimpleExpandableListAdapter(
                       myContext,						    //context
                       listDataGroup,                  // group list in the form:  List<? extends Map<String, ?>>
                       R.layout.evl2_group_row,        // Group item layout XML.
                       new String[] { "Group Item" },  // the key of group item.   String[] groupFrom, 
                       new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.  int[] groupTo
                       listDataChild,              // childData describes second-level entries. in the form List<? extends List<? extends Map<String, ?>>>
                       R.layout.evl2_child_row,             // Layout for sub-level entries(second level).
                       new String[] {"Sub Item A", "Sub Item B"},      // Keys in childData maps to display.
                       new int[] { R.id.grp_childA, R.id.grp_childB}     // Data under the keys above go into these TextViews.
                   );
      expListView.setAdapter( listAdapter );       // setting the adapter in the list.
    
       return myView;
}
 
Example 24
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
	MyLog.entry("menuItem = " + menuItem);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuItem.getMenuInfo();
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);

	//final MonsterInfoModel monsterInfo = getGroupMonsterItem(menuItem.getMenuInfo());

	switch (menuItem.getItemId()) {
		case MENU_ID_SELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, true);
			break;
		case MENU_ID_DESELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, false);
			break;
		default:
	}

	MyLog.exit();
	return true;
}
 
Example 25
Source Project: document-viewer   Source File: OPDSActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.emdev.ui.AbstractActionActivity#onCreateImpl(android.os.Bundle)
 */
@Override
protected void onCreateImpl(final Bundle savedInstanceState) {

    setContentView(R.layout.opds);
    setActionForView(R.id.opdsaddfeed);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    
    final OPDSActivityController c = getController();

    list = (ExpandableListView) findViewById(R.id.opdslist);
    list.setGroupIndicator(null);
    list.setChildIndicator(null);
    list.setOnGroupClickListener(c);
    list.setOnChildClickListener(c);
    list.setAdapter(c.adapter);

    this.registerForContextMenu(list);
}
 
Example 26
Source Project: FireFiles   Source File: RootsFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void onCurrentRootChanged() {
    if (mAdapter == null || mList == null) return;

    final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
    for (int i = 0; i < mAdapter.getGroupCount(); i++) {
        for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
            final Object item = mAdapter.getChild(i,j);
            if (item instanceof RootItem) {
                final RootInfo testRoot = ((RootItem) item).root;
                if (Objects.equal(testRoot, root)) {
                    try {
                        long id = ExpandableListView.getPackedPositionForChild(i, j);
                        int index = mList.getFlatListPosition(id);
                        //mList.setSelection(index);
                        mList.setItemChecked(index, true);
                    } catch (Exception e){
                        CrashReportingManager.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
Example 27
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_explist);

	list = (ExpandableListView) findViewById(android.R.id.list);
	
	listHandler = new ItemExpListHandler(list);
	
	ArrayList<MenuItemDesc> menuItems = fillMenu();
	
	listAdapter = new ItemExpListAdapter(R.layout.item, menuItems, listHandler);
	fillAdapter();
	list.setAdapter(listAdapter);

	listManager = new ItemExpListManager(this, listHandler, true);
}
 
Example 28
Source Project: FireFiles   Source File: RootsFragment.java    License: Apache License 2.0 6 votes vote down vote up
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
Example 29
@Override
public void trackExpListViewChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, boolean hasTrackClickAnn,long currentTime) {
    try {

        if (isTrackClickSwitchClose()) {
            return;
        }

        Object pageObj = AllegroUtils.getPageObjFromView(parent);
        if (!checkTrackClickEnable(pageObj, v, hasTrackClickAnn) || !checkTrackClickEnable(pageObj, parent, hasTrackClickAnn)) {
            return;
        }

        Map<String, Object> viewInfo = new HashMap<>();
        String[] viewTypeAndText = AllegroUtils.getViewTypeAndText(v);
        String viewType = "ExpandableListViewChildItem:" + viewTypeAndText[0];
        viewInfo.put(Constants.ELEMENT_TYPE, viewType);
        viewInfo.put(Constants.ELEMENT_CONTENT, viewTypeAndText[1]);
        viewInfo.put(Constants.ELEMENT_POSITION, groupPosition + ":" + childPosition);

        String idName = AllegroUtils.getViewIdResourceName(v);
        if (!TextUtils.isEmpty(idName)) {
            viewInfo.put(Constants.ELEMENT_ID, idName);
        }

        autoTrackClick(pageObj, viewInfo, hasTrackClickAnn,currentTime);
    } catch (Throwable ignore) {
        ExceptionUtil.exceptionThrow(ignore);
    }
}
 
Example 30
@Override
public void trackExpListViewGroupClick(ExpandableListView parent, View v, int groupPosition, boolean hasTrackClickAnn,long currentTime) {
    try {
        if (isTrackClickSwitchClose()) {
            return;
        }

        Object pageObj = AllegroUtils.getPageObjFromView(parent);
        if (!checkTrackClickEnable(pageObj, v, hasTrackClickAnn) || !checkTrackClickEnable(pageObj, parent, hasTrackClickAnn)) {
            return;
        }

        Map<String, Object> viewInfo = new HashMap<>();
        String[] viewTypeAndText = AllegroUtils.getViewTypeAndText(v);
        String viewType = "ExpandableListViewGroupItem:" + viewTypeAndText[0];
        viewInfo.put(Constants.ELEMENT_TYPE, viewType);
        viewInfo.put(Constants.ELEMENT_CONTENT, viewTypeAndText[1]);
        viewInfo.put(Constants.ELEMENT_POSITION, groupPosition);

        String idName = AllegroUtils.getViewIdResourceName(v);
        if (!TextUtils.isEmpty(idName)) {
            viewInfo.put(Constants.ELEMENT_ID, idName);
        }

        trackListView(parent, v, groupPosition, hasTrackClickAnn,currentTime);
    } catch (Throwable ignore) {
        ExceptionUtil.exceptionThrow(ignore);
    }
}