├── 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 |
5 |
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 |
13 |
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 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
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 |
120 |
121 |
122 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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/java/com/gtappdevelopers/instagram/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gtappdevelopers.instagram;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ImageButton;
13 | import android.widget.ProgressBar;
14 | import android.widget.Toast;
15 |
16 | import com.android.volley.Request;
17 | import com.android.volley.RequestQueue;
18 | import com.android.volley.Response;
19 | import com.android.volley.VolleyError;
20 | import com.android.volley.toolbox.JsonObjectRequest;
21 | import com.android.volley.toolbox.Volley;
22 |
23 | import org.json.JSONArray;
24 | import org.json.JSONException;
25 | import org.json.JSONObject;
26 |
27 | import java.util.ArrayList;
28 |
29 | public class MainActivity extends AppCompatActivity {
30 |
31 | //creating variables for our requestqueue, array list, progressbar, edittext, image button and our recycler view.
32 | private RequestQueue mRequestQueue;
33 | private ArrayList bookInfoArrayList;
34 | private ProgressBar progressBar;
35 | private EditText searchEdt;
36 | private ImageButton searchBtn;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_main);
42 | //initializing our views.
43 | progressBar = findViewById(R.id.idLoadingPB);
44 | searchEdt = findViewById(R.id.idEdtSearchBooks);
45 | searchBtn = findViewById(R.id.idBtnSearch);
46 |
47 | //initializing on click listner for our button.
48 | searchBtn.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | progressBar.setVisibility(View.VISIBLE);
52 | //checking if our edittext field is empty or not.
53 | if (searchEdt.getText().toString().isEmpty()) {
54 | searchEdt.setError("Please enter search query");
55 | return;
56 | }
57 | //if the search query is not empty then we are calling get book info method to load all the books from the API.
58 | getBooksInfo(searchEdt.getText().toString());
59 | }
60 | });
61 | }
62 |
63 | private void getBooksInfo(String query) {
64 | //creating a new array list.
65 | bookInfoArrayList = new ArrayList<>();
66 | //below line is use to initialze the variable for our request queue.
67 | mRequestQueue = Volley.newRequestQueue(MainActivity.this);
68 | //below line is use to clear cache this will be use when our data is being updated.
69 | mRequestQueue.getCache().clear();
70 | //below is the url for getting data from API in json format.
71 | String url = "https://www.googleapis.com/books/v1/volumes?q=" + query;
72 | //below line we are creating a new request queue.
73 | RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
74 |
75 | //below line is use to make json object request inside that we are passing url, get method and getting json object. .
76 | JsonObjectRequest booksObjrequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener() {
77 | @Override
78 | public void onResponse(JSONObject response) {
79 | progressBar.setVisibility(View.GONE);
80 | //inside on response method we are extracting all our json data.
81 | try {
82 | JSONArray itemsArray = response.getJSONArray("items");
83 |
84 | for (int i = 0; i < itemsArray.length(); i++) {
85 | JSONObject itemsObj = itemsArray.getJSONObject(i);
86 | JSONObject volumeObj = itemsObj.getJSONObject("volumeInfo");
87 | String title = volumeObj.optString("title");
88 | String subtitle = volumeObj.optString("subtitle");
89 | JSONArray authorsArray = volumeObj.getJSONArray("authors");
90 | String publisher = volumeObj.optString("publisher");
91 | String publishedDate = volumeObj.optString("publishedDate");
92 | String description = volumeObj.optString("description");
93 | int pageCount = volumeObj.optInt("pageCount");
94 | JSONObject imageLinks = volumeObj.optJSONObject("imageLinks");
95 | String thumbnail = imageLinks.optString("thumbnail");
96 | String previewLink = volumeObj.optString("previewLink");
97 | String infoLink = volumeObj.optString("infoLink");
98 | JSONObject saleInfoObj = itemsObj.optJSONObject("saleInfo");
99 | String buyLink = saleInfoObj.optString("buyLink");
100 | ArrayList authorsArrayList = new ArrayList<>();
101 | if (authorsArray.length() != 0) {
102 | for (int j = 0; j < authorsArray.length(); j++) {
103 | authorsArrayList.add(authorsArray.optString(i));
104 | }
105 | }
106 | //after extracting all the data we are saving this data in our modal class.
107 | BookInfo bookInfo = new BookInfo(title, subtitle, authorsArrayList, publisher, publishedDate, description, pageCount, thumbnail, previewLink, infoLink, buyLink);
108 | //beloe line is use to pass our modal class in our array list.
109 | bookInfoArrayList.add(bookInfo);
110 | //below line is use to pass our array list in adapter class.
111 | BookAdapter adapter = new BookAdapter(bookInfoArrayList, MainActivity.this);
112 | //below line is use to add linear layout manager for our recycler view.
113 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this, RecyclerView.VERTICAL, false);
114 | RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.idRVBooks);
115 | //in below line we are setting layout manager and adapter to our recycler view.
116 | mRecyclerView.setLayoutManager(linearLayoutManager);
117 | mRecyclerView.setAdapter(adapter);
118 | }
119 | } catch (JSONException e) {
120 | e.printStackTrace();
121 | //displaying a toast message when we get any erro from API
122 | Toast.makeText(MainActivity.this, "No Data Found" + e, Toast.LENGTH_SHORT).show();
123 | }
124 | }
125 | }, new Response.ErrorListener() {
126 | @Override
127 | public void onErrorResponse(VolleyError error) {
128 | //also displaying error message in toast.
129 | Toast.makeText(MainActivity.this, "Error found is " + error, Toast.LENGTH_SHORT).show();
130 | }
131 | });
132 | //at last we are adding our json object request in our request queue.
133 | queue.add(booksObjrequest);
134 |
135 | }
136 | }
--------------------------------------------------------------------------------