Example usage for android.widget LinearLayout setBackgroundColor

List of usage examples for android.widget LinearLayout setBackgroundColor

Introduction

In this page you can find the example usage for android.widget LinearLayout setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

private void listDirFilterLocal(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter,
        final AdapterFilterList fla, final NotifyEvent p_ntfy) {
    final String cdir = sti.getMasterDirectoryName();
    String localBaseDir_t = mGp.internalRootDirectory;
    if (sti.getMasterFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD))
        localBaseDir_t = mGp.sdcardRootDirectory;
    final String localBaseDir = localBaseDir_t;

    //??/*w w w.j a v a2  s.  c  o m*/
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.item_select_list_dlg);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
    final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);
    subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

    title.setText(mContext.getString(R.string.msgs_filter_list_dlg_add_dir_filter));
    subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + localBaseDir + "/" + cdir);
    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg);
    final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);

    final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select);
    ll_context.setVisibility(LinearLayout.VISIBLE);
    final ImageButton ib_select_all = (ImageButton) ll_context.findViewById(R.id.context_button_select_all);
    final ImageButton ib_unselect_all = (ImageButton) ll_context.findViewById(R.id.context_button_unselect_all);

    dlg_msg.setVisibility(TextView.VISIBLE);

    //        if (rows.size()<=2) 
    //           ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
    //           .setVisibility(TextView.VISIBLE);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    final ListView lv = (ListView) dialog.findViewById(android.R.id.list);
    final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, false, false);
    lv.setAdapter(tfa);
    ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, localBaseDir, "/" + cdir);
    if (tfl.size() < 1)
        tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty)));
    tfa.setDataList(tfl);
    lv.setScrollingCacheEnabled(false);
    lv.setScrollbarFadingEnabled(false);

    ib_select_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < tfa.getDataItemCount(); i++) {
                TreeFilelistItem tfli = tfa.getDataItem(i);
                if (!tfli.isHideListItem())
                    tfa.setDataItemIsSelected(i);
            }
            tfa.notifyDataSetChanged();
            btn_ok.setEnabled(true);
        }
    });

    ib_unselect_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < tfa.getDataItemCount(); i++) {
                tfa.setDataItemIsUnselected(i);
            }
            tfa.notifyDataSetChanged();
            btn_ok.setEnabled(false);
        }
    });

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
            final int pos = tfa.getItem(idx);
            final TreeFilelistItem tfi = tfa.getDataItem(pos);
            if (tfi.getName().startsWith("---"))
                return;
            expandHideLocalDirTree(true, localBaseDir, pos, tfi, tfa);
        }
    });
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
            final int t_pos = tfa.getItem(position);
            final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
            if (tfi.getName().startsWith("---"))
                return true;
            if (!tfa.getDataItem(t_pos).isChecked()) {
                tfa.setDataItemIsSelected(t_pos);
            }
            return true;
        }
    });

    //OK?
    btn_ok.setEnabled(false);
    NotifyEvent ntfy = new NotifyEvent(mContext);
    //Listen setRemoteShare response 
    ntfy.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context arg0, Object[] arg1) {
            btn_ok.setEnabled(true);
        }

        @Override
        public void negativeResponse(Context arg0, Object[] arg1) {
            boolean checked = false;
            for (int i = 0; i < tfa.getDataItemCount(); i++) {
                if (tfa.getDataItem(i).isChecked()) {
                    checked = true;
                    break;
                }
            }
            if (checked)
                btn_ok.setEnabled(true);
            else
                btn_ok.setEnabled(false);
        }
    });
    tfa.setCbCheckListener(ntfy);

    btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add));
    btn_ok.setVisibility(Button.VISIBLE);
    btn_ok.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (!addDirFilter(true, tfa, fla, "/" + cdir + "/", dlg_msg))
                return;
            addDirFilter(false, tfa, fla, "/" + cdir + "/", dlg_msg);
            dialog.dismiss();
            p_ntfy.notifyToListener(true, null);
        }
    });

    //CANCEL?
    final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
    btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close));
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            p_ntfy.notifyToListener(true, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    //        dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //        dialog.setCancelable(false);
    dialog.show();

    return;

}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void selectLocalDirDlg(final String url, final String dir, String p_dir, final NotifyEvent p_ntfy) {

    //??//from w w w  .ja  va 2s  .c o m
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.item_select_list_dlg);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
    final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);
    subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

    title.setText(mContext.getString(R.string.msgs_select_local_dir));
    subtitle.setText(mContext.getString(R.string.msgs_current_dir) + url + dir);

    final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);

    //        if (rows.size()<=2) 
    //           ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
    //           .setVisibility(TextView.VISIBLE);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    ListView lv = (ListView) dialog.findViewById(android.R.id.list);
    final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false);
    lv.setAdapter(tfa);
    ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, url, dir);
    if (tfl.size() < 1)
        tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty)));
    tfa.setDataList(tfl);
    lv.setScrollingCacheEnabled(false);
    lv.setScrollbarFadingEnabled(false);
    lv.setFastScrollEnabled(true);

    if (p_dir.length() != 0)
        for (int i = 0; i < tfa.getDataItemCount(); i++) {
            if (tfa.getDataItem(i).getName().equals(p_dir))
                lv.setSelection(i);
        }
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
            final int pos = tfa.getItem(idx);
            final TreeFilelistItem tfi = tfa.getDataItem(pos);
            if (tfi.getName().startsWith("---"))
                return;
            expandHideLocalDirTree(true, url, pos, tfi, tfa);
        }
    });
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
            final int t_pos = tfa.getItem(position);
            if (tfa.getDataItem(t_pos).isChecked()) {
                ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " "
                        + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                        .setOnClickListener(new CustomContextMenuOnClickListener() {
                            @Override
                            public void onClick(CharSequence menuTitle) {
                                final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                if (tfi.getName().startsWith("---"))
                                    return;
                                tfa.setDataItemIsUnselected(t_pos);
                                if (tfa.isDataItemIsSelected())
                                    btn_ok.setEnabled(true);
                                else
                                    btn_ok.setEnabled(false);
                            }
                        });
            } else {
                ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " "
                        + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                        .setOnClickListener(new CustomContextMenuOnClickListener() {
                            @Override
                            public void onClick(CharSequence menuTitle) {
                                final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                if (tfi.getName().startsWith("---"))
                                    return;
                                tfa.setDataItemIsSelected(t_pos);
                                btn_ok.setEnabled(true);
                            }
                        });
            }
            ccMenu.createMenu();
            return false;
        }
    });
    NotifyEvent ctv_ntfy = new NotifyEvent(mContext);
    ctv_ntfy.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            if (o != null) {
                int pos = (Integer) o[0];
                if (tfa.getDataItem(pos).isChecked())
                    btn_ok.setEnabled(true);
            }
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            btn_ok.setEnabled(false);
            for (int i = 0; i < tfa.getDataItemCount(); i++) {
                if (tfa.getDataItem(i).isChecked()) {
                    btn_ok.setEnabled(true);
                    break;
                }
            }
        }
    });
    tfa.setCbCheckListener(ctv_ntfy);

    //OK?
    btn_ok.setEnabled(false);
    btn_ok.setVisibility(Button.VISIBLE);
    btn_ok.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String sel = "";
            for (int i = 0; i < tfa.getCount(); i++) {
                if (tfa.getDataItem(i).isChecked()
                        && !tfa.getDataItem(i).getName().equals(mContext.getString(R.string.msgs_dir_empty))) {
                    if (tfa.getDataItem(i).getPath().length() == 1)
                        sel = tfa.getDataItem(i).getName();
                    else
                        sel = tfa.getDataItem(i).getPath().substring(1, tfa.getDataItem(i).getPath().length())
                                + tfa.getDataItem(i).getName();
                    break;
                }
            }
            if (sel.equals("")) {

            }
            dialog.dismiss();
            p_ntfy.notifyToListener(true, new Object[] { sel });
        }
    });

    //CANCEL?
    final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            p_ntfy.notifyToListener(false, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    //        dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //        dialog.setCancelable(false);
    dialog.show();

    return;
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void showSelectSdcardMsg(final NotifyEvent ntfy, String msg) {
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.show_select_sdcard_dlg);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.show_select_sdcard_dlg_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.show_select_sdcard_dlg_title);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);

    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.show_select_sdcard_dlg_msg);
    dlg_msg.setText(msg);//from w  w w.ja v  a2  s .c om
    ;

    final ImageView func_view = (ImageView) dialog.findViewById(R.id.show_select_sdcard_dlg_image);

    try {
        InputStream is = mContext.getResources().getAssets()
                .open(mContext.getString(R.string.msgs_main_external_sdcard_select_required_select_msg_file));
        Bitmap bm = BitmapFactory.decodeStream(is);
        func_view.setImageBitmap(bm);
    } catch (IOException e) {
        /* ? */
    }

    final Button btnOk = (Button) dialog.findViewById(R.id.show_select_sdcard_dlg_btn_ok);
    final Button btnCancel = (Button) dialog.findViewById(R.id.show_select_sdcard_dlg_btn_cancel);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            ntfy.notifyToListener(true, null);
        }
    });
    // Cancel?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            ntfy.notifyToListener(false, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });

    dialog.show();

}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void editDirFilterDlg(final SyncTaskItem sti, final String prof_master,
        final ArrayList<String> dir_filter, final NotifyEvent p_ntfy) {
    ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>();
    final AdapterFilterList filterAdapter;

    // ??/*  w  w  w.  j  a  v a 2 s.co  m*/
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.filter_list_dlg);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);

    filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList);
    final ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview);

    for (int i = 0; i < dir_filter.size(); i++) {
        String inc = dir_filter.get(i).substring(0, 1);
        String filter = dir_filter.get(i).substring(1, dir_filter.get(i).length());
        boolean b_inc = false;
        if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE))
            b_inc = true;
        filterAdapter.add(new FilterListItem(filter, b_inc));
    }
    if (filterAdapter.getCount() == 0)
        filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false));
    lv.setAdapter(filterAdapter);
    lv.setScrollingCacheEnabled(false);
    lv.setScrollbarFadingEnabled(false);

    title.setText(mContext.getString(R.string.msgs_filter_list_dlg_dir_filter));
    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg);
    final Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter);
    final Button addbtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn);
    final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
            FilterListItem fli = filterAdapter.getItem(idx);
            if (fli.getFilter().startsWith("---") || fli.isDeleted())
                return;
            // ????????
            editDirFilter(idx, filterAdapter, fli, fli.getFilter());
        }
    });

    // Add?
    et_filter.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() != 0) {
                if (isFilterExists(s.toString().trim(), filterAdapter)) {
                    String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified);
                    dlg_msg.setText(String.format(mtxt, s.toString().trim()));
                    addbtn.setEnabled(false);
                    dirbtn.setEnabled(true);
                    btn_ok.setEnabled(true);
                } else {
                    dlg_msg.setText("");
                    addbtn.setEnabled(true);
                    dirbtn.setEnabled(false);
                    btn_ok.setEnabled(false);
                }
            } else {
                addbtn.setEnabled(false);
                dirbtn.setEnabled(true);
                btn_ok.setEnabled(true);
            }
            //            et_filter.setText(s);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    addbtn.setEnabled(false);
    addbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dlg_msg.setText("");
            String newfilter = et_filter.getText().toString();
            if (isFilterExists(newfilter, filterAdapter)) {
                String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified);
                dlg_msg.setText(String.format(mtxt, newfilter));
                return;
            }
            dlg_msg.setText("");
            et_filter.setText("");
            if (filterAdapter.getItem(0).getFilter().startsWith("---"))
                filterAdapter.remove(filterAdapter.getItem(0));
            filterAdapter.add(new FilterListItem(newfilter, true));
            filterAdapter.setNotifyOnChange(true);
            filterAdapter.sort(new Comparator<FilterListItem>() {
                @Override
                public int compare(FilterListItem lhs, FilterListItem rhs) {
                    return lhs.getFilter().compareToIgnoreCase(rhs.getFilter());
                };
            });
            dirbtn.setEnabled(true);
            btn_ok.setEnabled(true);
        }
    });
    // Directory?
    //      if (getProfileType(prof_master,prof_dapter).equals("L")) {
    //         if (!mGp.externalStorageIsMounted) dirbtn.setEnabled(false);
    //      } else if (getProfileType(prof_master,prof_dapter).equals("R")) {
    //         if (util.isRemoteDisable()) dirbtn.setEnabled(false);
    //      } else dirbtn.setEnabled(false);
    dirbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            NotifyEvent ntfy = new NotifyEvent(mContext);
            //Listen setRemoteShare response 
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context arg0, Object[] arg1) {
                    dlg_msg.setText("");
                }

                @Override
                public void negativeResponse(Context arg0, Object[] arg1) {
                    if (arg1 != null)
                        dlg_msg.setText((String) arg1[0]);
                    else
                        dlg_msg.setText("");
                }
            });
            listDirFilter(sti, prof_master, dir_filter, filterAdapter, ntfy);
        }
    });

    // CANCEL?
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            //            glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    // OK?
    btn_ok.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            dir_filter.clear();
            if (filterAdapter.getCount() > 0) {
                for (int i = 0; i < filterAdapter.getCount(); i++) {
                    if (!filterAdapter.getItem(i).isDeleted()
                            && !filterAdapter.getItem(i).getFilter().startsWith("---")) {
                        String inc = SMBSYNC_PROF_FILTER_EXCLUDE;
                        if (filterAdapter.getItem(i).getInc())
                            inc = SMBSYNC_PROF_FILTER_INCLUDE;
                        dir_filter.add(inc + filterAdapter.getItem(i).getFilter());
                    }

                }
            }
            p_ntfy.notifyToListener(true, null);
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();

}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

