MiniumApps/launcher3/src/main/java/co/siempo/phone/activities/JunkfoodFlaggingActivity.java
/**
     * show pop dialog on List item click for flag/un-flag and application information.
     *
     * @param view
     * @param packagename
     * @param isFlagApp
     */
show pop dialog on List item click for flag/un-flag and application information.
show pop dialog on List item click for flag / un - flag and application information .
public void showPopUp(final View view, final String packagename, final
    boolean isFlagApp) {
        positionPopUP = 0;
        for (int i = 0; i < bindingList.size(); i++) {
            if (bindingList.get(i).packageName.equalsIgnoreCase(packagename)) {
                positionPopUP = i;
                break;
            }
        }
        if (popup != null) {
            popup.dismiss();
        }
        popup = new PopupMenu(JunkfoodFlaggingActivity.this, view, Gravity.END);
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                if (item.getItemId() == R.id.item_Unflag) {
                    try {
                        if (isLoadFirstTime && isFlagApp) {
                            showAlertForFirstTime(positionPopUP, view);
                        } else {
                            popup.dismiss();
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    showEmptyRowBeforeDelete(view);
                                    Handler handler = new Handler();
                                    handler.postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (adapterlist.contains
                                                    (packagename)) {
                                                adapterlist.remove(packagename);
                                            } else {
                                                adapterlist.add(packagename);
                                            }
                                            firstPosition = listAllApps.getFirstVisiblePosition();
                                            new FilterApps().execute();
                                            listAllApps.setEnabled(true);
                                            listAllApps.setClickable(true);
                                        }
                                    }, 300);
                                }
                            });
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else if (item.getItemId() == R.id.item_Info) {
                    try {
                        PackageUtil.appSettings(JunkfoodFlaggingActivity.this, packagename);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                return false;
            }
        });
        popup.getMenuInflater().inflate(R.menu.junkfood_popup, popup.getMenu());
        MenuItem menuItem = popup.getMenu().findItem(R.id.item_Unflag);
        menuItem.setTitle(adapterlist.contains(packagename) ? getString(R.string.unflagapp) : getString(R.string.flag_app));
        popup.show();
        popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
            @Override
            public void onDismiss(PopupMenu menu) {
                popup = null;
            }
        });
    }
public void showPopUp ( final View view , final String packagename , final boolean isFlagApp ) { positionPopUP = 0 ; for ( int i = 0 ; i < bindingList . size ( ) ; i ++ ) { if ( bindingList . get ( i ) . packageName . equalsIgnoreCase ( packagename ) ) { positionPopUP = i ; break ; } } if ( popup != null ) { popup . dismiss ( ) ; } popup = new PopupMenu ( JunkfoodFlaggingActivity . this , view , Gravity . END ) ; popup . setOnMenuItemClickListener ( new PopupMenu . OnMenuItemClickListener ( ) { @ Override public boolean onMenuItemClick ( MenuItem item ) { if ( item . getItemId ( ) == R . id . item_Unflag ) { try { if ( isLoadFirstTime && isFlagApp ) { showAlertForFirstTime ( positionPopUP , view ) ; } else { popup . dismiss ( ) ; runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { showEmptyRowBeforeDelete ( view ) ; Handler handler = new Handler ( ) ; handler . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { if ( adapterlist . contains ( packagename ) ) { adapterlist . remove ( packagename ) ; } else { adapterlist . add ( packagename ) ; } firstPosition = listAllApps . getFirstVisiblePosition ( ) ; new FilterApps ( ) . execute ( ) ; listAllApps . setEnabled ( true ) ; listAllApps . setClickable ( true ) ; } } , 300 ) ; } } ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } } else if ( item . getItemId ( ) == R . id . item_Info ) { try { PackageUtil . appSettings ( JunkfoodFlaggingActivity . this , packagename ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return false ; } } ) ; popup . getMenuInflater ( ) . inflate ( R . menu . junkfood_popup , popup . getMenu ( ) ) ; MenuItem menuItem = popup . getMenu ( ) . findItem ( R . id . item_Unflag ) ; menuItem . setTitle ( adapterlist . contains ( packagename ) ? getString ( R . string . unflagapp ) : getString ( R . string . flag_app ) ) ; popup . show ( ) ; popup . setOnDismissListener ( new PopupMenu . OnDismissListener ( ) { @ Override public void onDismiss ( PopupMenu menu ) { popup = null ; } } ) ; }
show pop dialog on List item click for flag/un-flag and application information.
show pop dialog on List item click for flag / un - flag and application information .