clean code

This commit is contained in:
Thomas 2024-02-23 09:37:54 +01:00
parent d0fb1b09dc
commit 70405221ea
7 changed files with 31 additions and 21 deletions

View file

@ -464,7 +464,8 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
} }
@Override @Override
public void onDownloaded(String saveFilePath, String downloadUrl, Error error) {} public void onDownloaded(String saveFilePath, String downloadUrl, Error error) {
}
@Override @Override
public void onUpdateProgress(int progress) { public void onUpdateProgress(int progress) {

View file

@ -22,8 +22,6 @@ import android.widget.RadioButton;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.LinearLayoutCompat; import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;

View file

@ -45,7 +45,8 @@ public class Tag implements Serializable {
for (History h : history) { for (History h : history) {
try { try {
weight += Integer.parseInt(h.accounts); weight += Integer.parseInt(h.accounts);
} catch (Exception ignored) {} } catch (Exception ignored) {
}
} }
} }
return weight; return weight;

View file

@ -909,7 +909,7 @@ public class Helper {
if (args != null) fragment.setArguments(args); if (args != null) fragment.setArguments(args);
ft = fragmentManager.beginTransaction(); ft = fragmentManager.beginTransaction();
ft.add(containerViewId, fragment, tag); ft.add(containerViewId, fragment, tag);
if (backStackName != null) { if (backStackName != null) {
ft = fragmentManager.beginTransaction(); ft = fragmentManager.beginTransaction();
ft.addToBackStack(backStackName); ft.addToBackStack(backStackName);
} }

View file

@ -499,7 +499,7 @@ public class MastodonHelper {
accountId = account.id; accountId = account.id;
acct = account.acct; acct = account.acct;
} }
accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountId, true, (int) delayToPass*1000) accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountId, true, (int) delayToPass * 1000)
.observe((LifecycleOwner) context, relationShip -> { .observe((LifecycleOwner) context, relationShip -> {
if (listener != null) { if (listener != null) {
listener.onTimedMute(relationShip); listener.onTimedMute(relationShip);

View file

@ -140,56 +140,67 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
String type = notificationList.get(position).type; String type = notificationList.get(position).type;
if (type != null) { if (type != null) {
switch (type) { switch (type) {
case "follow": case "follow" -> {
return TYPE_FOLLOW; return TYPE_FOLLOW;
case "follow_request": }
case "follow_request" -> {
return TYPE_FOLLOW_REQUEST; return TYPE_FOLLOW_REQUEST;
case "mention": }
case "mention" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_MENTION; return TYPE_MENTION;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "reblog": }
case "reblog" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_REBLOG; return TYPE_REBLOG;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "update": }
case "update" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_UPDATE; return TYPE_UPDATE;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "favourite": }
case "favourite" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_FAVOURITE; return TYPE_FAVOURITE;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "poll": }
case "poll" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_POLL; return TYPE_POLL;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "status": }
case "status" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_STATUS; return TYPE_STATUS;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
case "admin.sign_up": }
case "admin.sign_up" -> {
return TYPE_ADMIN_SIGNUP; return TYPE_ADMIN_SIGNUP;
case "admin.report": }
case "admin.report" -> {
return TYPE_ADMIN_REPORT; return TYPE_ADMIN_REPORT;
case "pleroma:emoji_reaction": }
case "pleroma:emoji_reaction" -> {
if (notificationList.get(position).status != null) { if (notificationList.get(position).status != null) {
return TYPE_REACTION; return TYPE_REACTION;
} else { } else {
return TYPE_HIDDEN; return TYPE_HIDDEN;
} }
}
} }
} }
return super.getItemViewType(position); return super.getItemViewType(position);

View file

@ -212,7 +212,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
private String publicTrendsDomain; private String publicTrendsDomain;
//Allow to recreate data when detaching/attaching fragment //Allow to recreate data when detaching/attaching fragment
public void recreate() { public void recreate() {
initialStatuses = null; initialStatuses = null;
@ -242,7 +241,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if(bundleParamsRetrieved) { if (bundleParamsRetrieved) {
initializeView(); initializeView();
} else { } else {
needToCallResume = true; needToCallResume = true;
@ -450,7 +449,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
} }
//When visiting a profile without being authenticated //When visiting a profile without being authenticated
if (checkRemotely) { if (checkRemotely) {
String[] acctArray = accountTimeline!=null?accountTimeline.acct.split("@"):new String[]{}; String[] acctArray = accountTimeline != null ? accountTimeline.acct.split("@") : new String[]{};
if (acctArray.length > 1) { if (acctArray.length > 1) {
remoteInstance = acctArray[1]; remoteInstance = acctArray[1];
} }
@ -505,7 +504,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
//AND Only the first fragment will initialize its view //AND Only the first fragment will initialize its view
flagLoading = false; flagLoading = false;
bundleParamsRetrieved = true; bundleParamsRetrieved = true;
if(needToCallResume) { if (needToCallResume) {
initializeView(); initializeView();
needToCallResume = false; needToCallResume = false;
} }