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.
Example 1
Project: AnyTime   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
Project: connectivity-samples   File: DeviceControlActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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
Project: bither-android   File: PinnedHeaderExpandableListView.java    License: Apache License 2.0 6 votes vote down vote up
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
Project: privacy-friendly-weather   File: HelpActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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
Project: AndroidChromium   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
Project: bither-android   File: PinnedHeaderExpandableListView.java    License: Apache License 2.0 6 votes vote down vote up
@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
Project: FloatingGroupExpandableListView   File: FloatingGroupExpandableListView.java    License: Apache License 2.0 6 votes vote down vote up
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
Project: buddycloud-android   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
Project: TreeView   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
Project: ui   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
Project: MonsterHunter4UDatabase   File: QuestExpandableListFragment.java    License: MIT License 6 votes vote down vote up
@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
Project: letv   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
Project: android-BluetoothLeGatt   File: DeviceControlActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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
Project: FireFiles   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
Project: arcgis-runtime-samples-android   File: ResultsActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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
Project: privacy-friendly-ludo   File: HelpActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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
Project: ActivityLauncher   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
Project: SkyTube   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
Project: delion   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
Project: privacy-friendly-netmonitor   File: HelpActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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
Project: FireFiles   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
Project: privacy-friendly-pedometer   File: HelpActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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
Project: ui   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
Project: PADListener   File: FilterFriendsChooseLeadersFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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
Project: document-viewer   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
Project: FireFiles   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
Project: ListView-Swipe-to-Delete   File: MainExpListActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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
Project: FireFiles   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
Project: ans-android-sdk   File: ViewClickProbe.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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
Project: ans-android-sdk   File: ViewClickProbe.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 31
Project: androidtestdebug   File: TheSimpleExpandableListAdapter.java    License: MIT License 5 votes vote down vote up
@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); 
    ExpandableListView eLV = (ExpandableListView) parent; 
    eLV.expandGroup(groupPosition); 
    return v; 
}
 
Example 32
Project: handmarkPulltorefreshLibrary   File: PullToRefreshExpandableListView.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 33
Project: zom-android-matrix   File: VectorUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Provides the visible child views.
 * The map key is the group position.
 * The map values are the visible child views.
 *
 * @param expandableListView the listview
 * @param adapter            the linked adapter
 * @return visible views map
 */
public static Map<Integer, List<Integer>> getVisibleChildViews(ExpandableListView expandableListView, BaseExpandableListAdapter adapter) {
    Map<Integer, List<Integer>> map = new HashMap<>();

    long firstPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getFirstVisiblePosition());

    int firstGroupPosition = ExpandableListView.getPackedPositionGroup(firstPackedPosition);
    int firstChildPosition = ExpandableListView.getPackedPositionChild(firstPackedPosition);

    long lastPackedPosition = expandableListView.getExpandableListPosition(expandableListView.getLastVisiblePosition());

    int lastGroupPosition = ExpandableListView.getPackedPositionGroup(lastPackedPosition);
    int lastChildPosition = ExpandableListView.getPackedPositionChild(lastPackedPosition);

    for (int groupPos = firstGroupPosition; groupPos <= lastGroupPosition; groupPos++) {
        List<Integer> list = new ArrayList<>();

        int startChildPos = (groupPos == firstGroupPosition) ? firstChildPosition : 0;
        int endChildPos = (groupPos == lastGroupPosition) ? lastChildPosition : adapter.getChildrenCount(groupPos) - 1;

        for (int index = startChildPos; index <= endChildPos; index++) {
            list.add(index);
        }

        map.put(groupPos, list);
    }

    return map;
}
 
Example 34
Project: yiim_v2   File: InviteFriendActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void initViews() {
	// TODO Auto-generated method stub
	mListView = (ExpandableListView) findViewById(R.id.invite_friend_list);

	mPinnedHeaderView = findViewById(R.id.invite_friend_list_group_header);

	mPinnedImageView = (ImageView) findViewById(R.id.friend_list_group_img);
	mPinnedTextView = (TextView) findViewById(R.id.friend_list_group_text);
	mPinnedRightTextView = (TextView) findViewById(R.id.friend_list_group_right_text);

	mPinnedImageView.setBackgroundResource(R.drawable.group_unfold_arrow);
}
 
Example 35
Project: FireFiles   File: RootsFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
 
Example 36
Project: privacy-friendly-food-tracker   File: HelpActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    LinkedHashMap<String, List<String>> expandableListDetail = buildData();

    ExpandableListView generalExpandableListView = findViewById(R.id.generalExpandableListView);
    generalExpandableListView.setAdapter(new HelpExpandableListAdapter(this, new ArrayList<>(expandableListDetail.keySet()), expandableListDetail));

    overridePendingTransition(0, 0);
}
 
Example 37
Project: opentasks   File: TaskListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int canFling(ListView v, int pos)
{
    long packedPos = mExpandableListView.getExpandableListPosition(pos);
    if (packedPos != ExpandableListView.PACKED_POSITION_VALUE_NULL
            && ExpandableListView.getPackedPositionType(packedPos) == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
    {
        return FlingDetector.RIGHT_FLING | FlingDetector.LEFT_FLING;
    }
    else
    {
        return 0;
    }
}
 
Example 38
Project: Dainty   File: HistoryListView.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mDockingHeaderVisible) {
        Rect rect = new Rect();
        mDockingHeader.getDrawingRect(rect);

        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (rect.contains((int)ev.getX(), (int)ev.getY())) {
                    // 阻止事件被list view的item消费
                    return true;
                }
                break;
            case MotionEvent.ACTION_UP:
                long flatPosition = getExpandableListPosition(getFirstVisiblePosition());
                int groupPos = ExpandableListView.getPackedPositionGroup(flatPosition);
                if (rect.contains((int)ev.getX(), (int)ev.getY()) &&
                        mDockingHeaderState == IDockingController.DOCKING_HEADER_DOCKED) {
                    // handle header view click event (do group expansion & collapse)
                    if (isGroupExpanded(groupPos)) {
                        collapseGroup(groupPos);
                    } else {
                        expandGroup(groupPos);
                    }
                    return true;
                }
                break;
        }
    }

    return super.onTouchEvent(ev);
}
 
Example 39
Project: coolreader   File: DisplayLightNovelDetailsActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
	ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

	MenuInflater inflater = getMenuInflater();
	int type = ExpandableListView.getPackedPositionType(info.packedPosition);
	if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
		inflater.inflate(R.menu.novel_details_volume_context_menu, menu);
	} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
		inflater.inflate(R.menu.novel_details_chapter_context_menu, menu);
	}
}
 
Example 40
Project: opentasks   File: TaskListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onGroupCollapse(int groupPosition)
{
    if (groupPosition == mActivatedPositionGroup)
    {
        mActivatedPositionChild = ExpandableListView.INVALID_POSITION;
        mActivatedPositionGroup = ExpandableListView.INVALID_POSITION;
    }

}