Example usage for android.widget ExpandableListView setAdapter

List of usage examples for android.widget ExpandableListView setAdapter

Introduction

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

Prototype

public void setAdapter(ExpandableListAdapter adapter) 

Source Link

Document

Sets the adapter that provides data to this view.

Usage

From source file:com.arcusapp.soundbox.fragment.ArtistsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_artists, container, false);

    ExpandableListView myExpandableList = (ExpandableListView) rootView
            .findViewById(R.id.expandableListArtists);
    myExpandableList.setGroupIndicator(null);

    myExpandableList.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override//w  ww . j a v a 2  s .  c  om
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
                int groupPosition = ExpandableListView.getPackedPositionGroup(id);
                myAdapter.onArtistLongClick(groupPosition);
                return true;
            } else if (ExpandableListView
                    .getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                int groupPosition = ExpandableListView.getPackedPositionGroup(id);
                int childPosition = ExpandableListView.getPackedPositionChild(id);
                myAdapter.onAlbumLongClick(groupPosition, childPosition);
                return true;
            }
            return false;
        }
    });

    myExpandableList.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            myAdapter.onAlbumClick(groupPosition, childPosition);
            return false;
        }
    });

    myExpandableList.setAdapter(myAdapter);
    return rootView;
}

From source file:info.staticfree.android.units.Units.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_ABOUT: {
        final Builder builder = new AlertDialog.Builder(this);

        builder.setTitle(R.string.dialog_about_title);
        builder.setIcon(R.drawable.icon);

        try {//  w w w.j ava  2  s.com
            final WebView wv = new WebView(this);
            final InputStream is = getAssets().open("README.xhtml");
            wv.loadDataWithBaseURL("file:///android_asset/", inputStreamToString(is), "application/xhtml+xml",
                    "utf-8", null);
            wv.setBackgroundColor(0);
            builder.setView(wv);
        } catch (final IOException e) {
            builder.setMessage(R.string.err_no_load_about);
            e.printStackTrace();
        }

        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                setResult(RESULT_OK);
            }
        });
        return builder.create();
    }

    case DIALOG_ALL_UNITS: {
        final Builder b = new Builder(Units.this);
        b.setTitle(R.string.dialog_all_units_title);
        final ExpandableListView unitExpandList = new ExpandableListView(Units.this);
        unitExpandList.setId(android.R.id.list);
        final String[] groupProjection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT };
        // any selection below will select from the grouping description
        final Cursor cursor = managedQuery(UsageEntry.CONTENT_URI_CONFORM_TOP, groupProjection, null, null,
                UnitUsageDBHelper.USAGE_SORT);

        unitExpandList.setAdapter(new UnitsExpandableListAdapter(cursor, this,
                android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1,
                new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 },
                new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 }));
        unitExpandList.setCacheColorHint(0);
        unitExpandList.setOnChildClickListener(allUnitChildClickListener);
        b.setView(unitExpandList);
        return b.create();
    }

    case DIALOG_UNIT_CATEGORY: {
        final Builder b = new Builder(new ContextThemeWrapper(this, android.R.style.Theme_Black));
        final String[] from = { UsageEntry._UNIT };
        final int[] to = { android.R.id.text1 };
        b.setTitle("all units");
        final String[] projection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT };
        final Cursor c = managedQuery(UsageEntry.CONTENT_URI, projection, null, null,
                UnitUsageDBHelper.USAGE_SORT);
        dialogUnitCategoryList = new SimpleCursorAdapter(this, android.R.layout.select_dialog_item, c, from,
                to);
        b.setAdapter(dialogUnitCategoryList, dialogUnitCategoryOnClickListener);

        return b.create();
    }

    case DIALOG_LOADING_UNITS: {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setIndeterminate(true);
        pd.setTitle(R.string.app_name);
        pd.setMessage(getText(R.string.dialog_loading_units));
        return pd;
    }

    default:
        throw new IllegalArgumentException("Unknown dialog ID:" + id);
    }
}

From source file:com.money.manager.ex.home.MainActivity.java

