├── .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 | 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 | 9 | -------------------------------------------------------------------------------- /.idea/render.experimental.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 { 189 | 190 | private LevelListDrawable mDrawable; 191 | 192 | @Override 193 | protected Bitmap doInBackground(Object... params) { 194 | String source = (String) params[0]; 195 | mDrawable = (LevelListDrawable) params[1]; 196 | 197 | try { 198 | InputStream is = new URL(source).openStream(); 199 | return BitmapFactory.decodeStream(is); 200 | } catch (FileNotFoundException e) { 201 | e.printStackTrace(); 202 | } catch (MalformedURLException e) { 203 | e.printStackTrace(); 204 | } catch (IOException e) { 205 | e.printStackTrace(); 206 | } 207 | return null; 208 | } 209 | 210 | @Override 211 | protected void onPostExecute(Bitmap bitmap) { 212 | 213 | if (bitmap != null) { 214 | BitmapDrawable d = new BitmapDrawable(bitmap); 215 | mDrawable.addLevel(1, 1, d); 216 | mDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); 217 | mDrawable.setLevel(1); 218 | // i don't know yet a better way to refresh TextView 219 | // mTv.invalidate() doesn't work as expected 220 | CharSequence t = bodyTextView.getText(); 221 | bodyTextView.setText(t); 222 | } 223 | } 224 | } 225 | } 226 | 227 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Activities/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Activities; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.appcompat.app.AppCompatActivity; 5 | 6 | import android.app.PendingIntent; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.widget.ProgressBar; 13 | import android.widget.Toast; 14 | 15 | import com.google.firebase.auth.TwitterAuthProvider; 16 | import com.teyyihan.gelecekbilimde.Models.CurrentUserInfo; 17 | import com.teyyihan.gelecekbilimde.R; 18 | import com.google.android.gms.auth.api.signin.GoogleSignIn; 19 | import com.google.android.gms.auth.api.signin.GoogleSignInAccount; 20 | import com.google.android.gms.auth.api.signin.GoogleSignInClient; 21 | import com.google.android.gms.auth.api.signin.GoogleSignInOptions; 22 | import com.google.android.gms.common.api.ApiException; 23 | import com.google.android.gms.tasks.OnCompleteListener; 24 | import com.google.android.gms.tasks.OnFailureListener; 25 | import com.google.android.gms.tasks.OnSuccessListener; 26 | import com.google.android.gms.tasks.Task; 27 | import com.google.firebase.auth.AuthCredential; 28 | import com.google.firebase.auth.AuthResult; 29 | import com.google.firebase.auth.FirebaseAuth; 30 | import com.google.firebase.auth.FirebaseUser; 31 | import com.google.firebase.auth.GoogleAuthProvider; 32 | import com.google.firebase.database.DatabaseReference; 33 | import com.google.firebase.database.FirebaseDatabase; 34 | import com.twitter.sdk.android.core.Callback; 35 | import com.twitter.sdk.android.core.Result; 36 | import com.twitter.sdk.android.core.Twitter; 37 | import com.twitter.sdk.android.core.TwitterAuthConfig; 38 | import com.twitter.sdk.android.core.TwitterConfig; 39 | import com.twitter.sdk.android.core.TwitterException; 40 | import com.twitter.sdk.android.core.TwitterSession; 41 | import com.twitter.sdk.android.core.identity.TwitterLoginButton; 42 | 43 | import java.util.ArrayList; 44 | import java.util.Arrays; 45 | import java.util.HashMap; 46 | import java.util.List; 47 | import java.util.Map; 48 | 49 | public class LoginActivity extends AppCompatActivity { 50 | 51 | private static final String TAG = "Teooo"; 52 | private static final int RC_SIGN_IN = 9001; 53 | private static final int TWITTER_SIGN_IN = 123; 54 | private boolean isNotificationOpened = false; 55 | 56 | private FirebaseAuth mAuth; 57 | private GoogleSignInClient mGoogleSignInClient; 58 | private ProgressBar progressBar; 59 | private DatabaseReference mRef; 60 | TwitterLoginButton twitterLoginButton; 61 | 62 | @Override 63 | protected void onCreate(Bundle savedInstanceState) { 64 | super.onCreate(savedInstanceState); 65 | 66 | TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key),getString(R.string.twitter_consumer_secret)); 67 | TwitterConfig twitterConfig = new TwitterConfig.Builder(this).twitterAuthConfig(authConfig).build(); 68 | 69 | Twitter.initialize(twitterConfig); 70 | 71 | setContentView(R.layout.activity_login); 72 | progressBar = findViewById(R.id.login_progress); 73 | progressBar.setVisibility(View.GONE); 74 | mRef = FirebaseDatabase.getInstance().getReference("Users"); 75 | 76 | twitterLoginButton = findViewById(R.id.twitter_login_btn); 77 | 78 | twitterLoginButton.setCallback(new Callback() { 79 | @Override 80 | public void success(Result result) { 81 | signToFirebaseWithTwitterSession(result.data); 82 | } 83 | 84 | @Override 85 | public void failure(TwitterException exception) { 86 | 87 | } 88 | }); 89 | 90 | 91 | //Google sign in 92 | findViewById(R.id.google_sign_in_btn).setOnClickListener(new View.OnClickListener() { 93 | @Override 94 | public void onClick(View view) { 95 | GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 96 | .requestIdToken(getString(R.string.default_web_client_id)) 97 | .requestEmail() 98 | .build(); 99 | 100 | mGoogleSignInClient = GoogleSignIn.getClient(LoginActivity.this, gso); 101 | progressBar.setVisibility(View.VISIBLE); 102 | signIn(); 103 | } 104 | }); 105 | 106 | 107 | 108 | mAuth = FirebaseAuth.getInstance(); 109 | } 110 | 111 | private void signToFirebaseWithTwitterSession(TwitterSession data) { 112 | 113 | AuthCredential twitterAuthCredential = TwitterAuthProvider.getCredential(data.getAuthToken().token,data.getAuthToken().secret); 114 | 115 | mAuth.signInWithCredential(twitterAuthCredential).addOnSuccessListener(new OnSuccessListener() { 116 | @Override 117 | public void onSuccess(AuthResult authResult) { 118 | saveUserToFirebaseDB(); 119 | } 120 | }).addOnFailureListener(new OnFailureListener() { 121 | @Override 122 | public void onFailure(@NonNull Exception e) { 123 | Toast.makeText(getApplicationContext()," "+e.getLocalizedMessage(),Toast.LENGTH_LONG).show(); 124 | 125 | } 126 | }); 127 | 128 | } 129 | 130 | @Override 131 | public void onStart() { 132 | super.onStart(); 133 | 134 | if(getIntent().hasExtra("url") && !isNotificationOpened){ 135 | 136 | 137 | findViewById(R.id.twitter_login_btn).setVisibility(View.GONE); 138 | findViewById(R.id.google_sign_in_btn).setVisibility(View.GONE); 139 | findViewById(R.id.textView).setVisibility(View.GONE); 140 | 141 | isNotificationOpened = true; 142 | Intent intent = new Intent(Intent.ACTION_VIEW); 143 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 144 | intent.setData(Uri.parse((String) getIntent().getExtras().get("url"))); 145 | startActivity(intent); 146 | }else{ 147 | // Check if user is signed in (non-null) and update UI accordingly. 148 | FirebaseUser currentUser = mAuth.getCurrentUser(); 149 | if (currentUser != null) { 150 | 151 | Map newUser = new HashMap<>(); 152 | newUser.put("photoURL",String.valueOf(currentUser.getPhotoUrl())); 153 | newUser.put("email",currentUser.getEmail()); 154 | newUser.put("displayName",currentUser.getDisplayName()); 155 | newUser.put("providerID",currentUser.getProviderId()); 156 | saveUserToStaticVars(newUser); 157 | 158 | startActivity(new Intent(LoginActivity.this,MainActivity.class)); 159 | } 160 | } 161 | 162 | 163 | } 164 | 165 | @Override 166 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 167 | super.onActivityResult(requestCode, resultCode, data); 168 | 169 | 170 | // Result returned from GOOGLE 171 | if (requestCode == RC_SIGN_IN) { 172 | Task task = GoogleSignIn.getSignedInAccountFromIntent(data); 173 | try { 174 | // Google Sign In was successful, authenticate with Firebase 175 | GoogleSignInAccount account = task.getResult(ApiException.class); 176 | firebaseAuthWithGoogle(account); 177 | 178 | 179 | } catch (ApiException e) { 180 | progressBar.setVisibility(View.GONE); 181 | Toast.makeText(getApplicationContext(), "Google hesabına giriş yapılırken bir hata oluştu" + e.getLocalizedMessage() , Toast.LENGTH_LONG).show(); 182 | } 183 | } else { 184 | twitterLoginButton.onActivityResult(requestCode,resultCode,data); 185 | 186 | } 187 | 188 | } 189 | 190 | private void firebaseAuthWithGoogle(GoogleSignInAccount acct){ 191 | 192 | 193 | AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); 194 | mAuth.signInWithCredential(credential) 195 | .addOnCompleteListener(this, new OnCompleteListener() { 196 | @Override 197 | public void onComplete(@NonNull Task task) { 198 | if (task.isSuccessful()) { 199 | 200 | 201 | saveUserToFirebaseDB(); 202 | 203 | 204 | //updateUI(user); 205 | } else { 206 | // If sign in fails, display a message to the user. 207 | Toast.makeText(getApplicationContext(),"Bir hata oluştu",Toast.LENGTH_LONG).show(); 208 | } 209 | 210 | } 211 | //Firebase login failed 212 | }).addOnFailureListener(new OnFailureListener() { 213 | @Override 214 | public void onFailure(@NonNull Exception e) { 215 | Toast.makeText(getApplicationContext(),"Bir hata oluştu"+e.getMessage()+" "+e.getLocalizedMessage(),Toast.LENGTH_LONG).show(); 216 | } 217 | }); 218 | } 219 | 220 | private void saveUserToStaticVars(Map newUser) { 221 | CurrentUserInfo.userInfo = newUser; 222 | } 223 | 224 | 225 | // for google 226 | private void signIn() { 227 | Intent signInIntent = mGoogleSignInClient.getSignInIntent(); 228 | startActivityForResult(signInIntent, RC_SIGN_IN); 229 | } 230 | 231 | 232 | void saveUserToFirebaseDB() { 233 | FirebaseUser user = mAuth.getCurrentUser(); 234 | 235 | Map newUser = new HashMap<>(); 236 | newUser.put("photoURL",String.valueOf(user.getPhotoUrl())); 237 | newUser.put("email",user.getEmail()); 238 | newUser.put("displayName",user.getDisplayName()); 239 | newUser.put("providerID",user.getProviderId()); 240 | 241 | // save user to db 242 | mRef.child(user.getUid()).setValue(newUser).addOnSuccessListener(new OnSuccessListener() { 243 | @Override 244 | public void onSuccess(Void aVoid) { 245 | newUser.put("userUID",user.getUid()); 246 | saveUserToStaticVars(newUser); 247 | progressBar.setVisibility(View.GONE); 248 | System.out.println("teooo buradaaaaaa"); 249 | startActivity(new Intent(LoginActivity.this,MainActivity.class)); 250 | } 251 | }).addOnFailureListener(new OnFailureListener() { 252 | @Override 253 | public void onFailure(@NonNull Exception e) { 254 | Toast.makeText(getApplicationContext(),"Bir hata oluştu",Toast.LENGTH_LONG).show(); 255 | } 256 | }); 257 | } 258 | 259 | } 260 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Activities/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Activities; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.MotionEvent; 9 | import android.view.View; 10 | import android.widget.Toast; 11 | 12 | import com.google.android.gms.tasks.OnCompleteListener; 13 | import com.google.android.gms.tasks.Task; 14 | import com.google.firebase.iid.FirebaseInstanceId; 15 | import com.google.firebase.iid.InstanceIdResult; 16 | import com.teyyihan.gelecekbilimde.Adapters.BottomNavViewPagerAdapter; 17 | import com.teyyihan.gelecekbilimde.CustomViewPager; 18 | import com.teyyihan.gelecekbilimde.Fragments.profile.ProfileFragment; 19 | import com.teyyihan.gelecekbilimde.R; 20 | import com.teyyihan.gelecekbilimde.Fragments.article.ArticleFragment; 21 | import com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragment; 22 | import com.teyyihan.gelecekbilimde.Fragments.video.VideoFragment; 23 | import com.google.android.material.bottomnavigation.BottomNavigationView; 24 | import com.miguelcatalan.materialsearchview.MaterialSearchView; 25 | 26 | import androidx.annotation.NonNull; 27 | import androidx.appcompat.app.AppCompatActivity; 28 | import androidx.appcompat.widget.Toolbar; 29 | import androidx.fragment.app.Fragment; 30 | import androidx.viewpager.widget.ViewPager; 31 | 32 | public class MainActivity extends AppCompatActivity { 33 | 34 | BottomNavigationView bottomNavigationView; 35 | CustomViewPager viewPager; 36 | Fragment first = new ArticleFragment(); 37 | Fragment second = new VideoFragment(); 38 | Fragment third = new BookmarkFragment(); 39 | Fragment fourth = new ProfileFragment(); 40 | MenuItem menuItem; 41 | MaterialSearchView materialSearchView; 42 | Toolbar toolbar; 43 | 44 | 45 | @Override 46 | protected void onCreate(Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(R.layout.activity_main); 49 | 50 | bottomNavigationView = findViewById(R.id.nav_view); 51 | viewPager = findViewById(R.id.main_viewpager); 52 | toolbar = findViewById(R.id.tooooooooolbar); 53 | setSupportActionBar(toolbar); 54 | toolbar.setTitleTextColor(Color.parseColor("#ffffff")); 55 | toolbar.setTitle("Makaleler"); 56 | materialSearchView = findViewById(R.id.seaaaaaaarch); 57 | 58 | materialSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() { 59 | @Override 60 | public boolean onQueryTextSubmit(String query) { 61 | ArticleFragment.title.postValue(query); 62 | return false; 63 | } 64 | 65 | @Override 66 | public boolean onQueryTextChange(String newText) { 67 | 68 | return false; 69 | } 70 | }); 71 | 72 | bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { 73 | @Override 74 | public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { 75 | switch (menuItem.getItemId()) { 76 | case R.id.navigation_first: 77 | viewPager.setCurrentItem(0); 78 | break; 79 | case R.id.navigation_second: 80 | viewPager.setCurrentItem(1); 81 | materialSearchView.closeSearch(); 82 | break; 83 | case R.id.navigation_third: 84 | viewPager.setCurrentItem(2); 85 | materialSearchView.closeSearch(); 86 | break; 87 | case R.id.navigation_fourth: 88 | viewPager.setCurrentItem(3); 89 | materialSearchView.closeSearch(); 90 | break; 91 | } 92 | return false; 93 | } 94 | }); 95 | 96 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 97 | @Override 98 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 99 | 100 | } 101 | 102 | @Override 103 | public void onPageSelected(int position) { 104 | if (menuItem != null) { 105 | menuItem.setChecked(false); 106 | } else { 107 | bottomNavigationView.getMenu().getItem(0).setChecked(false); 108 | } 109 | bottomNavigationView.getMenu().getItem(position).setChecked(true); 110 | menuItem = bottomNavigationView.getMenu().getItem(position); 111 | 112 | } 113 | 114 | @Override 115 | public void onPageScrollStateChanged(int state) { 116 | 117 | } 118 | }); 119 | viewPager.setOnTouchListener(new View.OnTouchListener() { 120 | @Override 121 | public boolean onTouch(View view, MotionEvent motionEvent) { 122 | return true; 123 | } 124 | }); 125 | 126 | setupViewPager(viewPager); 127 | } 128 | 129 | private void setupViewPager(ViewPager viewPager) { 130 | BottomNavViewPagerAdapter myAdapter = new BottomNavViewPagerAdapter(getSupportFragmentManager()); 131 | myAdapter.addFragment(first); 132 | myAdapter.addFragment(second); 133 | myAdapter.addFragment(third); 134 | myAdapter.addFragment(fourth); 135 | viewPager.setAdapter(myAdapter); 136 | } 137 | 138 | @Override 139 | public boolean onCreateOptionsMenu(Menu menu) { 140 | getMenuInflater().inflate(R.menu.article_search_menu,menu); 141 | MenuItem mmmmm = menu.findItem(R.id.action_search); 142 | materialSearchView.setMenuItem(mmmmm); 143 | return super.onCreateOptionsMenu(menu); 144 | } 145 | 146 | public void setTitle(String title) { 147 | toolbar.setTitle(title); 148 | } 149 | 150 | @Override 151 | public void onBackPressed() { 152 | 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Activities/YoutubeVideoActivity.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Activities; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | 6 | import com.teyyihan.gelecekbilimde.R; 7 | import com.teyyihan.gelecekbilimde.YoutubeAPI; 8 | import com.google.android.youtube.player.YouTubeBaseActivity; 9 | import com.google.android.youtube.player.YouTubeInitializationResult; 10 | import com.google.android.youtube.player.YouTubePlayer; 11 | import com.google.android.youtube.player.YouTubePlayerView; 12 | 13 | public class YoutubeVideoActivity extends YouTubeBaseActivity { 14 | 15 | YouTubePlayerView youTubePlayerView; 16 | YouTubePlayer.OnInitializedListener listener; 17 | String videoURL= " "; 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_youtube_video); 22 | 23 | youTubePlayerView = findViewById(R.id.youtube_video_player); 24 | 25 | getIncomingIntent(); 26 | 27 | listener = new YouTubePlayer.OnInitializedListener() { 28 | @Override 29 | public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { 30 | youTubePlayer.loadVideo(videoURL); 31 | } 32 | 33 | @Override 34 | public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { 35 | 36 | } 37 | }; 38 | 39 | 40 | youTubePlayerView.initialize(YoutubeAPI.api,listener); 41 | 42 | 43 | } 44 | 45 | private void getIncomingIntent() { 46 | 47 | if (getIntent().hasExtra("VIDEO_URL") ) { 48 | videoURL = getIntent().getStringExtra("VIDEO_URL"); 49 | } 50 | 51 | } 52 | 53 | public void exitVideoActivity(View view) { 54 | finish(); 55 | } 56 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Adapters/ArticleAdapter.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Adapters; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.text.Html; 6 | 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ImageView; 11 | import android.widget.RelativeLayout; 12 | import android.widget.TextView; 13 | 14 | import androidx.annotation.NonNull; 15 | import androidx.fragment.app.FragmentActivity; 16 | import androidx.lifecycle.ViewModelProviders; 17 | import androidx.paging.PagedListAdapter; 18 | import androidx.recyclerview.widget.DiffUtil; 19 | import androidx.recyclerview.widget.RecyclerView; 20 | 21 | import com.bumptech.glide.Glide; 22 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 23 | import com.teyyihan.gelecekbilimde.Activities.ArticleReadActivity; 24 | import com.teyyihan.gelecekbilimde.Fragments.article.ArticleViewModel; 25 | import com.teyyihan.gelecekbilimde.R; 26 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 27 | 28 | import java.text.ParseException; 29 | import java.text.SimpleDateFormat; 30 | import java.util.Date; 31 | 32 | public class ArticleAdapter extends PagedListAdapter { 33 | 34 | Context mContext; 35 | ArticleViewModel articleViewModel; 36 | public ArticleAdapter(Context mContext) { 37 | super(callback); 38 | this.mContext = mContext; 39 | articleViewModel = ViewModelProviders.of((FragmentActivity) mContext).get(ArticleViewModel.class); 40 | } 41 | 42 | private static final DiffUtil.ItemCallback callback = new DiffUtil.ItemCallback() { 43 | @Override 44 | public boolean areItemsTheSame(@NonNull ArticleModel oldItem, @NonNull ArticleModel newItem) { 45 | 46 | return oldItem.getArticleId() == newItem.getArticleId(); 47 | } 48 | 49 | @Override 50 | public boolean areContentsTheSame(@NonNull ArticleModel oldItem, @NonNull ArticleModel newItem) { 51 | 52 | if(oldItem.getArticleImageURL()!= null && newItem.getArticleImageURL()!=null){ 53 | return 54 | oldItem.getArticleTitle().equals(newItem.getArticleTitle()) && 55 | oldItem.isBookmarked()==newItem.isBookmarked() && 56 | oldItem.getArticleImageURL().equals(newItem.getArticleImageURL()); 57 | }else { 58 | return 59 | oldItem.getArticleTitle().equals(newItem.getArticleTitle()) && 60 | oldItem.isBookmarked()==newItem.isBookmarked(); 61 | } 62 | 63 | 64 | } 65 | }; 66 | 67 | public static class ArticleViewHolder extends RecyclerView.ViewHolder{ 68 | public ImageView articleImage; 69 | public ImageView articleBookmarkImage; 70 | public TextView articleHeadline; 71 | public TextView articledescription; 72 | public TextView articleDate; 73 | private RelativeLayout articleRelativeLay; 74 | 75 | public ArticleViewHolder(@NonNull View itemView) { 76 | super(itemView); 77 | articleImage = itemView.findViewById(R.id.article_image); 78 | articleBookmarkImage = itemView.findViewById(R.id.article_bookmark); 79 | articleHeadline = itemView.findViewById(R.id.article_headline); 80 | articledescription = itemView.findViewById(R.id.article_desc); 81 | articleDate = itemView.findViewById(R.id.article_date); 82 | articleRelativeLay = itemView.findViewById(R.id.article_cardview); 83 | } 84 | } 85 | 86 | 87 | @NonNull 88 | @Override 89 | public ArticleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 90 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.article_row_layout,parent,false); 91 | final ArticleViewHolder articleViewHolder = new ArticleViewHolder(view); 92 | 93 | //article cardview onclick methodu 94 | articleViewHolder.articleRelativeLay.setOnClickListener(new View.OnClickListener() { 95 | @Override 96 | public void onClick(View view) { 97 | 98 | } 99 | }); 100 | 101 | 102 | 103 | return articleViewHolder; 104 | } 105 | 106 | @Override 107 | public void onBindViewHolder(@NonNull final ArticleViewHolder holder, int position) { 108 | final ArticleModel currentArticle = getItem(position); 109 | String finalDateTime = " "; 110 | String initialStringDate = currentArticle.getArticleDate(); 111 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 112 | try { 113 | Date date = format.parse(initialStringDate); 114 | String stringDate = new SimpleDateFormat("dd/MM/yyyy").format(date); 115 | 116 | finalDateTime = stringDate; 117 | } catch (ParseException e) { e.printStackTrace(); } 118 | 119 | 120 | try { 121 | if ( currentArticle.getArticleImageURL()!=null && !(currentArticle.getArticleImageURL().matches("null"))) { 122 | System.out.println("teooo wtfff"+currentArticle.getArticleId()); 123 | Glide.with(mContext).load(currentArticle.getArticleImageURL()) 124 | .diskCacheStrategy(DiskCacheStrategy.ALL) 125 | .circleCrop() 126 | .placeholder(R.drawable.gelecekbilimdelogo) 127 | .into(holder.articleImage); 128 | }else { 129 | System.out.println("teooo wtfff"+currentArticle.getArticleId()); 130 | Glide.with(mContext).load(R.drawable.gelecekbilimdelogo) 131 | .circleCrop() 132 | .into(holder.articleImage); 133 | } 134 | } catch (Exception e) { 135 | System.out.println("teoooo tuttuttt"+e.getLocalizedMessage()); 136 | } 137 | 138 | 139 | if (currentArticle.isBookmarked()) { 140 | holder.articleBookmarkImage.setImageResource(R.drawable.bookmark_checked); 141 | } else { 142 | holder.articleBookmarkImage.setImageResource(R.drawable.bookmark_unchecked); 143 | } 144 | 145 | holder.articleDate.setText(finalDateTime); 146 | 147 | try { 148 | holder.articleHeadline.setText(Html.fromHtml(currentArticle.getArticleTitle())); 149 | holder.articledescription.setText(Html.fromHtml(currentArticle.getArticleDesc())); 150 | } catch (Exception e) { 151 | holder.articledescription.setText(" "); 152 | holder.articleHeadline.setText(" "); 153 | } 154 | 155 | 156 | 157 | // cardview onclick 158 | holder.articleRelativeLay.setOnClickListener(new View.OnClickListener() { 159 | @Override 160 | public void onClick(View view) { 161 | 162 | Intent intent = new Intent(mContext, ArticleReadActivity.class); 163 | intent.putExtra("ARTICLE_ID",currentArticle.getArticleId()); 164 | intent.putExtra("ARTICLE_IMAGE_URL",currentArticle.getArticleImageURL()); 165 | intent.putExtra("ARTICLE_TITLE",currentArticle.getArticleTitle()); 166 | mContext.startActivity(intent); 167 | } 168 | }); 169 | 170 | 171 | // bookmark click event 172 | holder.articleBookmarkImage.setOnClickListener(new View.OnClickListener() { 173 | @Override 174 | public void onClick(View view) { 175 | 176 | if (!currentArticle.isBookmarked()) { 177 | setBookmarkedTrue(currentArticle); 178 | } else { 179 | setBookmarkFalse(currentArticle); 180 | } 181 | 182 | } 183 | 184 | private void setBookmarkFalse(ArticleModel currentArticle) { 185 | currentArticle.setBookmarked(false); 186 | articleViewModel.updateArticle(currentArticle); 187 | holder.articleBookmarkImage.setImageResource(R.drawable.bookmark_unchecked); 188 | } 189 | 190 | private void setBookmarkedTrue(ArticleModel currentArticle) { 191 | currentArticle.setBookmarked(true); 192 | articleViewModel.updateArticle(currentArticle); 193 | holder.articleBookmarkImage.setImageResource(R.drawable.bookmark_checked); 194 | } 195 | }); 196 | 197 | } 198 | 199 | public ArticleModel getArticle(int position) { 200 | return getItem(position); 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Adapters/BookmarkTablayoutAdapter.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Adapters; 2 | 3 | import androidx.annotation.Nullable; 4 | import androidx.fragment.app.Fragment; 5 | import androidx.fragment.app.FragmentManager; 6 | import androidx.fragment.app.FragmentPagerAdapter; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class BookmarkTablayoutAdapter extends FragmentPagerAdapter { 12 | 13 | private final List fragments = new ArrayList<>(); 14 | private final List fragmentTitles = new ArrayList<>(); 15 | 16 | 17 | public BookmarkTablayoutAdapter(FragmentManager fm) { 18 | super(fm); 19 | } 20 | 21 | @Override 22 | public Fragment getItem(int position) { 23 | return fragments.get(position); 24 | } 25 | 26 | @Override 27 | public int getCount() { 28 | return fragments.size(); 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public CharSequence getPageTitle(int position) { 34 | return fragmentTitles.get(position); 35 | } 36 | 37 | public void addFragment(Fragment fragment, String string) { 38 | fragments.add(fragment); 39 | fragmentTitles.add(string); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Adapters/BottomNavViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Adapters; 2 | 3 | import androidx.fragment.app.Fragment; 4 | import androidx.fragment.app.FragmentManager; 5 | import androidx.fragment.app.FragmentPagerAdapter; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class BottomNavViewPagerAdapter extends FragmentPagerAdapter { 10 | 11 | ArrayList fragments = new ArrayList<>(); 12 | 13 | public BottomNavViewPagerAdapter(FragmentManager fm) { 14 | super(fm); 15 | } 16 | 17 | @Override 18 | public Fragment getItem(int position) { 19 | return fragments.get(position); 20 | } 21 | 22 | 23 | @Override 24 | public int getCount() { 25 | return fragments.size(); 26 | } 27 | 28 | public void addFragment(Fragment fragment){ 29 | fragments.add(fragment); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Adapters/ProfileListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Adapters; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.ListView; 9 | import android.widget.TextView; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import com.teyyihan.gelecekbilimde.Models.SettingModel; 15 | import com.teyyihan.gelecekbilimde.R; 16 | 17 | import java.util.HashMap; 18 | import java.util.List; 19 | 20 | public class ProfileListAdapter extends RecyclerView.Adapter { 21 | 22 | private List mData; 23 | private LayoutInflater mInflater; 24 | private ItemClickListener mClickListener; 25 | 26 | 27 | public ProfileListAdapter(Context context, List settings){ 28 | this.mInflater = LayoutInflater.from(context); 29 | this.mData = settings; 30 | } 31 | 32 | @NonNull 33 | @Override 34 | public ProfileListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 35 | View view = mInflater.inflate(R.layout.settings_row_layout, parent, false); 36 | return new ProfileListViewHolder(view); 37 | } 38 | 39 | 40 | @Override 41 | public void onBindViewHolder(@NonNull ProfileListViewHolder holder, int position) { 42 | String title = mData.get(position).getTitle(); 43 | int image = mData.get(position).getIcon(); 44 | 45 | holder.myTextView.setText(title); 46 | holder.mImageView.setImageResource(image); 47 | } 48 | 49 | 50 | 51 | @Override 52 | public int getItemCount() { 53 | return mData.size(); 54 | } 55 | 56 | public class ProfileListViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ 57 | TextView myTextView; 58 | ImageView mImageView; 59 | 60 | public ProfileListViewHolder(@NonNull View itemView) { 61 | super(itemView); 62 | myTextView = itemView.findViewById(R.id.settings_row_textView); 63 | mImageView = itemView.findViewById(R.id.settings_row_imageView); 64 | itemView.setOnClickListener(this); 65 | } 66 | 67 | @Override 68 | public void onClick(View view) { 69 | if (mClickListener != null) mClickListener.onItemClick(view, getAdapterPosition()); 70 | } 71 | } 72 | 73 | public SettingModel getItem(int position) { 74 | return mData.get(position); 75 | } 76 | 77 | // allows clicks events to be caught 78 | public void setClickListener(ItemClickListener itemClickListener) { 79 | this.mClickListener = itemClickListener; 80 | } 81 | 82 | // parent activity will implement this method to respond to click events 83 | public interface ItemClickListener { 84 | void onItemClick(View view, int position); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Adapters/VideoAdapter.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Adapters; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.text.Html; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.RelativeLayout; 11 | import android.widget.TextView; 12 | 13 | import androidx.annotation.NonNull; 14 | import androidx.fragment.app.FragmentActivity; 15 | import androidx.lifecycle.ViewModelProviders; 16 | import androidx.paging.PagedListAdapter; 17 | import androidx.recyclerview.widget.DiffUtil; 18 | import androidx.recyclerview.widget.RecyclerView; 19 | 20 | import com.bumptech.glide.Glide; 21 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 22 | import com.bumptech.glide.request.RequestOptions; 23 | import com.teyyihan.gelecekbilimde.Activities.YoutubeVideoActivity; 24 | import com.teyyihan.gelecekbilimde.Fragments.video.VideoViewModel; 25 | import com.teyyihan.gelecekbilimde.R; 26 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 27 | 28 | import java.text.ParseException; 29 | import java.text.SimpleDateFormat; 30 | import java.util.Date; 31 | 32 | public class VideoAdapter extends PagedListAdapter { 33 | 34 | Context mContext; 35 | VideoViewModel videoViewModel; 36 | 37 | public VideoAdapter(Context context) { 38 | super(callback); 39 | this.mContext = context; 40 | videoViewModel = ViewModelProviders.of((FragmentActivity)context).get(VideoViewModel.class); 41 | } 42 | 43 | private static final DiffUtil.ItemCallback callback = new DiffUtil.ItemCallback() { 44 | @Override 45 | public boolean areItemsTheSame(@NonNull VideoModel oldItem, @NonNull VideoModel newItem) { 46 | return oldItem.getVideoURLId().equals(newItem.getVideoURLId()); 47 | } 48 | 49 | @Override 50 | public boolean areContentsTheSame(@NonNull VideoModel oldItem, @NonNull VideoModel newItem) { 51 | return oldItem.getVideoTitle().equals(newItem.getVideoTitle()) && oldItem.isBookmarked()==newItem.isBookmarked(); 52 | } 53 | }; 54 | 55 | public class VideoViewHolder extends RecyclerView.ViewHolder{ 56 | 57 | public ImageView videoThumbnail; 58 | public ImageView videoPublisherLogo; 59 | public ImageView videoBookmarkLogo; 60 | public TextView videoTitle; 61 | public TextView videoDate; 62 | private RelativeLayout videoRelativeLayout; 63 | 64 | public VideoViewHolder(@NonNull View itemView) { 65 | super(itemView); 66 | videoThumbnail= itemView.findViewById(R.id.video_thumbnail); 67 | videoPublisherLogo= itemView.findViewById(R.id.video_publisher_logo); 68 | videoBookmarkLogo= itemView.findViewById(R.id.video_bookmark_logo); 69 | videoTitle= itemView.findViewById(R.id.video_title); 70 | videoDate= itemView.findViewById(R.id.video_date); 71 | videoRelativeLayout = itemView.findViewById(R.id.video_cardview); 72 | } 73 | } 74 | 75 | 76 | @NonNull 77 | @Override 78 | public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 79 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_row_layout,parent,false); 80 | final VideoViewHolder videoViewHolder = new VideoViewHolder(view); 81 | 82 | //video onclick methodu 83 | videoViewHolder.videoRelativeLayout.setOnClickListener(new View.OnClickListener() { 84 | @Override 85 | public void onClick(View view) { 86 | } 87 | }); 88 | 89 | 90 | return videoViewHolder; 91 | } 92 | 93 | 94 | @Override 95 | public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { 96 | final VideoModel selectedVideo = getItem(position); 97 | if(selectedVideo!=null){ 98 | if (selectedVideo != null) { 99 | if (selectedVideo.getVideoDate() != null) { 100 | String sdf = calculateDate(selectedVideo.getVideoDate()); 101 | holder.videoDate.setText(sdf); 102 | } 103 | 104 | Glide.with(mContext).load(selectedVideo.getVideoImageURL()) 105 | .diskCacheStrategy(DiskCacheStrategy.ALL) 106 | .centerCrop() 107 | .apply(new RequestOptions().override(1000, 550)) 108 | .placeholder(R.drawable.youtube_logo_min) 109 | .into(holder.videoThumbnail); 110 | 111 | holder.videoTitle.setText(Html.fromHtml(selectedVideo.getVideoTitle())); 112 | } 113 | 114 | 115 | if (selectedVideo.isBookmarked()) { 116 | holder.videoBookmarkLogo.setImageResource(R.drawable.bookmark_checked); 117 | } else { 118 | holder.videoBookmarkLogo.setImageResource(R.drawable.bookmark_unchecked); 119 | } 120 | 121 | holder.videoBookmarkLogo.setOnClickListener(new View.OnClickListener() { 122 | @Override 123 | public void onClick(View view) { 124 | 125 | if (!selectedVideo.isBookmarked()) { 126 | setBookmarkedTrue(selectedVideo); 127 | } else { 128 | setBookmarkFalse(selectedVideo); 129 | } 130 | 131 | } 132 | 133 | private void setBookmarkFalse(VideoModel currentVideo) { 134 | currentVideo.setBookmarked(false); 135 | videoViewModel.updateVideo(currentVideo); 136 | holder.videoBookmarkLogo.setImageResource(R.drawable.bookmark_unchecked); 137 | } 138 | 139 | private void setBookmarkedTrue(VideoModel currentVideo) { 140 | currentVideo.setBookmarked(true); 141 | videoViewModel.updateVideo(currentVideo); 142 | holder.videoBookmarkLogo.setImageResource(R.drawable.bookmark_checked); 143 | } 144 | }); 145 | 146 | // video onclick 147 | holder.videoThumbnail.setOnClickListener(new View.OnClickListener() { 148 | @Override 149 | public void onClick(View view) { 150 | Intent intent = new Intent(mContext, YoutubeVideoActivity.class); 151 | intent.putExtra("VIDEO_URL", selectedVideo.getVideoURLId()); 152 | mContext.startActivity(intent); 153 | } 154 | }); 155 | } 156 | } 157 | 158 | private String calculateDate(String videoDate) { 159 | 160 | Date date= null; 161 | String sdf = " "; 162 | try { 163 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); // 2019-12-26T12:00:08.000Z 164 | date = format.parse(videoDate.replaceAll("Z$", "+0000")); 165 | System.out.println(date); 166 | sdf = new SimpleDateFormat("dd/MM/yyyy").format(date); 167 | } catch (ParseException e) { 168 | 169 | try { 170 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); // 2020-05-14T10:08:11Z 171 | date = format.parse(videoDate.replaceAll("Z$", "+0000")); 172 | System.out.println(date); 173 | sdf = new SimpleDateFormat("dd/MM/yyyy").format(date); 174 | } catch (Exception ex) { 175 | 176 | } 177 | 178 | e.printStackTrace(); 179 | } 180 | 181 | 182 | 183 | return sdf; 184 | } 185 | 186 | 187 | } 188 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/CustomViewPager.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.MotionEvent; 6 | 7 | import androidx.viewpager.widget.ViewPager; 8 | 9 | public class CustomViewPager extends ViewPager { 10 | 11 | 12 | public CustomViewPager(Context context, AttributeSet attrs) { 13 | super(context, attrs); 14 | } 15 | 16 | @Override 17 | public boolean onTouchEvent(MotionEvent event) { 18 | return false; 19 | } 20 | 21 | @Override 22 | public boolean onInterceptTouchEvent(MotionEvent event) { 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Database/ArticleDao.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Database; 2 | 3 | 4 | import androidx.paging.DataSource; 5 | import androidx.room.Delete; 6 | import androidx.room.Insert; 7 | import androidx.room.OnConflictStrategy; 8 | import androidx.room.Query; 9 | import androidx.room.Update; 10 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 11 | 12 | 13 | @androidx.room.Dao 14 | public interface ArticleDao { 15 | 16 | @Insert(onConflict = OnConflictStrategy.IGNORE) 17 | void insertArticle(ArticleModel article); 18 | 19 | @Update 20 | void updateArticle(ArticleModel article); 21 | 22 | @Query("UPDATE article_table SET articleImageURL = :imageURL WHERE articleId = :articleID") 23 | void updateArticleImage(String imageURL,int articleID); 24 | 25 | @Delete 26 | void deleteArticle(ArticleModel article); 27 | 28 | @Query("DELETE FROM article_table") 29 | void deleteAllArticles(); 30 | 31 | @Query("Select * From article_table order by articleDate desc") 32 | DataSource.Factory getAllArticles(); 33 | 34 | @Query("Select * from article_table where bookmarked=1") 35 | DataSource.Factory getAllBookmarkedArticles(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Database/MyDatabase.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Database; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.room.Database; 7 | import androidx.room.Room; 8 | import androidx.room.RoomDatabase; 9 | import androidx.sqlite.db.SupportSQLiteDatabase; 10 | 11 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 12 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 13 | 14 | @Database(entities = {ArticleModel.class, VideoModel.class}, version = 33) 15 | public abstract class MyDatabase extends RoomDatabase { 16 | 17 | private static MyDatabase myDatabaseInstance; 18 | 19 | public abstract ArticleDao articleDao(); 20 | 21 | public abstract VideoDao videoDao(); 22 | 23 | 24 | public static synchronized MyDatabase getInstance(Context context) { 25 | if (myDatabaseInstance == null) { 26 | myDatabaseInstance = Room.databaseBuilder(context.getApplicationContext(), 27 | MyDatabase.class, "database") 28 | .fallbackToDestructiveMigration() 29 | .addCallback(callback) 30 | .build(); 31 | } 32 | return myDatabaseInstance; 33 | } 34 | 35 | 36 | private static RoomDatabase.Callback callback = new RoomDatabase.Callback() { 37 | 38 | @Override 39 | public void onCreate(@NonNull SupportSQLiteDatabase db) { 40 | super.onCreate(db); 41 | 42 | } 43 | }; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Database/VideoDao.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Database; 2 | 3 | import androidx.paging.DataSource; 4 | import androidx.room.Dao; 5 | import androidx.room.Delete; 6 | import androidx.room.Insert; 7 | import androidx.room.OnConflictStrategy; 8 | import androidx.room.Query; 9 | import androidx.room.Update; 10 | 11 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 12 | 13 | @Dao 14 | public interface VideoDao { 15 | 16 | @Insert(onConflict = OnConflictStrategy.IGNORE) 17 | void insertVideo(VideoModel video); 18 | 19 | @Update 20 | void updateVideo(VideoModel video); 21 | 22 | @Delete 23 | void deleteVideo(VideoModel video); 24 | 25 | @Query("DELETE FROM video_table") 26 | void deleteAllVideos(); 27 | 28 | @Query("Select * From video_table order by videoDate desc") 29 | DataSource.Factory getAllVideos(); 30 | 31 | @Query("Select * from video_table where bookmarked=1") 32 | DataSource.Factory getAllBookmarkedVideos(); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/article/ArticleFragment.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.article; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.Menu; 6 | import android.view.MenuInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | 13 | import androidx.fragment.app.Fragment; 14 | import androidx.lifecycle.MutableLiveData; 15 | import androidx.lifecycle.Observer; 16 | import androidx.lifecycle.ViewModelProviders; 17 | import androidx.paging.PagedList; 18 | import androidx.recyclerview.widget.LinearLayoutManager; 19 | import androidx.recyclerview.widget.RecyclerView; 20 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 21 | 22 | import com.teyyihan.gelecekbilimde.Activities.MainActivity; 23 | import com.teyyihan.gelecekbilimde.R; 24 | import com.teyyihan.gelecekbilimde.Adapters.ArticleAdapter; 25 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 26 | 27 | public class ArticleFragment extends Fragment { 28 | 29 | private ArticleViewModel articleViewModel; 30 | private RecyclerView mRecyclerview; 31 | private ArticleAdapter mAdapter; 32 | private SwipeRefreshLayout mSwipeRefreshLayout; 33 | private LinearLayoutManager manager; 34 | public static MutableLiveData title = new MutableLiveData<>(); 35 | private boolean isloadedBefore = false; 36 | 37 | @Override 38 | public void onCreate(@Nullable Bundle savedInstanceState) { 39 | setHasOptionsMenu(true); 40 | super.onCreate(savedInstanceState); 41 | } 42 | 43 | public View onCreateView(@NonNull LayoutInflater inflater, 44 | ViewGroup container, Bundle savedInstanceState) { 45 | final View view = inflater.inflate(R.layout.fragment_articles, container, false); 46 | 47 | mRecyclerview = view.findViewById(R.id.article_recyclerview2); 48 | mSwipeRefreshLayout = view.findViewById(R.id.article_swipe2); 49 | manager = new LinearLayoutManager(getContext()); 50 | mRecyclerview.setLayoutManager(manager); 51 | mAdapter = new ArticleAdapter(getContext()); 52 | mRecyclerview.setAdapter(mAdapter); 53 | articleViewModel = ViewModelProviders.of(this).get(ArticleViewModel.class); 54 | 55 | if (!isloadedBefore) { 56 | refreshArticleFeed(); 57 | isloadedBefore=true; 58 | } 59 | 60 | 61 | articleViewModel.getAllArticles().observe(this, new Observer>() { 62 | @Override 63 | public void onChanged(PagedList articleModels) { 64 | mAdapter.submitList(articleModels); 65 | } 66 | }); 67 | 68 | mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 69 | @Override 70 | public void onRefresh() { 71 | //articleViewModel.deleteAllArticles(); 72 | manager.scrollToPosition(0); 73 | refreshArticleFeed(); 74 | 75 | } 76 | }); 77 | 78 | articleViewModel.isLoading.observe(this, new Observer() { 79 | @Override 80 | public void onChanged(Boolean aBoolean) { 81 | mSwipeRefreshLayout.setRefreshing(aBoolean); 82 | } 83 | }); 84 | 85 | return view; 86 | } 87 | 88 | private void refreshArticleFeed() { 89 | articleViewModel.isLoading.postValue(true); 90 | articleViewModel.getTenArticlesfromFirebaseAndRetrofit(1); 91 | } 92 | 93 | @Override 94 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 95 | menu.findItem(R.id.action_search).setVisible(false); 96 | super.onCreateOptionsMenu(menu, inflater); 97 | ((MainActivity)getActivity()).setTitle("Makaleler"); 98 | } 99 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/article/ArticleItemBoundaryCallback.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.article; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.paging.PagedList; 5 | 6 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 7 | import com.teyyihan.gelecekbilimde.Repository.ArticleRepository; 8 | 9 | public class ArticleItemBoundaryCallback extends PagedList.BoundaryCallback { 10 | ArticleRepository repository; 11 | 12 | public ArticleItemBoundaryCallback(ArticleRepository repository) { 13 | this.repository =repository; 14 | } 15 | 16 | 17 | @Override 18 | public void onZeroItemsLoaded() { 19 | super.onZeroItemsLoaded(); 20 | repository.getTenArticlesfromFirebaseAndRetrofit(1); 21 | } 22 | 23 | @Override 24 | public void onItemAtEndLoaded(@NonNull ArticleModel itemAtEnd) { 25 | super.onItemAtEndLoaded(itemAtEnd); 26 | 27 | int page=0; 28 | if (itemAtEnd.getPage() == 0) { 29 | page = itemAtEnd.getPage() + 2; 30 | } else { 31 | page = itemAtEnd.getPage()+1; 32 | } 33 | 34 | repository.getTenArticlesfromFirebaseAndRetrofit(page); 35 | 36 | /* 37 | DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("Articles"); 38 | 39 | Query query = myRef.orderByChild("articleDate").endAt(itemAtEnd.getArticleDate()).limitToLast(5); 40 | query.addListenerForSingleValueEvent(new ValueEventListener() { 41 | @Override 42 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 43 | ArticleModel articleModel; 44 | if (dataSnapshot.hasChildren()) { 45 | for (DataSnapshot each: dataSnapshot.getChildren()) { 46 | articleModel= each.getValue(ArticleModel.class); 47 | repository.insertArticle(articleModel); 48 | } 49 | } 50 | } 51 | 52 | @Override 53 | public void onCancelled(@NonNull DatabaseError databaseError) { 54 | 55 | } 56 | 57 | 58 | });*/ 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/article/ArticleViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.article; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.lifecycle.AndroidViewModel; 6 | import androidx.lifecycle.LiveData; 7 | import androidx.lifecycle.MutableLiveData; 8 | import androidx.paging.DataSource; 9 | import androidx.paging.LivePagedListBuilder; 10 | import androidx.paging.PagedList; 11 | 12 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 13 | import com.teyyihan.gelecekbilimde.Repository.ArticleRepository; 14 | 15 | public class ArticleViewModel extends AndroidViewModel { 16 | private ArticleRepository articleRepository; 17 | private LiveData> allArticles; 18 | public static MutableLiveData isLoading = new MutableLiveData<>(); 19 | 20 | public ArticleViewModel(Application application) { 21 | super(application); 22 | articleRepository = new ArticleRepository(application); 23 | DataSource.Factory factory = articleRepository.getAllArticles(); 24 | ArticleItemBoundaryCallback boundaryCallback = new ArticleItemBoundaryCallback(articleRepository); 25 | LivePagedListBuilder pagedListBuilder = new LivePagedListBuilder(factory,10).setBoundaryCallback(boundaryCallback); 26 | allArticles = pagedListBuilder.build(); 27 | } 28 | 29 | public void insertArticle(ArticleModel article) { 30 | articleRepository.insertArticle(article); 31 | } 32 | 33 | 34 | public void deleteArticle(ArticleModel article) { 35 | articleRepository.deleteArticle(article); 36 | } 37 | 38 | public void deleteAllArticles() { 39 | articleRepository.deleteAllArticles(); 40 | } 41 | 42 | public void updateArticle(ArticleModel article) { 43 | articleRepository.updateArticle(article); 44 | } 45 | 46 | public LiveData> getAllArticles() { 47 | return allArticles; 48 | } 49 | 50 | public void getTenArticlesfromFirebaseAndRetrofit(int page) { 51 | articleRepository.getTenArticlesfromFirebaseAndRetrofit(page); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragment.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.Menu; 6 | import android.view.MenuInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | import androidx.fragment.app.Fragment; 13 | import androidx.lifecycle.ViewModelProviders; 14 | import androidx.viewpager.widget.ViewPager; 15 | 16 | import com.teyyihan.gelecekbilimde.Activities.MainActivity; 17 | import com.teyyihan.gelecekbilimde.Adapters.BookmarkTablayoutAdapter; 18 | import com.teyyihan.gelecekbilimde.R; 19 | import com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments.BookmarkedArticleFragment; 20 | import com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments.BookmarkedVideoFragment; 21 | import com.google.android.material.tabs.TabLayout; 22 | 23 | public class BookmarkFragment extends Fragment { 24 | 25 | 26 | TabLayout tabLayout; 27 | ViewPager viewPager; 28 | BookmarkTablayoutAdapter bookmarkTablayoutAdapter; 29 | private BookmarkViewModel bookmarkViewModel; 30 | 31 | @Override 32 | public void onCreate(@Nullable Bundle savedInstanceState) { 33 | setHasOptionsMenu(true); 34 | super.onCreate(savedInstanceState); 35 | } 36 | 37 | public View onCreateView(@NonNull LayoutInflater inflater, 38 | ViewGroup container, Bundle savedInstanceState) { 39 | bookmarkViewModel = 40 | ViewModelProviders.of(this).get(BookmarkViewModel.class); 41 | View view = inflater.inflate(R.layout.fragment_bookmark, container, false); 42 | 43 | tabLayout = view.findViewById(R.id.bookmark_tablayout); 44 | viewPager = view.findViewById(R.id.bookmark_viewpager); 45 | bookmarkTablayoutAdapter = new BookmarkTablayoutAdapter( getChildFragmentManager()); 46 | 47 | bookmarkTablayoutAdapter.addFragment(new BookmarkedArticleFragment(), "Makaleler"); 48 | bookmarkTablayoutAdapter.addFragment(new BookmarkedVideoFragment(), "Videolar"); 49 | 50 | viewPager.setAdapter(bookmarkTablayoutAdapter); 51 | tabLayout.setupWithViewPager(viewPager); 52 | 53 | return view; 54 | } 55 | 56 | @Override 57 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 58 | menu.findItem(R.id.action_search).setVisible(false); 59 | super.onCreateOptionsMenu(menu, inflater); 60 | ((MainActivity)getActivity()).setTitle("Kaydedilenler"); 61 | } 62 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedArticleBoundaryCallback.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.paging.PagedList; 5 | 6 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 7 | import com.teyyihan.gelecekbilimde.Repository.ArticleRepository; 8 | 9 | public class BookmarkedArticleBoundaryCallback extends PagedList.BoundaryCallback { 10 | ArticleRepository repository; 11 | 12 | public BookmarkedArticleBoundaryCallback(ArticleRepository repository) { 13 | this.repository =repository; 14 | } 15 | 16 | @Override 17 | public void onItemAtEndLoaded(@NonNull ArticleModel itemAtEnd) { 18 | super.onItemAtEndLoaded(itemAtEnd); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedArticleFragment.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | import androidx.fragment.app.Fragment; 11 | import androidx.lifecycle.Observer; 12 | import androidx.lifecycle.ViewModelProviders; 13 | import androidx.paging.PagedList; 14 | import androidx.recyclerview.widget.LinearLayoutManager; 15 | import androidx.recyclerview.widget.RecyclerView; 16 | 17 | import com.teyyihan.gelecekbilimde.R; 18 | import com.teyyihan.gelecekbilimde.Adapters.ArticleAdapter; 19 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 20 | 21 | public class BookmarkedArticleFragment extends Fragment { 22 | 23 | 24 | private RecyclerView mRecyclerview; 25 | private ArticleAdapter mAdapter; 26 | private BookmarkedArticleViewModel articleViewModel; 27 | 28 | public BookmarkedArticleFragment() { 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 34 | View v = inflater.inflate(R.layout.bookmarked_article_fragment,container,false); 35 | 36 | mRecyclerview = v.findViewById(R.id.bookmarked_article_recycler); 37 | mRecyclerview.setHasFixedSize(true) ; 38 | mAdapter = new ArticleAdapter(getContext()); 39 | mRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity())); 40 | mRecyclerview.setAdapter(mAdapter); 41 | 42 | articleViewModel = ViewModelProviders.of(this).get(BookmarkedArticleViewModel.class); 43 | 44 | 45 | articleViewModel.getAllBookmarkedArticles().observe(this, new Observer>() { 46 | @Override 47 | public void onChanged(PagedList articleModels) { 48 | mAdapter.submitList(articleModels); 49 | } 50 | }); 51 | 52 | 53 | return v; 54 | } 55 | 56 | @Override 57 | public void onCreate(@Nullable Bundle savedInstanceState) { 58 | super.onCreate(savedInstanceState); 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedArticleViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.lifecycle.AndroidViewModel; 6 | import androidx.lifecycle.LiveData; 7 | import androidx.paging.DataSource; 8 | import androidx.paging.LivePagedListBuilder; 9 | import androidx.paging.PagedList; 10 | 11 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 12 | import com.teyyihan.gelecekbilimde.Repository.ArticleRepository; 13 | 14 | public class BookmarkedArticleViewModel extends AndroidViewModel { 15 | private ArticleRepository articleRepository; 16 | private LiveData> allBookmarkedArticles; 17 | 18 | 19 | public BookmarkedArticleViewModel(Application application) { 20 | super(application); 21 | articleRepository = new ArticleRepository(application); 22 | 23 | DataSource.Factory factory = articleRepository.getAllBookmarkedArticles(); 24 | BookmarkedArticleBoundaryCallback boundaryCallback = new BookmarkedArticleBoundaryCallback(articleRepository); 25 | LivePagedListBuilder pagedListBuilder = new LivePagedListBuilder(factory,10).setBoundaryCallback(boundaryCallback); 26 | allBookmarkedArticles = pagedListBuilder.build(); 27 | 28 | //allArticles = articleRepository.getAllArticles(); 29 | } 30 | 31 | public void insertArticle(ArticleModel article) { 32 | articleRepository.insertArticle(article); 33 | } 34 | 35 | public void deleteArticle(ArticleModel article) { 36 | articleRepository.deleteArticle(article); 37 | } 38 | 39 | public void deleteAllArticles() { 40 | articleRepository.deleteAllArticles(); 41 | } 42 | 43 | public void updateArticle(ArticleModel article) { 44 | articleRepository.updateArticle(article); 45 | } 46 | 47 | public LiveData> getAllBookmarkedArticles() { 48 | return allBookmarkedArticles; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedVideoBoundaryCallback.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.paging.PagedList; 5 | 6 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 7 | import com.teyyihan.gelecekbilimde.Repository.VideoRepository; 8 | 9 | public class BookmarkedVideoBoundaryCallback extends PagedList.BoundaryCallback { 10 | VideoRepository repository; 11 | 12 | public BookmarkedVideoBoundaryCallback(VideoRepository repository) { 13 | this.repository =repository; 14 | } 15 | 16 | @Override 17 | public void onItemAtEndLoaded(@NonNull VideoModel itemAtEnd) { 18 | super.onItemAtEndLoaded(itemAtEnd); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedVideoFragment.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | import androidx.fragment.app.Fragment; 11 | import androidx.lifecycle.Observer; 12 | import androidx.lifecycle.ViewModelProviders; 13 | import androidx.paging.PagedList; 14 | import androidx.recyclerview.widget.DividerItemDecoration; 15 | import androidx.recyclerview.widget.LinearLayoutManager; 16 | import androidx.recyclerview.widget.RecyclerView; 17 | 18 | import com.teyyihan.gelecekbilimde.R; 19 | import com.teyyihan.gelecekbilimde.Adapters.VideoAdapter; 20 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 21 | 22 | public class BookmarkedVideoFragment extends Fragment { 23 | 24 | private RecyclerView mRecyclerview; 25 | private VideoAdapter mAdapter; 26 | private BookmarkedVideoViewModel videoViewModel; 27 | 28 | 29 | public BookmarkedVideoFragment() { 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 35 | View v = inflater.inflate(R.layout.bookmarked_video_fragment,container,false); 36 | 37 | mRecyclerview = v.findViewById(R.id.bookmarked_video_recycler); 38 | mRecyclerview.setHasFixedSize(true) ; 39 | mRecyclerview.addItemDecoration(new DividerItemDecoration(mRecyclerview.getContext(), DividerItemDecoration.VERTICAL)); 40 | mAdapter = new VideoAdapter(getContext()); 41 | mRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity())); 42 | mRecyclerview.setAdapter(mAdapter); 43 | 44 | videoViewModel = ViewModelProviders.of(this).get(BookmarkedVideoViewModel.class); 45 | 46 | videoViewModel.getAllBookmarkedVideos().observe(this, new Observer>() { 47 | @Override 48 | public void onChanged(PagedList videoModels) { 49 | mAdapter.submitList(videoModels); 50 | } 51 | }); 52 | 53 | 54 | return v; 55 | } 56 | 57 | @Override 58 | public void onCreate(@Nullable Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkFragments/BookmarkedVideoViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark.BookmarkFragments; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.lifecycle.AndroidViewModel; 7 | import androidx.lifecycle.LiveData; 8 | import androidx.paging.DataSource; 9 | import androidx.paging.LivePagedListBuilder; 10 | import androidx.paging.PagedList; 11 | 12 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 13 | import com.teyyihan.gelecekbilimde.Repository.VideoRepository; 14 | 15 | public class BookmarkedVideoViewModel extends AndroidViewModel { 16 | 17 | private VideoRepository videoRepository; 18 | private LiveData> allBookmarkedVideos; 19 | 20 | public BookmarkedVideoViewModel(@NonNull Application application) { 21 | super(application); 22 | videoRepository = new VideoRepository(application); 23 | 24 | DataSource.Factory factory = videoRepository.getAllBookmarkedVideos(); 25 | BookmarkedVideoBoundaryCallback boundaryCallback = new BookmarkedVideoBoundaryCallback(videoRepository); 26 | LivePagedListBuilder pagedListBuilder = new LivePagedListBuilder(factory,10).setBoundaryCallback(boundaryCallback); 27 | allBookmarkedVideos = pagedListBuilder.build(); 28 | } 29 | 30 | public LiveData> getAllBookmarkedVideos() { 31 | return allBookmarkedVideos; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/bookmark/BookmarkViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.bookmark; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | public class BookmarkViewModel extends ViewModel { 8 | 9 | private MutableLiveData mText; 10 | 11 | public BookmarkViewModel() { 12 | mText = new MutableLiveData<>(); 13 | mText.setValue("This is notifications fragment"); 14 | } 15 | 16 | public LiveData getText() { 17 | return mText; 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/profile/ProfileViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.profile; 2 | 3 | import androidx.lifecycle.ViewModel; 4 | 5 | public class ProfileViewModel extends ViewModel { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/video/VideoFragment.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.video; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.Menu; 6 | import android.view.MenuInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import androidx.annotation.Nullable; 11 | import androidx.annotation.NonNull; 12 | import androidx.fragment.app.Fragment; 13 | import androidx.lifecycle.Observer; 14 | import androidx.lifecycle.ViewModelProviders; 15 | import androidx.paging.PagedList; 16 | import androidx.recyclerview.widget.LinearLayoutManager; 17 | import androidx.recyclerview.widget.RecyclerView; 18 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 19 | 20 | import com.teyyihan.gelecekbilimde.Activities.MainActivity; 21 | import com.teyyihan.gelecekbilimde.Adapters.VideoAdapter; 22 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 23 | import com.teyyihan.gelecekbilimde.R; 24 | 25 | public class VideoFragment extends Fragment { 26 | 27 | private VideoViewModel videoViewModel; 28 | private SwipeRefreshLayout swipeRefreshLayout; 29 | private RecyclerView recyclerView; 30 | private VideoAdapter videoAdapter; 31 | private LinearLayoutManager manager; 32 | 33 | @Override 34 | public void onCreate(@Nullable Bundle savedInstanceState) { 35 | setHasOptionsMenu(true); 36 | super.onCreate(savedInstanceState); 37 | } 38 | 39 | public View onCreateView(@NonNull LayoutInflater inflater, 40 | ViewGroup container, Bundle savedInstanceState) { 41 | View view = inflater.inflate(R.layout.fragment_videos, container, false); 42 | 43 | videoViewModel = ViewModelProviders.of(this).get(VideoViewModel.class); 44 | recyclerView = view.findViewById(R.id.video_recycler); 45 | swipeRefreshLayout = view.findViewById(R.id.videos_swipe); 46 | manager = new LinearLayoutManager(getContext()); 47 | recyclerView.setLayoutManager(manager); 48 | videoAdapter = new VideoAdapter(getContext()); 49 | recyclerView.setAdapter(videoAdapter); 50 | 51 | 52 | 53 | 54 | swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 55 | @Override 56 | public void onRefresh() { 57 | // videoViewModel.deleteAllVideos(); 58 | manager.scrollToPosition(0); 59 | refreshVideoFeed(); 60 | } 61 | }); 62 | 63 | videoViewModel.isLoading.observe(this, new Observer() { 64 | @Override 65 | public void onChanged(Boolean aBoolean) { 66 | swipeRefreshLayout.setRefreshing(aBoolean); 67 | } 68 | }); 69 | 70 | videoViewModel.getAllVideos().observe(this, new Observer>() { 71 | @Override 72 | public void onChanged(PagedList videoModels) { 73 | videoAdapter.submitList(videoModels); 74 | } 75 | }); 76 | 77 | return view; 78 | } 79 | 80 | private void refreshVideoFeed() { 81 | videoViewModel.isLoading.postValue(true); 82 | videoViewModel.getTenVideosFromFirebase(); 83 | } 84 | 85 | @Override 86 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 87 | menu.findItem(R.id.action_search).setVisible(false); 88 | super.onCreateOptionsMenu(menu, inflater); 89 | ((MainActivity)getActivity()).setTitle("Videolar"); 90 | } 91 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/video/VideoItemBoundaryCallback.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.video; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.paging.PagedList; 5 | 6 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 7 | import com.teyyihan.gelecekbilimde.Repository.VideoRepository; 8 | import com.google.firebase.database.DataSnapshot; 9 | import com.google.firebase.database.DatabaseError; 10 | import com.google.firebase.database.DatabaseReference; 11 | import com.google.firebase.database.FirebaseDatabase; 12 | import com.google.firebase.database.Query; 13 | import com.google.firebase.database.ValueEventListener; 14 | 15 | public class VideoItemBoundaryCallback extends PagedList.BoundaryCallback { 16 | 17 | private VideoRepository repository; 18 | public VideoItemBoundaryCallback(VideoRepository videoRepository) { 19 | this.repository = videoRepository; 20 | } 21 | 22 | @Override 23 | public void onZeroItemsLoaded() { 24 | super.onZeroItemsLoaded(); 25 | repository.getTenVideosFromFirebase(); 26 | 27 | } 28 | 29 | @Override 30 | public void onItemAtEndLoaded(@NonNull VideoModel itemAtEnd) { 31 | super.onItemAtEndLoaded(itemAtEnd); 32 | DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("Videos"); 33 | 34 | Query query = myRef.orderByChild("videoDate").endAt(itemAtEnd.getVideoDate()).limitToLast(3); 35 | query.addListenerForSingleValueEvent(new ValueEventListener() { 36 | @Override 37 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 38 | VideoModel videoModel; 39 | if (dataSnapshot.hasChildren()) { 40 | for (DataSnapshot each: dataSnapshot.getChildren()) { 41 | videoModel= each.getValue(VideoModel.class); 42 | repository.insertVideo(videoModel); 43 | } 44 | } 45 | } 46 | 47 | @Override 48 | public void onCancelled(@NonNull DatabaseError databaseError) { 49 | 50 | } 51 | 52 | 53 | }); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Fragments/video/VideoViewModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Fragments.video; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.lifecycle.AndroidViewModel; 7 | import androidx.lifecycle.LiveData; 8 | import androidx.lifecycle.MutableLiveData; 9 | import androidx.paging.DataSource; 10 | import androidx.paging.LivePagedListBuilder; 11 | import androidx.paging.PagedList; 12 | 13 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 14 | import com.teyyihan.gelecekbilimde.Repository.VideoRepository; 15 | 16 | public class VideoViewModel extends AndroidViewModel { 17 | 18 | private VideoRepository videoRepository; 19 | private LiveData> allVideos; 20 | public static MutableLiveData isLoading =new MutableLiveData<>(); 21 | 22 | public VideoViewModel(@NonNull Application application) { 23 | super(application); 24 | videoRepository = new VideoRepository(application); 25 | 26 | DataSource.Factory factory = videoRepository.getAllVideos(); 27 | VideoItemBoundaryCallback boundaryCallback = new VideoItemBoundaryCallback(videoRepository); 28 | LivePagedListBuilder pagedListBuilder = new LivePagedListBuilder(factory,3).setBoundaryCallback(boundaryCallback); 29 | 30 | allVideos = pagedListBuilder.build(); 31 | 32 | } 33 | 34 | public void insertVideo(VideoModel video) { 35 | videoRepository.insertVideo(video); 36 | } 37 | public void updateVideo(VideoModel video) { 38 | videoRepository.updateVideo(video); 39 | } 40 | public void deleteVideo(VideoModel video) { 41 | videoRepository.deleteVideo(video); 42 | } 43 | public void deleteAllVideos() { 44 | videoRepository.deleteAllVideos(); 45 | } 46 | public LiveData> getAllVideos() { 47 | return allVideos; 48 | } 49 | public void getTenVideosFromFirebase() { 50 | videoRepository.getTenVideosFromFirebase(); 51 | } 52 | } -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/ArticleModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | import androidx.room.Entity; 4 | import androidx.room.Ignore; 5 | import androidx.room.PrimaryKey; 6 | 7 | @Entity(tableName = "article_table") 8 | public class ArticleModel { 9 | 10 | @PrimaryKey 11 | private int articleId; 12 | private String articleDate; 13 | private String articleImageURL; 14 | private String articleTitle; 15 | private String articleDesc; 16 | private int page; 17 | private boolean bookmarked; 18 | 19 | @Ignore 20 | public ArticleModel() { 21 | } 22 | 23 | public ArticleModel( int articleId, String articleDate, String articleDesc, String articleImageURL, String articleTitle, boolean bookmarked, int page) { 24 | this.articleId = articleId; 25 | this.articleDate = articleDate; 26 | this.articleImageURL = articleImageURL; 27 | this.articleTitle = articleTitle; 28 | this.bookmarked = bookmarked; 29 | this.articleDesc = articleDesc; 30 | this.page = page; 31 | } 32 | 33 | public int getPage() { 34 | return page; 35 | } 36 | 37 | public void setPage(int page) { 38 | this.page = page; 39 | } 40 | 41 | public int getArticleId() { 42 | return articleId; 43 | } 44 | 45 | public void setArticleId(int articleId) { 46 | this.articleId = articleId; 47 | } 48 | 49 | public String getArticleDate() { 50 | return articleDate; 51 | } 52 | 53 | public void setArticleDate(String articleDate) { 54 | this.articleDate = articleDate; 55 | } 56 | 57 | public String getArticleDesc() { 58 | return articleDesc; 59 | } 60 | 61 | public void setArticleDesc(String articleDesc) { 62 | this.articleDesc = articleDesc; 63 | } 64 | 65 | public String getArticleImageURL() { 66 | return articleImageURL; 67 | } 68 | 69 | public void setArticleImageURL(String articleImageURL) { 70 | this.articleImageURL = articleImageURL; 71 | } 72 | 73 | public String getArticleTitle() { 74 | return articleTitle; 75 | } 76 | 77 | public void setArticleTitle(String articleTitle) { 78 | this.articleTitle = articleTitle; 79 | } 80 | 81 | public boolean isBookmarked() { 82 | return bookmarked; 83 | } 84 | 85 | public void setBookmarked(boolean bookmarked) { 86 | this.bookmarked = bookmarked; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/Content.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class Content { 7 | 8 | @SerializedName("rendered") 9 | @Expose 10 | private String rendered; 11 | 12 | public String getRendered() { 13 | return rendered; 14 | } 15 | 16 | public void setRendered(String rendered) { 17 | this.rendered = rendered; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/CurrentUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class CurrentUserInfo { 7 | 8 | public static Map userInfo = new HashMap<>(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/RetrofitArticleBodyModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class RetrofitArticleBodyModel { 7 | 8 | @SerializedName("content") 9 | @Expose 10 | private Content content; 11 | @SerializedName("link") 12 | @Expose 13 | private String link; 14 | 15 | public Content getContent() { 16 | return content; 17 | } 18 | 19 | public void setContent(Content content) { 20 | this.content = content; 21 | } 22 | 23 | public String getLink() { 24 | return link; 25 | } 26 | 27 | public void setLink(String link) { 28 | this.link = link; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/RetrofitArticleModel/Content.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class Content { 7 | 8 | @SerializedName("rendered") 9 | @Expose 10 | private String rendered; 11 | 12 | public String getRendered() { 13 | return rendered; 14 | } 15 | 16 | public void setRendered(String rendered) { 17 | this.rendered = rendered; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/RetrofitArticleModel/Excerpt.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class Excerpt { 7 | 8 | @SerializedName("rendered") 9 | @Expose 10 | private String rendered; 11 | 12 | public String getRendered() { 13 | return rendered; 14 | } 15 | 16 | public void setRendered(String rendered) { 17 | this.rendered = rendered; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/RetrofitArticleModel/RetrofitArticleModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | public class RetrofitArticleModel { 8 | 9 | @SerializedName("id") 10 | @Expose 11 | private Integer id; 12 | @SerializedName("date") 13 | @Expose 14 | private String date; 15 | 16 | 17 | @SerializedName("title") 18 | @Expose 19 | private Title title; 20 | 21 | 22 | @SerializedName("content") 23 | @Expose 24 | private Content content; 25 | 26 | 27 | @SerializedName("excerpt") 28 | @Expose 29 | private Excerpt excerpt; 30 | 31 | 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Integer id) { 37 | this.id = id; 38 | } 39 | 40 | public String getDate() { 41 | return date; 42 | } 43 | 44 | public void setDate(String date) { 45 | this.date = date; 46 | } 47 | 48 | public Title getTitle() { 49 | return title; 50 | } 51 | 52 | public void setTitle(Title title) { 53 | this.title = title; 54 | } 55 | 56 | public Content getContent() { 57 | return content; 58 | } 59 | 60 | public void setContent(Content content) { 61 | this.content = content; 62 | } 63 | 64 | public Excerpt getExcerpt() { 65 | return excerpt; 66 | } 67 | 68 | public void setExcerpt(Excerpt excerpt) { 69 | this.excerpt = excerpt; 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/RetrofitArticleModel/Title.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class Title { 7 | 8 | @SerializedName("rendered") 9 | @Expose 10 | private String rendered; 11 | 12 | public String getRendered() { 13 | return rendered; 14 | } 15 | 16 | public void setRendered(String rendered) { 17 | this.rendered = rendered; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/SettingModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | public class SettingModel { 4 | 5 | private String title; 6 | private int icon; 7 | 8 | public SettingModel(String title, int icon) { 9 | this.title = title; 10 | this.icon = icon; 11 | } 12 | 13 | public String getTitle() { 14 | return title; 15 | } 16 | 17 | public void setTitle(String title) { 18 | this.title = title; 19 | } 20 | 21 | public int getIcon() { 22 | return icon; 23 | } 24 | 25 | public void setIcon(int icon) { 26 | this.icon = icon; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Models/VideoModel.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Models; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.room.Entity; 5 | import androidx.room.Ignore; 6 | import androidx.room.PrimaryKey; 7 | 8 | @Entity(tableName = "video_table") 9 | public class VideoModel { 10 | 11 | 12 | 13 | private String videoImageURL; 14 | private String videoTitle; 15 | private String videoDate; 16 | @NonNull 17 | @PrimaryKey 18 | private String videoURLId; 19 | private boolean bookmarked; 20 | 21 | @Ignore 22 | public VideoModel() { 23 | 24 | } 25 | 26 | public VideoModel(String videoImageURL, String videoTitle, String videoDate, boolean bookmarked, String videoURLId) { 27 | this.videoImageURL = videoImageURL; 28 | this.videoTitle = videoTitle; 29 | this.videoDate = videoDate; 30 | this.bookmarked = bookmarked; 31 | this.videoURLId =videoURLId; 32 | 33 | } 34 | 35 | 36 | public String getVideoImageURL() { 37 | return videoImageURL; 38 | } 39 | 40 | public String getVideoURLId() { 41 | return videoURLId; 42 | } 43 | 44 | public String getVideoTitle() { 45 | return videoTitle; 46 | } 47 | 48 | 49 | public String getVideoDate() { 50 | return videoDate; 51 | } 52 | 53 | public boolean isBookmarked() { 54 | return bookmarked; 55 | } 56 | 57 | public void setBookmarked(boolean bookmarked) { 58 | this.bookmarked = bookmarked; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/MyFbNotificationService.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.google.firebase.messaging.FirebaseMessagingService; 6 | import com.google.firebase.messaging.RemoteMessage; 7 | 8 | public class MyFbNotificationService extends FirebaseMessagingService { 9 | 10 | @Override 11 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { 12 | super.onMessageReceived(remoteMessage); 13 | System.out.println("teoooo geldi "+remoteMessage.getData()); 14 | System.out.println("teoooo geldi "+remoteMessage.getData().get("url")); 15 | } 16 | 17 | @Override 18 | public void onNewToken(@NonNull String s) { 19 | super.onNewToken(s); 20 | 21 | System.out.println("teoooo geldiiii2"); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Network/ArticleFirebaseAndRetrofit.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Network; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.teyyihan.gelecekbilimde.Fragments.article.ArticleViewModel; 6 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 7 | import com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel.RetrofitArticleModel; 8 | import com.teyyihan.gelecekbilimde.Repository.ArticleRepository; 9 | import com.google.firebase.database.DataSnapshot; 10 | import com.google.firebase.database.DatabaseError; 11 | import com.google.firebase.database.DatabaseReference; 12 | import com.google.firebase.database.FirebaseDatabase; 13 | import com.google.firebase.database.ValueEventListener; 14 | 15 | import java.util.List; 16 | 17 | import retrofit2.Call; 18 | import retrofit2.Callback; 19 | import retrofit2.Response; 20 | import retrofit2.Retrofit; 21 | import retrofit2.converter.gson.GsonConverterFactory; 22 | 23 | public class ArticleFirebaseAndRetrofit { 24 | DatabaseReference myRef; 25 | FirebaseDatabase database ; 26 | private String lastkey=""; 27 | 28 | public ArticleFirebaseAndRetrofit() { 29 | database = FirebaseDatabase.getInstance(); 30 | myRef = database.getReference("Articles"); 31 | } 32 | 33 | 34 | public void getTenArticlesfromFirebaseAndRetrofit(final ArticleRepository articleRepository, int page) { 35 | 36 | Retrofit retrofit = new Retrofit.Builder() 37 | .baseUrl("https://www.gelecekbilimde.net/wp-json/wp/v2/") 38 | .addConverterFactory(GsonConverterFactory.create()) 39 | .build(); 40 | 41 | RetrofitArticleAPI api = retrofit.create(RetrofitArticleAPI.class); 42 | 43 | Call> call = api.getPageOfPosts(page); 44 | 45 | 46 | //RETROFIT 47 | call.enqueue(new Callback>() { 48 | @Override 49 | public void onResponse(Call> call, Response> response) { 50 | if (response.isSuccessful()) { 51 | if (response != null) { 52 | 53 | for (RetrofitArticleModel each: response.body()) { 54 | 55 | ArticleModel article = new ArticleModel(each.getId(),each.getDate(),each.getExcerpt().getRendered(), 56 | "null",each.getTitle().getRendered(),false,page); 57 | articleRepository.insertArticle(article); 58 | 59 | //FIREBASE 60 | myRef.child(String.valueOf(each.getId())).child("articleImageURL").addListenerForSingleValueEvent(new ValueEventListener() { 61 | @Override 62 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 63 | String imageURL = dataSnapshot.getValue(String.class); 64 | 65 | articleRepository.updateArticleImage(imageURL,each.getId()); 66 | 67 | ArticleViewModel.isLoading.postValue(false); 68 | } 69 | 70 | @Override 71 | public void onCancelled(@NonNull DatabaseError databaseError) { 72 | 73 | } 74 | }); 75 | 76 | } 77 | } 78 | } else { 79 | ArticleViewModel.isLoading.postValue(false); 80 | } 81 | } 82 | 83 | @Override 84 | public void onFailure(Call> call, Throwable t) { 85 | 86 | } 87 | }); 88 | 89 | /* 90 | Query query = myRef.orderByChild("articleDate").limitToLast(10); 91 | 92 | query.addListenerForSingleValueEvent(new ValueEventListener() { 93 | @Override 94 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 95 | ArticleModel articleModel; 96 | if (dataSnapshot.hasChildren()) { 97 | for (DataSnapshot each: dataSnapshot.getChildren()) { 98 | articleModel= each.getValue(ArticleModel.class); 99 | articleRepository.insertArticle(articleModel); 100 | ArticleViewModel.isLoading.postValue(false); 101 | lastkey = each.getKey(); 102 | } 103 | } 104 | 105 | } 106 | 107 | @Override 108 | public void onCancelled(@NonNull DatabaseError databaseError) { 109 | 110 | } 111 | 112 | 113 | });*/ 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Network/RetrofitArticleAPI.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Network; 2 | 3 | import com.teyyihan.gelecekbilimde.Models.RetrofitArticleBodyModel; 4 | import com.teyyihan.gelecekbilimde.Models.RetrofitArticleModel.RetrofitArticleModel; 5 | 6 | import java.util.List; 7 | 8 | import retrofit2.Call; 9 | import retrofit2.http.GET; 10 | import retrofit2.http.Path; 11 | import retrofit2.http.Query; 12 | 13 | public interface RetrofitArticleAPI { 14 | 15 | @GET("{id}") 16 | Call getPost(@Path("id") int articleID); 17 | 18 | @GET("posts") 19 | Call> getPageOfPosts(@Query("page") Integer page); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Network/VideoFirebase.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Network; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.teyyihan.gelecekbilimde.Fragments.video.VideoViewModel; 6 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 7 | import com.teyyihan.gelecekbilimde.Repository.VideoRepository; 8 | import com.google.firebase.database.DataSnapshot; 9 | import com.google.firebase.database.DatabaseError; 10 | import com.google.firebase.database.DatabaseReference; 11 | import com.google.firebase.database.FirebaseDatabase; 12 | import com.google.firebase.database.Query; 13 | import com.google.firebase.database.ValueEventListener; 14 | 15 | public class VideoFirebase { 16 | DatabaseReference myRef; 17 | FirebaseDatabase firebaseDatabase; 18 | private String lastKey=""; 19 | 20 | public VideoFirebase() { 21 | firebaseDatabase = FirebaseDatabase.getInstance(); 22 | myRef = firebaseDatabase.getReference("/Videos"); 23 | } 24 | 25 | public void getTenArticlesFromFirebase(final VideoRepository videoRepository) { 26 | Query query = myRef.orderByChild("videoDate").limitToLast(5); 27 | 28 | query.addListenerForSingleValueEvent(new ValueEventListener() { 29 | @Override 30 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 31 | VideoModel videoModel; 32 | if (dataSnapshot.hasChildren()) { 33 | 34 | for (DataSnapshot each: dataSnapshot.getChildren()) { 35 | videoModel= each.getValue(VideoModel.class); 36 | videoRepository.insertVideo(videoModel); 37 | VideoViewModel.isLoading.postValue(false); 38 | lastKey =each.getKey(); 39 | } 40 | } 41 | 42 | } 43 | 44 | @Override 45 | public void onCancelled(@NonNull DatabaseError databaseError) { 46 | 47 | } 48 | 49 | 50 | }); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Repository/ArticleRepository.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Repository; 2 | 3 | import android.app.Application; 4 | import android.os.AsyncTask; 5 | import android.util.Log; 6 | 7 | import androidx.paging.DataSource; 8 | 9 | import com.teyyihan.gelecekbilimde.Database.ArticleDao; 10 | import com.teyyihan.gelecekbilimde.Database.MyDatabase; 11 | import com.teyyihan.gelecekbilimde.Models.ArticleModel; 12 | import com.teyyihan.gelecekbilimde.Network.ArticleFirebaseAndRetrofit; 13 | 14 | public class ArticleRepository { 15 | 16 | private ArticleDao dao; 17 | 18 | private DataSource.Factory allArticles; 19 | private DataSource.Factory allBookmarkedArticles; 20 | private ArticleFirebaseAndRetrofit articleFirebaseAndRetrofit; 21 | 22 | 23 | public ArticleRepository(Application application) { 24 | MyDatabase database = MyDatabase.getInstance(application); 25 | dao = database.articleDao(); 26 | 27 | 28 | articleFirebaseAndRetrofit = new ArticleFirebaseAndRetrofit(); 29 | allArticles = dao.getAllArticles(); 30 | allBookmarkedArticles = dao.getAllBookmarkedArticles(); 31 | } 32 | 33 | public void insertArticle(ArticleModel article) { 34 | new InsertArticleAsync(dao).execute(article); 35 | } 36 | 37 | public void updateArticle(ArticleModel article) { 38 | new UpdateArticleAsync(dao).execute(article); 39 | } 40 | 41 | public void updateArticleImage(String imageURL,int articleID) { 42 | new UpdateArticleImageAsync(dao).execute(new ArticleWithImage(imageURL,articleID)); 43 | } 44 | 45 | 46 | public void deleteArticle(ArticleModel article) { 47 | new DeleteArticleAsync(dao).execute(article); 48 | } 49 | public void deleteAllArticles() { 50 | new DeleteAllArticlesAsync(dao).execute(); 51 | } 52 | 53 | public DataSource.Factory getAllArticles(){ 54 | return allArticles; 55 | } 56 | 57 | public DataSource.Factory getAllBookmarkedArticles(){ 58 | return allBookmarkedArticles; 59 | } 60 | 61 | public void getTenArticlesfromFirebaseAndRetrofit(int page){ 62 | articleFirebaseAndRetrofit.getTenArticlesfromFirebaseAndRetrofit(this,page); 63 | } 64 | 65 | 66 | 67 | private static class InsertArticleAsync extends AsyncTask{ 68 | private ArticleDao dao; 69 | 70 | public InsertArticleAsync(ArticleDao articleDao){ 71 | this.dao = articleDao; 72 | } 73 | 74 | @Override 75 | protected Void doInBackground(ArticleModel... articleModels) { 76 | dao.insertArticle(articleModels[0]); 77 | return null; 78 | } 79 | } 80 | 81 | private static class UpdateArticleAsync extends AsyncTask{ 82 | private ArticleDao dao; 83 | 84 | public UpdateArticleAsync(ArticleDao articleDao){ 85 | this.dao = articleDao; 86 | } 87 | 88 | @Override 89 | protected Void doInBackground(ArticleModel... articleModels) { 90 | dao.updateArticle(articleModels[0]); 91 | return null; 92 | } 93 | } 94 | 95 | private static class UpdateArticleImageAsync extends AsyncTask{ 96 | private ArticleDao dao; 97 | 98 | public UpdateArticleImageAsync(ArticleDao articleDao){ 99 | this.dao = articleDao; 100 | } 101 | 102 | @Override 103 | protected Void doInBackground(ArticleWithImage... articleModels) { 104 | dao.updateArticleImage(articleModels[0].imageURL,articleModels[0].id); 105 | return null; 106 | } 107 | } 108 | private static class DeleteArticleAsync extends AsyncTask{ 109 | private ArticleDao dao; 110 | 111 | public DeleteArticleAsync(ArticleDao articleDao){ 112 | this.dao = articleDao; 113 | } 114 | 115 | @Override 116 | protected Void doInBackground(ArticleModel... articleModels) { 117 | dao.deleteArticle(articleModels[0]); 118 | return null; 119 | } 120 | } 121 | private static class DeleteAllArticlesAsync extends AsyncTask{ 122 | private ArticleDao dao; 123 | 124 | public DeleteAllArticlesAsync(ArticleDao articleDao){ 125 | this.dao = articleDao; 126 | } 127 | 128 | @Override 129 | protected Void doInBackground(Void... voids) { 130 | dao.deleteAllArticles(); 131 | return null; 132 | } 133 | } 134 | 135 | class ArticleWithImage{ 136 | String imageURL; 137 | int id; 138 | 139 | public ArticleWithImage(String imageURL, int id) { 140 | this.imageURL = imageURL; 141 | this.id = id; 142 | } 143 | 144 | public String getImageURL() { 145 | return imageURL; 146 | } 147 | 148 | public void setImageURL(String imageURL) { 149 | this.imageURL = imageURL; 150 | } 151 | 152 | public int getId() { 153 | return id; 154 | } 155 | 156 | public void setId(int id) { 157 | this.id = id; 158 | } 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /app/src/main/java/com/teyyihan/gelecekbilimde/Repository/VideoRepository.java: -------------------------------------------------------------------------------- 1 | package com.teyyihan.gelecekbilimde.Repository; 2 | 3 | import android.app.Application; 4 | import android.os.AsyncTask; 5 | 6 | import androidx.paging.DataSource; 7 | 8 | import com.teyyihan.gelecekbilimde.Database.MyDatabase; 9 | import com.teyyihan.gelecekbilimde.Database.VideoDao; 10 | import com.teyyihan.gelecekbilimde.Models.VideoModel; 11 | import com.teyyihan.gelecekbilimde.Network.VideoFirebase; 12 | 13 | public class VideoRepository { 14 | private VideoDao dao; 15 | private DataSource.Factory allVideos; 16 | private DataSource.Factory allBookmarkedVideos; 17 | private VideoFirebase videoFirebase; 18 | 19 | public VideoRepository(Application application){ 20 | MyDatabase database = MyDatabase.getInstance(application); 21 | dao = database.videoDao(); 22 | videoFirebase = new VideoFirebase(); 23 | allVideos = dao.getAllVideos(); 24 | allBookmarkedVideos = dao.getAllBookmarkedVideos(); 25 | } 26 | public void insertVideo(VideoModel video) { 27 | new InsertVideoAsync(dao).execute(video); 28 | } 29 | public void updateVideo(VideoModel video) { 30 | new UpdateVideoAsync(dao).execute(video); 31 | } 32 | public void deleteVideo(VideoModel video) { 33 | new DeleteVideoAsync(dao).execute(video); 34 | } 35 | public void deleteAllVideos() { 36 | new DeleteAllVideosAsync(dao).execute(); 37 | } 38 | 39 | public DataSource.Factory getAllVideos(){ 40 | return allVideos; 41 | } 42 | 43 | public DataSource.Factory getAllBookmarkedVideos(){ 44 | return allBookmarkedVideos; 45 | } 46 | 47 | public void getTenVideosFromFirebase() { 48 | videoFirebase.getTenArticlesFromFirebase(this); 49 | } 50 | 51 | 52 | 53 | private static class InsertVideoAsync extends AsyncTask { 54 | private VideoDao dao; 55 | 56 | public InsertVideoAsync(VideoDao videoDao){ 57 | this.dao = videoDao; 58 | } 59 | 60 | @Override 61 | protected Void doInBackground(VideoModel... videoModels) { 62 | dao.insertVideo(videoModels[0]); 63 | return null; 64 | } 65 | } 66 | private static class UpdateVideoAsync extends AsyncTask{ 67 | private VideoDao dao; 68 | 69 | public UpdateVideoAsync(VideoDao videoDao){ 70 | this.dao = videoDao; 71 | } 72 | 73 | @Override 74 | protected Void doInBackground(VideoModel... videoModels) { 75 | dao.updateVideo(videoModels[0]); 76 | return null; 77 | } 78 | } 79 | private static class DeleteVideoAsync extends AsyncTask{ 80 | private VideoDao dao; 81 | 82 | public DeleteVideoAsync(VideoDao videoDao){ 83 | this.dao = videoDao; 84 | } 85 | 86 | @Override 87 | protected Void doInBackground(VideoModel... videoModels) { 88 | dao.deleteVideo(videoModels[0]); 89 | return null; 90 | } 91 | } 92 | private static class DeleteAllVideosAsync extends AsyncTask{ 93 | private VideoDao dao; 94 | 95 | public DeleteAllVideosAsync(VideoDao videoDao){ 96 | this.dao = videoDao; 97 | } 98 | 99 | @Override 100 | protected Void doInBackground(Void... voids) { 101 | dao.deleteAllVideos(); 102 | return null; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/rate_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable-v24/rate_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/white_border_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 11 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/articles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/articles.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bookmark_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/bookmark_checked.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bookmark_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/bookmark_unchecked.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/developer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/developer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/empty_blue.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/gelecekbilimdelogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/gelecekbilimdelogo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gray_border_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 11 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/helpinghand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/helpinghand.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dashboard_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/instagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/instagram.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/logout.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/playbutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/playbutton.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/right_arrow.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_corner_green.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_corners.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_video.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/spotify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/spotify.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/twitch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/twitch.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/twitter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/video.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/video.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/videos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/videos.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/youtube_logo_min.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelecek-bilimde/Android-Application/0851c37455e62005ba4ce030547f4148817b4f03/app/src/main/res/drawable/youtube_logo_min.jpg -------------------------------------------------------------------------------- /app/src/main/res/font/merriweather_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_bold.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_bold_italic.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_condensed_bold.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_light_italic.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/font/rubik.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_article_read.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 25 | 26 | 29 | 30 | 34 | 35 | 36 | 37 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 13 | 14 | 15 | 28 | 29 | 30 | 47 | 48 | 58 | 59 | 70 | 71 | 72 | 73 | 74 | 81 | 82 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 16 | 17 | 26 | 27 | 28 | 32 | 33 | 39 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_youtube_video.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 |