-
Notifications
You must be signed in to change notification settings - Fork 982
/
CacheBrowserActivity.java
66 lines (52 loc) · 1.91 KB
/
CacheBrowserActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.osmdroid.debug.browser;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;
import org.osmdroid.MainActivity;
import org.osmdroid.R;
import org.osmdroid.debug.model.SqlTileWriterExt;
import org.osmdroid.debug.util.FileDateUtil;
import org.osmdroid.intro.StorageAdapter;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
/**
* A simple view for browsing the osmdroid tile cache database
* created on 12/20/2016.
*
* @author Alex O'Ree
* @see org.osmdroid.debug.CacheAnalyzerActivity
* @since 5.6.2
*/
public class CacheBrowserActivity extends AppCompatActivity {
SqlTileWriterExt cache = null;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cache_browser);
Toolbar toolbar = findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
public void onResume() {
super.onResume();
cache = new SqlTileWriterExt();
CacheAdapter adapter = new CacheAdapter(this, cache);
ListView lv = findViewById(R.id.cacheListView);
lv.setAdapter(adapter);
((TextView) findViewById(R.id.rows)).setText(cache.getRowCount(null) + "");
((TextView) findViewById(R.id.size)).setText(StorageAdapter.readableFileSize(MainActivity.updateStoragePreferences(this)));
((TextView) findViewById(R.id.date)).setText("Now " + FileDateUtil.getModifiedDate(System.currentTimeMillis()));
}
public void onPause() {
super.onPause();
cache.onDetach();
cache = null;
}
}