├── .idea
├── .name
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
├── jarRepositories.xml
└── codeStyles
│ └── Project.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── adstest
│ │ │ │ ├── CommentsRecyclerAdapter.java
│ │ │ │ ├── BlogPostId.java
│ │ │ │ ├── Comments.java
│ │ │ │ ├── CommentsActivity.java
│ │ │ │ ├── BlogPost.java
│ │ │ │ ├── LoginActivity.java
│ │ │ │ ├── RegisterActivity.java
│ │ │ │ ├── NewPostActivity.java
│ │ │ │ ├── SetupActivity.java
│ │ │ │ ├── BlogRecyclerAdapter.java
│ │ │ │ └── MainActivity.java
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── action_add.xml
│ │ │ │ ├── ic_home_black_24dp.xml
│ │ │ │ ├── action_comment_icon.xml
│ │ │ │ ├── ic_notifications_black_24dp.xml
│ │ │ │ ├── action_searc.xml
│ │ │ │ ├── ic_person_black_24dp.xml
│ │ │ │ ├── photo.xml
│ │ │ │ ├── ic_accent.xml
│ │ │ │ ├── ic_gray.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ │ ├── card_native_express_ad_container.xml
│ │ │ │ ├── activity_comments.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_new_post.xml
│ │ │ │ ├── activity_setup.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── activity_register.xml
│ │ │ │ └── card_data_item_container.xml
│ │ │ ├── menu
│ │ │ │ ├── main_menu.xml
│ │ │ │ └── menu.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── adstest
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── adstest
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── google-services.json
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Ads test
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "Ads test"
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/CommentsRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | public class CommentsRecyclerAdapter {
4 | }
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/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/ungaaaabungaaa/NativeRecyclerads/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/ungaaaabungaaa/NativeRecyclerads/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/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ungaaaabungaaa/NativeRecyclerads/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NativeRecyclerads
2 | ## simple blog app
3 | ### feature(like,comment,compression,pagination,nativeRecyclerads)
4 | 
5 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 22 00:15:32 IST 2020
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.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/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/drawable/action_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2196f3
4 | #0069C0
5 | #F44336
6 | #80ffffff
7 | #747474
8 | #F44336
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/BlogPostId.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.google.firebase.firestore.Exclude;
6 |
7 | public class BlogPostId {
8 |
9 | @Exclude
10 | public String BlogPostId;
11 | public T withId(@NonNull final String id) {
12 | this.BlogPostId = id;
13 | return (T) this;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_native_express_ad_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/action_comment_icon.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_comments.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/adstest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/action_searc.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/photo.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_accent.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/adstest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
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.example.adstest", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/Comments.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import java.util.Date;
4 |
5 | public class Comments {
6 |
7 | private String message, user_id;
8 | private Date timestamp;
9 |
10 | public Comments(){
11 |
12 | }
13 |
14 | public Comments(String message, String user_id, Date timestamp) {
15 | this.message = message;
16 | this.user_id = user_id;
17 | this.timestamp = timestamp;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | public void setMessage(String message) {
25 | this.message = message;
26 | }
27 |
28 | public String getUser_id() {
29 | return user_id;
30 | }
31 |
32 | public void setUser_id(String user_id) {
33 | this.user_id = user_id;
34 | }
35 |
36 | public Date getTimestamp() {
37 | return timestamp;
38 | }
39 |
40 | public void setTimestamp(Date timestamp) {
41 | this.timestamp = timestamp;
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_gray.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/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
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/src/main/java/com/example/adstest/CommentsActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.appcompat.widget.Toolbar;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import android.os.Bundle;
8 | import android.widget.EditText;
9 | import android.widget.ImageView;
10 |
11 | import com.google.firebase.auth.FirebaseAuth;
12 | import com.google.firebase.firestore.FirebaseFirestore;
13 |
14 | import java.util.List;
15 |
16 | public class CommentsActivity extends AppCompatActivity {
17 |
18 |
19 | private Toolbar commentToolbar;
20 | private EditText comment_field;
21 | private ImageView comment_post_btn;
22 | private RecyclerView comment_list;
23 | private CommentsRecyclerAdapter commentsRecyclerAdapter;
24 | private List commentsList;
25 | private FirebaseFirestore firebaseFirestore;
26 | private FirebaseAuth firebaseAuth;
27 | private String blog_post_id;
28 | private String current_user_id;
29 |
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_comments);
35 | }
36 | }
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "994842925152",
4 | "firebase_url": "https://ads-test-d6872.firebaseio.com",
5 | "project_id": "ads-test-d6872",
6 | "storage_bucket": "ads-test-d6872.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:994842925152:android:b94c78ec0cd572a3c94b05",
12 | "android_client_info": {
13 | "package_name": "com.example.adstest"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "994842925152-fcak88303tj73c4hu3rn0cfpr114942u.apps.googleusercontent.com",
19 | "client_type": 3
20 | }
21 | ],
22 | "api_key": [
23 | {
24 | "current_key": "AIzaSyDMTp1x2A0C7cTb20P2aUtBUsVpQn0EqKM"
25 | }
26 | ],
27 | "services": {
28 | "appinvite_service": {
29 | "other_platform_oauth_client": [
30 | {
31 | "client_id": "994842925152-fcak88303tj73c4hu3rn0cfpr114942u.apps.googleusercontent.com",
32 | "client_type": 3
33 | }
34 | ]
35 | }
36 | }
37 | }
38 | ],
39 | "configuration_version": "1"
40 | }
--------------------------------------------------------------------------------
/.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 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/BlogPost.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import java.util.Date;
4 |
5 | public class BlogPost extends BlogPostId {
6 |
7 | public String user_id, image_url, desc, image_thumb;
8 | public Date timestamp;
9 |
10 | public BlogPost() {}
11 |
12 | public BlogPost(String user_id, String image_url, String desc, String image_thumb, Date timestamp) {
13 | this.user_id = user_id;
14 | this.image_url = image_url;
15 | this.desc = desc;
16 | this.image_thumb = image_thumb;
17 | this.timestamp = timestamp;
18 | }
19 |
20 | public String getUser_id() {
21 | return user_id;
22 | }
23 |
24 | public void setUser_id(String user_id) {
25 | this.user_id = user_id;
26 | }
27 |
28 | public String getImage_url() {
29 | return image_url;
30 | }
31 |
32 | public void setImage_url(String image_url) {
33 | this.image_url = image_url;
34 | }
35 |
36 | public String getDesc() {
37 | return desc;
38 | }
39 |
40 | public void setDesc(String desc) {
41 | this.desc = desc;
42 | }
43 |
44 | public String getImage_thumb() {
45 | return image_thumb;
46 | }
47 |
48 | public void setImage_thumb(String image_thumb) {
49 | this.image_thumb = image_thumb;
50 | }
51 |
52 | public Date getTimestamp() {
53 | return timestamp;
54 | }
55 |
56 | public void setTimestamp(Date timestamp) {
57 | this.timestamp = timestamp;
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Ads test
3 | Password...
4 | Your Email...
5 | Logo Login Page
6 | Login to account
7 | Need a new Account?
8 | Search
9 | Account Settings
10 | Logout
11 | Create new Account
12 | Already have an Account?
13 | Password...
14 | Confirm Password...
15 | Your Name...
16 | Save Account Settings
17 | Your Name ...
18 | Save Account Settings
19 | Add Description ...
20 | Post Blog
21 | Home
22 | Notification
23 | Account
24 |
25 |
26 | Hello blank fragment
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
18 |
19 |
21 |
23 |
25 |
27 |
32 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'com.google.gms.google-services'
3 |
4 | android {
5 | compileSdkVersion 29
6 |
7 | defaultConfig {
8 | applicationId "com.example.adstest"
9 | minSdkVersion 21
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: "libs", include: ["*.jar"])
27 | implementation 'androidx.appcompat:appcompat:1.1.0'
28 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
29 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
30 | implementation 'com.google.android.material:material:1.1.0'
31 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
32 | implementation 'com.google.firebase:firebase-firestore:21.5.0'
33 | implementation 'com.google.firebase:firebase-storage:19.1.1'
34 | implementation 'com.google.firebase:firebase-auth:19.3.2'
35 | testImplementation 'junit:junit:4.12'
36 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38 | implementation 'com.github.bumptech.glide:glide:4.11.0'
39 | annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
40 | implementation 'id.zelory:compressor:2.1.0'
41 | implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
42 | implementation 'de.hdodenhof:circleimageview:3.1.0'
43 | implementation 'com.google.android.gms:play-services-ads:19.3.0'
44 | implementation 'com.google.firebase:firebase-ads:19.3.0'
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
21 |
32 |
33 |
41 |
42 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/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/activity_new_post.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
21 |
30 |
31 |
48 |
49 |
65 |
66 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_setup.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
22 |
23 |
24 |
35 |
36 |
51 |
52 |
68 |
69 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.text.TextUtils;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ProgressBar;
13 | import android.widget.Toast;
14 |
15 | import com.google.android.gms.tasks.OnCompleteListener;
16 | import com.google.android.gms.tasks.Task;
17 | import com.google.firebase.auth.AuthResult;
18 | import com.google.firebase.auth.FirebaseAuth;
19 | import com.google.firebase.auth.FirebaseUser;
20 |
21 | public class LoginActivity extends AppCompatActivity {
22 | private EditText loginEmailText;
23 | private EditText loginPassText;
24 | private Button loginBtn;
25 | private Button loginRegBtn;
26 | private FirebaseAuth mAuth;
27 | private ProgressBar loginProgress;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_login);
33 | mAuth = FirebaseAuth.getInstance();
34 | loginEmailText = findViewById(R.id.reg_email);
35 | loginPassText = findViewById(R.id.reg_confirm_pass);
36 | loginBtn = findViewById(R.id.login_btn);
37 | loginRegBtn = findViewById(R.id.login_reg_btn);
38 | loginProgress = findViewById(R.id.login_progress);
39 | loginRegBtn.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 |
43 | Intent regIntent = new Intent(LoginActivity.this, RegisterActivity.class);
44 | startActivity(regIntent);
45 |
46 | }
47 | });
48 |
49 |
50 | loginBtn.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | String loginEmail = loginEmailText.getText().toString();
54 | String loginPass = loginPassText.getText().toString();
55 | if(!TextUtils.isEmpty(loginEmail) && !TextUtils.isEmpty(loginPass)){
56 | loginProgress.setVisibility(View.VISIBLE);
57 | mAuth.signInWithEmailAndPassword(loginEmail, loginPass).addOnCompleteListener(new OnCompleteListener() {
58 | @Override
59 | public void onComplete(@NonNull Task task) {
60 |
61 | if(task.isSuccessful()){
62 |
63 | sendToMain();
64 |
65 | } else {
66 |
67 | String errorMessage = task.getException().getMessage();
68 | Toast.makeText(LoginActivity.this, "Error : " + errorMessage, Toast.LENGTH_LONG).show();
69 | }
70 | loginProgress.setVisibility(View.INVISIBLE);
71 | }
72 | });
73 | }
74 | }
75 | });
76 | }
77 |
78 | @Override
79 | protected void onStart() {
80 | super.onStart();
81 | FirebaseUser currentUser = mAuth.getCurrentUser();
82 | if(currentUser != null){
83 | sendToMain();
84 | }
85 | }
86 | private void sendToMain() {
87 | Intent mainIntent = new Intent(LoginActivity.this, MainActivity.class);
88 | startActivity(mainIntent);
89 | finish();
90 | }
91 | }
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/RegisterActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.text.TextUtils;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ProgressBar;
13 | import android.widget.Toast;
14 |
15 | import com.google.android.gms.tasks.OnCompleteListener;
16 | import com.google.android.gms.tasks.Task;
17 | import com.google.firebase.auth.AuthResult;
18 | import com.google.firebase.auth.FirebaseAuth;
19 | import com.google.firebase.auth.FirebaseUser;
20 |
21 | public class RegisterActivity extends AppCompatActivity {
22 |
23 | private EditText reg_email_field;
24 | private EditText reg_pass_field;
25 | private EditText reg_confirm_pass_field;
26 | private Button reg_btn;
27 | private Button reg_login_btn;
28 | private ProgressBar reg_progress;
29 | private FirebaseAuth mAuth;
30 |
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_register);
36 | mAuth = FirebaseAuth.getInstance();
37 |
38 |
39 | reg_email_field = findViewById(R.id.reg_email);
40 | reg_pass_field = findViewById(R.id.reg_pass);
41 | reg_confirm_pass_field = findViewById(R.id.reg_confirm_pass);
42 | reg_btn = findViewById(R.id.reg_btn);
43 | reg_login_btn = findViewById(R.id.reg_login_btn);
44 | reg_progress = findViewById(R.id.reg_progress);
45 |
46 | reg_login_btn.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 |
50 | finish();
51 |
52 | }
53 | });
54 |
55 | reg_btn.setOnClickListener(new View.OnClickListener() {
56 | @Override
57 | public void onClick(View v) {
58 |
59 | String email = reg_email_field.getText().toString();
60 | String pass = reg_pass_field.getText().toString();
61 | String confirm_pass = reg_confirm_pass_field.getText().toString();
62 |
63 | if(!TextUtils.isEmpty(email) && !TextUtils.isEmpty(pass) & !TextUtils.isEmpty(confirm_pass)){
64 | if(pass.equals(confirm_pass)){
65 |
66 | reg_progress.setVisibility(View.VISIBLE);
67 |
68 | mAuth.createUserWithEmailAndPassword(email, pass).addOnCompleteListener(new OnCompleteListener() {
69 | @Override
70 | public void onComplete(@NonNull Task task) {
71 |
72 | if(task.isSuccessful()){
73 |
74 | Intent setupIntent = new Intent(RegisterActivity.this, SetupActivity.class);
75 | startActivity(setupIntent);
76 | finish();
77 |
78 | } else {
79 |
80 | String errorMessage = task.getException().getMessage();
81 | Toast.makeText(RegisterActivity.this, "Error : " + errorMessage, Toast.LENGTH_LONG).show();
82 |
83 | }
84 |
85 | reg_progress.setVisibility(View.INVISIBLE);
86 | }
87 | });
88 |
89 | } else {
90 | Toast.makeText(RegisterActivity.this, "Confirm Password and Password Field doesn't match.", Toast.LENGTH_LONG).show();
91 |
92 | }
93 | }
94 |
95 |
96 | }
97 | });
98 |
99 |
100 | }
101 |
102 | @Override
103 | protected void onStart() {
104 | super.onStart();
105 | FirebaseUser currentUser = mAuth.getCurrentUser();
106 | if(currentUser != null){
107 | sendToMain();
108 | }
109 | }
110 |
111 | private void sendToMain() {
112 | Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
113 | startActivity(mainIntent);
114 | finish();
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
21 |
22 |
40 |
41 |
59 |
60 |
77 |
78 |
95 |
96 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_register.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
41 |
42 |
59 |
60 |
77 |
78 |
95 |
96 |
106 |
107 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/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/layout/card_data_item_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
19 |
22 |
23 |
34 |
35 |
43 |
44 |
54 |
55 |
63 |
64 |
73 |
74 |
85 |
86 |
97 |
98 |
109 |
110 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/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/example/adstest/NewPostActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.appcompat.widget.Toolbar;
6 |
7 | import android.content.Intent;
8 | import android.graphics.Bitmap;
9 | import android.net.Uri;
10 | import android.os.Bundle;
11 | import android.text.TextUtils;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 | import android.widget.ImageView;
16 | import android.widget.ProgressBar;
17 | import android.widget.Toast;
18 |
19 | import com.google.android.gms.tasks.OnCompleteListener;
20 | import com.google.android.gms.tasks.OnFailureListener;
21 | import com.google.android.gms.tasks.OnSuccessListener;
22 | import com.google.android.gms.tasks.Task;
23 | import com.google.firebase.auth.FirebaseAuth;
24 | import com.google.firebase.firestore.DocumentReference;
25 | import com.google.firebase.firestore.FieldValue;
26 | import com.google.firebase.firestore.FirebaseFirestore;
27 | import com.google.firebase.storage.FirebaseStorage;
28 | import com.google.firebase.storage.StorageReference;
29 | import com.google.firebase.storage.UploadTask;
30 | import com.theartofdev.edmodo.cropper.CropImage;
31 | import com.theartofdev.edmodo.cropper.CropImageView;
32 |
33 | import java.io.ByteArrayOutputStream;
34 | import java.io.File;
35 | import java.io.IOException;
36 | import java.util.HashMap;
37 | import java.util.Map;
38 | import java.util.UUID;
39 |
40 | import id.zelory.compressor.Compressor;
41 |
42 | public class NewPostActivity extends AppCompatActivity {
43 |
44 |
45 | private Toolbar newPostToolbar;
46 | private ImageView newPostImage;
47 | private EditText newPostDesc;
48 | private Button newPostBtn;
49 | private Uri postImageUri = null;
50 | private ProgressBar newPostProgress;
51 | private StorageReference storageReference;
52 | private FirebaseFirestore firebaseFirestore;
53 | private FirebaseAuth firebaseAuth;
54 | private String current_user_id;
55 | private Bitmap compressedImageFile;
56 |
57 |
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.activity_new_post);
62 | storageReference = FirebaseStorage.getInstance().getReference();
63 | firebaseFirestore = FirebaseFirestore.getInstance();
64 | firebaseAuth = FirebaseAuth.getInstance();
65 | current_user_id = firebaseAuth.getCurrentUser().getUid();
66 | newPostImage = findViewById(R.id.new_post_image);
67 | newPostDesc = findViewById(R.id.new_post_desc);
68 | newPostBtn = findViewById(R.id.post_btn);
69 | newPostProgress = findViewById(R.id.new_post_progress);
70 | newPostImage.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | CropImage.activity()
74 | .setGuidelines(CropImageView.Guidelines.ON)
75 | .setMinCropResultSize(512, 512)
76 | .setAspectRatio(1, 1)
77 | .start(NewPostActivity.this);
78 |
79 | }
80 | });
81 |
82 | newPostBtn.setOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View v) {
85 | final String desc = newPostDesc.getText().toString();
86 | if(!TextUtils.isEmpty(desc) && postImageUri != null){
87 | newPostProgress.setVisibility(View.VISIBLE);
88 | final String randomName = UUID.randomUUID().toString();
89 |
90 | // PHOTO UPLOAD
91 | File newImageFile = new File(postImageUri.getPath());
92 | try {
93 |
94 | compressedImageFile = new Compressor(NewPostActivity.this)
95 | .setMaxHeight(720)
96 | .setMaxWidth(720)
97 | .setQuality(50)
98 | .compressToBitmap(newImageFile);
99 |
100 | } catch (IOException e) {
101 | e.printStackTrace();
102 | }
103 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
104 | compressedImageFile.compress(Bitmap.CompressFormat.JPEG, 100, baos);
105 | byte[] imageData = baos.toByteArray();
106 | // PHOTO UPLOAD
107 | UploadTask filePath = storageReference.child("post_images").child(randomName + ".jpg").putBytes(imageData);
108 | filePath.addOnCompleteListener(new OnCompleteListener() {
109 | @Override
110 | public void onComplete(@NonNull final Task task) {
111 | final String downloadUri = task.getResult().toString();
112 | if(task.isSuccessful()){
113 |
114 | File newThumbFile = new File(postImageUri.getPath());
115 | try {
116 |
117 | compressedImageFile = new Compressor(NewPostActivity.this)
118 | .setMaxHeight(100)
119 | .setMaxWidth(100)
120 | .setQuality(1)
121 | .compressToBitmap(newThumbFile);
122 |
123 | } catch (IOException e) {
124 | e.printStackTrace();
125 | }
126 |
127 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
128 | compressedImageFile.compress(Bitmap.CompressFormat.JPEG, 100, baos);
129 | byte[] thumbData = baos.toByteArray();
130 |
131 | UploadTask uploadTask = storageReference.child("post_images/thumbs")
132 | .child(randomName + ".jpg").putBytes(thumbData);
133 |
134 | uploadTask.addOnSuccessListener(new OnSuccessListener() {
135 | @Override
136 | public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
137 | Task urlTask = taskSnapshot.getStorage().getDownloadUrl();
138 | while (!urlTask.isSuccessful());
139 | Uri downloadUrl = urlTask.getResult();
140 | String downloadthumbUri = downloadUri.toString();
141 | Map postMap = new HashMap<>();
142 | postMap.put("image_url", downloadUri);
143 | postMap.put("image_thumb", downloadthumbUri);
144 | postMap.put("desc", desc);
145 | postMap.put("user_id", current_user_id);
146 | postMap.put("timestamp", FieldValue.serverTimestamp());
147 | firebaseFirestore.collection("Posts").add(postMap).addOnCompleteListener(new OnCompleteListener() {
148 | @Override
149 | public void onComplete(@NonNull Task task) {
150 | if(task.isSuccessful()){
151 | Toast.makeText(NewPostActivity.this, "Post was added", Toast.LENGTH_LONG).show();
152 | Intent mainIntent = new Intent(NewPostActivity.this, MainActivity.class);
153 | startActivity(mainIntent);
154 | finish();
155 |
156 | } else {
157 |
158 |
159 | }
160 |
161 | newPostProgress.setVisibility(View.INVISIBLE);
162 |
163 | }
164 | });
165 |
166 | }
167 | }).addOnFailureListener(new OnFailureListener() {
168 | @Override
169 | public void onFailure(@NonNull Exception e) {
170 |
171 | //Error handling
172 |
173 | }
174 | });
175 |
176 |
177 | } else {
178 |
179 | newPostProgress.setVisibility(View.INVISIBLE);
180 |
181 | }
182 |
183 | }
184 | });
185 |
186 |
187 | }
188 |
189 | }
190 | });
191 |
192 |
193 | }
194 |
195 | @Override
196 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
197 | super.onActivityResult(requestCode, resultCode, data);
198 |
199 | if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
200 | CropImage.ActivityResult result = CropImage.getActivityResult(data);
201 | if (resultCode == RESULT_OK) {
202 | postImageUri = result.getUri();
203 | newPostImage.setImageURI(postImageUri);
204 |
205 | } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
206 | Exception error = result.getError();
207 |
208 | }
209 | }
210 |
211 | }
212 |
213 | }
214 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/SetupActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.core.app.ActivityCompat;
6 | import androidx.core.content.ContextCompat;
7 |
8 | import android.Manifest;
9 | import android.content.Intent;
10 | import android.content.pm.PackageManager;
11 | import android.graphics.Bitmap;
12 | import android.net.Uri;
13 | import android.os.Build;
14 | import android.os.Bundle;
15 | import android.text.TextUtils;
16 | import android.view.View;
17 | import android.widget.Button;
18 | import android.widget.EditText;
19 | import android.widget.ProgressBar;
20 | import android.widget.Toast;
21 |
22 | import com.bumptech.glide.Glide;
23 | import com.bumptech.glide.request.RequestOptions;
24 | import com.google.android.gms.tasks.OnCompleteListener;
25 | import com.google.android.gms.tasks.Task;
26 | import com.google.firebase.auth.FirebaseAuth;
27 | import com.google.firebase.firestore.DocumentSnapshot;
28 | import com.google.firebase.firestore.FirebaseFirestore;
29 | import com.google.firebase.storage.FirebaseStorage;
30 | import com.google.firebase.storage.StorageReference;
31 | import com.google.firebase.storage.UploadTask;
32 | import com.theartofdev.edmodo.cropper.CropImage;
33 | import com.theartofdev.edmodo.cropper.CropImageView;
34 |
35 | import java.io.ByteArrayOutputStream;
36 | import java.io.File;
37 | import java.io.IOException;
38 | import java.util.HashMap;
39 | import java.util.Map;
40 |
41 | import de.hdodenhof.circleimageview.CircleImageView;
42 | import id.zelory.compressor.Compressor;
43 |
44 | public class SetupActivity extends AppCompatActivity {
45 | private CircleImageView setupImage;
46 | private Uri mainImageURI = null;
47 | private String user_id;
48 | private boolean isChanged = false;
49 | private EditText setupName;
50 | private Button setupBtn;
51 | private ProgressBar setupProgress;
52 | private StorageReference storageReference;
53 | private FirebaseAuth firebaseAuth;
54 | private FirebaseFirestore firebaseFirestore;
55 | private Bitmap compressedImageFile;
56 | String string;
57 |
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.activity_setup);
62 | firebaseAuth = FirebaseAuth.getInstance();
63 | user_id = firebaseAuth.getCurrentUser().getUid();
64 |
65 | firebaseFirestore = FirebaseFirestore.getInstance();
66 | storageReference = FirebaseStorage.getInstance().getReference();
67 | setupImage = findViewById(R.id.setup_image);
68 | setupName = findViewById(R.id.setup_name);
69 | setupBtn = findViewById(R.id.setup_btn);
70 | setupProgress = findViewById(R.id.setup_progress);
71 | setupProgress.setVisibility(View.VISIBLE);
72 | setupBtn.setEnabled(false);
73 | firebaseFirestore.collection("Users").document(user_id).get().addOnCompleteListener(new OnCompleteListener() {
74 | @Override
75 | public void onComplete(@NonNull Task task) {
76 | if(task.isSuccessful()){
77 | if(task.getResult().exists()){
78 | String name = task.getResult().getString("name");
79 | String image = task.getResult().getString("image");
80 | mainImageURI = Uri.parse(image);
81 | setupName.setText(name);
82 | RequestOptions placeholderRequest = new RequestOptions();
83 | placeholderRequest.placeholder(R.drawable.photo);
84 | Glide.with(SetupActivity.this).setDefaultRequestOptions(placeholderRequest).load(image).into(setupImage);
85 | }
86 |
87 | } else {
88 |
89 | String error = task.getException().getMessage();
90 | Toast.makeText(SetupActivity.this, "(FIRESTORE Retrieve Error) : " + error, Toast.LENGTH_LONG).show();
91 | }
92 |
93 | setupProgress.setVisibility(View.INVISIBLE);
94 | setupBtn.setEnabled(true);
95 |
96 | }
97 | });
98 |
99 |
100 | setupBtn.setOnClickListener(new View.OnClickListener() {
101 | @Override
102 | public void onClick(View v) {
103 |
104 | final String user_name = setupName.getText().toString();
105 | if (!TextUtils.isEmpty(user_name) && mainImageURI != null) {
106 | setupProgress.setVisibility(View.VISIBLE);
107 | if (isChanged) {
108 | user_id = firebaseAuth.getCurrentUser().getUid();
109 | File newImageFile = new File(mainImageURI.getPath());
110 | try {
111 |
112 | compressedImageFile = new Compressor(SetupActivity.this)
113 | .setMaxHeight(125)
114 | .setMaxWidth(125)
115 | .setQuality(50)
116 | .compressToBitmap(newImageFile);
117 |
118 | } catch (IOException e) {
119 | e.printStackTrace();
120 | }
121 |
122 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
123 | compressedImageFile.compress(Bitmap.CompressFormat.JPEG, 100, baos);
124 | byte[] thumbData = baos.toByteArray();
125 | UploadTask image_path = storageReference.child("profile_images").child(user_id + ".jpg").putBytes(thumbData);
126 | image_path.addOnCompleteListener(new OnCompleteListener() {
127 | @Override
128 | public void onComplete(@NonNull Task task) {
129 |
130 | if (task.isSuccessful()) {
131 | storeFirestore(task, user_name);
132 |
133 | } else {
134 |
135 | String error = task.getException().getMessage();
136 | Toast.makeText(SetupActivity.this, "(IMAGE Error) : " + error, Toast.LENGTH_LONG).show();
137 |
138 | setupProgress.setVisibility(View.INVISIBLE);
139 |
140 | }
141 | }
142 | });
143 |
144 | } else {
145 |
146 | storeFirestore(null, user_name);
147 |
148 | }
149 |
150 | }
151 |
152 | }
153 |
154 | });
155 |
156 | setupImage.setOnClickListener(new View.OnClickListener() {
157 | @Override
158 | public void onClick(View v) {
159 |
160 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
161 | if(ContextCompat.checkSelfPermission(SetupActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
162 | Toast.makeText(SetupActivity.this, "Permission Denied", Toast.LENGTH_LONG).show();
163 | ActivityCompat.requestPermissions(SetupActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
164 | } else {
165 | BringImagePicker();
166 | }
167 | } else {
168 | BringImagePicker();
169 | }
170 | }
171 | });
172 | }
173 |
174 | private void storeFirestore(@NonNull Task task, String user_name) {
175 | Uri download_uri;
176 | if(task != null) {
177 | string=task.getResult().toString();
178 | } else {
179 | download_uri = mainImageURI;
180 | }
181 | Map userMap = new HashMap<>();
182 | userMap.put("name", user_name);
183 | userMap.put("image", string);
184 | firebaseFirestore.collection("Users").document(user_id).set(userMap).addOnCompleteListener(new OnCompleteListener() {
185 | @Override
186 | public void onComplete(@NonNull Task task) {
187 | if(task.isSuccessful()){
188 | Toast.makeText(SetupActivity.this, "The user Settings are updated.", Toast.LENGTH_LONG).show();
189 | Intent mainIntent = new Intent(SetupActivity.this, MainActivity.class);
190 | startActivity(mainIntent);
191 | finish();
192 |
193 | } else {
194 | String error = task.getException().getMessage();
195 | Toast.makeText(SetupActivity.this, "(FIRESTORE Error) : " + error, Toast.LENGTH_LONG).show();
196 |
197 | }
198 | setupProgress.setVisibility(View.INVISIBLE);
199 |
200 | }
201 | });
202 |
203 |
204 | }
205 |
206 | private void BringImagePicker() {
207 | CropImage.activity()
208 | .setGuidelines(CropImageView.Guidelines.ON)
209 | .setAspectRatio(1, 1)
210 | .start(SetupActivity.this);
211 |
212 | }
213 |
214 | @Override
215 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
216 | super.onActivityResult(requestCode, resultCode, data);
217 |
218 | if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
219 | CropImage.ActivityResult result = CropImage.getActivityResult(data);
220 | if (resultCode == RESULT_OK) {
221 |
222 | mainImageURI = result.getUri();
223 | setupImage.setImageURI(mainImageURI);
224 |
225 | isChanged = true;
226 |
227 | } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
228 |
229 | Exception error = result.getError();
230 |
231 | }
232 | }
233 |
234 | }
235 | }
236 |
237 |
238 |
239 |
240 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/BlogRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.text.format.DateFormat;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.recyclerview.widget.RecyclerView;
15 |
16 | import com.bumptech.glide.Glide;
17 | import com.bumptech.glide.request.RequestOptions;
18 | import com.google.android.gms.ads.NativeExpressAdView;
19 | import com.google.android.gms.tasks.OnCompleteListener;
20 | import com.google.android.gms.tasks.Task;
21 | import com.google.firebase.auth.FirebaseAuth;
22 | import com.google.firebase.firestore.DocumentSnapshot;
23 | import com.google.firebase.firestore.EventListener;
24 | import com.google.firebase.firestore.FieldValue;
25 | import com.google.firebase.firestore.FirebaseFirestore;
26 | import com.google.firebase.firestore.FirebaseFirestoreException;
27 | import com.google.firebase.firestore.QuerySnapshot;
28 |
29 | import java.util.Date;
30 | import java.util.HashMap;
31 | import java.util.List;
32 | import java.util.Map;
33 |
34 | import de.hdodenhof.circleimageview.CircleImageView;
35 |
36 | public class BlogRecyclerAdapter extends RecyclerView.Adapter {
37 |
38 |
39 | //this is my adapter class where admob has to addded sir
40 | public List blog_list;
41 | public Context context;
42 | private FirebaseFirestore firebaseFirestore;
43 | private FirebaseAuth firebaseAuth;
44 | private int spaceBetweenAds;
45 | private static final int DATA_VIEW_TYPE = 0;
46 | private static final int NATIVE_EXPRESS_AD_VIEW_TYPE = 1;
47 |
48 |
49 |
50 | public BlogRecyclerAdapter(List blog_list){
51 | this.blog_list = blog_list;
52 |
53 | }
54 |
55 | @Override
56 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
57 | switch (viewType) {
58 | case DATA_VIEW_TYPE:
59 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_data_item_container, parent, false);
60 | context = parent.getContext();
61 | firebaseFirestore = FirebaseFirestore.getInstance();
62 | firebaseAuth = FirebaseAuth.getInstance();
63 | return new ViewHolder(view);
64 | case NATIVE_EXPRESS_AD_VIEW_TYPE:
65 | // fall through
66 | default:
67 | View nativeExpressLayoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_native_express_ad_container, viewGroup, false);
68 | return new NativeExpressAdViewHolder(nativeExpressLayoutView);
69 | }
70 |
71 | }
72 |
73 | @Override
74 | public void onBindViewHolder(final ViewHolder holder, int position) {
75 | int viewType = getItemViewType(position);
76 | switch (viewType) {
77 | case DATA_VIEW_TYPE:
78 | holder.setIsRecyclable(false);
79 | final String blogPostId = blog_list.get(position).BlogPostId;
80 | final String currentUserId = firebaseAuth.getCurrentUser().getUid();
81 | String desc_data = blog_list.get(position).getDesc();
82 | holder.setDescText(desc_data);
83 | String image_url = blog_list.get(position).getImage_url();
84 | String thumbUri = blog_list.get(position).getImage_thumb();
85 | holder.setBlogImage(image_url, thumbUri);
86 | String user_id = blog_list.get(position).getUser_id();
87 | //User Data will be retrieved here...
88 | firebaseFirestore.collection("Users").document(user_id).get().addOnCompleteListener(new OnCompleteListener() {
89 | @Override
90 | public void onComplete(@NonNull Task task) {
91 | if(task.isSuccessful()){
92 | String userName = task.getResult().getString("name");
93 | String userImage = task.getResult().getString("image");
94 | holder.setUserData(userName, userImage);
95 | } else {
96 | //Firebase Exception
97 | }
98 | }
99 | });
100 | try {
101 | long millisecond = blog_list.get(position).getTimestamp().getTime();
102 | String dateString = DateFormat.format("MM/dd/yyyy", new Date(millisecond)).toString();
103 | holder.setTime(dateString);
104 | } catch (Exception e) {
105 |
106 | Toast.makeText(context, "Exception : " + e.getMessage(), Toast.LENGTH_SHORT).show();
107 | }
108 | //Get Likes Count
109 | firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").addSnapshotListener( new EventListener() {
110 | @Override
111 | public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
112 | if(!documentSnapshots.isEmpty()){
113 | int count = documentSnapshots.size();
114 | holder.updateLikesCount(count);
115 | } else {
116 | holder.updateLikesCount(0);
117 | }
118 | }
119 | });
120 |
121 | //Get Likes
122 | firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).addSnapshotListener(new EventListener() {
123 | @Override
124 | public void onEvent(DocumentSnapshot documentSnapshot, FirebaseFirestoreException e) {
125 | if(documentSnapshot.exists()){
126 | holder.blogLikeBtn.setImageDrawable(context.getDrawable(R.drawable.ic_gray));
127 | } else {
128 | holder.blogLikeBtn.setImageDrawable(context.getDrawable(R.drawable.ic_accent));
129 | }
130 | }
131 | });
132 |
133 | //Likes Feature
134 | holder.blogLikeBtn.setOnClickListener(new View.OnClickListener() {
135 | @Override
136 | public void onClick(View v) {
137 | firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).get().addOnCompleteListener(new OnCompleteListener() {
138 | @Override
139 | public void onComplete(@NonNull Task task) {
140 | if(!task.getResult().exists()){
141 | Map likesMap = new HashMap<>();
142 | likesMap.put("timestamp", FieldValue.serverTimestamp());
143 | firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).set(likesMap);
144 | } else {
145 | firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).delete();
146 | }
147 | }
148 | });
149 | }
150 | });
151 |
152 | holder.blogCommentBtn.setOnClickListener(new View.OnClickListener() {
153 | @Override
154 | public void onClick(View v) {
155 | Intent commentIntent = new Intent(context, CommentsActivity.class);
156 | commentIntent.putExtra("blog_post_id", blogPostId);
157 | context.startActivity(commentIntent);
158 | }
159 | });
160 |
161 | break;
162 | case NATIVE_EXPRESS_AD_VIEW_TYPE:
163 | // fall through
164 | default:
165 | //i have few errors here
166 | NativeExpressAdViewHolder nativeExpressHolder = (NativeExpressAdViewHolder) holder;
167 | NativeExpressAdView adView = (NativeExpressAdView) blog_list.get(position);
168 | ViewGroup adCardView = (ViewGroup) nativeExpressHolder.itemView;
169 | if (adCardView.getChildCount() > 0) {
170 | adCardView.removeAllViews();
171 | }
172 | if (adView.getParent() != null) {
173 | ((ViewGroup) adView.getParent()).removeView(adView);
174 | }
175 | adCardView.addView(adView);
176 | }
177 |
178 | }
179 |
180 |
181 |
182 |
183 | public class NativeExpressAdViewHolder extends RecyclerView.ViewHolder {
184 | NativeExpressAdViewHolder(View view) {
185 | super(view);
186 | }
187 | }
188 |
189 |
190 |
191 |
192 |
193 |
194 | @Override
195 | public int getItemCount() {
196 | return blog_list.size();
197 | }
198 |
199 | public class ViewHolder extends RecyclerView.ViewHolder {
200 | private View mView;
201 | private TextView descView;
202 | private ImageView blogImageView;
203 | private TextView blogDate;
204 | private TextView blogUserName;
205 | private CircleImageView blogUserImage;
206 | private ImageView blogLikeBtn;
207 | private TextView blogLikeCount;
208 | private ImageView blogCommentBtn;
209 |
210 | public ViewHolder(View itemView) {
211 | super(itemView);
212 | mView = itemView;
213 | blogLikeBtn = mView.findViewById(R.id.blog_like_btn);
214 | blogCommentBtn = mView.findViewById(R.id.blog_comment_icon);
215 | }
216 |
217 | public void setDescText(String descText){
218 | descView = mView.findViewById(R.id.blog_desc);
219 | descView.setText(descText);
220 | }
221 |
222 | public void setBlogImage(String downloadUri, String thumbUri){
223 | blogImageView = mView.findViewById(R.id.blog_image);
224 | RequestOptions requestOptions = new RequestOptions();
225 | requestOptions.placeholder(R.drawable.photo);
226 | Glide.with(context).applyDefaultRequestOptions(requestOptions).load(downloadUri).thumbnail(
227 | Glide.with(context).load(thumbUri)
228 | ).into(blogImageView);
229 |
230 | }
231 |
232 | public void setTime(String date) {
233 | blogDate = mView.findViewById(R.id.blog_date);
234 | blogDate.setText(date);
235 |
236 | }
237 |
238 | public void setUserData(String name, String image){
239 | blogUserImage = mView.findViewById(R.id.blog_user_image);
240 | blogUserName = mView.findViewById(R.id.blog_user_name);
241 | blogUserName.setText(name);
242 | RequestOptions placeholderOption = new RequestOptions();
243 | placeholderOption.placeholder(R.drawable.photo);
244 | Glide.with(context).applyDefaultRequestOptions(placeholderOption).load(image).into(blogUserImage);
245 | }
246 |
247 | public void updateLikesCount(int count){
248 | blogLikeCount = mView.findViewById(R.id.blog_like_count);
249 | blogLikeCount.setText(count + " Likes");
250 |
251 | }
252 |
253 | }
254 |
255 |
256 |
257 |
258 | }
259 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/adstest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.adstest;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.app.AppCompatActivity;
13 | import androidx.appcompat.widget.Toolbar;
14 | import androidx.recyclerview.widget.LinearLayoutManager;
15 | import androidx.recyclerview.widget.RecyclerView;
16 |
17 | import com.google.android.gms.ads.AdListener;
18 | import com.google.android.gms.ads.AdRequest;
19 | import com.google.android.gms.ads.AdSize;
20 | import com.google.android.gms.ads.MobileAds;
21 | import com.google.android.gms.ads.NativeExpressAdView;
22 | import com.google.android.gms.tasks.OnCompleteListener;
23 | import com.google.android.gms.tasks.Task;
24 | import com.google.android.material.bottomnavigation.BottomNavigationView;
25 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
26 | import com.google.firebase.auth.FirebaseAuth;
27 | import com.google.firebase.auth.FirebaseUser;
28 | import com.google.firebase.firestore.DocumentChange;
29 | import com.google.firebase.firestore.DocumentSnapshot;
30 | import com.google.firebase.firestore.EventListener;
31 | import com.google.firebase.firestore.FirebaseFirestore;
32 | import com.google.firebase.firestore.FirebaseFirestoreException;
33 | import com.google.firebase.firestore.Query;
34 | import com.google.firebase.firestore.QuerySnapshot;
35 |
36 | import java.util.ArrayList;
37 | import java.util.List;
38 |
39 | public class MainActivity extends AppCompatActivity {
40 |
41 | private Toolbar mainToolbar;
42 | private FirebaseAuth mAuth;
43 | private FirebaseFirestore firebaseFirestore;
44 | private String current_user_id;
45 | private FloatingActionButton addPostBtn;
46 | private BottomNavigationView mainbottomNav;
47 | private RecyclerView blog_list_view;
48 | private List blog_list;
49 | private FirebaseAuth firebaseAuth;
50 | private BlogRecyclerAdapter blogRecyclerAdapter;
51 | private DocumentSnapshot lastVisible;
52 | private Boolean isFirstPageFirstLoad = true;
53 | MobileAds mobileAds;
54 | public final static int spaceBetweenAds = 5;
55 |
56 |
57 | @Override
58 | protected void onCreate(Bundle savedInstanceState) {
59 | super.onCreate(savedInstanceState);
60 | setContentView(R.layout.activity_main);
61 | addPostBtn = findViewById(R.id.add_post_btn);
62 | addPostBtn.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | Intent newPostIntent = new Intent(MainActivity.this, NewPostActivity.class);
66 | startActivity(newPostIntent);
67 | }
68 | });
69 |
70 |
71 | //this is where i have confusion to attacth the add nob adpater
72 | // can you please help me i can send you cleaner code without your method so you can put ads in the recycler sir
73 | //love your work
74 | //thanks in advance
75 | blog_list = new ArrayList<>();
76 | blog_list_view = findViewById(R.id.main_container);
77 | firebaseAuth = FirebaseAuth.getInstance();
78 | blogRecyclerAdapter = new BlogRecyclerAdapter(blog_list);
79 | blog_list_view.setLayoutManager(new LinearLayoutManager(this));
80 | blog_list_view.setAdapter(blogRecyclerAdapter);
81 | blog_list_view.setHasFixedSize(true);
82 | if (firebaseAuth.getCurrentUser() != null) {
83 | firebaseFirestore = FirebaseFirestore.getInstance();
84 | blog_list_view.addOnScrollListener(new RecyclerView.OnScrollListener() {
85 | @Override
86 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
87 | super.onScrolled(recyclerView, dx, dy);
88 | Boolean reachedBottom = !recyclerView.canScrollVertically(1);
89 | if (reachedBottom) {
90 | loadMorePost();
91 | }
92 |
93 | }
94 | });
95 |
96 | // i am doing pagination here to load data in batches firestore
97 | Query firstQuery = firebaseFirestore.collection("Posts").orderBy("timestamp", Query.Direction.DESCENDING).limit(3);
98 | firstQuery.addSnapshotListener(this, new EventListener() {
99 | @Override
100 | public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
101 | if (!documentSnapshots.isEmpty()) {
102 | if (isFirstPageFirstLoad) {
103 | lastVisible = documentSnapshots.getDocuments().get(documentSnapshots.size() - 1);
104 | blog_list.clear();
105 | }
106 |
107 | for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
108 | if (doc.getType() == DocumentChange.Type.ADDED) {
109 | String blogPostId = doc.getDocument().getId();
110 | BlogPost blogPost = doc.getDocument().toObject(BlogPost.class).withId(blogPostId);
111 | if (isFirstPageFirstLoad) {
112 | blog_list.add(blogPost);
113 | } else {
114 | blog_list.add(0, blogPost);
115 | }
116 |
117 | blogRecyclerAdapter.notifyDataSetChanged();
118 | }
119 | }
120 | isFirstPageFirstLoad = false;
121 | }
122 | }
123 | });
124 | }
125 | // Then we will call method to add Native Express Ads to mDataset
126 | addNativeExpressAds();
127 |
128 | }
129 |
130 |
131 | private void addNativeExpressAds() {
132 |
133 | for (int i = spaceBetweenAds; i <= blog_list.size(); i += (spaceBetweenAds + 1)) {
134 | NativeExpressAdView adView = new NativeExpressAdView(this);
135 | // I have used a Test ID provided by Admob below
136 | // you should replace it with yours
137 | // And if wou are just experimenting, then just copy the code
138 | adView.setAdUnitId("ca-app-pub-3940256099942544/2793859312");
139 | blog_list.add(i, adView);
140 | //have a error here too
141 | }
142 | }
143 |
144 |
145 |
146 |
147 |
148 | blog_list_view.post(new Runnable(){
149 | @Override
150 | public void run () {
151 | float scale = MainActivity.this.getResources().getDisplayMetrics().density;
152 | int adWidth = (int) (blog_list_view.getWidth() - (2 * MainActivity.this.getResources().getDimension(R.dimen.activity_horizontal_margin)));
153 |
154 | // we are setting size of adView
155 | // you should check admob's site for possible ads size
156 | AdSize adSize = new AdSize((int) (adWidth / scale), 150);
157 | // looping over mDataset to sesize every Native Express Ad to ew adSize
158 | for (int i = spaceBetweenAds; i <= blog_list.size(); i += (spaceBetweenAds + 1)) {
159 | NativeExpressAdView adViewToSize = (NativeExpressAdView) blog_list.get(i);
160 | adViewToSize.setAdSize(adSize);
161 | }
162 | // calling method to load native ads in their views one by one
163 | loadNativeExpressAd(spaceBetweenAds);
164 | }
165 | });
166 |
167 |
168 |
169 |
170 |
171 |
172 | private void loadNativeExpressAd(final int index) {
173 |
174 | if (index >= blog_list.size()) {
175 | return;
176 | }
177 |
178 | Object item = blog_list.get(index);
179 | if (!(item instanceof NativeExpressAdView)) {
180 | throw new ClassCastException("Expected item at index " + index + " to be a Native"
181 | + " Express ad.");
182 | }
183 |
184 | final NativeExpressAdView adView = (NativeExpressAdView) item;
185 |
186 | // Set an AdListener on the NativeExpressAdView to wait for the previous Native Express ad
187 | // to finish loading before loading the next ad in the items list.
188 | adView.setAdListener(new AdListener() {
189 | @Override
190 | public void onAdLoaded() {
191 | super.onAdLoaded();
192 | // The previous Native Express ad loaded successfully, call this method again to
193 | // load the next ad in the items list.
194 | loadNativeExpressAd(index + spaceBetweenAds + 1);
195 | }
196 |
197 | @Override
198 | public void onAdFailedToLoad(int errorCode) {
199 | // The previous Native Express ad failed to load. Call this method again to load
200 | // the next ad in the items list.
201 | Log.e("AdmobMainActivity", "The previous Native Express ad failed to load. Attempting to"
202 | + " load the next Native Express ad in the items list.");
203 | loadNativeExpressAd(index + spaceBetweenAds + 1);
204 | }
205 | });
206 |
207 | // Load the Native Express ad.
208 | //We also registering our device as Test Device with addTestDevic("ID") method
209 | adView.loadAd(new AdRequest.Builder().addTestDevice("YOUR_TEST_DEVICE_ID").build());
210 | }
211 |
212 |
213 |
214 |
215 |
216 | public void loadMorePost(){
217 | if(firebaseAuth.getCurrentUser() != null) {
218 | Query nextQuery = firebaseFirestore.collection("Posts")
219 | .orderBy("timestamp", Query.Direction.DESCENDING)
220 | .startAfter(lastVisible)
221 | .limit(3);
222 | nextQuery.addSnapshotListener(this, new EventListener() {
223 | @Override
224 | public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
225 |
226 | if (!documentSnapshots.isEmpty()) {
227 |
228 | lastVisible = documentSnapshots.getDocuments().get(documentSnapshots.size() - 1);
229 | for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
230 |
231 | if (doc.getType() == DocumentChange.Type.ADDED) {
232 |
233 | String blogPostId = doc.getDocument().getId();
234 | BlogPost blogPost = doc.getDocument().toObject(BlogPost.class).withId(blogPostId);
235 | blog_list.add(blogPost);
236 |
237 | blogRecyclerAdapter.notifyDataSetChanged();
238 | }
239 |
240 | }
241 | }
242 |
243 | }
244 | });
245 |
246 | }
247 |
248 | }
249 |
250 |
251 |
252 |
253 | @Override
254 | protected void onStart() {
255 | super.onStart();
256 | FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
257 | if(currentUser == null){
258 | sendToLogin();
259 | } else {
260 | current_user_id = mAuth.getCurrentUser().getUid();
261 | firebaseFirestore.collection("Users").document(current_user_id).get().addOnCompleteListener(new OnCompleteListener() {
262 | @Override
263 | public void onComplete(@NonNull Task task) {
264 | if(task.isSuccessful()){
265 | if(!task.getResult().exists()){
266 | Intent setupIntent = new Intent(MainActivity.this, SetupActivity.class);
267 | startActivity(setupIntent);
268 | finish();
269 | }
270 | } else {
271 | String errorMessage = task.getException().getMessage();
272 | Toast.makeText(MainActivity.this, "Error : " + errorMessage, Toast.LENGTH_LONG).show();
273 | }
274 | }
275 | });
276 | }
277 | }
278 |
279 |
280 | @Override
281 | public boolean onCreateOptionsMenu(Menu menu) {
282 | getMenuInflater().inflate(R.menu.main_menu, menu);
283 | return true;
284 |
285 | }
286 |
287 | @Override
288 | public boolean onOptionsItemSelected(MenuItem item) {
289 | switch (item.getItemId()) {
290 | case R.id.action_logout_btn:
291 | logOut();
292 | return true;
293 | case R.id.action_settings_btn:
294 | Intent settingsIntent = new Intent(MainActivity.this, SetupActivity.class);
295 | startActivity(settingsIntent);
296 | return true;
297 | default:
298 | return false;
299 |
300 |
301 | }
302 |
303 | }
304 |
305 | private void logOut() {
306 | mAuth.signOut();
307 | sendToLogin();
308 | }
309 |
310 | private void sendToLogin() {
311 | Intent loginIntent = new Intent(MainActivity.this, LoginActivity.class);
312 | startActivity(loginIntent);
313 | finish();
314 |
315 | }
316 |
317 |
318 | }
319 |
320 |
321 |
322 |
323 |
324 |
325 |
--------------------------------------------------------------------------------