Closed kishandonga closed 4 years ago
When you initialize PickiT
you pass it a context:
pickiT = new PickiT(this, this, this);
PickiT
then has the context, why would you want to pass it a new context?
You can just call pickiT.deleteTemporaryFile();
because it already has context.
Could you read what I mention on the comment's it is helping when you used fragments okay! no worry I'm pasting here.
onBackPressed() && isChangingConfigurations() not available on the fragment easily, so remove temp file facility given to the user-friendly way, so the user can remove temp file from anywhere when needed like splash screen called or detached fragments.
I did read it and I understand what you are saying. No need for exclamation marks.
Let me explain the point I'm trying to make.
You are probably inflating a Fragment
to display the file that was selected using PickiT
and you want to delete the file after the user has viewed it (or something similar), am I right?
What I'm saying is that your Activity
has the reference to PickiT
, your Activity
is also inflating your Fragment
. So you can delete the file when you leave your Activity
- onBackPressed()
. Why would you want to delete the file from your Fragment
when you can delete it from your Activity
?
Yes, Activity inflates Fragment but Fragment has its own lifecycle.
Even Glide give this type of functionality
For example:
Glide.get(getContext()).clearDiskCache();
Few cases:
1) when user kill app onDestory()
not called so I want to clear my cache every time when an open application then How Can I do?
2) Forex, I make-instance of PickiT on my fragment so you said to make this instance static and access on an activity like you suggested but if you using ViewPager then?
3) ViewPager with 3 Fragments and 1 and 3 fragment has PickiT instance so as per your understanding How can I delete my temporary files
Implemented and is now available in 0.1.14
.
okay not an issue but still few things missing
pickiT = new PickiT(this, this, this);
for simply clearing temporary files
pickiT.deleteTemporyFile(context)
if this method is not static then I have already instance why need to pass while already passed on the constructor ...
ok great ...