Skip to content

Commit

Permalink
NClientV2 2.7.9
Browse files Browse the repository at this point in the history
* Refactoring
  • Loading branch information
Dar9586 committed Mar 20, 2021
1 parent 33e895e commit 43143d7
Show file tree
Hide file tree
Showing 33 changed files with 91 additions and 89 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/com/dar/nclientv2/BookmarkActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.dar.nclientv2.adapters.BookmarkAdapter;
import com.dar.nclientv2.components.activities.GeneralActivity;
import com.dar.nclientv2.components.widgets.CustomLinearLayoutManager;
import com.dar.nclientv2.settings.Global;

public class BookmarkActivity extends GeneralActivity {
BookmarkAdapter adapter;
Expand All @@ -18,7 +17,7 @@ public class BookmarkActivity extends GeneralActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_bookmark);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/dar/nclientv2/CommentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.dar.nclientv2.api.comments.CommentsFetcher;
import com.dar.nclientv2.components.activities.BaseActivity;
import com.dar.nclientv2.settings.AuthRequest;
import com.dar.nclientv2.settings.Global;
import com.dar.nclientv2.settings.Login;
import com.dar.nclientv2.utility.Utility;

Expand All @@ -41,7 +40,7 @@ public class CommentActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_comment);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/FavoriteActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static int getEntryPerPage() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);

setContentView(R.layout.app_bar_main);
Toolbar toolbar = findViewById(R.id.toolbar);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class GalleryActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_gallery);
if (Global.isLockScreen())
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/HistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class HistoryActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_bookmark);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/dar/nclientv2/LocalActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

public class LocalActivity extends BaseActivity {
private Menu optionMenu;
private LocalAdapter adapter;
private final MultichoiceAdapter.MultichoiceListener listener = new MultichoiceAdapter.DefaultMultichoiceListener() {

@Override
public void choiceChanged() {
setMenuVisibility(optionMenu);
}
};
private LocalAdapter adapter;
private Toolbar toolbar;
private int colCount;
private int idGalleryPosition = -1;
Expand All @@ -47,7 +47,7 @@ public void choiceChanged() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.app_bar_main);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class LoginActivity extends GeneralActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_login);
final Toolbar toolbar = findViewById(R.id.toolbar);
webView = findViewById(R.id.webView);
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/dar/nclientv2/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.dar.nclientv2.async.downloader.DownloadGalleryV2;
import com.dar.nclientv2.components.GlideX;
import com.dar.nclientv2.components.activities.BaseActivity;
import com.dar.nclientv2.components.views.CustomWebView;
import com.dar.nclientv2.components.views.PageSwitcher;
import com.dar.nclientv2.components.widgets.CustomGridLayoutManager;
import com.dar.nclientv2.settings.Global;
Expand Down Expand Up @@ -116,13 +115,11 @@ public void onSuccess(List<GenericGallery> galleries) {
};
private DrawerLayout drawerLayout;
private Toolbar toolbar;
private CustomWebView webView = null;
private Setting setting = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
setContentView(R.layout.activity_main);
//load inspector
selectStartMode(getIntent(), getPackageName());
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/PINActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PINActivity extends GeneralActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_pin);
preferences = getSharedPreferences("Settings", 0);
setMode = getIntent().getBooleanExtra(getPackageName() + ".SET", false);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/RandomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RandomActivity extends GeneralActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_random);
loader = new RandomLoader(this);

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/SearchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void setQuery(String str, boolean submit) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_search);
//init toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/dar/nclientv2/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
import java.io.IOException;

public class SettingsActivity extends AppCompatActivity {
GeneralPreferenceFragment fragment;
private static final int STORAGE_MANAGER_REQUEST = 987;
GeneralPreferenceFragment fragment;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_settings);

