Clear cache, configure cache size #482

Merged
mmarif merged 9 commits from app-cache into master 2020-05-09 14:51:23 +00:00
Owner

Closes #347 and closes #349

To do:

  • make picasso use the cache setter
Closes #347 and closes #349 To do: - [x] make picasso use the cache setter
mmarif added this to the 3.0.0 milestone 2020-05-03 17:12:37 +00:00
mmarif added the
Feature
WIP
labels 2020-05-03 17:12:37 +00:00
mmarif self-assigned this 2020-05-03 17:12:37 +00:00
opyale reviewed 2020-05-05 00:00:59 +00:00
Dismissed
@ -636,3 +646,3 @@
<string name="appreanceHintText">Themes, fonts, badges, code block theme</string>
<string name="fileViewerHintText">PDF mode, source code theme</string>
<string name="securityHintText">SSL certificates</string>
<string name="securityHintText">SSL certificates, cache</string>

Would use an uppercase 'c' instead.

Would use an uppercase 'c' instead.
Author
Owner

I have used lower for all subsequent text following Android settings screen.

I have used lower for all subsequent text following Android settings screen.

Then its ok. :)

Then its ok. :)
opyale marked this conversation as resolved
opyale reviewed 2020-05-05 00:05:20 +00:00
Dismissed
@ -32,2 +34,3 @@
TinyDB tinyDb = new TinyDB(ctx);
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
int cacheSize = 50 * 1024 * 1024; // 50MB
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024; // 50MB

Please remove // 50MB.

Please remove ``// 50MB``.
opyale reviewed 2020-05-05 00:06:54 +00:00
Dismissed
@ -43,0 +98,4 @@
try {
FileUtils.deleteDirectory(cacheDir);
FileUtils.mkdir(String.valueOf(cacheDir));

Would'nt cacheDir.getAbsolutePath() be better?

Would'nt ``cacheDir.getAbsolutePath()`` be better?

Or just use cacheDir.mkdirs()

Or just use ``cacheDir.mkdirs()``
Author
Owner

getCacheDir() also return absolute path.

getCacheDir() also return absolute path.

But it returns a file. cacheDir.getAbsolutePath() returns a string and that is what you would need.

But it returns a file. ``cacheDir.getAbsolutePath()`` returns a string and that is what you would need.
Author
Owner

I thought you meant the path. Yes, I will use that. :)

I thought you meant the path. Yes, I will use that. :)
opyale reviewed 2020-05-05 00:18:03 +00:00
Dismissed
@ -0,0 +17,4 @@
String sizeInNumber = "";
if(fileSize.contains("MB")) {
sizeInNumber = fileSize.replace(" MB", "");

My suggestion would be to just use:

return Integer.parseInt(fileSize.substring(0, fileSize.indexOf(" ")));
My suggestion would be to just use: ``` return Integer.parseInt(fileSize.substring(0, fileSize.indexOf(" "))); ```
Author
Owner

One liner. Nice.

One liner. Nice.
mmarif marked this conversation as resolved
Member
@mmarif For picasso cache: https://gitea.com/gitnex/GitNex/src/branch/master/app/src/main/java/org/mian/gitnex/helpers/PicassoCache.java#L29
Author
Owner

@opyale I just checked the picasso cache and the maxSize does take any arguments. Need to pass context to TinyDb. Another way I am thinking of is to pass context to the constructor and set the CACHE_SIZE there.

@opyale I just checked the picasso cache and the maxSize does take any arguments. Need to pass context to TinyDb. Another way I am thinking of is to pass context to the constructor and set the CACHE_SIZE there.
mmarif added
LGTM-need
and removed
WIP
labels 2020-05-05 19:12:23 +00:00
Author
Owner

Ok, this PR is ready for a ride.

Ok, this PR is ready for a ride.
opyale requested changes 2020-05-06 12:18:26 +00:00
Dismissed
@ -117,2 +120,3 @@
return CACHE_SIZE;
TinyDB tinyDb = new TinyDB(ctx);
return FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeImagesStr")) * 1024 * 1024;

maxSize() gets called over and over again. Every time something gets cached.

I dont think this is very good for overall performance.

I would just initialize the variable CACHE_SIZE with the current chache size from TinyDB.

``maxSize()`` gets called over and over again. Every time something gets cached. I dont think this is very good for overall performance. I would just initialize the variable ``CACHE_SIZE`` with the current chache size from TinyDB.
Author
Owner

This will fix the init, 4b4e31c230

This will fix the init, https://gitea.com/gitnex/GitNex/commit/4b4e31c23050ba0bc563c6de69d0eda811dafef9

Great.

Great.
opyale approved these changes 2020-05-09 13:49:56 +00:00
Dismissed
opyale left a comment
Member

Works. 👍

The only thing I noticed was that my profile picture wont load anymore (in the navigation drawer) once I cleared the cache, but this may possibly not be related to these changes.

Works. :+1: The only thing I noticed was that my profile picture wont load anymore (in the navigation drawer) once I cleared the cache, but this may possibly not be related to these changes.
opyale added
LGTM-done
and removed
LGTM-need
labels 2020-05-09 13:50:59 +00:00
Author
Owner

The only thing I noticed was that my profile picture wont load anymore (in the navigation drawer) once I cleared the cache, but this may possibly not be related to these changes.

Just noticed this, but yeah it's not related to these changes.

> The only thing I noticed was that my profile picture wont load anymore (in the navigation drawer) once I cleared the cache, but this may possibly not be related to these changes. Just noticed this, but yeah it's not related to these changes.
mmarif merged commit ab8a5ed505 into master 2020-05-09 14:51:06 +00:00
mmarif deleted branch app-cache 2020-05-09 14:52:04 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitnex/GitNex#482
No description provided.