protected override async Task <Java.Lang.Void> RunInBackground(params Java.Lang.Void[] @params) { ISharedPreferences info = Application.Context.GetSharedPreferences(context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); bool LoggedIn = info.GetBoolean(context.GetString(Resource.String.LogIn), false); MeritMoneyBrain.CurrentAccessToken = info.GetString(context.GetString(Resource.String.CurrentAccessToken), String.Empty); if (context.NetworkStatus.State != NetworkState.Disconnected) { if (LoggedIn) { Profile p = await MeritMoneyBrain.GetProfile(); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } context.StartActivity(new Intent(Application.Context, typeof(MainActivity))); } else { await Task.Delay(500); context.StartActivity(new Intent(Application.Context, typeof(NoInternetActivity))); } return(null); }
public override async void OnResume() { base.OnResume(); if (Network.State != NetworkState.Disconnected) { historyList = await MeritMoneyBrain.GetHistory(Offset, BatchSize, type); LoadingPanel.Visibility = ViewStates.Gone; } else { LoadingPanel.Visibility = ViewStates.Invisible; NoInternetText.Visibility = ViewStates.Visible; } Refresh.Refresh += History_Refresh; RecyclerViewManager = new LinearLayoutManager(this.Context); HistoryView.SetLayoutManager(RecyclerViewManager); RecyclerViewAdapter = new HistoryAdapter(historyList, this.Context, LastHistoryItemDate, users); HistoryView.SetAdapter(RecyclerViewAdapter); mScrollListener = new ScrollListener(RecyclerViewManager, historyList, type); HistoryView.AddOnScrollListener(mScrollListener); for (int i = 0; i < historyList.Count(); i++) { new CacheListItemImage(RecyclerViewAdapter, i, Application.Context).Execute(historyList[i]); } }
private async void HandleSignInResult(GoogleSignInResult result) { if (result.IsSuccess) { // Signed in successfully, show authenticated UI. ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Retrieving profile data", true); GoogleSignInAccount acct = result.SignInAccount; await MeritMoneyBrain.SingInWithGoogle(acct.IdToken); Profile profile = await MeritMoneyBrain.GetProfile(); Intent returnIntent = new Intent(); returnIntent.PutExtra(GetString(Resource.String.LogIn), true); SetResult(Result.Ok, returnIntent); await new SaveData().Execute(profile).GetAsync(); progressDialog.Dismiss(); Finish(); //updateUI(true); } else { // Signed out, show unauthenticated UI. //updateUI(false); } }
private async void MainToolbar_MenuItemClick(object sender, SupportToolBar.MenuItemClickEventArgs e) { switch (e.Item.ItemId) { case Resource.Id.menu_logout: ProgressDialog dialog = ProgressDialog.Show(this, "", "Logging out..."); await MeritMoneyBrain.LogOut(); ProfileDatabase pdb = new ProfileDatabase(); pdb.DeleteDatabase(); UsersDatabase udb = new UsersDatabase(); udb.DeleteDatabase(); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); ISharedPreferencesEditor editor = info.Edit(); editor.Clear(); editor.Apply(); dialog.Dismiss(); Intent LogInIntent = new Intent(this, typeof(LogInActivity)); this.StartActivityForResult(LogInIntent, LOG_IN_REQUEST); break; } }
protected override async Task <Bitmap> RunInBackground(params Java.Lang.Void[] @params) { Android.Graphics.Drawables.BitmapDrawable drawable = (Android.Graphics.Drawables.BitmapDrawable)image.Drawable; Bitmap bitmap = drawable.Bitmap; url = await MeritMoneyBrain.UploadImage(bitmap); return(bitmap); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SearchPerson); ToolBar = FindViewById <SupportToolBar>(Resource.Id.toolbar); SearchUserView = FindViewById <SupportRecyclerView>(Resource.Id.searchUserList); SetSupportActionBar(ToolBar); SupportActionBar.Title = "Select Person"; SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); UsersDatabase db = new UsersDatabase(); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); String Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty); ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Loading, please wait...", true); List <UserListItem> tmp = await MeritMoneyBrain.GetListOfUsers(modifyAfter : Date); if (db.IsExist()) { db.Merge(tmp); } else { db.CreateDatabase(); db.Insert(tmp); } SearchUsersList = db.GetUsers(); progressDialog.Dismiss(); RecyclerViewManager = new LinearLayoutManager(this); SearchUserView.SetLayoutManager(RecyclerViewManager); RecyclerViewAdapter = new UsersAdapter(SearchUsersList, this); SearchUserView.SetAdapter(RecyclerViewAdapter); for (int i = 0; i < SearchUsersList.Count; i++) { new CacheListItemImage(RecyclerViewAdapter, i, Application.Context).Execute(SearchUsersList[i]); } //ToolBar.MenuItemClick += ToolBar_MenuItemClick; }
private async Task HandleResult() { if (EditName.Text != String.Empty) { UserName.Text = EditName.Text; EditName.Text = String.Empty; } if (SaveSwitchState != NotificationSwitch.Checked) { SwitchWasChanged = true; } else { SwitchWasChanged = false; } if (SaveName != UserName.Text) { nameWasChanged = true; } else { nameWasChanged = false; } if (AvatarWasChanged) { new UploadAvatarOnServer(UserAvatar).Execute().Get(); AvatarWasChanged = false; } if (SwitchWasChanged && !nameWasChanged) { Profile p = await MeritMoneyBrain.updateProfile(String.Empty, SwitchWasChanged, NotificationSwitch.Checked); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } if (nameWasChanged) { Profile p = await MeritMoneyBrain.updateProfile(UserName.Text, SwitchWasChanged, NotificationSwitch.Checked); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } }
private async void Profile_Refresh(object sender, EventArgs e) { if (NetworkStatus.State != NetworkState.Disconnected) { Profile profile = await MeritMoneyBrain.GetProfile(); ProfileDatabase db = new ProfileDatabase(); db.Update(profile); InitializeProfile(); } else { Toast.MakeText(this, GetString(Resource.String.NoInternet), ToastLength.Short).Show(); } RefreshInfo.Refreshing = false; }
public override async void onLoadMore(int page, RecyclerView view) { if (history.hasMore) { HistoryList listItem = await MeritMoneyBrain.GetHistory(page *BatchSize, BatchSize, type); var previousPosition = history.Count(); var itemsAdded = listItem.Count(); history.AddList(listItem); history.hasMore = listItem.hasMore; view.GetAdapter().NotifyItemRangeInserted(previousPosition + 1, itemsAdded); for (int i = previousPosition; i < previousPosition + itemsAdded; i++) { new CacheListItemImage(view.GetAdapter(), i, Application.Context).Execute(history[i]); } } }
private async void History_Refresh(object sender, EventArgs e) { if (Network.State != NetworkState.Disconnected) { Offset = 0; var historyList = await MeritMoneyBrain.GetHistory(Offset, BatchSize, type); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); String Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty); LastHistoryItemDate = info.GetString(Application.Context.GetString(Resource.String.HistoryLoadedDate), "0"); RecyclerViewAdapter.AddNewList(historyList, LastHistoryItemDate); } else { Toast.MakeText(this.Context, GetString(Resource.String.NoInternet), ToastLength.Short).Show(); } Refresh.Refreshing = false; }
public async void OnClick(IDialogInterface dialog, int which) { switch (which) { case (int)DialogButtonType.Neutral: dialog.Dismiss(); NumberOfPoints.Text = String.Empty; SendPointsButton.Enabled = false; break; case (int)DialogButtonType.Positive: try { ProfileDatabase pdb = new ProfileDatabase(); if (Convert.ToInt64(NumberOfPoints.Text) > pdb.GetProfile().distribute) { Toast.MakeText(this, "Unavailible points amount.", ToastLength.Short).Show(); break; } } catch (Exception) { Toast.MakeText(this, "Too many points to send.", ToastLength.Short).Show(); break; } ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Sending points...", true); String name = userNameToDistribute.Text; userNameToDistribute.Text = String.Empty; String number = NumberOfPoints.Text; NumberOfPoints.Text = String.Empty; String notes = Notes.Text; Profile p = await MeritMoneyBrain.DistributePoints(number, userIDtoDistribute, notes); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); new UpdateProfileData(this, progressDialog, number, name).Execute(p); break; } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); FrameLayout MainLayout = new FrameLayout(this); SetContentView(MainLayout); base.CombineWith(MainLayout, Resource.Layout.History, ActivityIs.History); MainToolbar = FindViewById <SupportToolBar>(Resource.Id.toolbar); TabLayout = FindViewById <SupportTabLayout>(Resource.Id.tabLayout); ViewPager = FindViewById <SupportViewPager>(Resource.Id.viewPager); MainToolbar.Title = "History"; String LastHistoryItemDate = String.Empty; ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Loading list of users, please wait.", true); if (NetworkStatus.State != NetworkState.Disconnected) { UsersDatabase db = new UsersDatabase(); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); String Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty); LastHistoryItemDate = info.GetString(Application.Context.GetString(Resource.String.HistoryLoadedDate), "0"); List <UserListItem> tmp = await MeritMoneyBrain.GetListOfUsers(modifyAfter : Date); if (db.IsExist()) { db.Update(tmp); } else { db.CreateDatabase(); db.Insert(tmp); } } else { StartActivity(new Intent(this, typeof(NoInternetActivity))); } progressDialog.Dismiss(); var db2 = new UsersDatabase(); var Users = db2.GetUsers(); ViewPagerAdapter = new ViewPagerAdapter(SupportFragmentManager); ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Personal, LastHistoryItemDate, NetworkStatus, Users), new Java.Lang.String("Personal")); ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Company, LastHistoryItemDate, NetworkStatus, Users), new Java.Lang.String("Company")); ViewPager.Adapter = ViewPagerAdapter; TabLayout.SetupWithViewPager(ViewPager); }