private void createExpandableDrawer() {
    UIHelper uiHelper = new UIHelper(this);
    int iconColor = uiHelper.getSecondaryTextColor();

    // Menu.//from   ww w.j  av a2s  . co m

    final ArrayList<DrawerMenuItem> groupItems = getDrawerMenuItems();
    final ArrayList<Object> childItems = new ArrayList<>();

    // Home
    childItems.add(null);

    // Open Database. Display the recent db list.
    ArrayList<DrawerMenuItem> childDatabases = getRecentDatabasesDrawerMenuItems();
    childItems.add(childDatabases);

    // Synchronization
    if (new SyncManager(this).isActive()) {
        childItems.add(null);
    }

    // Entities
    ArrayList<DrawerMenuItem> childTools = new ArrayList<>();
    // manage: account
    childTools.add(new DrawerMenuItem().withId(R.id.menu_account).withText(getString(R.string.accounts))
            .withIconDrawable(uiHelper.getIcon(MMXIconFont.Icon.mmx_temple).color(iconColor)));
    // manage: categories
    childTools.add(new DrawerMenuItem().withId(R.id.menu_category).withText(getString(R.string.categories))
            .withIconDrawable(uiHelper.getIcon(MMXIconFont.Icon.mmx_tag_empty).color(iconColor)));
    // manage: currencies
    childTools.add(new DrawerMenuItem().withId(R.id.menu_currency).withText(getString(R.string.currencies))
            .withIconDrawable(uiHelper.getIcon(GoogleMaterial.Icon.gmd_euro_symbol).color(iconColor)));
    // manage: payees
    childTools.add(new DrawerMenuItem().withId(R.id.menu_payee).withText(getString(R.string.payees))
            .withIconDrawable(uiHelper.getIcon(GoogleMaterial.Icon.gmd_group).color(iconColor)));
    childItems.add(childTools);

    // Recurring Transactions
    childItems.add(null);

    // Budgets
    childItems.add(null);

    // Asset Allocation
    //if (BuildConfig.DEBUG) <- this was used to hide the menu item while testing.
    childItems.add(null);

    // Search transaction
    childItems.add(null);

    // reports
    childItems.add(null);

    // Settings
    childItems.add(null);

    // Donate
    childItems.add(null);

    // Help
    childItems.add(null);

    // Adapter.
    final ExpandableListView drawerList = (ExpandableListView) findViewById(R.id.drawerExpandableList);
    DrawerMenuGroupAdapter adapter = new DrawerMenuGroupAdapter(this, groupItems, childItems);
    drawerList.setAdapter(adapter);

    // set listener on item click
    drawerList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (mDrawer == null)
                return false;
            // if the group has child items, do not e.
            ArrayList<String> children = (ArrayList<String>) childItems.get(groupPosition);
            if (children != null)
                return false;

            // Highlight the selected item, update the title, and close the drawer
            drawerList.setItemChecked(groupPosition, true);

            // You should reset item counter
            mDrawer.closeDrawer(mDrawerLayout);
            // check item selected
            final DrawerMenuItem item = (DrawerMenuItem) drawerList.getExpandableListAdapter()
                    .getGroup(groupPosition);
            if (item != null) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        // execute operation
                        onDrawerMenuAndOptionMenuSelected(item);
                    }
                }, 200);
            }
            return true;
        }
    });

    drawerList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            if (mDrawer == null)
                return false;

            mDrawer.closeDrawer(mDrawerLayout);

            ArrayList<Object> children = (ArrayList) childItems.get(groupPosition);
            final DrawerMenuItem selectedItem = (DrawerMenuItem) children.get(childPosition);
            if (selectedItem != null) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        onDrawerMenuAndOptionMenuSelected(selectedItem);
                    }
                }, 200);
                return true;
            } else {
                return false;
            }
        }
    });
}

From source file:com.norman0406.slimgress.FragmentInventory.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_inventory, container, false);

    final ExpandableListView list = (ExpandableListView) rootView.findViewById(R.id.listView);
    final ProgressBar progress = (ProgressBar) rootView.findViewById(R.id.progressBar1);

    list.setVisibility(View.INVISIBLE);
    progress.setVisibility(View.VISIBLE);

    // create group names
    mGroupNames = new ArrayList<String>();
    mGroups = new ArrayList<Object>();

    mGroupMedia = new ArrayList<String>();
    mGroupMods = new ArrayList<String>();
    mGroupPortalKeys = new ArrayList<String>();
    mGroupPowerCubes = new ArrayList<String>();
    mGroupResonators = new ArrayList<String>();
    mGroupWeapons = new ArrayList<String>();

    final FragmentInventory thisObject = this;

    final Handler handler = new Handler();

    mGame.intGetInventory(new Handler(new Handler.Callback() {
        @Override//ww w .  ja  v a2s . c o  m
        public boolean handleMessage(Message msg) {
            fillInventory(new Runnable() {
                @Override
                public void run() {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            InventoryList inventoryList = new InventoryList(mGroupNames, mGroups);
                            inventoryList.setInflater(inflater, thisObject.getActivity());
                            list.setAdapter(inventoryList);
                            list.setOnChildClickListener(thisObject);

                            list.setVisibility(View.VISIBLE);
                            progress.setVisibility(View.INVISIBLE);
                        }
                    });
                }
            });
            return true;
        }
    }));

    return rootView;
}

