Code improvements
This commit is contained in:
parent
2db6e9310a
commit
76f8f49cdf
|
@ -41,7 +41,7 @@ public class FileDiffView implements Serializable {
|
|||
|
||||
public String getFileName() {
|
||||
|
||||
if (fileOldName.length() != 0 && !fileOldName.equals(fileNewName)) {
|
||||
if (!fileOldName.isEmpty() && !fileOldName.equals(fileNewName)) {
|
||||
return fileOldName + " -> " + fileNewName;
|
||||
}
|
||||
return fileNewName;
|
||||
|
|
|
@ -170,7 +170,6 @@ public class Markdown {
|
|||
private Context context;
|
||||
private String markdown;
|
||||
private TextView textView;
|
||||
TinyDB tinyDB = TinyDB.getInstance(null);
|
||||
|
||||
public Renderer(Slot slot) {
|
||||
|
||||
|
@ -320,7 +319,6 @@ public class Markdown {
|
|||
private RecyclerView recyclerView;
|
||||
private MarkwonAdapter adapter;
|
||||
private RepositoryContext repository;
|
||||
TinyDB tinyDB = TinyDB.getInstance(null);
|
||||
|
||||
private LinkPostProcessor linkPostProcessor;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ public class MergePullRequestSpinner implements Serializable {
|
|||
this.mergerMethod = mergerMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull @Override
|
||||
public String toString() {
|
||||
return mergerMethod;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ public class PicassoCache implements Cache {
|
|||
private final int CACHE_SIZE;
|
||||
private final File cachePath;
|
||||
private final HashMap<String, String> cacheMap;
|
||||
private final Context ctx;
|
||||
|
||||
public PicassoCache(File cachePath, Context ctx) throws IOException, ClassNotFoundException {
|
||||
|
||||
|
@ -41,7 +40,6 @@ public class PicassoCache implements Cache {
|
|||
* 1024;
|
||||
this.cachePath = cachePath;
|
||||
cacheMap = new HashMap<>();
|
||||
this.ctx = ctx;
|
||||
|
||||
if (cacheMapExists(cachePath)) {
|
||||
|
||||
|
@ -104,7 +102,8 @@ public class PicassoCache implements Cache {
|
|||
|
||||
for (String key : cacheMap.keySet()) {
|
||||
|
||||
currentSize += new File(cachePath, Objects.requireNonNull(cacheMap.get(key))).length();
|
||||
currentSize +=
|
||||
(int) new File(cachePath, Objects.requireNonNull(cacheMap.get(key))).length();
|
||||
}
|
||||
|
||||
return currentSize;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import android.util.Log;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -14,7 +16,7 @@ public class UrlHelper {
|
|||
try {
|
||||
uri = new URI(url);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("UrlHelper", Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
assert uri != null;
|
||||
|
|
|
@ -28,8 +28,8 @@ public class Version {
|
|||
/**
|
||||
* valid return true if string is a valid version
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public static boolean valid(String value) {
|
||||
|
||||
|
@ -37,15 +37,13 @@ public class Version {
|
|||
return false;
|
||||
}
|
||||
final Pattern patternValid =
|
||||
Pattern.compile("^[vV]?(\\d+)+(\\.(\\d+))*([_\\-+][\\w\\-+\\.]*)?$");
|
||||
Pattern.compile("^[vV]?(\\d+)+(\\.(\\d+))*([_\\-+][\\w\\-+.]*)?$");
|
||||
return value.equals("main") || patternValid.matcher(value).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* init parse and store values for other functions of an Version instance it use the raw
|
||||
* variable as base
|
||||
*
|
||||
* @return if parse was successfully
|
||||
*/
|
||||
private void init() {
|
||||
|
||||
|
@ -84,7 +82,7 @@ public class Version {
|
|||
/**
|
||||
* equal return true if version is the same
|
||||
*
|
||||
* @param value
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean equal(String value) {
|
||||
|
@ -95,8 +93,8 @@ public class Version {
|
|||
/**
|
||||
* equal return true if version is the same
|
||||
*
|
||||
* @param v
|
||||
* @return
|
||||
* @param v Version
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean equal(@NonNull Version v) {
|
||||
|
||||
|
@ -116,7 +114,7 @@ public class Version {
|
|||
/**
|
||||
* less return true if version is less
|
||||
*
|
||||
* @param value
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean less(String value) {
|
||||
|
@ -127,8 +125,8 @@ public class Version {
|
|||
/**
|
||||
* less return true if version is less
|
||||
*
|
||||
* @param v
|
||||
* @return
|
||||
* @param v Version
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean less(@NonNull Version v) {
|
||||
|
||||
|
@ -138,7 +136,7 @@ public class Version {
|
|||
/**
|
||||
* higher return true if version is higher
|
||||
*
|
||||
* @param value
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean higher(String value) {
|
||||
|
@ -149,8 +147,8 @@ public class Version {
|
|||
/**
|
||||
* higher return true if version is higher
|
||||
*
|
||||
* @param v
|
||||
* @return
|
||||
* @param v Version
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean higher(@NonNull Version v) {
|
||||
|
||||
|
@ -180,7 +178,7 @@ public class Version {
|
|||
/**
|
||||
* lessOrEqual return true if version is less or equal
|
||||
*
|
||||
* @param value
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean lessOrEqual(String value) {
|
||||
|
@ -191,8 +189,8 @@ public class Version {
|
|||
/**
|
||||
* lessOrEqual return true if version is less or equal
|
||||
*
|
||||
* @param v
|
||||
* @return
|
||||
* @param v Version
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean lessOrEqual(@NonNull Version v) {
|
||||
|
||||
|
@ -202,7 +200,7 @@ public class Version {
|
|||
/**
|
||||
* higherOrEqual return true if version is higher or equal
|
||||
*
|
||||
* @param value
|
||||
* @param value String
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean higherOrEqual(String value) {
|
||||
|
@ -213,8 +211,8 @@ public class Version {
|
|||
/**
|
||||
* higherOrEqual return true if version is higher or equal
|
||||
*
|
||||
* @param v
|
||||
* @return
|
||||
* @param v Version
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean higherOrEqual(@NonNull Version v) {
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
@ -22,13 +24,13 @@ public class AttachmentUtils {
|
|||
new File(
|
||||
ctx.getFilesDir().getPath() + File.separatorChar + queryName(ctx, uri));
|
||||
} catch (AssertionError e) {
|
||||
destinationFilename = new File(uri.getPath());
|
||||
destinationFilename = new File(Objects.requireNonNull(uri.getPath()));
|
||||
}
|
||||
|
||||
try (InputStream ins = ctx.getContentResolver().openInputStream(uri)) {
|
||||
createFileFromStream(ins, destinationFilename);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e("AttachmentUtils", Objects.requireNonNull(ex.getMessage()));
|
||||
}
|
||||
return destinationFilename;
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ public class AttachmentUtils {
|
|||
}
|
||||
os.flush();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e("AttachmentUtils", Objects.requireNonNull(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.text.Layout;
|
|||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.EditText;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* @author AmrDeveloper
|
||||
|
@ -18,7 +19,7 @@ public class SourcePositionListener {
|
|||
new View.AccessibilityDelegate() {
|
||||
|
||||
@Override
|
||||
public void sendAccessibilityEvent(View host, int eventType) {
|
||||
public void sendAccessibilityEvent(@NonNull View host, int eventType) {
|
||||
super.sendAccessibilityEvent(host, eventType);
|
||||
if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
|
||||
&& onPositionChanged != null) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class LanguageStatisticsBar extends androidx.appcompat.widget.AppCompatSe
|
|||
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
if (progressItemsList.size() > 0) {
|
||||
if (!progressItemsList.isEmpty()) {
|
||||
|
||||
int progressBarWidth = getWidth();
|
||||
int progressBarHeight = getHeight();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class AdminGetUsersViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class DashboardViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -101,7 +101,7 @@ public class IssueCommentsViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -135,7 +135,7 @@ public class IssuesViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class MembersByOrgViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MilestonesViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class OrganizationsViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class RepoWatchersViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ public class RepositoriesViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class RepositoryForksViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class WikiViewModel extends ViewModel {
|
|||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (response.body().size() != 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import org.gitnex.tea4j.v2.models.Reaction;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
|
@ -108,8 +109,9 @@ public class ReactionList extends HorizontalScrollView {
|
|||
|
||||
if (sortedReactions.containsKey(
|
||||
issueReaction.getContent())) {
|
||||
sortedReactions
|
||||
.get(issueReaction.getContent())
|
||||
Objects.requireNonNull(
|
||||
sortedReactions.get(
|
||||
issueReaction.getContent()))
|
||||
.add(issueReaction);
|
||||
} else {
|
||||
List<Reaction> issueReactions = new ArrayList<>();
|
||||
|
@ -135,6 +137,7 @@ public class ReactionList extends HorizontalScrollView {
|
|||
this,
|
||||
false);
|
||||
|
||||
assert issueReactions != null;
|
||||
for (Reaction issueReaction : issueReactions) {
|
||||
if (issueReaction
|
||||
.getUser()
|
||||
|
|
|
@ -100,7 +100,7 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||
|
||||
public void setContent(@NonNull String source, @NonNull String extension) {
|
||||
|
||||
if (source.length() > 0) {
|
||||
if (!source.isEmpty()) {
|
||||
|
||||
Thread highlightingThread =
|
||||
new Thread(
|
||||
|
|
Loading…
Reference in New Issue