From 79726b9a08d8b55f6965e2336857e1587bf1795c Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 3 Sep 2019 14:37:20 +0800 Subject: Display a splash screen when the app starts. --- app/src/main/AndroidManifest.xml | 2 +- .../infinityforreddit/MainActivity.java | 2 ++ .../infinityforreddit/PostDataSourceFactory.java | 2 +- .../infinityforreddit/PostFragment.java | 2 +- .../infinityforreddit/PostViewModel.java | 18 +++++++++--------- app/src/main/res/drawable-hdpi/splash_icon.png | Bin 0 -> 10148 bytes app/src/main/res/drawable-mdpi/splash_icon.png | Bin 0 -> 6472 bytes app/src/main/res/drawable-xhdpi/splash_icon.png | Bin 0 -> 14868 bytes app/src/main/res/drawable-xxhdpi/splash_icon.png | Bin 0 -> 23498 bytes app/src/main/res/drawable-xxxhdpi/splash_icon.png | Bin 0 -> 32987 bytes app/src/main/res/drawable/splash_icon.png | Bin 0 -> 6472 bytes app/src/main/res/drawable/splash_screen.xml | 12 ++++++++++++ app/src/main/res/values-night-v27/styles.xml | 8 ++++++++ app/src/main/res/values-v27/styles.xml | 10 ++++++++++ app/src/main/res/values/styles.xml | 4 ++++ 15 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/splash_icon.png create mode 100644 app/src/main/res/drawable-mdpi/splash_icon.png create mode 100644 app/src/main/res/drawable-xhdpi/splash_icon.png create mode 100644 app/src/main/res/drawable-xxhdpi/splash_icon.png create mode 100644 app/src/main/res/drawable-xxxhdpi/splash_icon.png create mode 100644 app/src/main/res/drawable/splash_icon.png create mode 100644 app/src/main/res/drawable/splash_screen.xml create mode 100644 app/src/main/res/values-night-v27/styles.xml create mode 100644 app/src/main/res/values-v27/styles.xml (limited to 'app') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3de6dc2..ef9a7dc8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -144,7 +144,7 @@ + android:theme="@style/AppTheme.Launcher"> diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index abe26221..dc1bbb99 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -157,6 +157,8 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java index cd3ae2d3..3942bec3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java @@ -78,7 +78,7 @@ class PostDataSourceFactory extends DataSource.Factory { @NonNull @Override - public DataSource create() { + public DataSource create() { if(postType == PostDataSource.TYPE_FRONT_PAGE) { postDataSource = new PostDataSource(retrofit, accessToken, locale, postType, sortType, filter, nsfw); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index 2aa27594..e6e6fb12 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -450,10 +450,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator { stopLazyMode(); } + mAdapter.setNetworkState(null); mFetchPostInfoLinearLayout.setVisibility(View.GONE); hasPost = false; mPostViewModel.refresh(); - mAdapter.setNetworkState(null); } private void showErrorView(int stringResId) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java index 62e58547..412a0d0e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java @@ -23,7 +23,7 @@ public class PostViewModel extends ViewModel { private LiveData> posts; private MutableLiveData nsfwLiveData; private MutableLiveData sortTypeLiveData; - private PostViewModel.NSFWAndSortTypeLiveData NSFWAndSortTypeLiveData; + private NSFWAndSortTypeLiveData nsfwAndSortTypeLiveData; public PostViewModel(Retrofit retrofit, String accessToken, Locale locale, int postType, String sortType, int filter, boolean nsfw) { @@ -42,7 +42,7 @@ public class PostViewModel extends ViewModel { sortTypeLiveData = new MutableLiveData<>(); sortTypeLiveData.postValue(sortType); - NSFWAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); + nsfwAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) @@ -50,7 +50,7 @@ public class PostViewModel extends ViewModel { .setPageSize(25) .build(); - posts = Transformations.switchMap(NSFWAndSortTypeLiveData, nsfwAndSort -> { + posts = Transformations.switchMap(nsfwAndSortTypeLiveData, nsfwAndSort -> { postDataSourceFactory.changeNSFWAndSortType(nsfwLiveData.getValue(), sortTypeLiveData.getValue()); return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build(); }); @@ -73,7 +73,7 @@ public class PostViewModel extends ViewModel { sortTypeLiveData = new MutableLiveData<>(); sortTypeLiveData.postValue(sortType); - NSFWAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); + nsfwAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) @@ -81,7 +81,7 @@ public class PostViewModel extends ViewModel { .setPageSize(25) .build(); - posts = Transformations.switchMap(NSFWAndSortTypeLiveData, nsfwAndSort -> { + posts = Transformations.switchMap(nsfwAndSortTypeLiveData, nsfwAndSort -> { postDataSourceFactory.changeNSFWAndSortType(nsfwLiveData.getValue(), sortTypeLiveData.getValue()); return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build(); }); @@ -104,7 +104,7 @@ public class PostViewModel extends ViewModel { sortTypeLiveData = new MutableLiveData<>(); sortTypeLiveData.postValue(sortType); - NSFWAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); + nsfwAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) @@ -112,7 +112,7 @@ public class PostViewModel extends ViewModel { .setPageSize(25) .build(); - posts = Transformations.switchMap(NSFWAndSortTypeLiveData, nsfwAndSort -> { + posts = Transformations.switchMap(nsfwAndSortTypeLiveData, nsfwAndSort -> { postDataSourceFactory.changeNSFWAndSortType(nsfwLiveData.getValue(), sortTypeLiveData.getValue()); return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build(); }); @@ -135,7 +135,7 @@ public class PostViewModel extends ViewModel { sortTypeLiveData = new MutableLiveData<>(); sortTypeLiveData.postValue(sortType); - NSFWAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); + nsfwAndSortTypeLiveData = new NSFWAndSortTypeLiveData(nsfwLiveData, sortTypeLiveData); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) @@ -143,7 +143,7 @@ public class PostViewModel extends ViewModel { .setPageSize(25) .build(); - posts = Transformations.switchMap(NSFWAndSortTypeLiveData, nsfwAndSort -> { + posts = Transformations.switchMap(nsfwAndSortTypeLiveData, nsfwAndSort -> { postDataSourceFactory.changeNSFWAndSortType(nsfwLiveData.getValue(), sortTypeLiveData.getValue()); return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build(); }); diff --git a/app/src/main/res/drawable-hdpi/splash_icon.png b/app/src/main/res/drawable-hdpi/splash_icon.png new file mode 100644 index 00000000..1cb4280e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/splash_icon.png differ diff --git a/app/src/main/res/drawable-mdpi/splash_icon.png b/app/src/main/res/drawable-mdpi/splash_icon.png new file mode 100644 index 00000000..637d7c35 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/splash_icon.png differ diff --git a/app/src/main/res/drawable-xhdpi/splash_icon.png b/app/src/main/res/drawable-xhdpi/splash_icon.png new file mode 100644 index 00000000..3d41cc71 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/splash_icon.png differ diff --git a/app/src/main/res/drawable-xxhdpi/splash_icon.png b/app/src/main/res/drawable-xxhdpi/splash_icon.png new file mode 100644 index 00000000..643d5f55 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/splash_icon.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/splash_icon.png b/app/src/main/res/drawable-xxxhdpi/splash_icon.png new file mode 100644 index 00000000..14da901c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/splash_icon.png differ diff --git a/app/src/main/res/drawable/splash_icon.png b/app/src/main/res/drawable/splash_icon.png new file mode 100644 index 00000000..637d7c35 Binary files /dev/null and b/app/src/main/res/drawable/splash_icon.png differ diff --git a/app/src/main/res/drawable/splash_screen.xml b/app/src/main/res/drawable/splash_screen.xml new file mode 100644 index 00000000..c3ccc627 --- /dev/null +++ b/app/src/main/res/drawable/splash_screen.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night-v27/styles.xml b/app/src/main/res/values-night-v27/styles.xml new file mode 100644 index 00000000..275f4057 --- /dev/null +++ b/app/src/main/res/values-night-v27/styles.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml new file mode 100644 index 00000000..c354ca2c --- /dev/null +++ b/app/src/main/res/values-v27/styles.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 03c4361a..e4119c67 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -10,6 +10,10 @@ @android:color/white + +