diff --git a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/Videos_Adapter.java b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/Videos_Adapter.java index c85642a..1922d57 100644 --- a/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/Videos_Adapter.java +++ b/app/src/main/java/com/thundersharp/cadmin/core/globalAdapters/Videos_Adapter.java @@ -9,6 +9,7 @@ import android.widget.ImageView; import android.widget.MediaController; import android.widget.ProgressBar; +import android.widget.VideoView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/AddProject.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/AddProject.java index 3a13fdc..d2e9f07 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/AddProject.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/AddProject.java @@ -3,6 +3,7 @@ import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.view.LayoutInflater; @@ -18,6 +19,7 @@ import androidx.fragment.app.Fragment; import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.Task; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.textfield.TextInputLayout; @@ -92,6 +94,47 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, @Override public void onClick(View v) { + + android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); + builder.setTitle("Delete"); + builder.setMessage("Are You Really Going To Delete This Data???"); + builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface dialog, int which) { + progressDialog = new ProgressDialog(getActivity()); + progressDialog.setTitle("Deleting"); + progressDialog.setMessage("Deleting please wait!!!"); + progressDialog.show(); + + FirebaseDatabase.getInstance().getReference() + .child("organisation") + .child("org_id").child("projects").removeValue() + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + dialog.dismiss(); + progressDialog.dismiss(); + Toast.makeText(getActivity(), "Deleted", Toast.LENGTH_SHORT).show(); + } + } + }).addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + progressDialog.dismiss(); + Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.show(); + MainActivity.navController.navigate(R.id.nav_proj); } }); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/Organisation.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/Organisation.java index e395168..95f103f 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/Organisation.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/Organisation.java @@ -86,9 +86,6 @@ public void onRefresh() { if (datapref == null){ progressorg.setVisibility(View.VISIBLE); - imageView.setVisibility(View.VISIBLE); - imageView.setImageResource(R.drawable.sad); - Toast.makeText(getActivity(),"profile server",Toast.LENGTH_SHORT).show(); fetchProfilefromsever(); progressorg.setVisibility(View.GONE); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/OrginasationDetails.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/OrginasationDetails.java index 58fe43e..ab6d109 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/OrginasationDetails.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/OrginasationDetails.java @@ -1,6 +1,8 @@ package com.thundersharp.cadmin.ui.fragment; import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.DialogInterface; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; @@ -51,6 +53,7 @@ public class OrginasationDetails extends Fragment { CircleImageView org_logo12; String org_name,org_desc,org_image,organiser_id,no_of_workforce; public static String org_id; + ProgressDialog progressDialog; int users; @Override @@ -101,21 +104,65 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, @Override public void onClick(View view) { - // if (orgs.isManager()){ - //Alert dilog here - //Toast.makeText(getActivity(), "You have deleted the noe from everywhere", Toast.LENGTH_SHORT).show(); - // }else{ - // Toast.makeText(getActivity(),"Sorry you can't delete this organisation !",Toast.LENGTH_SHORT).show(); - //} -/* - FirebaseDatabase.getInstance().getReference("users").child("organisations").child(data.getOrganisation_id()).removeValue().addOnCompleteListener(new OnCompleteListener() { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle("Delete"); + builder.setMessage("Are You Really Going To Delete This Data???"); + builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface dialog, int which) { + progressDialog = new ProgressDialog(getActivity()); + progressDialog.setTitle("Deleting"); + progressDialog.setMessage("Deleting please wait!!!"); + progressDialog.show(); + + FirebaseDatabase.getInstance().getReference() + .child("organisation") + .child(org_id).removeValue() + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + dialog.dismiss(); + progressDialog.dismiss(); + Toast.makeText(getActivity(), "Deleted", Toast.LENGTH_SHORT).show(); + } + } + }).addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + progressDialog.dismiss(); + Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.show(); + + /* + if (orgs.isManager()){ + Alert dilog here + Toast.makeText(getActivity(), "You have deleted the noe from everywhere", Toast.LENGTH_SHORT).show(); + }else{ + Toast.makeText(getActivity(),"Sorry you can't delete this organisation !",Toast.LENGTH_SHORT).show(); + } + + FirebaseDatabase.getInstance().getReference("users").child("organisations") + .child(data.getOrganisation_id()).removeValue() + .addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { } }); -*/ + */ + MainActivity.navController.navigate(R.id.nav_organisation); } }); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/ProjectsFragment.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/ProjectsFragment.java index 62ca7d0..812bb2f 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/ProjectsFragment.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/ProjectsFragment.java @@ -162,14 +162,7 @@ private void fetchListofAllProject(@NonNull List projects){ .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { - if (!snapshot.exists()){ - textView.setVisibility(View.VISIBLE); - imageView.setVisibility(View.VISIBLE); - imageView.setImageResource(R.drawable.sad); - } - else if (snapshot.exists()){ - textView.setVisibility(View.GONE); - imageView.setVisibility(View.GONE); + if (snapshot.exists()){ dataorg.add(snapshot.getValue(AddProject_model.class)); savefetchListofAllProjects(dataorg); //checking the size @@ -202,7 +195,14 @@ private void fetchProfileFromServer(){ .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { - if (snapshot.exists()){ + if (!snapshot.exists()){ + textView.setVisibility(View.VISIBLE); + imageView.setVisibility(View.VISIBLE); + imageView.setImageResource(R.drawable.sad); + } + else if (snapshot.exists()){ + textView.setVisibility(View.GONE); + imageView.setVisibility(View.GONE); for (DataSnapshot dataSnapshot : snapshot.getChildren()){ Projects projects = new Projects(dataSnapshot.getKey(),dataSnapshot.getValue(String.class)); list.add(projects); diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java index 74d0a51..cc09477 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Files.java @@ -128,8 +128,10 @@ public void onDataChange(@NonNull DataSnapshot snapshot) { } Toast.makeText(getActivity(),""+url.size(),Toast.LENGTH_SHORT).show(); PdfAdapter pdfAdapter = new PdfAdapter(getActivity(),url); + pdfAdapter.notifyDataSetChanged(); filesRecycler.setAdapter(pdfAdapter); + }else { } @@ -210,4 +212,5 @@ public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) { } }); } + } \ No newline at end of file diff --git a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java index b8e5912..ed24f9a 100644 --- a/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java +++ b/app/src/main/java/com/thundersharp/cadmin/ui/fragment/projetinfo/Video.java @@ -12,6 +12,7 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; @@ -38,6 +39,7 @@ import com.google.firebase.storage.StorageReference; import com.google.firebase.storage.UploadTask; import com.thundersharp.cadmin.R; +import com.thundersharp.cadmin.core.globalAdapters.Videos_Adapter; import java.util.ArrayList; import java.util.List; @@ -78,10 +80,8 @@ public void onClick(View view) { }); imageView = view.findViewById(R.id.imageView_video); textView = view.findViewById(R.id.tv_video); - - imageView.setVisibility(View.VISIBLE); - imageView.setImageResource(R.drawable.sad); - textView.setVisibility(View.VISIBLE); + storage = FirebaseStorage.getInstance(); + database = FirebaseDatabase.getInstance(); mediaController = new MediaController(getContext()); @@ -89,7 +89,7 @@ public void onClick(View view) { sharedPreferences =getActivity().getSharedPreferences("selected_org", Context.MODE_PRIVATE); videoRecycler= view.findViewById(R.id.recyclerVideo); videoRecycler.setHasFixedSize(true); - videoRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3)); + videoRecycler.setLayoutManager(new LinearLayoutManager(getActivity())); org_id = sharedPreferences.getString("selected",null); @@ -125,13 +125,17 @@ public void onDataChange(@NonNull DataSnapshot snapshot) { textView.setVisibility(View.VISIBLE); } if (snapshot.exists()){ + imageView.setVisibility(View.GONE); + textView.setVisibility(View.GONE); for (DataSnapshot snapshot1 : snapshot.getChildren()){ url.add(snapshot1.getValue(String.class)); } Toast.makeText(getActivity(),""+url.size(),Toast.LENGTH_SHORT).show(); -// GallaryAdapter gallaryAdapter = new GallaryAdapter(getActivity(),url); -// filesRecycler.setAdapter(gallaryAdapter); + Videos_Adapter videos_adapter = new Videos_Adapter(getActivity(),url); + videos_adapter.notifyDataSetChanged(); + videoRecycler.setAdapter(videos_adapter); + videos_adapter.notifyDataSetChanged(); }else { @@ -172,24 +176,30 @@ private void uploadVideoFile(Uri data) { .addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { - String url = taskSnapshot.getMetadata().toString(); - DatabaseReference reference = database.getReference("organisation") - .child(org_id) - .child("projects") - .child(project_key) - .child("videoFiles"); - reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener() { + taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener() { @Override - public void onComplete(@NonNull Task task) { - if (task.isSuccessful()){ - progressDialog.dismiss(); - Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show(); - } else { - progressDialog.dismiss(); - Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show(); - } + public void onSuccess(Uri uri) { + String url = uri.toString(); + DatabaseReference reference = database.getReference("organisation") + .child(org_id) + .child("projects") + .child(project_key) + .child("videoFiles"); + reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()){ + progressDialog.dismiss(); + Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show(); + } else { + progressDialog.dismiss(); + Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show(); + } + } + }); } }); + } }).addOnFailureListener(new OnFailureListener() { @Override @@ -205,4 +215,5 @@ public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) { } }); } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_play_circle_filled_24.xml b/app/src/main/res/drawable/ic_baseline_play_circle_filled_24.xml new file mode 100644 index 0000000..8278016 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_play_circle_filled_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/fragment_video.xml b/app/src/main/res/layout/fragment_video.xml index d1a5051..26a5363 100644 --- a/app/src/main/res/layout/fragment_video.xml +++ b/app/src/main/res/layout/fragment_video.xml @@ -31,7 +31,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/recyclerVideo" - shimmer:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/> + shimmer:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/> \ No newline at end of file diff --git a/app/src/main/res/layout/project_videos.xml b/app/src/main/res/layout/project_videos.xml index bc7be5f..f6b000c 100644 --- a/app/src/main/res/layout/project_videos.xml +++ b/app/src/main/res/layout/project_videos.xml @@ -3,12 +3,21 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_margin="1dp" android:layout_width="match_parent" - android:layout_height="130dp"> + android:layout_height="120dp"> - + android:layout_marginHorizontal="20dp" + android:layout_marginTop="@dimen/padding_10" + android:background="#A5E3A5"/> + + \ No newline at end of file diff --git a/app/src/main/res/layout/video_item.xml b/app/src/main/res/layout/video_item.xml new file mode 100644 index 0000000..c11dc21 --- /dev/null +++ b/app/src/main/res/layout/video_item.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file