From source file:org.anurag.file.quest.FileQuestHD.java

private void init_drawer_menu() {
    // TODO Auto-generated method stub
    ExpandableListView drLs = (ExpandableListView) drawer.findViewById(R.id.drawer_menu_list);
    drLs.setAdapter(new drAdpt());
    drLs.setSelector(R.drawable.while_list_selector_hd);

    drLs.setOnGroupClickListener(new OnGroupClickListener() {
        @Override/*from  ww  w  . j a va 2s .c o  m*/
        public boolean onGroupClick(ExpandableListView arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            switch (arg2) {
            case 0:
                Intent intent = new Intent(FileQuestHD.this, GraphAnalysis.class);
                startActivity(intent);
                break;

            case 5:
                //checks the new update for file quest....
                update_checker();
                break;
            }
            return false;
        }
    });

    drLs.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2, int arg3, long arg4) {
            // TODO Auto-generated method stub
            String type = null;
            int tweakwhat = 0;
            switch (arg3) {
            case 0:
                tweakwhat = 0;
                type = " favorite ";
                break;

            case 1:
                tweakwhat = 1;
                type = " music ";
                break;

            case 2:
                tweakwhat = 2;
                type = " apps ";
                break;

            case 3:
                tweakwhat = 3;
                type = " photos ";
                break;

            case 4:
                tweakwhat = 4;
                type = " videos ";
                break;

            case 5:
                tweakwhat = 5;
                type = " documents ";
                break;

            case 6:
                tweakwhat = 6;
                type = " archives ";
                break;

            case 7:
                tweakwhat = 7;
                type = " unknown ";
                break;
            }

            new ConfirmTweakTask(FileQuestHD.this, arg2, type, tweakwhat);

            return false;
        }
    });
}

From source file:org.mixare.MixListView.java

public void loadStopDetailsDialog(String title, StopMarker stop) {
    Dialog d = new Dialog(this) {
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK)
                this.dismiss();
            return true;
        }/*w ww  .  j  a  v  a2s . co m*/
    };

    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.getWindow().setGravity(Gravity.CENTER);
    d.setContentView(R.layout.stopdetailsdialog);

    TextView titleView = (TextView) d.findViewById(R.id.stopDetailDialogTitle);
    titleView.setText(title);

    ExpandableListView list = (ExpandableListView) d.findViewById(R.id.stopDetailDialogRouteList);

    final Button button = (Button) d.findViewById(R.id.stopWalkRouteButton);
    final double longitude = stop.getLongitude();
    final double latitude = stop.getLatitude();

    final Location start = mixContext.getCurrentLocation();

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent mapIntent = new Intent(org.mixare.maps.HelloGoogleMapsActivity.class.getName());
            mapIntent.putExtra("startLocation", start);
            mapIntent.putExtra("destLat", latitude);
            mapIntent.putExtra("destLong", longitude);

            startActivity(mapIntent);
        }
    });

    List<Map<String, ?>> groupMaps = stop.getRouteList();
    List<List<Map<String, ?>>> childMaps = stop.getRouteSubdataList();

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, groupMaps,
            R.layout.stopdetailsdialogitemroute, new String[] { "id", "name" },
            new int[] { R.id.routeNumber, R.id.routeName }, childMaps, R.layout.stopdetailsdialogroutevariation,
            new String[] { "direction", "name", "times" },
            new int[] { R.id.routeVariationDirection, R.id.routeVariationName, R.id.routeVariationTimes });

    list.setAdapter(adapter);

    d.show();

    new StopTimesTask(adapter, stop).execute(groupMaps, childMaps);
}

From source file:com.huishen.edrive.center.CoachMealListFragment.java

