Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Working on new features, one by one
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsdayrs committed Jun 12, 2019
1 parent 31a570c commit d56e875
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.github.Doomsdayrs:novelreader-core:v1.0.8'
implementation 'com.github.Doomsdayrs:novelreader-core:v1.1.0'
implementation 'com.github.Doomsdayrs:novelreader-extensions:v1.0.9'
implementation 'com.github.Doomsdayrs:novelreader-services:1.0.7'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'org.jetbrains:annotations:15.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.github.Doomsdayrs.api.novelreader_core.services.core.dep.Formatter;
import com.github.Doomsdayrs.api.novelreader_core.services.core.objects.NovelChapter;
Expand All @@ -23,6 +24,7 @@
import com.github.Doomsdayrs.apps.shosetsu.adapters.novel.NovelChaptersAdapter;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
Expand All @@ -47,6 +49,8 @@
*/
public class NovelFragmentChapters extends Fragment {


public boolean reversed;
public List<NovelChapter> novelChapters;
private Formatter formatter;
private String novelURL;
Expand Down Expand Up @@ -80,6 +84,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
Log.d("OnCreate", "NovelFragmentChapters");
View view = inflater.inflate(R.layout.fragment_novel_chapters, container, false);
recyclerView = view.findViewById(R.id.fragment_novel_chapters_recycler);

setNovels(novelChapters);
this.context = Objects.requireNonNull(container).getContext();
Log.d("OnCreate", "Complete");
Expand All @@ -96,10 +101,29 @@ public void setNovels(List<NovelChapter> novels) {
recyclerView.setAdapter(adapter);
}

Button button;

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.toolbar_chapters, menu);
button = (Button) menu.findItem(R.id.chapter_filter).getActionView();
button.setOnClickListener(new onFilter(this));
}


static class onFilter implements View.OnClickListener {
NovelFragmentChapters novelFragmentChapters;

public onFilter(NovelFragmentChapters novelFragmentChapters) {
this.novelFragmentChapters = novelFragmentChapters;
}

@Override
public void onClick(View v) {
Collections.reverse(novelFragmentChapters.novelChapters);
novelFragmentChapters.reversed = true;
novelFragmentChapters.recyclerView.post(() -> novelFragmentChapters.adapter.notifyDataSetChanged());
}
}


Expand All @@ -114,7 +138,6 @@ static class addMore extends AsyncTask<Integer, Void, Boolean> {
protected Boolean doInBackground(Integer... integers) {
if (novelFragmentChapters.formatter.isIncrementingChapterList())
try {

NovelPage novelPage;
if (integers.length == 0)
novelPage = novelFragmentChapters.formatter.parseNovel("http://novelfull.com/" + novelFragmentChapters.novelURL);
Expand All @@ -125,7 +148,6 @@ protected Boolean doInBackground(Integer... integers) {
if (!novelPage.novelChapters.get(novelPage.novelChapters.size() - 1).link
.equals(novelFragmentChapters.novelChapters.get(novelFragmentChapters.novelChapters.size() - 1).link))
novelFragmentChapters.novelChapters.addAll(novelPage.novelChapters);

return true;
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -148,6 +170,8 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (!running)
if (!novelFragmentChapters.recyclerView.canScrollVertically(1)) {
Log.d("NovelFragmentsScrollLoad", "Loading...");
if (novelFragmentChapters.reversed)
Collections.reverse(novelFragmentChapters.novelChapters);
running = true;
novelFragmentChapters.currentMaxPage++;
try {
Expand All @@ -160,6 +184,8 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
}
Log.d("NovelFragmentsScrollLoad", "Completed.");
running = false;
if (novelFragmentChapters.reversed)
Collections.reverse(novelFragmentChapters.novelChapters);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.Doomsdayrs.api.novelreader_core.services.core.dep.Formatter;
import com.github.Doomsdayrs.api.novelreader_core.services.core.objects.NovelPage;
import com.github.Doomsdayrs.apps.shosetsu.R;
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_filter_list_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
</vector>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/include_progress_overlay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progressBarHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:animateLayoutChanges="true"
android:background="#000000"
android:visibility="gone"
android:touchscreenBlocksFocus="true"
android:clickable="true">

<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />
</FrameLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/menu/toolbar_chapters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/chapter_filter"
android:icon="@drawable/ic_filter_list_black_24dp"
android:title="@string/filter"
app:actionViewClass="android.widget.Button"
app:showAsAction="always" />
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="search">Search</string>
<string name="configure_parsers">configure_parsers</string>
<string name="filter">filter</string>
</resources>

0 comments on commit d56e875

Please sign in to comment.