Example usage for android.widget ExpandableListView isGroupExpanded

List of usage examples for android.widget ExpandableListView isGroupExpanded

Introduction

In this page you can find the example usage for android.widget ExpandableListView isGroupExpanded.

Prototype

public boolean isGroupExpanded(int groupPosition) 

Source Link

Document

Whether the given group is currently expanded.

Usage

From source file:dev.drsoran.moloko.fragments.TaskListsFragment.java

@Override
public void onGroupIndicatorClicked(View groupView) {
    final ExpandableListView listView = getExpandableListView();
    final int pos = ExpandableListView
            .getPackedPositionGroup(listView.getExpandableListPosition(listView.getPositionForView(groupView)));

    if (listView.isGroupExpanded(pos))
        listView.collapseGroup(pos);/*w w  w . j a v  a 2 s . c  o m*/
    else
        listView.expandGroup(pos);
}

From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    seasonsEpisodesListView.setEmptyView(emptyView);
    seasonsEpisodesListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override//  w  ww  . j  a  v  a 2s .  c  om
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (parent.isGroupExpanded(groupPosition)) {
                parent.collapseGroup(groupPosition);
            } else {
                parent.expandGroup(groupPosition);
            }
            return true;
        }
    });
    seasonsEpisodesListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            // Get the movie id from the tag
            EpisodeViewHolder tag = (EpisodeViewHolder) v.getTag();
            // Notify the activity
            listenerActivity.onEpisodeSelected(tvshowId, tag.episodeId);
            return true;
        }
    });

    // Configure the adapter and start the loader
    adapter = new SeasonsEpisodesAdapter(getActivity());
    getLoaderManager().initLoader(LOADER_SEASONS, null, this);
    seasonsEpisodesListView.setAdapter(adapter);

    setHasOptionsMenu(true);
}

From source file:org.xbmc.kore.ui.TVShowEpisodeListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    seasonsEpisodesListView.setEmptyView(emptyView);
    seasonsEpisodesListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override//from w ww .ja va 2s  .  c o m
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (parent.isGroupExpanded(groupPosition)) {
                parent.collapseGroup(groupPosition);
                groupsExpanded.remove(groupPosition);
            } else {
                parent.expandGroup(groupPosition);
                groupsExpanded.put(groupPosition, true);
            }
            return true;
        }
    });
    seasonsEpisodesListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            // Get the movie id from the tag
            EpisodeViewHolder tag = (EpisodeViewHolder) v.getTag();
            // Notify the activity
            listenerActivity.onEpisodeSelected(tvshowId, tag.episodeId);
            return true;
        }
    });

    setHasOptionsMenu(true);

    if (savedInstanceState != null) {
        listPosition = savedInstanceState.getInt(BUNDLE_SAVEDINSTANCE_LISTPOSITION, 0);
        itemPosition = savedInstanceState.getInt(BUNDLE_SAVEDINSTANCE_ITEMPOSITION, 0);
        groupsExpanded = (HashMap) savedInstanceState.getSerializable(BUNDLE_SAVEDINSTANCE_GROUPSEXPANDED);
        isReturning = true;
    }

    initLoader();
}

From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java

private void setListViewHeight(ExpandableListView listView, int group) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (mDefaultHeight == 0)
        mDefaultHeight = listView.getHeight();
    int totalHeight = 0;

    int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.EXACTLY);
    for (int i = 0; i < listAdapter.getGroupCount(); i++) {
        if (((listView.isGroupExpanded(i)) && (i != group))
                || ((!listView.isGroupExpanded(i)) && (i == group))) {
            for (int j = 0; j < listAdapter.getChildrenCount(i); j++) {
                View listItem = listAdapter.getChildView(i, j, false, null, listView);
                listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
                totalHeight += listItem.getMeasuredHeight();
            }// w ww.j  av  a 2s  . c o  m
            totalHeight += mDefaultHeight;
        }
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    int height = totalHeight + (listView.getDividerHeight() * (listAdapter.getGroupCount() - 1));
    if (height < mDefaultHeight)
        height = mDefaultHeight;
    params.height = height;
    listView.setLayoutParams(params);
    listView.requestLayout();
}

From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java

