Example #1
0
        private void CheckBoxApprove_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e)
        {
            var btn  = (sender as CheckBox);
            var item = (btn.Tag as JavaObjectWrapper <int>).Obj;

            UserResponseAPI.ApproveUserSettings(item);
        }
 public void GetAdminVideoList()
 {
     if (VideoEnum == AdminVideoEnum.UserSettings)
     {
         AdminVideoList = new ObservableCollection <UserSettingVideo>(UserResponseAPI.GetAdminUserSettings().VideosData);
     }
     else
     {
         LatestResponse = new ObservableCollection <AdminVideoResponse>(UserResponseAPI.GetAdminVideos().VideoResponse);
     }
 }
Example #3
0
        private void BtnAcceptReject_Click(object sender, EventArgs e)
        {
            var responseId = UserResponseAPI.AcceptRejectResponse(selectedMedia.Id);

            if (responseId == 1)
            {
                btnAcceptReject.Text               = "Reject";
                btnAcceptReject.Background         = Resources.GetDrawable(Resource.Drawable.Shape_Radius_Btn);
                btnAcceptReject.BackgroundTintList = Resources.GetColorStateList(Resource.Color.gnt_red);
            }
            else
            {
                btnAcceptReject.Text               = "Accept";
                btnAcceptReject.Background         = Resources.GetDrawable(Resource.Drawable.Shape_Radius_Btn);
                btnAcceptReject.BackgroundTintList = Resources.GetColorStateList(Android.Resource.Color.HoloGreenLight);
            }
            TabbedMainActivity.GetInstance().MyChannelFragment.latestResponse.adpater.LatestResponse
            .Where(x => x.Id == selectedMedia.Id).FirstOrDefault().Status = responseId;
        }
Example #4
0
        public async Task DeleteLatestVideo()
        {
            try
            {
                this.RunOnUiThread(() => LoadingView.Show(this, "Deleting..."));
                var deleteResponse = await UserResponseAPI.DeleteResponse(selectedMedia.Id);

                TabbedMainActivity.GetInstance().MyChannelFragment.latestResponse.adpater.LatestResponse =
                    new ObservableCollection <AdminVideoResponse>(UserResponseAPI.GetAdminVideos().VideoResponse);
                this.RunOnUiThread(() => Toast.MakeText(this, "Deleted Successfully", ToastLength.Long));
            }
            catch (Exception ex)
            {
            }
            finally
            {
                this.RunOnUiThread(() => LoadingView.Hide());
                this.Finish();
            }
        }
Example #5
0
        public async System.Threading.Tasks.Task UploadRecordedResponse(string Description)
        {
            try
            {
                this.RunOnUiThread(() => LoadingView.Show(this, "Uploading..."));
                var binaryData = VideoManager.GetVideoData();
                if (VideoManager.IsRecorderStop && binaryData != null)
                {
                    string msg = string.Empty;
                    if (UserResponseType == UserResponse.Video)
                    {
                        msg = await UserResponseAPI.UploadUserResponse(videoId, binaryData, InputSelectedType.Recorded, Description);
                    }
                    else
                    {
                        msg = await UserResponseAPI.UploadAudioUserResponse(videoId, binaryData, InputSelectedType.Recorded, Description);
                    }
                    if (ResponseFragment != null)
                    {
                        await ResponseFragment.GetResponseList(videoId);

                        ResponseFragment.GetUserResponse(videoId);
                    }
                    if (msg.Contains("ok"))
                    {
                        this.RunOnUiThread(() => Toast.MakeText(this, "Response Uploaded successfully", ToastLength.Short).Show());
                    }
                    else
                    {
                        this.RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Short).Show());
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                this.RunOnUiThread(() => LoadingView.Hide());
            }
        }
