Example usage for android.widget ListView setScrollingCacheEnabled

List of usage examples for android.widget ListView setScrollingCacheEnabled

Introduction

In this page you can find the example usage for android.widget ListView setScrollingCacheEnabled.

Prototype

public void setScrollingCacheEnabled(boolean enabled) 

Source Link

Document

Enables or disables the children's drawing cache during a scroll.

Usage

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 ww  . j  a  va2 s. c o 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.SMBExplorer.SMBExplorerMain.java

private void setRemoteShare(final String prof_user, final String prof_pass, final String prof_addr,
        final NotifyEvent p_ntfy) {
    final ArrayList<String> rows = new ArrayList<String>();

    NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override/* www  . ja  v a  2 s  . c  o m*/
        public void positiveResponse(Context c, Object[] o) {
            FileListAdapter tfl = (FileListAdapter) o[0];

            for (int i = 0; i < tfl.getCount(); i++) {
                FileListItem item = tfl.getItem(i);
                if (item.isDir() && item.canRead() && !item.getName().startsWith("IPC$")) {
                    String tmp = item.getName();
                    rows.add(tmp);
                }
            }
            if (rows.size() < 1)
                rows.add(getString(R.string.msgs_no_shared_resource));

            //??
            final Dialog dialog = new Dialog(c);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);
            ((TextView) dialog.findViewById(R.id.item_select_list_dlg_title)).setText("Select remote share");
            ((TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle)).setText("");

            CommonDialog.setDlgBoxSizeLimit(dialog, false);

            ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            lv.setAdapter(new ArrayAdapter<String>(c, R.layout.simple_list_item_1m, rows));
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    if (rows.get(idx).startsWith("---"))
                        return;
                    dialog.dismiss();
                    // ????????
                    p_ntfy.notifyToListener(true, new Object[] { rows.get(idx).toString() });
                }
            });
            //CANCEL?
            final Button btnCancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            btnCancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, new Object[] { "" });
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btnCancel.performClick();
                }
            });
            //              dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
            //              dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, new Object[] { "Remote file list creation error" });
        }
    });
    createRemoteFileList("smb://" + prof_addr + "/", ntfy);
    return;
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number) {
    //??/* w ww .j a  va2  s  .  c  o  m*/
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.scan_remote_ntwk_dlg);
    final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel);
    final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_msg);
    final TextView tv_result = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_title);
    tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_press_scan_btn));
    tv_result.setVisibility(TextView.GONE);

    final String from = getLocalIpAddress();
    String subnet = from.substring(0, from.lastIndexOf("."));
    String subnet_o1, subnet_o2, subnet_o3;
    subnet_o1 = subnet.substring(0, subnet.indexOf("."));
    subnet_o2 = subnet.substring(subnet.indexOf(".") + 1, subnet.lastIndexOf("."));
    subnet_o3 = subnet.substring(subnet.lastIndexOf(".") + 1, subnet.length());
    final EditText baEt1 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o1);
    final EditText baEt2 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o2);
    final EditText baEt3 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o3);
    final EditText baEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o4);
    final EditText eaEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_end_address_o4);
    baEt1.setText(subnet_o1);
    baEt2.setText(subnet_o2);
    baEt3.setText(subnet_o3);
    baEt4.setText("1");
    baEt4.setSelection(1);
    eaEt4.setText("254");
    baEt4.requestFocus();

    final CheckBox cb_use_port_number = (CheckBox) dialog.findViewById(R.id.scan_remote_ntwk_use_port);
    final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    if (port_number.equals("")) {
        et_port_number.setEnabled(false);
        cb_use_port_number.setChecked(false);
    } else {
        et_port_number.setEnabled(true);
        et_port_number.setText(port_number);
        cb_use_port_number.setChecked(true);
    }
    cb_use_port_number.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            et_port_number.setEnabled(isChecked);
        }
    });

    final NotifyEvent ntfy_lv_click = new NotifyEvent(mContext);
    ntfy_lv_click.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            dialog.dismiss();
            p_ntfy.notifyToListener(true, o);
        }

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

    final ArrayList<ScanAddressResultListItem> ipAddressList = new ArrayList<ScanAddressResultListItem>();
    //      ScanAddressResultListItem li=new ScanAddressResultListItem();
    //      li.server_name=mContext.getString(R.string.msgs_ip_address_no_address);
    //      ipAddressList.add(li);
    final ListView lv = (ListView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_list);
    final AdapterScanAddressResultList adap = new AdapterScanAddressResultList(mContext,
            R.layout.scan_address_result_list_item, ipAddressList, ntfy_lv_click);
    lv.setAdapter(adap);
    lv.setScrollingCacheEnabled(false);
    lv.setScrollbarFadingEnabled(false);

    //SCAN?
    btn_scan.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ipAddressList.clear();
            NotifyEvent ntfy = new NotifyEvent(mContext);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    if (ipAddressList.size() < 1) {
                        tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_not_detected));
                        tv_result.setVisibility(TextView.GONE);
                    } else {
                        tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_select_detected_host));
                        tv_result.setVisibility(TextView.VISIBLE);
                    }
                    //                   adap.clear();
                    //                   for (int i=0;i<ipAddressList.size();i++) 
                    //                      adap.add(ipAddressList.get(i));
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                }

            });
            if (auditScanAddressRangeValue(dialog)) {
                tv_result.setVisibility(TextView.GONE);
                String ba1 = baEt1.getText().toString();
                String ba2 = baEt2.getText().toString();
                String ba3 = baEt3.getText().toString();
                String ba4 = baEt4.getText().toString();
                String ea4 = eaEt4.getText().toString();
                String subnet = ba1 + "." + ba2 + "." + ba3;
                int begin_addr = Integer.parseInt(ba4);
                int end_addr = Integer.parseInt(ea4);
                scanRemoteNetwork(dialog, lv, adap, ipAddressList, subnet, begin_addr, end_addr, ntfy);
            } else {
                //error
            }
        }
    });

    //CANCEL?
    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.show();

}