private void listDirFilterSMB(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter,
        final AdapterFilterList fla, final NotifyEvent p_ntfy) {
    setSmbUserPass(sti.getMasterRemoteUserID(), sti.getMasterRemotePassword());
    String t_remurl = "";
    if (sti.getMasterRemoteHostname().equals(""))
        t_remurl = sti.getMasterRemoteAddr();
    else/*from ww w. j  a v a2  s.  c  o m*/
        t_remurl = sti.getMasterRemoteHostname();
    String h_port = "";
    if (!sti.getMasterRemotePassword().equals(""))
        h_port = ":" + sti.getMasterRemotePort();
    final String remurl = "smb://" + t_remurl + h_port + "/" + sti.getMasterRemoteSmbShareName();
    final String remdir = "/" + sti.getMasterDirectoryName() + "/";

    NotifyEvent ntfy = new NotifyEvent(mContext);
    // set thread response 
    ntfy.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>();
            @SuppressWarnings("unchecked")
            ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0];

            for (int i = 0; i < rfl.size(); i++) {
                if (rfl.get(i).isDir() && rfl.get(i).canRead())
                    rows.add(rfl.get(i));
            }
            Collections.sort(rows);
            if (rows.size() < 1)
                rows.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty)));
            //??
            final Dialog dialog = new Dialog(mContext);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);

            LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
            ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

            final LinearLayout title_view = (LinearLayout) dialog
                    .findViewById(R.id.item_select_list_dlg_title_view);
            final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
            final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
            title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
            title.setTextColor(mGp.themeColorList.text_color_dialog_title);
            subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

            title.setText(mContext.getString(R.string.msgs_filter_list_dlg_add_dir_filter));
            subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + remurl + remdir);
            final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg);
            final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select);
            ll_context.setVisibility(LinearLayout.VISIBLE);
            final ImageButton ib_select_all = (ImageButton) ll_context
                    .findViewById(R.id.context_button_select_all);
            final ImageButton ib_unselect_all = (ImageButton) ll_context
                    .findViewById(R.id.context_button_unselect_all);
            final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);
            dlg_msg.setVisibility(TextView.VISIBLE);

            //              if (rows.size()<=2) 
            //                 ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
            //                 .setVisibility(TextView.VISIBLE);

            CommonDialog.setDlgBoxSizeLimit(dialog, true);

            final ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, false, false);
            tfa.setDataList(rows);
            lv.setAdapter(tfa);
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);
            //             lv.setFastScrollEnabled(true);

            ib_select_all.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    for (int i = 0; i < tfa.getDataItemCount(); i++) {
                        TreeFilelistItem tfli = tfa.getDataItem(i);
                        if (!tfli.isHideListItem())
                            tfa.setDataItemIsSelected(i);
                    }
                    tfa.notifyDataSetChanged();
                    btn_ok.setEnabled(true);
                }
            });

            ib_unselect_all.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    for (int i = 0; i < tfa.getDataItemCount(); i++) {
                        tfa.setDataItemIsUnselected(i);
                    }
                    tfa.notifyDataSetChanged();
                    btn_ok.setEnabled(false);
                }
            });

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    // ????????
                    final int pos = tfa.getItem(idx);
                    final TreeFilelistItem tfi = tfa.getDataItem(pos);
                    if (tfi.getName().startsWith("---"))
                        return;
                    expandHideRemoteDirTree(remurl, pos, tfi, tfa);
                }
            });

            lv.setOnItemLongClickListener(new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
                    final int t_pos = tfa.getItem(position);
                    final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                    if (tfi.getName().startsWith("---"))
                        return true;
                    if (!tfa.getDataItem(t_pos).isChecked()) {
                        tfa.setDataItemIsSelected(t_pos);
                    }
                    return true;
                }
            });

            //OK?
            btn_ok.setEnabled(false);
            NotifyEvent ntfy = new NotifyEvent(mContext);
            //Listen setRemoteShare response 
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context arg0, Object[] arg1) {
                    btn_ok.setEnabled(true);
                }

                @Override
                public void negativeResponse(Context arg0, Object[] arg1) {
                    if (tfa.isDataItemIsSelected())
                        btn_ok.setEnabled(true);
                    else
                        btn_ok.setEnabled(false);
                }
            });
            tfa.setCbCheckListener(ntfy);

            btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add));
            btn_ok.setVisibility(Button.VISIBLE);
            btn_ok.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (!addDirFilter(true, tfa, fla, remdir, dlg_msg))
                        return;
                    addDirFilter(false, tfa, fla, remdir, dlg_msg);
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, null);
                }
            });
            //CANCEL?
            final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close));
            btn_cancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, null);
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btn_cancel.performClick();
                }
            });
            //            dialog.setOnKeyListener(new DialogOnKeyListener(context));
            //            dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, o);
        }
    });
    createRemoteFileList(remurl, remdir, ntfy, true);
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void setRemoteDir(final String remurl, final String curdir, final String p_dir,
        final NotifyEvent p_ntfy) {
    final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>();

    NotifyEvent ntfy = new NotifyEvent(mContext);
    // set thread response 
    ntfy.setListener(new NotifyEventListener() {
        @Override/*from w  w w .  j av a  2s  . c o m*/
        public void positiveResponse(Context c, Object[] o) {
            @SuppressWarnings("unchecked")
            ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0];
            for (int i = 0; i < rfl.size(); i++) {
                if (rfl.get(i).isDir() && rfl.get(i).canRead())
                    rows.add(rfl.get(i));
            }
            Collections.sort(rows);
            if (rows.size() < 1)
                rows.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty)));
            //??
            final Dialog dialog = new Dialog(mContext);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);

            LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
            ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

            final LinearLayout title_view = (LinearLayout) dialog
                    .findViewById(R.id.item_select_list_dlg_title_view);
            final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
            final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
            title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
            title.setTextColor(mGp.themeColorList.text_color_dialog_title);
            subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

            title.setText(mContext.getString(R.string.msgs_select_remote_dir));
            subtitle.setText(mContext.getString(R.string.msgs_current_dir) + "/" + remurl);
            //             if (rows.size()<1) {
            //                TextView dlg_msg=(TextView)dialog.findViewById(R.id.item_select_list_dlg_msg);
            //                dlg_msg.setText(msgs_dir_empty);
            //                dlg_msg.setVisibility(TextView.VISIBLE);
            //             }
            final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);
            //              if (rows.size()<=2) 
            //                 ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
            //                 .setVisibility(TextView.VISIBLE);

            CommonDialog.setDlgBoxSizeLimit(dialog, true);

            final ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false);
            //            tfa.setNotifyOnChange(true);
            tfa.setDataList(rows);
            lv.setAdapter(tfa);
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);
            lv.setFastScrollEnabled(true);

            if (p_dir.length() != 0)
                for (int i = 0; i < tfa.getDataItemCount(); i++) {
                    if (tfa.getDataItem(i).getName().equals(p_dir))
                        lv.setSelection(i);
                }

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    // ????????
                    final int pos = tfa.getItem(idx);
                    final TreeFilelistItem tfi = tfa.getDataItem(pos);
                    if (tfi.getName().startsWith("---"))
                        return;
                    expandHideRemoteDirTree(remurl, pos, tfi, tfa);
                }
            });
            lv.setOnItemLongClickListener(new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
                    final int t_pos = tfa.getItem(position);
                    if (tfa.getDataItem(t_pos).isChecked()) {
                        ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_unselect_this_entry)
                                + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                                .setOnClickListener(new CustomContextMenuOnClickListener() {
                                    @Override
                                    public void onClick(CharSequence menuTitle) {
                                        final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                        if (tfi.getName().startsWith("---"))
                                            return;
                                        tfa.setDataItemIsUnselected(t_pos);
                                        btn_ok.setEnabled(false);
                                    }
                                });
                    } else {
                        ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " "
                                + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                                .setOnClickListener(new CustomContextMenuOnClickListener() {
                                    @Override
                                    public void onClick(CharSequence menuTitle) {
                                        final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                        if (tfi.getName().startsWith("---"))
                                            return;
                                        tfa.setDataItemIsSelected(t_pos);
                                        btn_ok.setEnabled(true);
                                    }
                                });
                    }
                    ccMenu.createMenu();
                    return false;
                }
            });
            NotifyEvent ctv_ntfy = new NotifyEvent(mContext);
            // set file list thread response listener 
            ctv_ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    if (o != null) {
                        int pos = (Integer) o[0];
                        if (tfa.getDataItem(pos).isChecked())
                            btn_ok.setEnabled(true);
                    }
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    btn_ok.setEnabled(false);
                    for (int i = 0; i < tfa.getDataItemCount(); i++) {
                        if (tfa.getDataItem(i).isChecked()) {
                            btn_ok.setEnabled(true);
                            break;
                        }
                    }
                }
            });
            tfa.setCbCheckListener(ctv_ntfy);

            //OK?
            btn_ok.setEnabled(false);
            btn_ok.setVisibility(Button.VISIBLE);
            btn_ok.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    String sel = "";
                    for (int i = 0; i < tfa.getCount(); i++) {
                        if (tfa.getDataItem(i).isChecked() && !tfa.getDataItem(i).getName()
                                .equals(mContext.getString(R.string.msgs_dir_empty))) {
                            if (tfa.getDataItem(i).getPath().length() == 1)
                                sel = tfa.getDataItem(i).getName();
                            else
                                sel = tfa.getDataItem(i).getPath().substring(1,
                                        tfa.getDataItem(i).getPath().length()) + tfa.getDataItem(i).getName();
                            break;
                        }
                    }
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, new Object[] { sel });
                }
            });
            //CANCEL?
            final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            btn_cancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(false, null);
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btn_cancel.performClick();
                }
            });

            //             dialog.setOnKeyListener(new DialogOnKeyListener(context));
            //             dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, o);
        }
    });
    createRemoteFileList(remurl, curdir, ntfy, true);
    return;
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