public void setList(String data, ExpandableListView list) {
    if (loading.getVisibility() == View.VISIBLE) {
        loading.setVisibility(View.GONE);
    }/*from w  w w  . j  a v a 2s.  c o  m*/
    //
    mGroupData = new ArrayList<HashMap<String, String>>();
    mData = new ArrayList<ArrayList<String>>();
    try {
        //[{"carTypeContent":"","cash":50,"cohId":1,"content":"?",
        //            "createDate":"2015-03-01","id":1,"schoolId":1,"title":"","type":2},
        //         {"carTypeContent":"?","cash":50,"cohId":1,"content":"??","createDate":"2015-03-18",
        //         "id":2,"schoolId":1,"title":"?","type":2}]
        JSONArray array = new JSONArray(data);
        for (int i = 0; i < array.length(); i++) {
            JSONObject json = array.getJSONObject(i);
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("mealname", json.optString(SRL.ReturnField.COACH_MEAL_TITLE, ""));
            map.put("mealprize", json.optString(SRL.ReturnField.COACH_MEAL_PRIZE, ""));
            mGroupData.add(map);
            ArrayList<String> childmap = new ArrayList<String>();
            childmap.add("???"
                    + json.optString(SRL.ReturnField.COACH_MEAL_CONTENT, ""));
            childmap.add("" + json.optString(SRL.ReturnField.COACH_MEAL_CARTYPE, ""));
            childmap.add("?        " + json.optString(SRL.ReturnField.COACH_MEAL_CLASSTYPE, ""));
            childmap.add("" + json.optString(SRL.ReturnField.COACH_MEAL_LICENSETYPE, ""));
            mData.add(childmap);
        }

        CoachMealListExpandAdapter judgeAdapter = new CoachMealListExpandAdapter(this.getActivity(), mGroupData,
                mData);
        list.setAdapter(judgeAdapter);
        if (mGroupData.size() > 0) {
            list.expandGroup(0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.benefit.buy.library.http.query.AbstractAQuery.java

/**
 * Set the adapter of an ExpandableListView.
 * @param adapter adapter//from   w ww  . j ava 2s  . c om
 * @return self
 */
public T adapter(ExpandableListAdapter adapter) {
    if (view instanceof ExpandableListView) {
        ExpandableListView av = (ExpandableListView) view;
        av.setAdapter(adapter);
    }
    return self();
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final int userId = Util.getUserId(Process.myUid());

    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;/* w ww  . j  a  v a  2  s .co  m*/

    // Set layout
    setContentView(R.layout.restrictionlist);

    // Get arguments
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }

    int uid = extras.getInt(cUid);
    String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null);
    String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null);

    // Get app info
    mAppInfo = new ApplicationInfoEx(this, uid);
    if (mAppInfo.getPackageName().size() == 0) {
        finish();
        return;
    }

    // Set title
    setTitle(String.format("%s - %s", getString(R.string.app_name),
            TextUtils.join(", ", mAppInfo.getApplicationName())));

    // Handle info click
    ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo);
    imgInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Packages can be selected on the web site
            Util.viewUri(ActivityApp.this,
                    Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s",
                            mAppInfo.getPackageName().get(0))));
        }
    });

    // Display app name
    TextView tvAppName = (TextView) findViewById(R.id.tvApp);
    tvAppName.setText(mAppInfo.toString());

    // Background color
    if (mAppInfo.isSystem()) {
        LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo);
        llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
    }

    // Display app icon
    final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon);
    imgIcon.setImageDrawable(mAppInfo.getIcon(this));

    // Handle icon click
    imgIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openContextMenu(imgIcon);
        }
    });

    // Display on-demand state
    final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand);
    if (PrivacyManager.isApplication(mAppInfo.getUid())
            && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) {
        boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                false);
        imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());

        imgCbOnDemand.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(),
                        PrivacyManager.cSettingOnDemand, false);
                PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                        Boolean.toString(ondemand));
                imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());
                if (mPrivacyListAdapter != null)
                    mPrivacyListAdapter.notifyDataSetChanged();
            }
        });
    } else
        imgCbOnDemand.setVisibility(View.GONE);

    // Display restriction state
    swEnabled = (Switch) findViewById(R.id.swEnable);
    swEnabled.setChecked(
            PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true));
    swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted,
                    Boolean.toString(isChecked));
            if (mPrivacyListAdapter != null)
                mPrivacyListAdapter.notifyDataSetChanged();
            imgCbOnDemand.setEnabled(isChecked);
        }
    });
    imgCbOnDemand.setEnabled(swEnabled.isChecked());

    // Add context menu to icon
    registerForContextMenu(imgIcon);

    // Check if internet access
    if (!mAppInfo.hasInternet(this)) {
        ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet);
        imgInternet.setVisibility(View.INVISIBLE);
    }

    // Check if frozen
    if (!mAppInfo.isFrozen(this)) {
        ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen);
        imgFrozen.setVisibility(View.INVISIBLE);
    }

    // Display version
    TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
    tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this)));

    // Display package name
    TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName);
    tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName()));

    // Fill privacy list view adapter
    final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction);
    lvRestriction.setGroupIndicator(null);
    mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName,
            methodName);
    lvRestriction.setAdapter(mPrivacyListAdapter);
    if (restrictionName != null) {
        int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values())
                .indexOf(restrictionName);
        lvRestriction.expandGroup(groupPosition);
        lvRestriction.setSelectedGroup(groupPosition);
        if (methodName != null) {
            int childPosition = PrivacyManager.getHooks(restrictionName)
                    .indexOf(new Hook(restrictionName, methodName));
            lvRestriction.setSelectedChild(groupPosition, childPosition, true);
        }
    }

    // Listen for package add/remove
    IntentFilter iff = new IntentFilter();
    iff.addAction(Intent.ACTION_PACKAGE_REMOVED);
    iff.addDataScheme("package");
    registerReceiver(mPackageChangeReceiver, iff);
    mPackageChangeReceiverRegistered = true;

    // Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // Tutorial
    if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) {
        ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
        ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
    }
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewParent parent = view.getParent();
            while (!parent.getClass().equals(ScrollView.class))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString());
        }
    };
    ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener);
    ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener);

    // Process actions
    if (extras.containsKey(cAction)) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(mAppInfo.getUid());
        if (extras.getInt(cAction) == cActionClear)
            optionClear();
        else if (extras.getInt(cAction) == cActionSettings)
            optionSettings();
    }

    // Annotate
    Meta.annotate(this);
}

