move cache location
This commit is contained in:
parent
6c83a96491
commit
ce28a53de7
5 changed files with 48 additions and 7 deletions
|
@ -11,10 +11,16 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider;
|
||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import asgardius.page.s3manager.databinding.ActivitySettingsBinding;
|
||||
|
||||
public class Settings extends AppCompatActivity {
|
||||
|
@ -24,13 +30,13 @@ public class Settings extends AppCompatActivity {
|
|||
SQLiteDatabase db;
|
||||
String videocache, videotime, buffersize, playlisttime;
|
||||
EditText vcachepick, vtimepick, bsizepick, ptimepick;
|
||||
Button saveprefs, about;
|
||||
Button saveprefs, about, clearcache;
|
||||
SwitchMaterial isplaylist;
|
||||
StandaloneDatabaseProvider standaloneDatabaseProvider;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
vcachepick = (EditText)findViewById(R.id.videocache);
|
||||
|
@ -73,6 +79,7 @@ public class Settings extends AppCompatActivity {
|
|||
playlisttime = (cursor.getString(0));
|
||||
}
|
||||
db.close();
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
@ -100,6 +107,25 @@ public class Settings extends AppCompatActivity {
|
|||
});
|
||||
getprefs.start();
|
||||
|
||||
clearcache = (Button)findViewById(R.id.clearcache);
|
||||
clearcache.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//buttonaction
|
||||
try {
|
||||
standaloneDatabaseProvider = new StandaloneDatabaseProvider(getApplicationContext());
|
||||
SimpleCache.delete(new File(getApplicationContext().getFilesDir(), "media"), standaloneDatabaseProvider);
|
||||
standaloneDatabaseProvider.close();
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.clearcache_ok), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
//This launch account add screen
|
||||
//addaccount(false);
|
||||
}
|
||||
});
|
||||
|
||||
//This is to add new user account
|
||||
saveprefs = (Button)findViewById(R.id.saveprefs);
|
||||
saveprefs.setOnClickListener(new View.OnClickListener(){
|
||||
|
@ -153,6 +179,12 @@ public class Settings extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void aboutPage () {
|
||||
|
||||
Intent intent = new Intent(this, WebBrowser.class);
|
||||
|
@ -163,7 +195,6 @@ public class Settings extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void mainmenu() {
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra("EXIT", true);
|
||||
|
|
|
@ -127,7 +127,7 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
mediaSession.setActive(true);
|
||||
evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
|
||||
simpleCache = new SimpleCache(
|
||||
new File(this.getCacheDir(), "media"),
|
||||
new File(this.getFilesDir(), "media"),
|
||||
evictor,
|
||||
standaloneDatabaseProvider);
|
||||
playerView.setPlayer(player);
|
||||
|
@ -338,7 +338,7 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
//System.out.println("WakeLock acquired");
|
||||
}
|
||||
mediaSessionConnector.setPlayer(null);
|
||||
deleteCache(this, standaloneDatabaseProvider);
|
||||
//deleteCache(this, standaloneDatabaseProvider);
|
||||
mediaSession.setActive(false);
|
||||
playerNotificationManager.setPlayer(null);
|
||||
player.release();
|
||||
|
@ -429,9 +429,9 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
super.onStop();
|
||||
}
|
||||
|
||||
static void deleteCache(Context context, StandaloneDatabaseProvider database) {
|
||||
/*static void deleteCache(Context context, StandaloneDatabaseProvider database) {
|
||||
SimpleCache.delete(new File(context.getCacheDir(), "media"), database);
|
||||
}
|
||||
}*/
|
||||
|
||||
public void onBackPressed() {
|
||||
try {
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
android:inputType="number"
|
||||
android:textColorHint="?attr/colorOnSecondary"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/clearcache"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:text="@string/clearcache" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -125,4 +125,6 @@
|
|||
<string name="set_private">Establecer como privado</string>
|
||||
<string name="parent_policy">Política establecida por carpeta padre</string>
|
||||
<string name="expiration_not_required">Fecha de expiración no requerida</string>
|
||||
<string name="clearcache">Limpiar Cache de Video</string>
|
||||
<string name="clearcache_ok">Cache limpiada exitosamente</string>
|
||||
</resources>
|
|
@ -129,4 +129,6 @@
|
|||
<string name="set_private">Set as private</string>
|
||||
<string name="parent_policy">Policy set by parent folder</string>
|
||||
<string name="expiration_not_required">Expiration date not required</string>
|
||||
<string name="clearcache">Clear Video Cache</string>
|
||||
<string name="clearcache_ok">Cache clean successfully</string>
|
||||
</resources>
|
Loading…
Reference in a new issue