Example #6
0
        private async void btnShare_Click(object sender, EventArgs e)
        {
            try
            {
                //Share Plugin same as video
                if (!CrossShare.IsSupported)
                {
                    return;
                }

                await CrossShare.Current.Share(new ShareMessage
                {
                    Text = string.IsNullOrEmpty(selectedMedia.Description) ? "" : selectedMedia.Description,
                    Url  = System.IO.Path.Combine(UserResponseURL.DirectoryURL, selectedMedia.VideoLocation)
                });

                await Task.Delay(TimeSpan.FromSeconds(5));

                string msg = UserResponseAPI.ShareVideoResponse(selectedMedia.Id.ToString());
                if (msg.Contains("ok"))
                {
                    var x = Convert.ToDouble(txtShareNumber.Text);
                    x++;
                    txtShareNumber.Text = x.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    int index = mediaList.FindIndex(x => x.Id == selectedMedia.Id);
                    mediaList[index].Shares = (Convert.ToDouble(mediaList[index].Shares) + 1).ToString();

                    TabbedMainActivity.GetInstance().MyChannelFragment.latestResponse.adpater.LatestResponse =
                        new ObservableCollection <AdminVideoResponse>(UserResponseAPI.GetAdminVideos().VideoResponse);
                    //var ActivityContext = TabbedMainActivity.GetInstance();
                    //await ActivityContext.VideoDataWithEventsLoader.ResponseFragment.GetResponseList(ActivityContext.VideoData.VideoId);
                    //ActivityContext.VideoDataWithEventsLoader.ResponseFragment.GetUserResponse(ActivityContext.VideoData.VideoId);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #7
0
 private void ViewPagerOnPageSelected(object sender, ViewPager.PageSelectedEventArgs page)
 {
     try
     {
         var p = page.Position;
         if (p == 0)
         {
         }
         else if (p == 1)
         {
             PlayListFragment.StartApiService();
         }
         else if (p == 2)
         {
         }
         else if (p == 3)
         {
         }
         else if (p == 5)
         {
             int UnseenResponseCount = UserResponseAPI.GetUnseenResponseNotification();
             if (UnseenResponseCount > 0)
             {
                 Tabs.GetTabAt(p).SetText("Latest Response " + "(" + UnSeenReponse + ")");
                 MainContext.FragmentBottomNavigator.txtUnSeenCount.Visibility = ViewStates.Visible;
                 MainContext.FragmentBottomNavigator.txtUnSeenCount.Text       = UnseenResponseCount.ToString();
             }
             else
             {
                 MainContext.FragmentBottomNavigator.txtUnSeenCount.Visibility = ViewStates.Gone;
                 Tabs.GetTabAt(p).SetText("Latest Response");
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Example #8
0
        private async void btnLike_Click(object sender, EventArgs e)
        {
            try
            {
                var ActivityContext = TabbedMainActivity.GetInstance();
                if (Helpers.Utils.Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        try
                        {
                            //If User Liked
                            if (btnLike.Tag.ToString() == "0")
                            {
                                btnLike.Tag = "1";
                                btnLike.SetImageResource(Resource.Drawable.like_blue);

                                if (!txtLikeNumber.Text.Contains("K") && !txtLikeNumber.Text.Contains("M"))
                                {
                                    var x = Convert.ToDouble(txtLikeNumber.Text);
                                    x++;
                                    txtLikeNumber.Text = x.ToString(System.Globalization.CultureInfo.InvariantCulture);
                                }

                                int index = mediaList.FindIndex(x => x.Id == selectedMedia.Id);
                                mediaList[index].IsLiked = "1";
                                mediaList[index].Likes   = (Convert.ToDouble(mediaList[index].Likes) + 1).ToString();
                                //AddToLiked
                                //ActivityContext.LibrarySynchronizer.AddToLiked(VideoDataHandler);

                                Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_Video_Liked), ToastLength.Short).Show();

                                //Send API Request here for Like
                                using (var client = new System.Net.Http.HttpClient())
                                {
                                    var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                                    {
                                        new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                                        new KeyValuePair <string, string>("video_id", selectedMedia.Id.ToString()),
                                        new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                                        new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                                    });

                                    //  send a Post request
                                    var uri    = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=like_response_videos";
                                    var result = await client.PostAsync(uri, formContent);

                                    //if (result.IsSuccessStatusCode)
                                    //{
                                    //    // handling the answer
                                    //    var resultString = await result.Content.ReadAsStringAsync();
                                    //    var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                                    //    if (jConfigObject["api_status"].ToString() == "200" && jConfigObject["data"] != null)
                                    //    {
                                    //    }
                                    //}
                                }
                            }
                            else
                            {
                                btnLike.Tag = "0";
                                btnLike.SetImageResource(Resource.Drawable.like_white);

                                if (!txtLikeNumber.Text.Contains("K") && !txtLikeNumber.Text.Contains("M"))
                                {
                                    var x = Convert.ToDouble(txtLikeNumber.Text);
                                    if (x > 0)
                                    {
                                        x--;
                                    }
                                    else
                                    {
                                        x = 0;
                                    }

                                    txtLikeNumber.Text = x.ToString(System.Globalization.CultureInfo.CurrentCulture);
                                }

                                int index = mediaList.FindIndex(x => x.Id == selectedMedia.Id);
                                mediaList[index].IsLiked = "0";
                                var y = Convert.ToDouble(mediaList[index].Likes);
                                if (y > 0)
                                {
                                    y--;
                                }
                                else
                                {
                                    y = 0;
                                }
                                mediaList[index].Likes = y.ToString();

                                Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_Remove_Video_Liked), ToastLength.Short).Show();

                                //Send API Request here for Remove Like
                                using (var client = new System.Net.Http.HttpClient())
                                {
                                    var formContent = new System.Net.Http.FormUrlEncodedContent(new[]
                                    {
                                        new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"),
                                        new KeyValuePair <string, string>("video_id", selectedMedia.Id.ToString()),
                                        new KeyValuePair <string, string>("user_id", UserDetails.UserId),
                                        new KeyValuePair <string, string>("s", UserDetails.AccessToken)
                                    });

                                    //  send a Post request
                                    var uri    = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=like_response_videos";
                                    var result = await client.PostAsync(uri, formContent);

                                    //if (result.IsSuccessStatusCode)
                                    //{
                                    //    // handling the answer
                                    //    var resultString = await result.Content.ReadAsStringAsync();
                                    //    var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString);
                                    //    if (jConfigObject["api_status"].ToString() == "200" && jConfigObject["data"] != null)
                                    //    {
                                    //    }
                                    //}
                                }
                            }
                            TabbedMainActivity.GetInstance().MyChannelFragment.latestResponse.adpater.LatestResponse =
                                new ObservableCollection <AdminVideoResponse>(UserResponseAPI.GetAdminVideos().VideoResponse);
                            //await ActivityContext.VideoDataWithEventsLoader.ResponseFragment.GetResponseList(ActivityContext.VideoData.VideoId);
                            //ActivityContext.VideoDataWithEventsLoader.ResponseFragment.GetUserResponse(ActivityContext.VideoData.VideoId);
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception);
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(ActivityContext, ActivityContext.VideoDataWithEventsLoader.VideoDataHandler, "Login");
                        dialog.ShowNormalDialog(this.GetText(Resource.String.Lbl_Warning), this.GetText(Resource.String.Lbl_Please_sign_in_Like), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #9
0
        private async Task LoadDataAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList;
                AdminVideoResponseModel response;
                if (VideoEnum == ResponsesEnum.FollowingResponses)
                {
                    countList = adpater.FollowingResponses.Count;
                    response  = await UserResponseAPI.GetFollowingResponseVideos();
                }
                else
                {
                    countList = adpater.ForYouResponses.Count;
                    response  = await UserResponseAPI.GetForYouResponseVideos();
                }

                if (VideoEnum == ResponsesEnum.FollowingResponses)
                {
                    var videoList   = response.VideoResponse.ToList();
                    var respondList = videoList.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in from item in videoList let check = adpater.FollowingResponses.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item)
                            {
                                adpater.FollowingResponses.Add(item);
                            }

                            Activity.RunOnUiThread(() => { adpater.NotifyItemRangeInserted(countList, adpater.FollowingResponses.Count - countList); });
                        }
                        else
                        {
                            adpater.FollowingResponses = new ObservableCollection <AdminVideoResponse>(response.VideoResponse);
                            Activity.RunOnUiThread(() => { adpater.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (((VideoEnum == ResponsesEnum.FollowingResponses && adpater.FollowingResponses.Count > 10) || (VideoEnum == ResponsesEnum.ForYouResponses && adpater.ForYouResponses.Count > 10)) && !recyclerViewUserSettigs.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreVideos), ToastLength.Short).Show();
                        }
                    }
                }
                else
                {
                    var videoList   = response.VideoResponse.ToList();
                    var respondList = videoList.Count;
                    if (respondList > 0)
                    {
                        if (countList > 0)
                        {
                            foreach (var item in from item in videoList let check = adpater.ForYouResponses.FirstOrDefault(a => a.VideoId == item.VideoId) where check == null select item)
                            {
                                adpater.ForYouResponses.Add(item);
                            }

                            Activity.RunOnUiThread(() => { adpater.NotifyItemRangeInserted(countList, adpater.ForYouResponses.Count - countList); });
                        }
                        else
                        {
                            adpater.ForYouResponses = new ObservableCollection <AdminVideoResponse>(response.VideoResponse);
                            Activity.RunOnUiThread(() => { adpater.NotifyDataSetChanged(); });
                        }
                    }
                    else
                    {
                        if (((VideoEnum == ResponsesEnum.FollowingResponses && adpater.FollowingResponses.Count > 10) || (VideoEnum == ResponsesEnum.ForYouResponses && adpater.ForYouResponses.Count > 10)) && !recyclerViewUserSettigs.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreVideos), ToastLength.Short).Show();
                        }
                    }
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
            MainScrollEvent.IsLoading = false;
        }
Example #10
0
        //private IMediaSource CreateCacheMediaSource(IMediaSource videoSource, Android.Net.Uri videoUrL)
        //{
        //    try
        //    {
        //        var url = System.IO.Path.Combine(UserResponseURL.DirectoryURL, selectedMedia.VideoLocation);
        //        var file = VideoDownloadAsyncController.GetDownloadedDiskVideoUri(url);

        //        SimpleCache cache = new SimpleCache(this.CacheDir, new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 10));
        //        CacheDataSourceFactory cacheDataSource = new CacheDataSourceFactory(cache, DefaultDataMediaFactory);

        //        if (!string.IsNullOrEmpty(file))
        //        {
        //            videoUrL = Android.Net.Uri.Parse(file);

        //            videoSource = GetMediaSourceFromUrl(videoUrL, "normal");
        //            return videoSource;
        //        }
        //        else
        //        {
        //            return null;
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        Console.WriteLine(exception);
        //        return null;
        //    }
        //}

        public void PlayAsync()
        {
            try
            {
                progressBar.Visibility = ViewStates.Visible;
                if (Player != null)
                {
                    Player.Stop();
                    Player.Release();
                }
                InitializePlayer();
                if (selectedMedia.VideoLocation.Contains(".mp4"))
                {
                    imgAudio.Visibility               = ViewStates.Gone;
                    SimpleExoPlayerView.Visibility    = ViewStates.Visible;
                    SimpleExoPlayerView.ResizeMode    = AspectRatioFrameLayout.ResizeModeZoom;
                    SimpleExoPlayerView.Player        = Player;
                    SimpleExoPlayerView.UseController = false;
                    swipListener.SwipeEvent          -= SwipListener_SwipeEvent;
                    swipListener.SwipeEvent          += SwipListener_SwipeEvent;
                    SimpleExoPlayerView.SetOnTouchListener(swipListener);
                }
                else
                {
                    imgAudio.Visibility            = ViewStates.Visible;
                    SimpleExoPlayerView.Visibility = ViewStates.Gone;
                    swipListener.SwipeEvent       -= SwipListener_SwipeEvent;
                    swipListener.SwipeEvent       += SwipListener_SwipeEvent;
                    imgAudio.SetOnTouchListener(swipListener);
                    Glide.With(this).Load(System.IO.Path.Combine(UserResponseURL.DirectoryURL, selectedMedia.Thumbnail)).Into(imgAudio);
                }
                var url         = Android.Net.Uri.Parse(System.IO.Path.Combine(UserResponseURL.DirectoryURL, selectedMedia.VideoLocation));
                var VideoSource = GetMediaSourceFromUrl(url, "normal");
                Player.Prepare(VideoSource);
                PlayerListener playerListener = new PlayerListener(this);
                playerListener.MediaPlayCompleted = () =>
                {
                    if (!string.IsNullOrEmpty(UserDetails.AccessToken))
                    {
                        UserResponseAPI.ViewVideoResponse(selectedMedia.RvId);
                        TabbedMainActivity.GetInstance().VideoDataWithEventsLoader
                        .ResponseFragment.UserResponseAdapter.UserResponseList
                        .Where(x => x.VideoLocation == selectedMedia.VideoLocation)
                        .FirstOrDefault().RvvId = string.Empty;
                        TabbedMainActivity.GetInstance().VideoDataWithEventsLoader
                        .ResponseFragment.UserResponseAdapter
                        .NotifyItemChanged(mediaList.FindIndex(x => x.VideoLocation == selectedMedia.VideoLocation));
                    }
                };
                Player.AddListener(playerListener);
                Player.PlayWhenReady = true;
                Glide.With(this).Load(UserResponseURL.DirectoryUserSettings + selectedMedia.Avatar).Into(imgProfile);
                txtUserName.Text      = selectedMedia.Username;
                txtdays.Text          = Helpers.DateTimeHelper.GetDateTimeString(selectedMedia.Timestamp);
                txtDescription.Text   = selectedMedia.Description;
                txtLikeNumber.Text    = selectedMedia.Likes;
                txtShareNumber.Text   = selectedMedia.Shares;
                txtCommentNumber.Text = selectedMedia.Comments;

                if (selectedMedia.IsLiked == "1") // true
                {
                    btnLike.Tag = "1";
                    btnLike.SetImageResource(Resource.Drawable.like_blue);
                }
                else
                {
                    btnLike.Tag = "0";
                    btnLike.SetImageResource(Resource.Drawable.like_white);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Example #11
0
        public async Task GetResponseList(string videoId)
        {
            var response = await UserResponseAPI.GetUserResponse(videoId);

            ResponseList = new ObservableCollection <RvDatum>(response);
        }