From source file:org.ale.scanner.zotero.MainActivity.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.main);/*from   w w  w .  j  a  va2  s .  c om*/
    Bundle extras = getIntent().getExtras();

    mUIThreadHandler = new Handler();

    // Get the account we're logged in as
    mAccount = (Account) extras.getParcelable(INTENT_EXTRA_ACCOUNT);

    // Load preferences
    SharedPreferences prefs = getSharedPreferences(mAccount.getUid(), MODE_PRIVATE);
    // The group we'll upload to (default to user's personal library)
    mSelectedGroup = prefs.getInt(PREF_GROUP, Group.GROUP_LIBRARY);
    mISBNService = prefs.getInt(PREF_SERVICE, SERVICE_GOOGLE);

    // Initialize Clients
    mGoogleBooksAPI = new GoogleBooksAPIClient();
    mWorldCatAPI = new WorldCatAPIClient();
    mZAPI = new ZoteroAPIClient();
    mZAPI.setAccount(mAccount);

    // BibItem list
    ExpandableListView bibItemList = (ExpandableListView) findViewById(R.id.bib_items);

    // Pending item list
    View pendingListHolder = getLayoutInflater().inflate(R.layout.pending_item_list, bibItemList, false);
    bibItemList.addHeaderView(pendingListHolder);

    mPendingList = (ListView) pendingListHolder.findViewById(R.id.pending_item_list);

    int[] checked;
    if (state == null) { // Fresh activity
        mAccountAccess = null; // will check for permissions in onResume
        mPendingItems = new ArrayList<String>(2); // RC_PEND
        mPendingStatus = new ArrayList<Integer>(2); // RC_PEND_STAT
        checked = new int[0];
        mUploadState = UPLOAD_STATE_WAIT;
        mGroups = new SparseArray<PString>();
    } else { // Recreating activity
             // Rebuild pending list
        mAccountAccess = state.getParcelable(RC_ACCESS);
        mPendingItems = state.getStringArrayList(RC_PEND);
        mPendingStatus = state.getIntegerArrayList(RC_PEND_STAT);
        // Set checked items
        checked = state.getIntArray(RC_CHECKED);

        mUploadState = state.getInt(RC_UPLOADING);
        mGroups = state.getSparseParcelableArray(RC_GROUPS);
    }

    // Initialize list adapters
    mItemAdapter = new BibItemListAdapter(MainActivity.this);
    mItemAdapter.setChecked(checked);
    bibItemList.setAdapter(mItemAdapter);
    registerForContextMenu(bibItemList);

    mPendingAdapter = new PendingListAdapter(MainActivity.this, R.layout.pending_item, R.id.pending_item_id,
            mPendingItems, mPendingStatus);
    mPendingList.setAdapter(mPendingAdapter);
    registerForContextMenu(mPendingList);

    // Listeners
    findViewById(R.id.scan_isbn).setOnClickListener(scanIsbn);
    findViewById(R.id.upload).setOnClickListener(uploadSelected);

    // Load animations
    mAnimations = new Animation[] { AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_in_next),
            AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_out_next),
            AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_in_previous),
            AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_out_previous) };

    // Upload Bar
    findViewById(R.id.upload_progress).setOnClickListener(dismissUploadStatus);
}