├── .gitignore
├── .idea
├── .name
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── render.experimental.xml
├── runConfigurations.xml
└── vcs.xml
├── Gelecek Bilimde.zip
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── YouTubeAndroidPlayerApi.jar
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── teyyihan
│ │ └── gelecekbilimde
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── teyyihan
│ │ │ └── gelecekbilimde
│ │ │ ├── Activities
│ │ │ ├── ArticleReadActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── MainActivity.java
│ │ │ └── YoutubeVideoActivity.java
│ │ │ ├── Adapters
│ │ │ ├── ArticleAdapter.java
│ │ │ ├── BookmarkTablayoutAdapter.java
│ │ │ ├── BottomNavViewPagerAdapter.java
│ │ │ ├── ProfileListAdapter.java
│ │ │ └── VideoAdapter.java
│ │ │ ├── CustomViewPager.java
│ │ │ ├── Database
│ │ │ ├── ArticleDao.java
│ │ │ ├── MyDatabase.java
│ │ │ └── VideoDao.java
│ │ │ ├── Fragments
│ │ │ ├── article
│ │ │ │ ├── ArticleFragment.java
│ │ │ │ ├── ArticleItemBoundaryCallback.java
│ │ │ │ └── ArticleViewModel.java
│ │ │ ├── bookmark
│ │ │ │ ├── BookmarkFragment.java
│ │ │ │ ├── BookmarkFragments
│ │ │ │ │ ├── BookmarkedArticleBoundaryCallback.java
│ │ │ │ │ ├── BookmarkedArticleFragment.java
│ │ │ │ │ ├── BookmarkedArticleViewModel.java
│ │ │ │ │ ├── BookmarkedVideoBoundaryCallback.java
│ │ │ │ │ ├── BookmarkedVideoFragment.java
│ │ │ │ │ └── BookmarkedVideoViewModel.java
│ │ │ │ └── BookmarkViewModel.java
│ │ │ ├── profile
│ │ │ │ ├── ProfileFragment.java
│ │ │ │ └── ProfileViewModel.java
│ │ │ └── video
│ │ │ │ ├── VideoFragment.java
│ │ │ │ ├── VideoItemBoundaryCallback.java
│ │ │ │ └── VideoViewModel.java
│ │ │ ├── Models
│ │ │ ├── ArticleModel.java
│ │ │ ├── Content.java
│ │ │ ├── CurrentUserInfo.java
│ │ │ ├── RetrofitArticleBodyModel.java
│ │ │ ├── RetrofitArticleModel
│ │ │ │ ├── Content.java
│ │ │ │ ├── Excerpt.java
│ │ │ │ ├── RetrofitArticleModel.java
│ │ │ │ └── Title.java
│ │ │ ├── SettingModel.java
│ │ │ └── VideoModel.java
│ │ │ ├── MyFbNotificationService.java
│ │ │ ├── Network
│ │ │ ├── ArticleFirebaseAndRetrofit.java
│ │ │ ├── RetrofitArticleAPI.java
│ │ │ └── VideoFirebase.java
│ │ │ └── Repository
│ │ │ ├── ArticleRepository.java
│ │ │ └── VideoRepository.java
│ └── res
│ │ ├── anim
│ │ ├── fade_in.xml
│ │ └── fade_out.xml
│ │ ├── drawable-v24
│ │ ├── ic_launcher_foreground.xml
│ │ ├── rate_app.png
│ │ └── white_border_bottom.xml
│ │ ├── drawable
│ │ ├── articles.png
│ │ ├── bookmark.png
│ │ ├── bookmark_checked.png
│ │ ├── bookmark_unchecked.png
│ │ ├── developer.png
│ │ ├── empty_blue.xml
│ │ ├── gelecekbilimdelogo.png
│ │ ├── gray_border_bottom.xml
│ │ ├── helpinghand.png
│ │ ├── ic_dashboard_black_24dp.xml
│ │ ├── ic_home_black_24dp.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_notifications_black_24dp.xml
│ │ ├── ic_search_black_24dp.xml
│ │ ├── ic_share_black_24dp.xml
│ │ ├── instagram.png
│ │ ├── logout.png
│ │ ├── playbutton.png
│ │ ├── right_arrow.xml
│ │ ├── rounded_corner_green.xml
│ │ ├── rounded_corners.xml
│ │ ├── rounded_video.xml
│ │ ├── selector.xml
│ │ ├── spotify.png
│ │ ├── twitch.png
│ │ ├── twitter.png
│ │ ├── user.png
│ │ ├── video.jpg
│ │ ├── videos.png
│ │ └── youtube_logo_min.jpg
│ │ ├── font
│ │ ├── merriweather_light.xml
│ │ ├── roboto.xml
│ │ ├── roboto_bold.xml
│ │ ├── roboto_bold_italic.xml
│ │ ├── roboto_condensed_bold.xml
│ │ ├── roboto_light.xml
│ │ ├── roboto_light_italic.xml
│ │ └── rubik.xml
│ │ ├── layout
│ │ ├── activity_article_read.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_youtube_video.xml
│ │ ├── article_row_layout.xml
│ │ ├── bookmarked_article_fragment.xml
│ │ ├── bookmarked_video_fragment.xml
│ │ ├── content_article_read.xml
│ │ ├── fragment_articles.xml
│ │ ├── fragment_bookmark.xml
│ │ ├── fragment_edit_profile.xml
│ │ ├── fragment_profile.xml
│ │ ├── fragment_support_us.xml
│ │ ├── fragment_videos.xml
│ │ ├── profile_merge.xml
│ │ ├── settings_row_layout.xml
│ │ ├── simple_list_item_white.xml
│ │ ├── video_row_layout.xml
│ │ └── view_pager_merge.xml
│ │ ├── menu
│ │ ├── article_search_menu.xml
│ │ ├── bottom_nav_menu.xml
│ │ ├── bottom_nav_menu2.xml
│ │ └── menu_article_read.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── font_certs.xml
│ │ ├── preloaded_fonts.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── teyyihan
│ └── gelecekbilimde
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Gelecek Bilimde
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/render.experimental.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Gelecek Bilimde.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/Gelecek Bilimde.zip
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 gelecek-bilimde
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android-Application
2 | Gelecek Bilimde Android App using:
3 | * Room
4 | * Retrofit
5 | * Firebase Auth and Realtime DB
6 | * Paging Library 2.1
7 | * Glide
8 | * MVVM design pattern
9 |
10 | [Play Store link](https://play.google.com/store/apps/details?id=com.teyyihan.gelecekbilimde)
11 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'com.google.gms.google-services'
5 |
6 | android {
7 | signingConfigs {
8 | release {
9 | storeFile file('C:\\Users\\teyyi\\androidKeys\\gbreleasekey.jks')
10 | storePassword 'gelecek2317'
11 | keyAlias 'release'
12 | keyPassword 'gelecek2317'
13 | }
14 | }
15 | compileSdkVersion 29
16 | buildToolsVersion "29.0.2"
17 | defaultConfig {
18 | manifestPlaceholders = [
19 | appAuthRedirectScheme: 'io.identityserver.demo'
20 | ]
21 | applicationId "com.teyyihan.gelecekbilimde"
22 | minSdkVersion 21
23 | targetSdkVersion 29
24 | versionCode 8
25 | versionName "1.6"
26 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
27 | vectorDrawables.useSupportLibrary = true
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | buildTypes {
34 | release {
35 | signingConfig signingConfigs.release
36 | }
37 | }
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(include: ['*.jar'], dir: 'libs')
42 | implementation 'androidx.appcompat:appcompat:1.0.2'
43 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
44 | def lifecycle_version = "2.1.0"
45 | implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
46 | implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
47 | implementation 'com.google.firebase:firebase-database:18.0.0'
48 | implementation 'com.google.firebase:firebase-messaging:20.1.1'
49 | implementation 'com.google.firebase:firebase-analytics:17.2.3'
50 | annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
51 | implementation "android.arch.lifecycle:extensions:$lifecycle_version"
52 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
53 | implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
54 | implementation 'androidx.navigation:navigation-fragment:2.0.0'
55 | implementation 'androidx.navigation:navigation-ui:2.0.0'
56 | testImplementation 'junit:junit:4.12'
57 | androidTestImplementation 'androidx.test:runner:1.1.1'
58 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
59 | implementation 'com.miguelcatalan:materialsearchview:1.4.0'
60 | implementation 'com.android.support:appcompat-v7:28.0.0'
61 | implementation 'com.android.support:support-v4:28.0.0'
62 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
63 | implementation 'com.google.android.material:material:1.0.0'
64 | implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
65 | //Paging
66 | implementation 'androidx.paging:paging-runtime:2.1.1'
67 | //Glide
68 | implementation 'com.github.bumptech.glide:glide:4.10.0'
69 | annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
70 | //Retrofit
71 | implementation 'com.squareup.retrofit2:retrofit:2.4.0'
72 | implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
73 | //Room
74 | def room_version = "2.2.3"
75 | implementation "androidx.room:room-runtime:$room_version"
76 | annotationProcessor "androidx.room:room-compiler:$room_version"
77 | implementation "android.arch.persistence.room:runtime:$room_version"
78 | //Login
79 | implementation 'com.google.firebase:firebase-auth:19.2.0'
80 | implementation 'com.google.android.gms:play-services-auth:18.1.0'
81 | implementation 'com.twitter.sdk.android:twitter:3.1.1'
82 | implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
83 | implementation files('libs/YouTubeAndroidPlayerApi.jar')
84 | implementation "androidx.core:core-ktx:+"
85 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
86 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
87 | }
88 | repositories {
89 | mavenCentral()
90 | }
91 |
--------------------------------------------------------------------------------
/app/libs/YouTubeAndroidPlayerApi.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/libs/YouTubeAndroidPlayerApi.jar
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"1.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/teyyihan/gelecekbilimde/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.teyyihan.gelecekbilimde;
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 |
25 | assertEquals("com.gelecekbilimde.gelecekbilimde", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
23 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
39 |
40 |
41 |
42 |
43 |
44 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/teyyihan/gelecekbilimde/Activities/ArticleReadActivity.java:
--------------------------------------------------------------------------------
1 | package com.teyyihan.gelecekbilimde.Activities;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.drawable.BitmapDrawable;
7 | import android.graphics.drawable.Drawable;
8 | import android.graphics.drawable.LevelListDrawable;
9 | import android.os.AsyncTask;
10 | import android.os.Bundle;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
14 | import com.teyyihan.gelecekbilimde.Models.RetrofitArticleBodyModel;
15 | import com.teyyihan.gelecekbilimde.Network.RetrofitArticleAPI;
16 | import com.google.android.material.appbar.AppBarLayout;
17 | import com.google.android.material.appbar.CollapsingToolbarLayout;
18 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
19 | import com.google.android.material.snackbar.Snackbar;
20 |
21 | import androidx.appcompat.app.AppCompatActivity;
22 | import androidx.appcompat.widget.Toolbar;
23 |
24 | import android.text.Html;
25 | import android.text.Spanned;
26 | import android.text.method.LinkMovementMethod;
27 | import android.view.View;
28 | import android.widget.Button;
29 | import android.widget.ImageView;
30 | import android.widget.ProgressBar;
31 | import android.widget.TextView;
32 | import android.widget.Toast;
33 |
34 | import com.teyyihan.gelecekbilimde.R;
35 |
36 | import java.io.FileNotFoundException;
37 | import java.io.IOException;
38 | import java.io.InputStream;
39 | import java.net.MalformedURLException;
40 | import java.net.URL;
41 |
42 | import retrofit2.Call;
43 | import retrofit2.Callback;
44 | import retrofit2.Response;
45 | import retrofit2.Retrofit;
46 | import retrofit2.converter.gson.GsonConverterFactory;
47 |
48 | public class ArticleReadActivity extends AppCompatActivity implements Html.ImageGetter {
49 |
50 | ImageView imageView;
51 | TextView bodyTextView;
52 | TextView titleTxt;
53 | CollapsingToolbarLayout collapsingToolbarLayout;
54 | Toolbar toolbar;
55 | AppBarLayout appBarLayout;
56 | ProgressBar progressBar;
57 | String articleURL;
58 | FloatingActionButton fab;
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.activity_article_read);
64 | toolbar = findViewById(R.id.article_read_toolbar);
65 | appBarLayout = findViewById(R.id.article_read_appbar);
66 | setSupportActionBar(toolbar);
67 | imageView = findViewById(R.id.article_read_image);
68 | bodyTextView = findViewById(R.id.article_read_text);
69 | titleTxt = findViewById(R.id.article_read_title);
70 | progressBar = findViewById(R.id.article_read_progress);
71 | getIncomingIntent();
72 |
73 |
74 | fab = findViewById(R.id.fab);
75 | fab.setOnClickListener(new View.OnClickListener() {
76 | @Override
77 | public void onClick(View view) {
78 | Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
79 | sharingIntent.setType("text/plain");
80 | sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Paylaş");
81 | sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, articleURL);
82 | startActivity(Intent.createChooser(sharingIntent, "Şununla paylaş:"));
83 | }
84 | });
85 | fab.setClickable(false);
86 | }
87 |
88 |
89 | private void getIncomingIntent() {
90 |
91 | if (getIntent().hasExtra("ARTICLE_IMAGE_URL") && getIntent().hasExtra("ARTICLE_TITLE") && getIntent().hasExtra("ARTICLE_ID")) {
92 | String imageUrl = getIntent().getStringExtra("ARTICLE_IMAGE_URL");
93 | int articleID = getIntent().getIntExtra("ARTICLE_ID", 0);
94 | String title = getIntent().getStringExtra("ARTICLE_TITLE");
95 | progressBar.setVisibility(View.VISIBLE);
96 | setImageAndBody(imageUrl, articleID, title);
97 | }
98 |
99 | }
100 |
101 | private void setImageAndBody(String imageUrl, int articleID, final String title) {
102 | Glide.with(this).load(imageUrl).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
103 | //bodyTextView.setText(Html.fromHtml(body));
104 | collapsingToolbarLayout = findViewById(R.id.toolbar_layout);
105 | collapsingToolbarLayout.setTitle(title);
106 |
107 | Retrofit retrofit = new Retrofit.Builder()
108 | .baseUrl("https://www.gelecekbilimde.net/wp-json/wp/v2/posts/")
109 | .addConverterFactory(GsonConverterFactory.create())
110 | .build();
111 |
112 | RetrofitArticleAPI api = retrofit.create(RetrofitArticleAPI.class);
113 |
114 | Call call = api.getPost(articleID);
115 |
116 | call.enqueue(new Callback() {
117 | @Override
118 | public void onResponse(Call call, Response response) {
119 |
120 | if (!response.isSuccessful()) {
121 | Toast.makeText(getApplicationContext(), "Hata: " + response.code(), Toast.LENGTH_LONG).show();
122 | } else {
123 | progressBar.setVisibility(View.GONE);
124 | RetrofitArticleBodyModel model = response.body();
125 | String body = model.getContent().getRendered();
126 | body = body.replace("", "
");
127 | articleURL = model.getLink();
128 | fab.setClickable(true);
129 |
130 | Spanned spanned = Html.fromHtml(body, s -> {
131 | LevelListDrawable d = new LevelListDrawable();
132 | Drawable empty = getResources().getDrawable(R.drawable.empty_blue);
133 | d.addLevel(0, 0, empty);
134 | d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
135 |
136 | new LoadImage().execute(s, d);
137 |
138 | return d;
139 | }, null);
140 | bodyTextView.setText(spanned);
141 | bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
142 |
143 | titleTxt.setText(Html.fromHtml(title));
144 | }
145 |
146 | }
147 |
148 | @Override
149 | public void onFailure(Call call, Throwable t) {
150 |
151 | }
152 | });
153 |
154 | //top bar title
155 | appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
156 | boolean isShow = true;
157 | int scrollRange = -1;
158 |
159 | @Override
160 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
161 | if (scrollRange == -1) {
162 | scrollRange = appBarLayout.getTotalScrollRange();
163 | }
164 | if (scrollRange + verticalOffset == 0) {
165 | collapsingToolbarLayout.setTitle("Makale");
166 | isShow = true;
167 | } else if (isShow) {
168 | collapsingToolbarLayout.setTitle(" ");//careful there should a space between double quote otherwise it wont work
169 | isShow = false;
170 | }
171 | }
172 | });
173 |
174 | }
175 |
176 | @Override
177 | public Drawable getDrawable(String s) {
178 | LevelListDrawable d = new LevelListDrawable();
179 | Drawable empty = getResources().getDrawable(R.drawable.empty_blue);
180 | d.addLevel(0, 0, empty);
181 | d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
182 |
183 | new LoadImage().execute(s, d);
184 |
185 | return d;
186 | }
187 |
188 | class LoadImage extends AsyncTask