├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.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 │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_search.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── book_rv_item.xml │ │ │ │ └── activity_book_details.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── gtappdevelopers │ │ │ └── instagram │ │ │ ├── BookInfo.java │ │ │ ├── BookAdapter.java │ │ │ ├── BookDetails.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── gtappdevelopers │ │ │ └── instagram │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── gtappdevelopers │ │ └── instagram │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── androidDexCompiler.xml ├── misc.xml ├── gradle.xml └── jarRepositories.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "Instagram" -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GFG 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaitanyaMunje/LibraryApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/androidDexCompiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jan 16 12:36:38 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /.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 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0F9D58 4 | #0F9D58 5 | #0F9D58 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/gtappdevelopers/instagram/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.gtappdevelopers.instagram; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/gtappdevelopers/instagram/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.gtappdevelopers.instagram; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.gtappdevelopers.instagram", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 30 7 | buildToolsVersion "30.0.3" 8 | 9 | defaultConfig { 10 | applicationId "com.gtappdevelopers.instagram" 11 | minSdkVersion 19 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | } 30 | 31 | dependencies { 32 | 33 | implementation 'androidx.appcompat:appcompat:1.2.0' 34 | implementation 'com.google.android.material:material:1.2.1' 35 | implementation 'com.android.volley:volley:1.1.1' 36 | implementation 'com.squareup.picasso:picasso:2.71828' 37 | 38 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 39 | testImplementation 'junit:junit:4.+' 40 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 41 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 42 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 17 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | 41 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/book_rv_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 19 | 20 | 30 | 31 | 42 | 43 | 44 | 55 | 56 | 57 | 58 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/gtappdevelopers/instagram/BookInfo.java: -------------------------------------------------------------------------------- 1 | package com.gtappdevelopers.instagram; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class BookInfo { 6 | 7 | //creating string, int and array list vaiables for our book details 8 | private String title; 9 | private String subtitle; 10 | private ArrayList authors; 11 | private String publisher; 12 | private String publishedDate; 13 | private String description; 14 | private int pageCount; 15 | private String thumbnail; 16 | private String previewLink; 17 | private String infoLink; 18 | private String buyLink; 19 | 20 | //creating getter and setter methods 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | public String getSubtitle() { 30 | return subtitle; 31 | } 32 | 33 | public void setSubtitle(String subtitle) { 34 | this.subtitle = subtitle; 35 | } 36 | 37 | public ArrayList getAuthors() { 38 | return authors; 39 | } 40 | 41 | public void setAuthors(ArrayList authors) { 42 | this.authors = authors; 43 | } 44 | 45 | public String getPublisher() { 46 | return publisher; 47 | } 48 | 49 | public void setPublisher(String publisher) { 50 | this.publisher = publisher; 51 | } 52 | 53 | public String getPublishedDate() { 54 | return publishedDate; 55 | } 56 | 57 | public void setPublishedDate(String publishedDate) { 58 | this.publishedDate = publishedDate; 59 | } 60 | 61 | public String getDescription() { 62 | return description; 63 | } 64 | 65 | public void setDescription(String description) { 66 | this.description = description; 67 | } 68 | 69 | public int getPageCount() { 70 | return pageCount; 71 | } 72 | 73 | public void setPageCount(int pageCount) { 74 | this.pageCount = pageCount; 75 | } 76 | 77 | 78 | public String getThumbnail() { 79 | return thumbnail; 80 | } 81 | 82 | public void setThumbnail(String thumbnail) { 83 | this.thumbnail = thumbnail; 84 | } 85 | 86 | public String getPreviewLink() { 87 | return previewLink; 88 | } 89 | 90 | public void setPreviewLink(String previewLink) { 91 | this.previewLink = previewLink; 92 | } 93 | 94 | public String getInfoLink() { 95 | return infoLink; 96 | } 97 | 98 | public void setInfoLink(String infoLink) { 99 | this.infoLink = infoLink; 100 | } 101 | 102 | public String getBuyLink() { 103 | return buyLink; 104 | } 105 | 106 | public void setBuyLink(String buyLink) { 107 | this.buyLink = buyLink; 108 | } 109 | 110 | //creating a constructr class for our BookInfo 111 | public BookInfo(String title, String subtitle, ArrayList authors, String publisher, String publishedDate, String description, int pageCount, String thumbnail, String previewLink, String infoLink, String buyLink) { 112 | this.title = title; 113 | this.subtitle = subtitle; 114 | this.authors = authors; 115 | this.publisher = publisher; 116 | this.publishedDate = publishedDate; 117 | this.description = description; 118 | this.pageCount = pageCount; 119 | this.thumbnail = thumbnail; 120 | this.previewLink = previewLink; 121 | this.infoLink = infoLink; 122 | this.buyLink = buyLink; 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /app/src/main/java/com/gtappdevelopers/instagram/BookAdapter.java: -------------------------------------------------------------------------------- 1 | package com.gtappdevelopers.instagram; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import com.squareup.picasso.Picasso; 15 | 16 | import java.lang.reflect.Array; 17 | import java.util.ArrayList; 18 | 19 | public class BookAdapter extends RecyclerView.Adapter { 20 | 21 | //creating variables for arraylist and context. 22 | private ArrayList bookInfoArrayList; 23 | private Context mcontext; 24 | 25 | //creating constructor for array list and context. 26 | public BookAdapter(ArrayList bookInfoArrayList, Context mcontext) { 27 | this.bookInfoArrayList = bookInfoArrayList; 28 | this.mcontext = mcontext; 29 | } 30 | 31 | 32 | @NonNull 33 | @Override 34 | public BookViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 35 | //inflating our layout for item of recycler view item. 36 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.book_rv_item, parent, false); 37 | return new BookViewHolder(view); 38 | } 39 | 40 | @Override 41 | public void onBindViewHolder(@NonNull BookViewHolder holder, int position) { 42 | //inside on bind view holder method we are setting ou data to each UI component. 43 | BookInfo bookInfo = bookInfoArrayList.get(position); 44 | holder.nameTV.setText(bookInfo.getTitle()); 45 | holder.publisherTV.setText(bookInfo.getPublisher()); 46 | holder.pageCountTV.setText("No of Pages : " + bookInfo.getPageCount()); 47 | holder.dateTV.setText(bookInfo.getPublishedDate()); 48 | //below line is use to set image from URL in our image view. 49 | Picasso.get().load(bookInfo.getThumbnail()).into(holder.bookIV); 50 | 51 | //below line is use to add on click listner for our item of recycler view. 52 | holder.itemView.setOnClickListener(new View.OnClickListener() { 53 | @Override 54 | public void onClick(View v) { 55 | //inside on click listner method we are calling a new activity and passing all the data of that item in next intent. 56 | Intent i = new Intent(mcontext, BookDetails.class); 57 | i.putExtra("title", bookInfo.getTitle()); 58 | i.putExtra("subtitle", bookInfo.getSubtitle()); 59 | i.putExtra("authors", bookInfo.getAuthors()); 60 | i.putExtra("publisher", bookInfo.getPublisher()); 61 | i.putExtra("publishedDate", bookInfo.getPublishedDate()); 62 | i.putExtra("description", bookInfo.getDescription()); 63 | i.putExtra("pageCount", bookInfo.getPageCount()); 64 | i.putExtra("thumbnail", bookInfo.getThumbnail()); 65 | i.putExtra("previewLink", bookInfo.getPreviewLink()); 66 | i.putExtra("infoLink", bookInfo.getInfoLink()); 67 | i.putExtra("buyLink", bookInfo.getBuyLink()); 68 | //after passing that data we are starting our new intent. 69 | mcontext.startActivity(i); 70 | } 71 | }); 72 | } 73 | 74 | 75 | @Override 76 | public int getItemCount() { 77 | 78 | //inside get item count method we are returning the size of our array list. 79 | return bookInfoArrayList.size(); 80 | } 81 | 82 | public class BookViewHolder extends RecyclerView.ViewHolder { 83 | //below line is use to initialize our text view and image views. 84 | TextView nameTV, publisherTV, pageCountTV, dateTV; 85 | ImageView bookIV; 86 | 87 | public BookViewHolder(View itemView) { 88 | super(itemView); 89 | nameTV = itemView.findViewById(R.id.idTVBookTitle); 90 | publisherTV = itemView.findViewById(R.id.idTVpublisher); 91 | pageCountTV = itemView.findViewById(R.id.idTVPageCount); 92 | dateTV = itemView.findViewById(R.id.idTVDate); 93 | bookIV = itemView.findViewById(R.id.idIVbook); 94 | 95 | 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/gtappdevelopers/instagram/BookDetails.java: -------------------------------------------------------------------------------- 1 | package com.gtappdevelopers.instagram; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | import android.widget.Toast; 13 | 14 | import com.squareup.picasso.Picasso; 15 | 16 | import java.util.ArrayList; 17 | 18 | public class BookDetails extends AppCompatActivity { 19 | //creating variables for strings,text view, image views and button. 20 | String title, subtitle, publisher, publishedDate, description, thumbnail, previewLink, infoLink, buyLink; 21 | int pageCount; 22 | private ArrayList authors; 23 | 24 | TextView titleTV, subtitleTV, publisherTV, descTV, pageTV, publishDateTV; 25 | Button previewBtn, buyBtn; 26 | private ImageView bookIV; 27 | 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_book_details); 33 | //initializing our views.. 34 | titleTV = findViewById(R.id.idTVTitle); 35 | subtitleTV = findViewById(R.id.idTVSubTitle); 36 | publisherTV = findViewById(R.id.idTVpublisher); 37 | descTV = findViewById(R.id.idTVDescription); 38 | pageTV = findViewById(R.id.idTVNoOfPages); 39 | publishDateTV = findViewById(R.id.idTVPublishDate); 40 | previewBtn = findViewById(R.id.idBtnPreview); 41 | buyBtn = findViewById(R.id.idBtnBuy); 42 | bookIV = findViewById(R.id.idIVbook); 43 | 44 | //getting the data which we have passesd from our adapter class. 45 | title = getIntent().getStringExtra("title"); 46 | subtitle = getIntent().getStringExtra("subtitle"); 47 | publisher = getIntent().getStringExtra("publisher"); 48 | publishedDate = getIntent().getStringExtra("publishedDate"); 49 | description = getIntent().getStringExtra("description"); 50 | pageCount = getIntent().getIntExtra("pageCount", 0); 51 | thumbnail = getIntent().getStringExtra("thumbnail"); 52 | previewLink = getIntent().getStringExtra("previewLink"); 53 | infoLink = getIntent().getStringExtra("infoLink"); 54 | buyLink = getIntent().getStringExtra("buyLink"); 55 | 56 | //after getting the data we are setting that data to our text views and image view. 57 | titleTV.setText(title); 58 | subtitleTV.setText(subtitle); 59 | publisherTV.setText(publisher); 60 | publishDateTV.setText("Published On : " + publishedDate); 61 | descTV.setText(description); 62 | pageTV.setText("No Of Pages : " + pageCount); 63 | Picasso.get().load(thumbnail).into(bookIV); 64 | 65 | //adding on click listner for our preview button. 66 | previewBtn.setOnClickListener(new View.OnClickListener() { 67 | @Override 68 | public void onClick(View v) { 69 | if(previewLink.isEmpty()){ 70 | //below toast message is displayed when preview link is not present. 71 | Toast.makeText(BookDetails.this, "No preview Link present", Toast.LENGTH_SHORT).show(); 72 | return; 73 | } 74 | //if the link is present we are opening that link via an intent. 75 | Uri uri = Uri.parse(previewLink); 76 | Intent i = new Intent(Intent.ACTION_VIEW, uri); 77 | startActivity(i); 78 | } 79 | }); 80 | 81 | //initializing on click listner for buy button. 82 | buyBtn.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | if (buyLink.isEmpty()) { 86 | //below toast message is displaying when buy link is empty. 87 | Toast.makeText(BookDetails.this, "No buy page present for this book", Toast.LENGTH_SHORT).show(); 88 | return; 89 | } 90 | //if the link is present we are opening the link via an intent. 91 | Uri uri = Uri.parse(buyLink); 92 | Intent i = new Intent(Intent.ACTION_VIEW, uri); 93 | startActivity(i); 94 | } 95 | }); 96 | 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_book_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | 26 | 27 | 32 | 33 | 34 | 42 | 43 | 44 | 53 | 54 | 55 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 79 | 80 | 81 | 90 | 91 | 92 | 93 | 102 | 103 | 104 | 110 | 111 | 112 |