private void selectGroup(ExpandableListView parent, int groupPosition, boolean simulateChildClick) {
    QueryType queryType = null;/*  w  ww.  j  a  va  2  s . com*/
    String subTitle = null;

    switch (groupPosition) {
    case DrawerListAdapter.ALL_GROUP:
        // selected all group item
        queryType = new QueryType(QueryMode.All);
        subTitle = (String) mDrawerAdapter.getGroup(groupPosition);
        break;
    case DrawerListAdapter.FAVORITES_GROUP:
        // selected favorite group item
        queryType = new QueryType(QueryMode.Favorites);
        subTitle = (String) mDrawerAdapter.getGroup(groupPosition);
        break;
    case DrawerListAdapter.CITIES_GROUP:
    case DrawerListAdapter.ROUTES_GROUP:
        // selected routes group item
        if (parent.isGroupExpanded(groupPosition)) {
            parent.collapseGroup(groupPosition);
        } else {
            parent.expandGroup(groupPosition);
        }
        setCurrentGroup(groupPosition);
        if (simulateChildClick) {
            selectCamera(getCurrentChild());
        }
        break;
    case DrawerListAdapter.NEAR_ME_GROUP:
        // selected favorite group item
        queryType = new QueryType(QueryMode.NearMe);
        subTitle = (String) mDrawerAdapter.getGroup(groupPosition);
        break;
    }

    if (queryType != null) {
        mFragment.getCameras(queryType);
        mDrawerLayout.closeDrawer(mDrawerList);
        mActionBar.setSubtitle(subTitle);
        setCurrentGroup(groupPosition);
    }
}

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

