Skip to content

Commit

Permalink
Saket
Browse files Browse the repository at this point in the history
  • Loading branch information
Saket105 committed Aug 2, 2020
1 parent f1b02c3 commit 14a6db8
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Void>() {
@Override
public void onComplete(@NonNull Task<Void> 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);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Void>() {
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<Void>() {
@Override
public void onComplete(@NonNull Task<Void> 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<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
}
});
*/
*/

MainActivity.navController.navigate(R.id.nav_organisation);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,7 @@ private void fetchListofAllProject(@NonNull List<Projects> 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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

}
Expand Down Expand Up @@ -210,4 +212,5 @@ public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -78,18 +80,16 @@ 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());

url = new ArrayList<>();
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);
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -172,24 +176,30 @@ private void uploadVideoFile(Uri data) {
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@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<Void>() {
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Void> 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<Void>() {
@Override
public void onComplete(@NonNull Task<Void> 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
Expand All @@ -205,4 +215,5 @@ public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,16.5v-9l6,4.5 -6,4.5z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>


</RelativeLayout>
15 changes: 12 additions & 3 deletions app/src/main/res/layout/project_videos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<VideoView
<ImageView
android:id="@+id/project_videos"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
android:layout_marginHorizontal="20dp"
android:layout_marginTop="@dimen/padding_10"
android:background="#A5E3A5"/>

<ImageButton
android:id="@+id/play_btn"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:background="@drawable/ic_baseline_play_circle_filled_24"/>

</RelativeLayout>
Loading

0 comments on commit 14a6db8

Please sign in to comment.