Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
lfuelling committed Sep 25, 2019
1 parent 4f62b6d commit b8cb884
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.

This file was deleted.

40 changes: 28 additions & 12 deletions app/src/main/java/io/lerk/lrkFM/activities/file/FileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
import android.os.Bundle;
import android.os.Environment;
import android.os.StrictMode;

import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.browser.customtabs.CustomTabsIntent;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;

import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;

import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
Expand Down Expand Up @@ -218,6 +222,16 @@ public class FileActivity extends ThemedAppCompatActivity {
*/
private boolean exploringArchive;

/**
* Error text visible when no files are shown.
*/
private View errorText;

/**
* Error text/Hint visible when no files are shown.
*/
private View emptyText;

/**
* Getter for the fileListView.
*
Expand All @@ -229,7 +243,7 @@ public ListView getFileListView() {
}

@Override
protected void onSaveInstanceState(Bundle outState) {
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(STATE_KEY_CURRENT_DIR, currentDirectory);
outState.putString(STATE_KEY_OP_CONTEXT_OP, fileOpContext.getFirst().name());
Expand Down Expand Up @@ -407,7 +421,11 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
loadPath(savedInstanceState.getString(STATE_KEY_CURRENT_DIR));
Operation savedOperation = Operation.valueOf(savedInstanceState.getString(STATE_KEY_OP_CONTEXT_OP));
List<String> savedFilePaths = Arrays.asList(savedInstanceState.getStringArray(STATE_KEY_OP_CONTEXT_FILES));
String[] opContextFiles = savedInstanceState.getStringArray(STATE_KEY_OP_CONTEXT_FILES);
if (opContextFiles == null) {
opContextFiles = new String[]{};
}
List<String> savedFilePaths = Arrays.asList(opContextFiles);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
savedFilePaths.forEach(s -> addFileToOpContext(savedOperation, new FMFile(new File(s))));
} else {
Expand All @@ -430,9 +448,14 @@ public int getColorByAttr(@AttrRes int id) {
*/
private void initUi() {
fileListView = findViewById(R.id.fileView);
registerForContextMenu(fileListView);

errorText = findViewById(R.id.unableToLoadText);
emptyText = findViewById(R.id.emptyDirText);
toolbar = findViewById(R.id.toolbar);
navigationView = findViewById(R.id.nav_view);
headerView = navigationView.inflateHeaderView(R.layout.nav_header_main);
currentDirectoryTextView = headerView.findViewById(R.id.currentDirectoryTextView);

registerForContextMenu(fileListView);

FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener((v) -> {
Expand All @@ -456,7 +479,7 @@ public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
}
});
navigationView = findViewById(R.id.nav_view);

setSupportActionBar(toolbar);
navigationView.setNavigationItemSelectedListener(item -> {
int id = item.getItemId();
Expand Down Expand Up @@ -490,8 +513,6 @@ public void onDrawerStateChanged(int newState) {
drawer.closeDrawer(GravityCompat.START);
return true;
});
headerView = navigationView.inflateHeaderView(R.layout.nav_header_main);
currentDirectoryTextView = headerView.findViewById(R.id.currentDirectoryTextView);
loadUserBookmarks();
setFreeSpaceText();
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
Expand Down Expand Up @@ -686,9 +707,6 @@ public void loadPath(String path) {
private void loadDirectory(String path) {
currentDirectory = path;
new DirectoryLoaderTask(this, path, files -> {
View errorText = findViewById(R.id.unableToLoadText);
View emptyText = findViewById(R.id.emptyDirText);

if (files != null) {
fileListView.setVisibility(VISIBLE);
errorText.setVisibility(GONE);
Expand Down Expand Up @@ -731,8 +749,6 @@ private void loadDirectory(String path) {
private void loadArchive(String path, FMArchive archive) {
ArrayList<FMFile> files;
ArchiveLoader loader = new ArchiveLoader(archive, path);
View errorText = findViewById(R.id.unableToLoadText);
View emptyText = findViewById(R.id.emptyDirText);
exploringArchive = true;

files = loader.loadLocationFiles();
Expand Down

0 comments on commit b8cb884

Please sign in to comment.