MiniumApps/launcher3/src/main/java/co/siempo/phone/activities/JunkfoodFlaggingActivity.java
/**
     * Show save dialog for saving the user filter data.
     */
Show save dialog for saving the user filter data.
Show save dialog for saving the user filter data .
private void showSaveDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(JunkfoodFlaggingActivity.this);
        builder.setTitle(getString(R.string.msg_congratulations));
        builder.setMessage(R.string.msg_flage_save_dialog);
        builder.setPositiveButton(R.string.strcontinue, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        favoriteList.removeAll(adapterlist);
                        getToolsAppList().removeAll(adapterlist);
                        HashMap<Integer, AppMenu> newMap = CoreApplication.getInstance().getToolsSettings();
                        for(int i=0;i<newMap.size();i++){
                            if(newMap!=null && newMap.get(i)!=null && !TextUtils.isEmpty(newMap.get(i).getApplicationName())){
                                if(adapterlist.contains(newMap.get(i).getApplicationName())){
                                    newMap.get(i).setApplicationName("");
                                }
                            }
                        }
                        String hashMapToolSettings = new Gson().toJson(newMap);
                        PrefSiempo.getInstance(JunkfoodFlaggingActivity.this).write(PrefSiempo.TOOLS_SETTING, hashMapToolSettings);
                        PrefSiempo.getInstance(JunkfoodFlaggingActivity.this).write(PrefSiempo.FAVORITE_APPS, favoriteList);
                        PrefSiempo.getInstance(JunkfoodFlaggingActivity.this).write
                                (PrefSiempo.JUNKFOOD_APPS, adapterlist);
                        if (adapterlist.size() == 0 && !DashboardActivity.isJunkFoodOpen) {
                            DashboardActivity.isJunkFoodOpen = true;
                        }
                        new LoadFavoritePane(PrefSiempo.getInstance(JunkfoodFlaggingActivity.this)).execute();
                        new LoadJunkFoodPane(PrefSiempo.getInstance(JunkfoodFlaggingActivity.this)).execute();
                        new LoadToolPane().execute();
                        EventBus.getDefault().postSticky(new NotifySearchRefresh(true));
                        FirebaseHelper.getInstance().logScreenUsageTime(this.getClass().getSimpleName(), startTime);
                        finish();
                        JunkfoodFlaggingActivity.this.overridePendingTransition(R
                                .anim.in_from_right_email, R.anim
                                .out_to_left_email);
                    }
                });
            }
        });
        AlertDialog dialog = builder.create();
        dialog.show();
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(this, R.color.dialog_blue));
    }
private void showSaveDialog ( ) { AlertDialog . Builder builder = new AlertDialog . Builder ( JunkfoodFlaggingActivity . this ) ; builder . setTitle ( getString ( R . string . msg_congratulations ) ) ; builder . setMessage ( R . string . msg_flage_save_dialog ) ; builder . setPositiveButton ( R . string . strcontinue , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { favoriteList . removeAll ( adapterlist ) ; getToolsAppList ( ) . removeAll ( adapterlist ) ; HashMap < Integer , AppMenu > newMap = CoreApplication . getInstance ( ) . getToolsSettings ( ) ; for ( int i = 0 ; i < newMap . size ( ) ; i ++ ) { if ( newMap != null && newMap . get ( i ) != null && ! TextUtils . isEmpty ( newMap . get ( i ) . getApplicationName ( ) ) ) { if ( adapterlist . contains ( newMap . get ( i ) . getApplicationName ( ) ) ) { newMap . get ( i ) . setApplicationName ( "" ) ; } } } String hashMapToolSettings = new Gson ( ) . toJson ( newMap ) ; PrefSiempo . getInstance ( JunkfoodFlaggingActivity . this ) . write ( PrefSiempo . TOOLS_SETTING , hashMapToolSettings ) ; PrefSiempo . getInstance ( JunkfoodFlaggingActivity . this ) . write ( PrefSiempo . FAVORITE_APPS , favoriteList ) ; PrefSiempo . getInstance ( JunkfoodFlaggingActivity . this ) . write ( PrefSiempo . JUNKFOOD_APPS , adapterlist ) ; if ( adapterlist . size ( ) == 0 && ! DashboardActivity . isJunkFoodOpen ) { DashboardActivity . isJunkFoodOpen = true ; } new LoadFavoritePane ( PrefSiempo . getInstance ( JunkfoodFlaggingActivity . this ) ) . execute ( ) ; new LoadJunkFoodPane ( PrefSiempo . getInstance ( JunkfoodFlaggingActivity . this ) ) . execute ( ) ; new LoadToolPane ( ) . execute ( ) ; EventBus . getDefault ( ) . postSticky ( new NotifySearchRefresh ( true ) ) ; FirebaseHelper . getInstance ( ) . logScreenUsageTime ( this . getClass ( ) . getSimpleName ( ) , startTime ) ; finish ( ) ; JunkfoodFlaggingActivity . this . overridePendingTransition ( R . anim . in_from_right_email , R . anim . out_to_left_email ) ; } } ) ; } } ) ; AlertDialog dialog = builder . create ( ) ; dialog . show ( ) ; dialog . getButton ( AlertDialog . BUTTON_POSITIVE ) . setTextColor ( ContextCompat . getColor ( this , R . color . dialog_blue ) ) ; }
Show save dialog for saving the user filter data.
Show save dialog for saving the user filter data .