private void populateAdapter(ArrayList<PkgListItem> paramArrayList, Comparator<PkgListItem> paramComparator) {
      if ((paramArrayList == null) || (paramArrayList.size() == 0)) {
          lv.invalidate();//  www .j av  a  2 s.c om
          if (menu_adapter == null) {
              menu_adapter = new MenuItemAdapter(getContext(), getConfig().getInt("viewsize", 0),
                      new ArrayList());
          }
          menu_lv.invalidate();
          menu_lv.setGroupIndicator(null);
          menu_lv.setAdapter(menu_adapter);
          menu_lv.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
              public boolean onGroupClick(ExpandableListView paramAnonymousExpandableListView,
                      View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong) {
                  paramAnonymousExpandableListView = listAppsFragment.menu_adapter.getGroup(paramAnonymousInt);
                  if ((paramAnonymousExpandableListView.childs.size() == 0)
                          || (paramAnonymousExpandableListView.type == 1)) {
                      switch (paramAnonymousExpandableListView.type) {
                      default:
                          listAppsFragment.this.runId(paramAnonymousExpandableListView.punkt_menu);
                      case 1:
                      case 2:
                          do {
                              return true;
                              switch (paramAnonymousExpandableListView.punkt_menu) {
                              default:
                                  return true;
                              case 2131165190:
                                  listAppsFragment.this.showAbout();
                                  return true;
                              case 2131165509:
                                  listAppsFragment.this.selectLanguage();
                                  return true;
                              case 2131165411:
                                  listAppsFragment.this.changeDefaultDir();
                                  return true;
                              case 2131165483:
                                  paramAnonymousExpandableListView = new Intent(listAppsFragment.patchAct,
                                          HelpActivity.class);
                                  listAppsFragment.this.startActivity(paramAnonymousExpandableListView);
                                  return true;
                              }
                          } while (listAppsFragment.frag == null);
                          listAppsFragment.this.runUpdate();
                          return true;
                          listAppsFragment.this.sendLog();
                          return true;
                          listAppsFragment.this.changeDayOnUp();
                          return true;
                      }
                      listAppsFragment.this.runToMain(paramAnonymousExpandableListView.runCode);
                      return true;
                  }
                  return false;
              }
          });
          menu_lv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
              public boolean onChildClick(ExpandableListView paramAnonymousExpandableListView,
                      View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2,
                      long paramAnonymousLong) {
                  paramAnonymousInt1 = ((Integer) listAppsFragment.menu_adapter
                          .getGroup(paramAnonymousInt1).childs.get(paramAnonymousInt2)).intValue();
                  listAppsFragment.this.runId(paramAnonymousInt1);
                  return false;
              }
          });
          return;
      }
      Collections.sort(paramArrayList, paramComparator);
      if (getConfig().getBoolean("no_icon", false)) {
      }
      for (int i = 2130968628;; i = 2130968627) {
          plia = new PkgListItemAdapter(getContext(), i, getConfig().getInt("viewsize", 0), paramArrayList);
          adapter_boot = new BootListItemAdapter(getContext(), 2130968593, getConfig().getInt("viewsize", 0),
                  boot_pat);
          plia.sorter = paramComparator;
          removeDialogLP(3);
          lv.invalidate();
          lv.setAdapter(plia);
          lv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
              public boolean onChildClick(ExpandableListView paramAnonymousExpandableListView,
                      View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2,
                      long paramAnonymousLong) {
                  if (listAppsFragment.getConfig().getBoolean("vibration", false)) {
                      listAppsFragment.this.vib = ((Vibrator) listAppsFragment.this.getContext()
                              .getSystemService("vibrator"));
                      listAppsFragment.this.vib.vibrate(50L);
                  }
                  listAppsFragment.pli = listAppsFragment.plia.getItem(paramAnonymousInt1);
                  switch (listAppsFragment.plia.getChild(paramAnonymousInt1, paramAnonymousInt2).intValue()) {
                  default:
                      return false;
                  case 2131165322:
                      listAppsFragment.this.launch_click();
                      return false;
                  case 2131165197:
                      listAppsFragment.this.contextmenu_click();
                      return false;
                  case 2131165288:
                      listAppsFragment.this.contextmenutools_click();
                      return false;
                  case 2131165731:
                      listAppsFragment.this.uninstall_click();
                      return false;
                  case 2131165253:
                      listAppsFragment.this.cleardata_click();
                      return false;
                  case 2131165556:
                      listAppsFragment.this.move_to_sdcard_click();
                      return false;
                  case 2131165554:
                      listAppsFragment.this.move_to_internal_memory_click();
                      return false;
                  case 2131165206:
                      listAppsFragment.this.show_app_manager_click();
                      return false;
                  }
                  listAppsFragment.plia.updateItem(listAppsFragment.pli.pkgName);
                  listAppsFragment.plia.notifyDataSetChanged(listAppsFragment.plia.getItem(paramAnonymousInt1));
                  listAppsFragment.removeDialogLP(6);
                  listAppsFragment.showDialogLP(6);
                  return false;
              }
          });
          lv.setDividerHeight(2);
          lv.setGroupIndicator(null);
          lv.setClickable(true);
          lv.setLongClickable(true);
          lv.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
              public void onGroupExpand(int paramAnonymousInt) {
              }
          });
          lv.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
              public boolean onGroupClick(ExpandableListView paramAnonymousExpandableListView,
                      View paramAnonymousView, final int paramAnonymousInt, long paramAnonymousLong) {
                  System.out.println(paramAnonymousExpandableListView.getItemAtPosition(paramAnonymousInt));
                  System.out.println(paramAnonymousInt);
                  listAppsFragment.pli = listAppsFragment.plia.getItem(paramAnonymousInt);
                  listAppsFragment.createExpandMenu();
                  if (paramAnonymousExpandableListView.isGroupExpanded(paramAnonymousInt)) {
                      paramAnonymousExpandableListView.collapseGroup(paramAnonymousInt);
                  }
                  for (;;) {
                      return true;
                      paramAnonymousExpandableListView.expandGroup(paramAnonymousInt);
                      if (listAppsFragment.api > 7) {
                          paramAnonymousExpandableListView.smoothScrollToPosition(paramAnonymousInt);
                      } else {
                          listAppsFragment.lv.clearFocus();
                          listAppsFragment.lv.post(new Runnable() {
                              public void run() {
                                  listAppsFragment.lv.setSelection(paramAnonymousInt);
                              }
                          });
                      }
                  }
              }
          });
          lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
              public boolean onItemLongClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView,
                      int paramAnonymousInt, long paramAnonymousLong) {
                  if (listAppsFragment.getConfig().getBoolean("vibration", false)) {
                      listAppsFragment.this.vib = ((Vibrator) listAppsFragment.this.getContext()
                              .getSystemService("vibrator"));
                      listAppsFragment.this.vib.vibrate(50L);
                  }
                  try {
                      listAppsFragment.pli = (PkgListItem) paramAnonymousAdapterView
                              .getItemAtPosition(paramAnonymousInt);
                      listAppsFragment.this.contextlevel0();
                      return false;
                  } catch (Exception paramAnonymousAdapterView) {
                      System.out.println("LuckyPatcher (Context menu long click): " + paramAnonymousAdapterView);
                      paramAnonymousAdapterView.printStackTrace();
                  }
                  return false;
              }
          });
          break;
      }
  }