Java language level + javadoc + xml

replace with <>
String builder

BUILD SUCCESSFUL in 4s
39 actionable tasks: 4 executed, 35 up-to-date
This commit is contained in:
BO41 2018-08-28 20:14:26 +02:00
parent 802b26e870
commit af280a7343
30 changed files with 141 additions and 379 deletions

View file

@ -179,12 +179,16 @@ public class RouterActivity extends AppCompatActivity {
if (selectedChoiceKey.equals(alwaysAskKey)) {
final List<AdapterChoiceItem> choices = getChoicesForService(currentService, currentLinkType);
if (choices.size() == 1) {
handleChoice(choices.get(0).key);
} else if (choices.size() == 0) {
handleChoice(showInfoKey);
} else {
showDialog(choices);
switch (choices.size()) {
case 1:
handleChoice(choices.get(0).key);
break;
case 0:
handleChoice(showInfoKey);
break;
default:
showDialog(choices);
break;
}
} else if (selectedChoiceKey.equals(showInfoKey)) {
handleChoice(showInfoKey);

View file

@ -77,18 +77,18 @@ public class LicenseFragmentHelper extends AsyncTask<Object, Void, Integer> {
throw new NullPointerException("license is null");
}
String licenseContent = "";
StringBuilder licenseContent = new StringBuilder();
String webViewData;
try {
BufferedReader in = new BufferedReader(new InputStreamReader(context.getAssets().open(license.getFilename()), "UTF-8"));
String str;
while ((str = in.readLine()) != null) {
licenseContent += str;
licenseContent.append(str);
}
in.close();
// split the HTML file and insert the stylesheet into the HEAD of the file
String[] insert = licenseContent.split("</head>");
String[] insert = licenseContent.toString().split("</head>");
webViewData = insert[0] + "<style type=\"text/css\">"
+ getLicenseStylesheet(context) + "</style></head>"
+ insert[1];

View file

@ -144,12 +144,16 @@ public class SubscriptionsImportService extends BaseImportExportService {
showToast(R.string.import_ongoing);
Flowable<List<SubscriptionItem>> flowable = null;
if (currentMode == CHANNEL_URL_MODE) {
flowable = importFromChannelUrl();
} else if (currentMode == INPUT_STREAM_MODE) {
flowable = importFromInputStream();
} else if (currentMode == PREVIOUS_EXPORT_MODE) {
flowable = importFromPreviousExport();
switch (currentMode) {
case CHANNEL_URL_MODE:
flowable = importFromChannelUrl();
break;
case INPUT_STREAM_MODE:
flowable = importFromInputStream();
break;
case PREVIOUS_EXPORT_MODE:
flowable = importFromPreviousExport();
break;
}
if (flowable == null) {

View file

@ -274,15 +274,14 @@ public class ErrorActivity extends AppCompatActivity {
}
private String formErrorText(String[] el) {
String text = "";
StringBuilder text = new StringBuilder();
if (el != null) {
for (String e : el) {
text += "-------------------------------------\n"
+ e;
text.append("-------------------------------------\n").append(e);
}
}
text += "-------------------------------------";
return text;
text.append("-------------------------------------");
return text.toString();
}
/**

View file

@ -56,7 +56,6 @@ public class ZipHelper {
/**
* This will extract data from Zipfiles.
* Caution this will override the original file.
* @param inZip The ZipOutputStream where the data is stored in
* @param file The path of the file on the disk where the data should be extracted to.
* @param name The path of the file inside the zip.
* @return will return true if the file was found within the zip file

View file

@ -123,7 +123,7 @@ public class DownloadManagerImpl implements DownloadManager {
Collections.sort(missions, new Comparator<DownloadMission>() {
@Override
public int compare(DownloadMission o1, DownloadMission o2) {
return Long.valueOf(o1.timestamp).compareTo(o2.timestamp);
return Long.compare(o1.timestamp, o2.timestamp);
}
});
}

View file

@ -67,8 +67,8 @@ public class DownloadMission implements Serializable {
public long done;
public int threadCount = 3;
public int finishCount;
private final List<Long> threadPositions = new ArrayList<Long>();
public final Map<Long, Boolean> blockState = new HashMap<Long, Boolean>();
private final List<Long> threadPositions = new ArrayList<>();
public final Map<Long, Boolean> blockState = new HashMap<>();
public boolean running;
public boolean finished;
public boolean fallback;
@ -77,7 +77,7 @@ public class DownloadMission implements Serializable {
public transient boolean recovered;
private transient ArrayList<WeakReference<MissionListener>> mListeners = new ArrayList<WeakReference<MissionListener>>();
private transient ArrayList<WeakReference<MissionListener>> mListeners = new ArrayList<>();
private transient boolean mWritingToFile;
private static final int NO_IDENTIFIER = -1;
@ -232,7 +232,7 @@ public class DownloadMission implements Serializable {
public synchronized void addListener(MissionListener listener) {
Handler handler = new Handler(Looper.getMainLooper());
MissionListener.handlerStore.put(listener, handler);
mListeners.add(new WeakReference<MissionListener>(listener));
mListeners.add(new WeakReference<>(listener));
}
public synchronized void removeListener(MissionListener listener) {

View file

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/selectedTabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/list_choose_tabs"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/addTabsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:focusable="true"
app:backgroundTint="?attr/colorPrimary"
app:fabSize="auto"
app:srcCompat="?attr/ic_add"/>
</RelativeLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<paths>
<external-path name="external_files" path="."/>
<root-path name="external_files" path="/storage/" />
</paths>

View file

@ -188,7 +188,7 @@ public class ListHelperTest {
@Test
public void getHighestQualityAudioNull() {
assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, null));
assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList<AudioStream>()));
assertEquals(-1, ListHelper.getHighestQualityAudioIndex(null, new ArrayList<>()));
}
@Test
@ -252,7 +252,7 @@ public class ListHelperTest {
@Test
public void getLowestQualityAudioNull() {
assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, null));
assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList<AudioStream>()));
assertEquals(-1, ListHelper.getMostCompactAudioIndex(null, new ArrayList<>()));
}
@Test

View file

@ -42,12 +42,12 @@ public class DownloadManagerImplTest {
missions.add(generateFinishedDownloadMission());
}
when(downloadDataSource.loadMissions()).thenReturn(new ArrayList<>(missions));
downloadManager = new DownloadManagerImpl(new ArrayList<String>(), downloadDataSource);
downloadManager = new DownloadManagerImpl(new ArrayList<>(), downloadDataSource);
}
@Test(expected = NullPointerException.class)
public void testConstructorWithNullAsDownloadDataSource() {
new DownloadManagerImpl(new ArrayList<String>(), null);
new DownloadManagerImpl(new ArrayList<>(), null);
}
@ -84,7 +84,7 @@ public class DownloadManagerImplTest {
downloadDataSource = mock(DownloadDataSource.class);
when(downloadDataSource.loadMissions()).thenReturn(new ArrayList<>(missions));
downloadManager = new DownloadManagerImpl(new ArrayList<String>(), downloadDataSource);
downloadManager = new DownloadManagerImpl(new ArrayList<>(), downloadDataSource);
verify(downloadDataSource, times(1)).loadMissions();
assertEquals(50, downloadManager.getCount());