예제 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.weld_count_fragment, container, false);

            var refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.srl);

            if (refresher != null)
            {
                refresher.Refresh += delegate
                {
                    Refresh(forced: true);
                    refresher.Refreshing = false;
                };
            }

            listView            = view.FindViewById <ListView>(Resource.Id.listView);
            listView.Adapter    = adapter;
            listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                var builder = new AlertDialog.Builder(Context);
                builder.SetItems(Resource.Array.select_dialog_items, (object sender1, DialogClickEventArgs e1) =>
                {
                    var items = Resources.GetStringArray(Resource.Array.select_dialog_items);
                    var item  = items[(int)e1.Which];
                    if (e1.Which == 0)
                    {
                        ListView_Click(e.Position);
                    }
                    else if (e1.Which == 1)
                    {
                        Pref.TextViewDialog(Context, null, adapter.GetItem(e.Position).RowText());
                    }
                });
                builder.Create().Show();
            };
            listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
            {
                ListView_Click(e.Position);
            };

            return(view);
        }
예제 #2
0
        public string RefreshFilesList(string directory = null)
        {
            IList <FileSystemInfo> visibleThings = new List <FileSystemInfo>();

            try {
                if (directory == null)
                {
                    directory = DirPath;
                }
                var dir = new DirectoryInfo(directory);
                visibleThings.Add(dir);
                foreach (var item in dir.GetFileSystemInfos().Where(item => item.IsVisible()))
                {
                    visibleThings.Add(item);
                }
                directoryInfo = dir;
                Pref.SetPath(PrefKey, dir.FullName);
                adapter.AddDirectoryContents(visibleThings);
                listView.RefreshDrawableState();
            } catch { }

            return(DirPath);
        }
예제 #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.file_list_fragment, container, false);

            var refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.srl);

            if (refresher != null)
            {
                refresher.Refresh += delegate
                {
                    RefreshFilesList(DirPath);
                    refresher.Refreshing = false;
                };
            }

            listView            = view.FindViewById <ListView>(Resource.Id.listView);
            listView.Adapter    = adapter;
            listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                var fileSystemInfo = adapter.GetItem(e.Position);
                if (e.Position == 0)
                {
                    RefreshFilesList(Path.GetDirectoryName(fileSystemInfo.FullName));
                }
                else if (fileSystemInfo.IsDirectory())
                {
                    RefreshFilesList(fileSystemInfo.FullName);
                }
                else
                {
                    Pref.TextViewDialog(Context, fileSystemInfo.FullName);
                }
            };
            listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
            {
                if (e.Position == 0)
                {
                    return;
                }

                var fileSystemInfo = adapter.GetItem(e.Position);
                var actionName     = fileSystemInfo.IsDirectory() ? "폴더 삭제" : "파일 삭제";
                var fileType       = fileSystemInfo.IsDirectory() ? "이 폴더를 " : "이 파일을 ";
                var msg            = fileType + "완전히 삭제 하시겠습니까?\n\n" + fileSystemInfo.Name + "\n\n수정한 날짜: " + fileSystemInfo.LastWriteTime.ToString();

                var builder = new AlertDialog.Builder(Context);
                builder.SetTitle(actionName)
                .SetMessage(msg)
                .SetNegativeButton("취소", delegate
                {
                    RefreshFilesList(DirPath);
                    Show("삭제가 취소 되었습니다");
                })
                .SetPositiveButton("삭제", delegate
                {
                    try {
                        Directory.Delete(fileSystemInfo.FullName, true);
                        RefreshFilesList(DirPath);
                    } catch {
                        Show("삭제할 수 없습니다");
                    }
                });
                builder.Create().Show();
            };

            return(view);
        }
예제 #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.weld_condition_fragment, container, false);

            coordinatorLayout = view.FindViewById <CoordinatorLayout>(Resource.Id.coordinator_layout);

            selectedBackGroundColor = Context.Resources.GetColor(Resource.Color.tab3_textview_background);
            listView                   = view.FindViewById <ListView>(Resource.Id.wcdListView);
            listView.Adapter           = wcdListAdapter;
            listView.FastScrollEnabled = false;
            listView.ChoiceMode        = ChoiceMode.Multiple;
            listView.ItemClick        += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                wcdListAdapter[e.Position].ItemChecked = listView.IsItemChecked(e.Position);
                if (listView.IsItemChecked(e.Position))
                {
                    lastPosition = e.Position;
                    e.View.SetBackgroundColor(selectedBackGroundColor);
                }
                else
                {
                    e.View.SetBackgroundColor(defaultBackgroundColor);                      // 기본 백그라운드 색깔
                }

                try {
                    if (wcdListAdapter.Count == 0)
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
                    }
                    else if (listView.CheckedItemCount == 0)
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
                    }
                    else
                    {
                        fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
                    }
                } catch { }

                if (snackbar == null)
                {
                    snackbar = Snackbar.Make(coordinatorLayout, listView.CheckedItemCount.ToString() + "개 항목 선택됨", Snackbar.LengthIndefinite)
                               .SetAction("선택 취소", (view) => { CheckListItem(); snackbar = null; });
                }
                if (listView.CheckedItemCount > 0)
                {
                    if (snackbar.IsShown)
                    {
                        snackbar.SetText(listView.CheckedItemCount.ToString() + "개 항목 선택됨");
                    }
                    else
                    {
                        snackbar.Show();
                    }
                }
                else if (snackbar != null)
                {
                    snackbar.Dismiss();
                    snackbar = null;
                }
            };
            listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
            {
                FabWcd_Click(sender, e);
            };

            var refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.srl);

            if (refresher != null)
            {
                refresher.Refresh += delegate
                {
                    Refresh(forced: true);
                    refresher.Refreshing = false;
                };
            }

            // 떠 있는 액션버튼
            fabWcd        = view.FindViewById <FloatingActionButton>(Resource.Id.fab_wcd);
            fabWcd.Click += (object sender, EventArgs e) =>
            {
                if (listView.CheckedItemCount == 0)
                {
                    Pref.TextViewDialog(Context, robotPath);
                }
                else
                {
                    FabWcd_Click(sender, e);
                }
            };

            try {
                if (wcdListAdapter.Count == 0)
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
                }
                else if (listView.CheckedItemCount == 0)
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
                }
                else
                {
                    fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
                }
            } catch { }

            return(view);
        }