//public void ckb_OnClick(View v) //{ // switch (v.Id) // { // case Resource.Id.cbBooks: // if (books == true) // books = false; // else // books = true; // break; // case Resource.Id.cbMovies: // if (movies == true) // movies = false; // else // movies = true; // break; // case Resource.Id.cbMusic: // if (music == true) // music = false; // else // music = true; // break; // case Resource.Id.cbTV: // if (shows == true) // shows = false; // else // shows = true; // break; // } //} protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here //Step 1--Set our view from the "main" layout resource SetContentView(Resource.Layout.Home); ActionBar.Hide(); currentUser = JsonConvert.DeserializeObject <LoginTable>(Intent.GetStringExtra("CurrentUser")); //Step 3--Find Controls IVlogo = FindViewById <ImageView>(Resource.Id.IVlogo); IVlogo.SetImageResource(Resource.Drawable.logo); btnProfile = FindViewById <ImageButton>(Resource.Id.btnProfile); btnProfile.SetImageResource(Resource.Drawable.ic_action_person); btnAdd = FindViewById <ImageButton>(Resource.Id.btnAdd); btnAdd.SetImageResource(Resource.Drawable.ic_action_add_box); btnHome = FindViewById <ImageButton>(Resource.Id.btnHome); btnHome.SetImageResource(Resource.Drawable.ic_action_home); btnSearch = FindViewById <ImageButton>(Resource.Id.btnSearch); btnSearch.SetImageResource(Resource.Drawable.ic_action_search); btnLogout = FindViewById <ImageButton>(Resource.Id.btnLogout); btnLogout.SetImageResource(Resource.Drawable.ic_action_exit_to_app); cbBooks = FindViewById <CheckBox>(Resource.Id.cbBooks); cbMovies = FindViewById <CheckBox>(Resource.Id.cbMovies); cbMusic = FindViewById <CheckBox>(Resource.Id.cbMusic); cbTV = FindViewById <CheckBox>(Resource.Id.cbTV); cbOwnOption = FindViewById <CheckBox>(Resource.Id.cbOwnOption); cbOnlyOption = FindViewById <CheckBox>(Resource.Id.cbOnlyOption); btnApply = FindViewById <Button>(Resource.Id.btnApply); lvFeed = FindViewById <ListView>(Resource.Id.lvFeed); string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Call Database var db = new SQLiteConnection(dpPath); var data = db.Table <Recommendation>(); //Call Table // var data1 = data.Where(x => x.recAuthor == currentUser.username).FirstOrDefault(); //Linq Query currentUser.myRecommendations = new List <Recommendation>(); currentUser.followers = (from x in db.Table <Friendship>() where (x.friendFrom).Contains(currentUser.username) select x).ToList <Friendship>(); currentUser.noOfFollowers = currentUser.followers.Count; if (data != null) { foreach (var item in data) { currentUser.myRecommendations.Add(item); } } RecommendationAdapter adapter = new RecommendationAdapter(this, Resource.Layout.ListView_Recommendation, currentUser.myRecommendations); lvFeed.Adapter = adapter; if (currentUser.myRecommendations.Count == 0) { Toast.MakeText(this, "No Results", ToastLength.Short).Show(); } //Step 4--Event Handler(s) btnSearch.Click += BtnSearch_Click; btnAdd.Click += BtnAdd_Click; btnHome.Click += BtnHome_Click; btnLogout.Click += BtnLogout_Click; btnProfile.Click += BtnProfile_Click; // btnApply.Click += BtnApply_Click; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.activity_recommendations, container, false); var list = view.FindViewById <RecyclerView>(Resource.Id.list_recommendations); var progress = view.FindViewById <ProgressBar>(Resource.Id.progressBar_recommendations); adapter = new RecommendationAdapter(new List <IBlock>(), this); adapter.ItemClick += AdapterOnItemClick; list.Clickable = true; //progress.Visibility = ViewStates.Invisible; Handler handler = new Handler(Looper.MainLooper); var scroll_listener = new Listeners.OnScrollToBottomListener(() => { if (!hasLoading) { return; } if (recom_blocks?.Count > 0) { Task.Run(() => { System.Threading.Thread.Sleep(300); var buffer = new List <IBlock>(); buffer.Add(recom_blocks.First()); adapter.AddBlocks(buffer); handler.Post(new Runnable(() => { adapter.NotifyItemRangeChanged(adapter.ItemCount - 1, 1); })); }).ContinueWith((t) => { recom_blocks.Remove(recom_blocks.First()); progress.Visibility = ViewStates.Invisible; }); } else { hasLoading = false; return; } }); List <IBlock> recs = new List <IBlock>(); Task.Run(() => { recs = Recommendations.NewSync().Blocks; }).ContinueWith((t) => { recom_blocks.AddRange(recs); scroll_listener.InvokeCallback(); }); list.AddOnScrollListener(scroll_listener); list.SetAdapter(adapter); list.SetLayoutManager(new LinearLayoutManager(Application.Context, LinearLayoutManager.Vertical, false)); return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here //Step 1--Set our view from the "main" layout resource ActionBar.Hide(); SetContentView(Resource.Layout.Profile); currentUser = JsonConvert.DeserializeObject <LoginTable>(Intent.GetStringExtra("CurrentUser")); //Step 3--Find Controls IVlogo = FindViewById <ImageView>(Resource.Id.IVlogo); IVlogo.SetImageResource(Resource.Drawable.logo); btnProfile = FindViewById <ImageButton>(Resource.Id.btnProfile); btnProfile.SetImageResource(Resource.Drawable.ic_action_person); btnAdd = FindViewById <ImageButton>(Resource.Id.btnAdd); btnAdd.SetImageResource(Resource.Drawable.ic_action_add_box); btnHome = FindViewById <ImageButton>(Resource.Id.btnHome); btnHome.SetImageResource(Resource.Drawable.ic_action_home); btnSearch = FindViewById <ImageButton>(Resource.Id.btnSearch); btnSearch.SetImageResource(Resource.Drawable.ic_action_search); btnLogout = FindViewById <ImageButton>(Resource.Id.btnLogout); btnLogout.SetImageResource(Resource.Drawable.ic_action_exit_to_app); txtUsernameInput = FindViewById <TextView>(Resource.Id.txtUsernameInput); txtEmailInput = FindViewById <TextView>(Resource.Id.txtEmailInput); txtDateInput = FindViewById <TextView>(Resource.Id.txtDateInput); txtRecNumInput = FindViewById <TextView>(Resource.Id.txtRecNumInput); txtFollowNum = FindViewById <TextView>(Resource.Id.txtFollowNum); txtFollowerNum = FindViewById <TextView>(Resource.Id.txtFollowerNum); btnFollowers = FindViewById <Button>(Resource.Id.btnFollowers); btnFollowing = FindViewById <Button>(Resource.Id.btnFollowing); btnChangePW = FindViewById <Button>(Resource.Id.btnChangePW); txtEmpty = FindViewById <TextView>(Resource.Id.txtEmpty); lvToDo = FindViewById <ListView>(Resource.Id.lvToDo); txtUsernameInput.Text = currentUser.username; txtEmailInput.Text = currentUser.email; txtDateInput.Text = currentUser.membersince.ToShortDateString(); string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Call Database var db = new SQLiteConnection(dpPath); //-----------------Calculate Followers---------------------- currentUser.followers = (from x in db.Table <Friendship>() where (x.friendFrom).Contains(currentUser.username) select x).ToList <Friendship>(); currentUser.noOfFollowers = currentUser.followers.Count; txtFollowNum.Text += currentUser.noOfFollowers.ToString(); //----------------Calculate Following-------------------------- currentUser.following = (from x in db.Table <Friendship>() where (x.friendTo).Contains(currentUser.username) select x).ToList <Friendship>(); currentUser.noOfFollowing = currentUser.following.Count; txtFollowerNum.Text += currentUser.noOfFollowing.ToString(); //----------------Calculate RecomNum-------------------- var data = db.Table <Recommendation>(); //Call Table recomNum = 0; foreach (var item in data) { if (item.recAuthor.Equals(currentUser.username)) { recomNum++; } } txtRecNumInput.Text = recomNum.ToString(); // txtRecNumInput.Text = currentUser.getRecommendationNum().ToString(); if (currentUser.GetToDo().Count == 0) { txtEmpty.Text = "No items in To Do List"; } else { RecommendationAdapter adapter = new RecommendationAdapter(this, Resource.Layout.ListView_Recommendation, currentUser.GetToDo()); lvToDo.Adapter = adapter; } //Step 4--Event Handler(s) btnSearch.Click += BtnSearch_Click; btnAdd.Click += BtnAdd_Click; btnHome.Click += BtnHome_Click; btnLogout.Click += BtnLogout_Click; btnProfile.Click += BtnProfile_Click; }