private void selectImportProfileItem(final AdapterSyncTask tfl, final NotifyEvent p_ntfy) {
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.export_import_profile_dlg);
    dialog.setCanceledOnTouchOutside(false);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    ArrayList<ExportImportProfileListItem> eipl = new ArrayList<ExportImportProfileListItem>();

    for (int i = 0; i < tfl.getCount(); i++) {
        SyncTaskItem pl = tfl.getItem(i);
        ExportImportProfileListItem eipli = new ExportImportProfileListItem();
        eipli.isChecked = true;//from   w w w . java  2 s.  c om
        eipli.item_name = pl.getSyncTaskName();
        eipl.add(eipli);
    }
    //      Collections.sort(eipl, new Comparator<ExportImportProfileListItem>(){
    //         @Override
    //         public int compare(ExportImportProfileListItem arg0,
    //               ExportImportProfileListItem arg1) {
    //            if (arg0.item_name.equals(arg1.item_name)) return arg0.item_type.compareToIgnoreCase(arg1.item_type);
    //            return arg0.item_name.compareToIgnoreCase(arg1.item_name);
    //         }
    //      });
    //      ExportImportProfileListItem eipli=new ExportImportProfileListItem();
    //      eipli.isChecked=true;
    //      eipli.item_type="*";
    //      eipli.item_name=mContext.getString(R.string.msgs_export_import_profile_setting_parms);
    //      eipl.add(eipli);
    final AdapterExportImportSyncTask imp_list_adapt = new AdapterExportImportSyncTask(mContext,
            R.layout.export_import_profile_list_item, eipl);

    ListView lv = (ListView) dialog.findViewById(R.id.export_import_profile_listview);
    lv.setAdapter(imp_list_adapt);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.export_import_profile_title);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);
    title.setText(mContext.getString(R.string.msgs_export_import_profile_title));
    //      TextView tv_msgx=(TextView)dialog.findViewById(R.id.export_import_profile_msg);
    //      tv_msgx.setVisibility(LinearLayout.GONE);
    LinearLayout ll_filelist = (LinearLayout) dialog.findViewById(R.id.export_import_profile_file_list);
    ll_filelist.setVisibility(LinearLayout.GONE);
    final Button ok_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_ok);
    Button cancel_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_cancel);

    final Button rb_select_all = (Button) dialog.findViewById(R.id.export_import_profile_list_select_all);
    final Button rb_unselect_all = (Button) dialog.findViewById(R.id.export_import_profile_list_unselect_all);
    final CheckedTextView ctv_reset_profile = (CheckedTextView) dialog
            .findViewById(R.id.export_import_profile_list_ctv_reset_profile);
    final CheckedTextView ctv_import_settings = (CheckedTextView) dialog
            .findViewById(R.id.export_import_profile_list_ctv_import_settings);
    final CheckedTextView ctv_import_schedule = (CheckedTextView) dialog
            .findViewById(R.id.export_import_profile_list_ctv_import_schedule);

    ctv_reset_profile.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ((CheckedTextView) v).toggle();
            setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt,
                    ok_btn);
        }
    });

    ctv_import_settings.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ((CheckedTextView) v).toggle();
            setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt,
                    ok_btn);
        }
    });

    ctv_import_schedule.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ((CheckedTextView) v).toggle();
            setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt,
                    ok_btn);
        }
    });

    ctv_import_settings.setChecked(true);
    ctv_import_schedule.setChecked(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
            //              imp_list_adapt.getItem(pos).isChecked=!imp_list_adapt.getItem(pos).isChecked;
            //              imp_list_adapt.notifyDataSetChanged();
            //              if (imp_list_adapt.isItemSelected()) {
            //                 ok_btn.setEnabled(true);
            //              } else {
            //                 ok_btn.setEnabled(false);
            //              }
            setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt,
                    ok_btn);
        }
    });

    //      lv.setOnItemLongClickListener(new OnItemLongClickListener(){
    //         @Override
    //         public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
    //               int pos, long arg3) {
    //            ccMenu.addMenuItem(
    //                  mContext.getString(R.string.msgs_export_import_profile_select_all),R.drawable.blank)
    //              .setOnClickListener(new CustomContextMenuOnClickListener() {
    //              @Override
    //              final public void onClick(CharSequence menuTitle) {
    //                 for (int i=0;i<imp_list_adapt.getCount();i++)
    //                    imp_list_adapt.getItem(i).isChecked=true;
    //                 imp_list_adapt.notifyDataSetChanged();
    //                 ok_btn.setEnabled(true);
    //                 }
    //              });
    //            ccMenu.addMenuItem(
    //                  mContext.getString(R.string.msgs_export_import_profile_unselect_all),R.drawable.blank)
    //              .setOnClickListener(new CustomContextMenuOnClickListener() {
    //              @Override
    //              final public void onClick(CharSequence menuTitle) {
    //                 for (int i=0;i<imp_list_adapt.getCount();i++)
    //                    imp_list_adapt.getItem(i).isChecked=false;
    //                 imp_list_adapt.notifyDataSetChanged();
    //                 ok_btn.setEnabled(false);
    //                 }
    //              });
    //            ccMenu.createMenu();
    //            return false;
    //         }
    //      });

    rb_select_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < imp_list_adapt.getCount(); i++)
                imp_list_adapt.getItem(i).isChecked = true;
            ctv_import_settings.setChecked(true);
            ctv_import_schedule.setChecked(true);
            imp_list_adapt.notifyDataSetChanged();
            ok_btn.setEnabled(true);
        }
    });
    rb_unselect_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < imp_list_adapt.getCount(); i++)
                imp_list_adapt.getItem(i).isChecked = false;
            ctv_import_settings.setChecked(false);
            ctv_import_schedule.setChecked(false);
            imp_list_adapt.notifyDataSetChanged();
            ok_btn.setEnabled(false);
        }
    });

    NotifyEvent ntfy_ctv_listener = new NotifyEvent(mContext);
    ntfy_ctv_listener.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            //              if (imp_list_adapt.isItemSelected()) {
            //                 ok_btn.setEnabled(true);
            //              } else {
            //                 if (ctv_import_settings.isChecked()) ok_btn.setEnabled(true);
            //                 else ok_btn.setEnabled(false);
            //              }
            setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt,
                    ok_btn);
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }
    });
    imp_list_adapt.setCheckButtonListener(ntfy_ctv_listener);

    ok_btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (ctv_reset_profile.isChecked())
                mGp.syncTaskAdapter.clear();
            importSelectedSyncTaskItem(imp_list_adapt, tfl, ctv_import_settings.isChecked(),
                    ctv_import_schedule.isChecked(), p_ntfy);
            dialog.dismiss();
        }
    });
    cancel_btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            dialog.dismiss();
        }
    });

    dialog.show();

}

