├── .gitignore ├── .idea ├── encodings.xml ├── gradle.xml ├── misc.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle ├── google-services.json ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── techriz │ │ └── firebasemultiplefiledownloaderfirestorerecyclerview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── techriz │ │ │ └── firebasemultiplefiledownloaderfirestorerecyclerview │ │ │ ├── DownModel.java │ │ │ ├── MainActivity.java │ │ │ ├── MyAdapter.java │ │ │ └── MyViewHolder.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── elements.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── techriz │ └── firebasemultiplefiledownloaderfirestorerecyclerview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.google.gms.google-services' 3 | 4 | android { 5 | compileSdkVersion 28 6 | defaultConfig { 7 | applicationId "com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview" 8 | minSdkVersion 22 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'com.android.support:appcompat-v7:28.0.0' 25 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 26 | implementation 'com.google.firebase:firebase-firestore:17.1.2' 27 | testImplementation 'junit:junit:4.12' 28 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 30 | implementation 'com.android.support:recyclerview-v7:28.0.0' 31 | implementation 'com.android.support:cardview-v7:28.0.0' 32 | } 33 | -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "673527800896", 4 | "firebase_url": "https://fir-multiplefiledownloader.firebaseio.com", 5 | "project_id": "fir-multiplefiledownloader", 6 | "storage_bucket": "fir-multiplefiledownloader.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:673527800896:android:ffa4c14be98378ca", 12 | "android_client_info": { 13 | "package_name": "com.techriz.firebasemultiplefiledownloader" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "673527800896-bjt4n9fcci2fbp5va7mng0caqo9jm50l.apps.googleusercontent.com", 19 | "client_type": 1, 20 | "android_info": { 21 | "package_name": "com.techriz.firebasemultiplefiledownloader", 22 | "certificate_hash": "f462860ff0b5aa47c69fe8ce5b94f83d0071508b" 23 | } 24 | }, 25 | { 26 | "client_id": "673527800896-81l3b8eice8lb2600j0d1oj3uqdehjcs.apps.googleusercontent.com", 27 | "client_type": 3 28 | } 29 | ], 30 | "api_key": [ 31 | { 32 | "current_key": "AIzaSyCID7ZhcyjsDTVV6ux8KhfRdRp1neb3e78" 33 | } 34 | ], 35 | "services": { 36 | "appinvite_service": { 37 | "other_platform_oauth_client": [ 38 | { 39 | "client_id": "673527800896-81l3b8eice8lb2600j0d1oj3uqdehjcs.apps.googleusercontent.com", 40 | "client_type": 3 41 | } 42 | ] 43 | } 44 | } 45 | }, 46 | { 47 | "client_info": { 48 | "mobilesdk_app_id": "1:673527800896:android:83aac53c43a26e72", 49 | "android_client_info": { 50 | "package_name": "com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview" 51 | } 52 | }, 53 | "oauth_client": [ 54 | { 55 | "client_id": "673527800896-b5u5fev9geh07ce52m8bsk3e95d4ant0.apps.googleusercontent.com", 56 | "client_type": 1, 57 | "android_info": { 58 | "package_name": "com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview", 59 | "certificate_hash": "f462860ff0b5aa47c69fe8ce5b94f83d0071508b" 60 | } 61 | }, 62 | { 63 | "client_id": "673527800896-81l3b8eice8lb2600j0d1oj3uqdehjcs.apps.googleusercontent.com", 64 | "client_type": 3 65 | } 66 | ], 67 | "api_key": [ 68 | { 69 | "current_key": "AIzaSyCID7ZhcyjsDTVV6ux8KhfRdRp1neb3e78" 70 | } 71 | ], 72 | "services": { 73 | "appinvite_service": { 74 | "other_platform_oauth_client": [ 75 | { 76 | "client_id": "673527800896-81l3b8eice8lb2600j0d1oj3uqdehjcs.apps.googleusercontent.com", 77 | "client_type": 3 78 | } 79 | ] 80 | } 81 | } 82 | } 83 | ], 84 | "configuration_version": "1" 85 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/techriz/firebasemultiplefiledownloaderfirestorerecyclerview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/techriz/firebasemultiplefiledownloaderfirestorerecyclerview/DownModel.java: -------------------------------------------------------------------------------- 1 | package com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview; 2 | 3 | public class DownModel { 4 | 5 | String Name,Link; 6 | 7 | public String getName() { 8 | return Name; 9 | } 10 | 11 | public void setName(String name) { 12 | Name = name; 13 | } 14 | 15 | public String getLink() { 16 | return Link; 17 | } 18 | 19 | public void setLink(String link) { 20 | Link = link; 21 | } 22 | public DownModel(String Name, String Link){ 23 | this.Link=Link; 24 | this.Name=Name; 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/techriz/firebasemultiplefiledownloaderfirestorerecyclerview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.widget.Toast; 9 | 10 | import com.google.android.gms.tasks.OnCompleteListener; 11 | import com.google.android.gms.tasks.OnFailureListener; 12 | import com.google.android.gms.tasks.Task; 13 | import com.google.firebase.firestore.DocumentSnapshot; 14 | import com.google.firebase.firestore.FirebaseFirestore; 15 | import com.google.firebase.firestore.QuerySnapshot; 16 | 17 | import java.util.ArrayList; 18 | 19 | public class MainActivity extends AppCompatActivity { 20 | FirebaseFirestore db; 21 | RecyclerView mRecyclerView; 22 | ArrayList downModelArrayList = new ArrayList<>(); 23 | MyAdapter myAdapter; 24 | 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | 31 | 32 | 33 | setUpRV(); 34 | setUpFB(); 35 | dataFromFirebase(); 36 | } 37 | 38 | 39 | private void dataFromFirebase() { 40 | if(downModelArrayList.size()>0) 41 | downModelArrayList.clear(); 42 | 43 | //db=FirebaseFirestore.getInstance(); 44 | 45 | db.collection("files") 46 | .get() 47 | .addOnCompleteListener(new OnCompleteListener() { 48 | @Override 49 | public void onComplete(@NonNull Task task) { 50 | for(DocumentSnapshot documentSnapshot: task.getResult()) { 51 | 52 | DownModel downModel= new DownModel(documentSnapshot.getString("name"), 53 | documentSnapshot.getString("link")); 54 | downModelArrayList.add(downModel); 55 | 56 | } 57 | 58 | myAdapter= new MyAdapter(MainActivity.this,downModelArrayList); 59 | mRecyclerView.setAdapter(myAdapter); 60 | } 61 | }) 62 | 63 | .addOnFailureListener(new OnFailureListener() { 64 | @Override 65 | public void onFailure(@NonNull Exception e) { 66 | Toast.makeText(MainActivity.this, "Error ;-.-;", Toast.LENGTH_SHORT).show(); 67 | } 68 | }) 69 | ; 70 | 71 | 72 | } 73 | 74 | private void setUpFB(){ 75 | db=FirebaseFirestore.getInstance(); 76 | } 77 | 78 | private void setUpRV(){ 79 | mRecyclerView= findViewById(R.id.recycle); 80 | mRecyclerView.setHasFixedSize(true); 81 | mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 82 | } 83 | 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/techriz/firebasemultiplefiledownloaderfirestorerecyclerview/MyAdapter.java: -------------------------------------------------------------------------------- 1 | package com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview; 2 | 3 | import android.app.DownloadManager; 4 | import android.content.Context; 5 | import android.net.Uri; 6 | import android.support.annotation.NonNull; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import static android.os.Environment.DIRECTORY_DOWNLOADS; 12 | 13 | import java.util.ArrayList; 14 | 15 | public class MyAdapter extends RecyclerView.Adapter { 16 | 17 | MainActivity mainActivity; 18 | ArrayList downModels; 19 | 20 | public MyAdapter(MainActivity mainActivity, ArrayList downModels) { 21 | this.mainActivity = mainActivity; 22 | this.downModels = downModels; 23 | } 24 | 25 | @NonNull 26 | @Override 27 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { 28 | 29 | LayoutInflater layoutInflater = LayoutInflater.from(mainActivity.getBaseContext()); 30 | View view = layoutInflater.inflate(R.layout.elements, null, false); 31 | 32 | return new MyViewHolder(view); 33 | } 34 | 35 | @Override 36 | public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) { 37 | 38 | myViewHolder.mName.setText(downModels.get(i).getName()); 39 | myViewHolder.mLink.setText(downModels.get(i).getLink()); 40 | myViewHolder.mDownload.setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | downloadFile(myViewHolder.mName.getContext(),downModels.get(i).getName(),".pdf",DIRECTORY_DOWNLOADS,downModels.get(i).getLink()); 44 | } 45 | }); 46 | 47 | 48 | } 49 | 50 | public void downloadFile(Context context, String fileName, String fileExtension, String destinationDirectory, String url) { 51 | 52 | DownloadManager downloadmanager = (DownloadManager) context. 53 | getSystemService(Context.DOWNLOAD_SERVICE); 54 | Uri uri = Uri.parse(url); 55 | DownloadManager.Request request = new DownloadManager.Request(uri); 56 | 57 | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); 58 | request.setDestinationInExternalFilesDir(context, destinationDirectory, fileName + fileExtension); 59 | 60 | downloadmanager.enqueue(request); 61 | } 62 | 63 | 64 | @Override 65 | public int getItemCount() { 66 | return downModels.size(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/techriz/firebasemultiplefiledownloaderfirestorerecyclerview/MyViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.techriz.firebasemultiplefiledownloaderfirestorerecyclerview; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.TextView; 8 | 9 | public class MyViewHolder extends RecyclerView.ViewHolder { 10 | 11 | TextView mName;TextView mLink; 12 | Button mDownload; 13 | public MyViewHolder(@NonNull View itemView) { 14 | super(itemView); 15 | 16 | mName=itemView.findViewById(R.id.name); 17 | mLink=itemView.findViewById(R.id.link); 18 | mDownload=itemView.findViewById(R.id.down); 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/elements.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 19 | 20 | 25 | 26 | 32 | 33 | 39 | 40 | 41 | 42 |