Toolbar toolbar = findViewById(R.id.toolbar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.dar.nclientv2.adapters.StatusManagerAdapter;
import com.dar.nclientv2.components.activities.GeneralActivity;
import com.dar.nclientv2.components.widgets.CustomLinearLayoutManager;
import com.dar.nclientv2.settings.Global;

public class StatusManagerActivity extends GeneralActivity {

Expand All @@ -19,7 +18,7 @@ public class StatusManagerActivity extends GeneralActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_bookmark);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dar/nclientv2/TagFilterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ViewPager getViewPager() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
setContentView(R.layout.activity_tag_filter);

//init toolbar
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/dar/nclientv2/ZoomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ZoomActivity extends GeneralActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Global.initActivity(this);
//Global.initActivity(this);
SharedPreferences preferences = getSharedPreferences("Settings", 0);
side = preferences.getBoolean(VOLUME_SIDE_KEY, true);
scrollType = ScrollType.values()[preferences.getInt(SCROLL_TYPE_KEY, ScrollType.HORIZONTAL.ordinal())];
Expand Down Expand Up @@ -124,7 +124,7 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
public void onPageSelected(int newPage) {
int oldPage = actualPage;
actualPage = newPage;
setPageText(offsetPage(newPage)+1);
setPageText(offsetPage(newPage) + 1);
seekBar.setProgress(offsetPage(newPage));
clearFarRequests(oldPage, newPage);
}
Expand Down Expand Up @@ -180,8 +180,8 @@ int offsetPage(int page) {
return invertDirection() ? gallery.getPageCount() - 1 - page : page;
}

private boolean invertDirection(){
return Global.useRtl()&&scrollType==ScrollType.HORIZONTAL;
private boolean invertDirection() {
return Global.useRtl() && scrollType == ScrollType.HORIZONTAL;
}

@Override
Expand Down Expand Up @@ -224,7 +224,7 @@ private void changeSide() {
}

private void changeClosePage(boolean next) {
if(scrollType==ScrollType.VERTICAL)next=!next;
if (scrollType == ScrollType.VERTICAL) next = !next;
if (next && mViewPager.getCurrentItem() < (mViewPager.getAdapter().getCount() - 1))
changePage(mViewPager.getCurrentItem() + 1);
if (!next && mViewPager.getCurrentItem() > 0) changePage(mViewPager.getCurrentItem() - 1);
Expand All @@ -233,7 +233,7 @@ private void changeClosePage(boolean next) {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
changeLayout(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE);
changeLayout(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);
}

private boolean hardwareKeys() {
Expand Down Expand Up @@ -267,7 +267,7 @@ private void changeScrollTypeDialog() {
scrollType = tmpScrollType;
mViewPager.setVerticalMode(scrollType == ScrollType.VERTICAL);
getSharedPreferences("Settings", 0).edit().putInt(SCROLL_TYPE_KEY, scrollType.ordinal()).apply();
changePage(gallery.getPageCount()-1-mViewPager.getCurrentItem());
changePage(gallery.getPageCount() - 1 - mViewPager.getCurrentItem());
}
}).setNegativeButton(R.string.cancel, null);
builder.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
public class FavoriteAdapter extends RecyclerView.Adapter<GenericAdapter.ViewHolder> implements Filterable {
private final int perPage = FavoriteActivity.getEntryPerPage();
private final SparseIntArray statuses = new SparseIntArray();
private Gallery[] galleries;
private final FavoriteActivity activity;
private Gallery[] galleries;
private CharSequence lastQuery;
private Cursor cursor;
private boolean force = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHold
private final SparseIntArray angles = new SparseIntArray();
private final GalleryActivity context;
private final GenericGallery gallery;
private GalleryFolder directory=null;
private GalleryFolder directory = null;
private Size maxImageSize = null;
private Policy policy;
private int colCount;
Expand All @@ -72,9 +72,9 @@ public GalleryAdapter(GalleryActivity cont, GenericGallery gallery, int colCount
minSize = gallery.getMinSize();
setColCount(colCount);
try {
if(gallery instanceof LocalGallery){
directory=gallery.getGalleryFolder();
}else if (Global.hasStoragePermission(cont)) {
if (gallery instanceof LocalGallery) {
directory = gallery.getGalleryFolder();
} else if (Global.hasStoragePermission(cont)) {
if (gallery.getId() != -1) {
File f = Global.findGalleryFolder(context, gallery.getId());
if (f != null) directory = new GalleryFolder(f);
Expand Down Expand Up @@ -388,7 +388,6 @@ else if (!gallery.isLocal()) {
}



private boolean hasTags() {
return gallery.hasGalleryData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void onFailure(Exception e) {

@Override
public void onSuccess(List<GenericGallery> galleries) {
if(galleries.size() != 1){
if (galleries.size() != 1) {
if (context.getMasterLayout() != null) {
context.runOnUiThread(() ->
Snackbar.make(context.getMasterLayout(), R.string.no_entry_found, Snackbar.LENGTH_SHORT).show()
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/dar/nclientv2/api/InspectorV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.dar.nclientv2.api.local.LocalGallery;
import com.dar.nclientv2.async.database.Queries;
import com.dar.nclientv2.settings.Global;
import com.dar.nclientv2.settings.Login;
import com.dar.nclientv2.utility.LogUtility;
import com.dar.nclientv2.utility.Utility;

Expand Down Expand Up @@ -179,7 +178,7 @@ private static HashSet<Tag> getDefaultTags() {
tags.addAll(getLanguageTags(Global.getOnlyLanguage()));
if (Global.removeAvoidedGalleries())
tags.addAll(Queries.TagTable.getAllStatus(TagStatus.AVOIDED));
if (Login.isLogged()) tags.addAll(Queries.TagTable.getAllOnlineBlacklisted());
tags.addAll(Queries.TagTable.getAllOnlineBlacklisted());
return tags;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public Gallery[] newArray(int size) {
private final GalleryData galleryData;
@Nullable
private final GalleryFolder folder;
private final boolean onlineFavorite;
private List<SimpleGallery> related = new ArrayList<>();
private Language language = Language.UNKNOWN;
private Size maxSize = new Size(0, 0), minSize = new Size(Integer.MAX_VALUE, Integer.MAX_VALUE);
private final boolean onlineFavorite;

public Gallery(Context context, String json, Elements related, boolean isFavorite) throws IOException {
LogUtility.d("Found JSON: " + json);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/dar/nclientv2/api/enums/TagType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public TagType[] newArray(int size) {
};
private final byte id;
private final String single, plural;

private TagType(int id, String single, String plural) {
this.id = (byte) id;
this.single = single;
this.plural = plural;
}

protected TagType(Parcel in) {
id = in.readByte();
single = in.readString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class LocalSortType {
@NonNull
public final Type type;
public final boolean descending;

public LocalSortType(@NonNull Type type, boolean ascending) {
this.type = type;
this.descending = ascending;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/dar/nclientv2/async/VersionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public void onResponse(@NonNull Call call, @NonNull Response response) throws IO
}

private static int extractVersion(String version) {
int index=version.indexOf('-');
if(index>=0)version=version.substring(0,index);
int index = version.indexOf('-');
if (index >= 0) version = version.substring(0, index);
return Integer.parseInt(version.replace(".", ""));
}

Expand Down
Loading

0 comments on commit 43143d7

Please sign in to comment.