From source file:processing.core.PApplet.java

/** Called with the activity is first created. */
@Override/*from   w w  w .  j ava2  s. c om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // println("PApplet.onCreate()");

    if (DEBUG)
        println("onCreate() happening here: " + Thread.currentThread().getName());

    // commented to use fragments
    /*
     * Window window = getWindow();
     * 
     * // Take up as much area as possible
     * requestWindowFeature(Window.FEATURE_NO_TITLE);
     * window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
     * WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
     * 
     * // This does the actual full screen work
     * window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
     * WindowManager.LayoutParams.FLAG_FULLSCREEN);
     */

    DisplayMetrics dm = new DisplayMetrics();
    this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    displayWidth = dm.widthPixels;
    displayHeight = dm.heightPixels;
    // println("density is " + dm.density);
    // println("densityDpi is " + dm.densityDpi);
    if (DEBUG)
        println("display metrics: " + dm);

    // println("screen size is " + screenWidth + "x" + screenHeight);

    // LinearLayout layout = new LinearLayout(this);
    // layout.setOrientation(LinearLayout.VERTICAL |
    // LinearLayout.HORIZONTAL);
    // viewGroup = new ViewGroup();
    // surfaceView.setLayoutParams();
    // viewGroup.setLayoutParams(LayoutParams.)
    // RelativeLayout layout = new RelativeLayout(this);
    // RelativeLayout overallLayout = new RelativeLayout(this);
    // RelativeLayout.LayoutParams lp = new
    // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.FILL_PARENT);
    // lp.addRule(RelativeLayout.RIGHT_OF, tv1.getId());
    // layout.setGravity(RelativeLayout.CENTER_IN_PARENT);

    int sw = sketchWidth();
    int sh = sketchHeight();

    if (sketchRenderer().equals(JAVA2D)) {
        surfaceView = new SketchSurfaceView(this.getActivity(), sw, sh);
    } else if (sketchRenderer().equals(P2D) || sketchRenderer().equals(P3D)) {
        surfaceView = new SketchSurfaceViewGL(this.getActivity(), sw, sh, sketchRenderer().equals(P3D));
    }
    // g = ((SketchSurfaceView) surfaceView).getGraphics();

    // surfaceView.setLayoutParams(new LayoutParams(sketchWidth(),
    // sketchHeight()));

    // layout.addView(surfaceView);
    // surfaceView.setVisibility(1);
    // println("visibility " + surfaceView.getVisibility() + " " +
    // SurfaceView.VISIBLE);
    // layout.addView(surfaceView);
    // AttributeSet as = new AttributeSet();
    // RelativeLayout.LayoutParams lp = new
    // RelativeLayout.LayoutParams(layout, as);

    // lp.addRule(android.R.styleable.ViewGroup_Layout_layout_height,
    // layout.add
    // lp.addRule(, arg1)
    // layout.addView(surfaceView, sketchWidth(), sketchHeight());

    // new
    // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
    // RelativeLayout.LayoutParams.FILL_PARENT);

    if (sw == displayWidth && sh == displayHeight) {
        // If using the full screen, don't embed inside other layouts
        // window.setContentView(surfaceView); no para fragments
    } else {
        // If not using full screen, setup awkward view-inside-a-view so
        // that
        // the sketch can be centered on screen. (If anyone has a more
        // efficient
        // way to do this, please file an issue on Google Code, otherwise
        // you
        // can keep your "talentless hack" comments to yourself. Ahem.)
        RelativeLayout overallLayout = new RelativeLayout(this.getActivity());
        overallLayout.setBackgroundColor(0x00000000);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);

        LinearLayout layout = new LinearLayout(this.getActivity());
        layout.setBackgroundColor(0x00000000);
        layout.addView(surfaceView, sketchWidth(), sketchHeight());
        overallLayout.addView(layout, lp);
        // window.setContentView(overallLayout); no para fragments
    }

    /*
     * // Here we use Honeycomb API (11+) to hide (in reality, just make the
     * status icons into small dots) // the status bar. Since the core is
     * still built against API 7 (2.1), we use introspection to get // the
     * setSystemUiVisibility() method from the view class. Method
     * visibilityMethod = null; try { visibilityMethod =
     * surfaceView.getClass().getMethod("setSystemUiVisibility", new Class[]
     * { int.class}); } catch (NoSuchMethodException e) { // Nothing to do.
     * This means that we are running with a version of Android previous to
     * Honeycomb. } if (visibilityMethod != null) { try { // This is
     * equivalent to calling:
     * //surfaceView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); // The
     * value of View.STATUS_BAR_HIDDEN is 1.
     * visibilityMethod.invoke(surfaceView, new Object[] { 1 }); } catch
     * (InvocationTargetException e) { } catch (IllegalAccessException e) {
     * } } window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
     * WindowManager.LayoutParams.FLAG_FULLSCREEN);
     */

    // layout.addView(surfaceView, lp);
    // surfaceView.setLayoutParams(new LayoutParams(sketchWidth(),
    // sketchHeight()));

    // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams()
    // layout.addView(surfaceView, new LayoutParams(arg0)

    // TODO probably don't want to set these here, can't we wait for
    // surfaceChanged()?
    // removing this in 0187
    // width = screenWidth;
    // height = screenHeight;

    // int left = (screenWidth - iwidth) / 2;
    // int right = screenWidth - (left + iwidth);
    // int top = (screenHeight - iheight) / 2;
    // int bottom = screenHeight - (top + iheight);
    // surfaceView.setPadding(left, top, right, bottom);
    // android:layout_width

    // window.setContentView(surfaceView); // set full screen

    // code below here formerly from init()

    // millisOffset = System.currentTimeMillis(); // moved to the variable
    // declaration

    finished = false; // just for clarity

    // this will be cleared by draw() if it is not overridden
    looping = true;
    redraw = true; // draw this guy once
    firstMotion = true;

    // these need to be inited before setup
    sizeMethods = new RegisteredMethods();
    preMethods = new RegisteredMethods();
    drawMethods = new RegisteredMethods();
    postMethods = new RegisteredMethods();
    mouseEventMethods = new RegisteredMethods();
    keyEventMethods = new RegisteredMethods();
    disposeMethods = new RegisteredMethods();

    Context context = this.getActivity().getApplicationContext();
    sketchPath = context.getFilesDir().getAbsolutePath();

    // Looper.prepare();
    handler = new Handler();
    // println("calling loop()");
    // Looper.loop();
    // println("done with loop() call, will continue...");

    start();
    return surfaceView;
}