mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Some fixes
This commit is contained in:
parent
365179def8
commit
72fd064f8a
9 changed files with 59 additions and 43 deletions
|
@ -35,7 +35,6 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
|
|
|
@ -122,7 +122,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
for (Status status : statusList) {
|
||||
if (status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
if (attachment.local_path.equalsIgnoreCase(imgpath)) {
|
||||
if (attachment.local_path != null && attachment.local_path.equalsIgnoreCase(imgpath)) {
|
||||
if (focusX != -2) {
|
||||
attachment.focus = focusX + "," + focusY;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
visibility = b.getString(Helper.ARG_VISIBILITY, null);
|
||||
if (visibility == null && statusReply != null) {
|
||||
visibility = getVisibility(statusReply.visibility);
|
||||
} else if (visibility == null && currentAccount != null && currentAccount.mastodon_account.source != null) {
|
||||
} else if (visibility == null && currentAccount != null && currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) {
|
||||
visibility = currentAccount.mastodon_account.source.privacy;
|
||||
}
|
||||
mentionBooster = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_MENTION_BOOSTER);
|
||||
|
@ -615,7 +615,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
//We change order for mentions
|
||||
//At first place the account that has been mentioned if it's not our
|
||||
statusDraftList.get(0).mentions = new ArrayList<>();
|
||||
if (statusReply.account.acct != null && !statusReply.account.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
if (statusReply.account.acct != null && currentAccount.mastodon_account != null && !statusReply.account.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
Mention mention = new Mention();
|
||||
mention.acct = "@" + statusReply.account.acct;
|
||||
mention.url = statusReply.account.url;
|
||||
|
@ -626,7 +626,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
//There are other mentions to
|
||||
if (statusReply.mentions != null && statusReply.mentions.size() > 0) {
|
||||
for (Mention mentionTmp : statusReply.mentions) {
|
||||
if (statusReply.account.acct != null && !mentionTmp.acct.equalsIgnoreCase(statusReply.account.acct) && !mentionTmp.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
if (statusReply.account.acct != null && !mentionTmp.acct.equalsIgnoreCase(statusReply.account.acct) && currentAccount.mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
|
||||
statusDraftList.get(0).mentions.add(mentionTmp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ public class MastodonListActivity extends BaseActivity implements MastodonListAd
|
|||
if (mastodonListList == null) {
|
||||
mastodonListList = new ArrayList<>();
|
||||
}
|
||||
if (newMastodonList != null) {
|
||||
if (newMastodonList != null && mastodonListAdapter != null) {
|
||||
mastodonListList.add(0, newMastodonList);
|
||||
mastodonListAdapter.notifyItemInserted(0);
|
||||
} else {
|
||||
|
|
|
@ -663,7 +663,10 @@ public class ProfileActivity extends BaseActivity {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
String[] splitAcct = account.acct.split("@");
|
||||
String[] splitAcct = null;
|
||||
if (account.acct != null) {
|
||||
splitAcct = account.acct.split("@");
|
||||
}
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
|
||||
AlertDialog.Builder builderInner = null;
|
||||
final boolean isOwner = account.id != null && BaseMainActivity.currentUserID != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0;
|
||||
|
@ -677,7 +680,7 @@ public class ProfileActivity extends BaseActivity {
|
|||
if (itemId == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_follow_instance) {
|
||||
} else if (itemId == R.id.action_follow_instance && splitAcct != null) {
|
||||
String finalInstanceName = splitAcct[1];
|
||||
ReorderVM reorderVM = new ViewModelProvider(ProfileActivity.this).get(ReorderVM.class);
|
||||
//Get pinned instances
|
||||
|
|
|
@ -59,7 +59,12 @@ public class DomainsBlock {
|
|||
List<String> domains = new ArrayList<>();
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.startsWith("0.0.0.0 ")) {
|
||||
domains.add(line.replace("0.0.0.0 ", "").trim());
|
||||
try {
|
||||
domains.add(line.replace("0.0.0.0 ", "").trim());
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
|
|
|
@ -95,7 +95,9 @@ public class CustomEmoji extends ReplacementSpan {
|
|||
((Animatable) resource).start();
|
||||
}
|
||||
imageDrawable = resource;
|
||||
view.invalidate();
|
||||
if (view != null) {
|
||||
view.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -990,8 +990,12 @@ public class Helper {
|
|||
*/
|
||||
public static String getFileName(Context context, Uri uri) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Cursor returnCursor =
|
||||
resolver.query(uri, null, null, null, null);
|
||||
Cursor returnCursor = null;
|
||||
try {
|
||||
returnCursor =
|
||||
resolver.query(uri, null, null, null, null);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (returnCursor != null) {
|
||||
try {
|
||||
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||
|
@ -1092,7 +1096,7 @@ public class Helper {
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false);
|
||||
String targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar;
|
||||
if (targetedUrl != null) {
|
||||
if (targetedUrl != null && Helper.isValidContextForGlide(view.getContext())) {
|
||||
if (disableGif || (!targetedUrl.endsWith(".gif"))) {
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(view.getContext())
|
||||
.asDrawable()
|
||||
|
@ -1112,7 +1116,7 @@ public class Helper {
|
|||
}
|
||||
requestBuilder.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))).into(view);
|
||||
}
|
||||
} else {
|
||||
} else if (Helper.isValidContextForGlide(view.getContext())) {
|
||||
Glide.with(view.getContext())
|
||||
.asDrawable()
|
||||
.load(R.drawable.ic_person)
|
||||
|
@ -1201,7 +1205,7 @@ public class Helper {
|
|||
|
||||
int w = options.outWidth;
|
||||
int h = options.outHeight;
|
||||
float valx = (float) 1.0 - (float) width / (float) w;
|
||||
float valx = (float) 1.0 - width / (float) w;
|
||||
if (valx < 0)
|
||||
valx = 0;
|
||||
float valy = (h - Helper.convertDpToPixel(textSize, context) - 10) / (float) h;
|
||||
|
|
|
@ -488,7 +488,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
});
|
||||
//For first tab we fetch new messages, if we keep position
|
||||
if (slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0 && rememberPosition) {
|
||||
if (slug != null && slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0 && rememberPosition) {
|
||||
route(DIRECTION.FETCH_NEW, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,39 +66,42 @@ public class NodeInfoVM extends AndroidViewModel {
|
|||
* @return LiveData<WellKnownNodeinfo.NodeInfo>
|
||||
*/
|
||||
public LiveData<WellKnownNodeinfo.NodeInfo> getNodeInfo(String instance) {
|
||||
NodeInfoService nodeInfoService = init(instance);
|
||||
nodeInfoMutableLiveData = new MutableLiveData<>();
|
||||
new Thread(() -> {
|
||||
WellKnownNodeinfo.NodeInfo nodeInfo = null;
|
||||
if (instance != null) {
|
||||
NodeInfoService nodeInfoService = init(instance);
|
||||
nodeInfoMutableLiveData = new MutableLiveData<>();
|
||||
new Thread(() -> {
|
||||
WellKnownNodeinfo.NodeInfo nodeInfo = null;
|
||||
|
||||
Call<WellKnownNodeinfo> nodeInfoLinksCall = nodeInfoService.getWellKnownNodeinfoLinks();
|
||||
if (nodeInfoLinksCall != null) {
|
||||
try {
|
||||
Response<WellKnownNodeinfo> nodeInfoLinksResponse = nodeInfoLinksCall.execute();
|
||||
if (nodeInfoLinksResponse.isSuccessful() && nodeInfoLinksResponse.body() != null) {
|
||||
WellKnownNodeinfo wellKnownNodeinfo = nodeInfoLinksResponse.body();
|
||||
Call<WellKnownNodeinfo.NodeInfo> wellKnownNodeinfoCall = nodeInfoService.getNodeinfo(wellKnownNodeinfo.links.get(0).href);
|
||||
if (wellKnownNodeinfoCall != null) {
|
||||
try {
|
||||
Response<WellKnownNodeinfo.NodeInfo> response = wellKnownNodeinfoCall.execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
nodeInfo = response.body();
|
||||
Call<WellKnownNodeinfo> nodeInfoLinksCall = nodeInfoService.getWellKnownNodeinfoLinks();
|
||||
if (nodeInfoLinksCall != null) {
|
||||
try {
|
||||
Response<WellKnownNodeinfo> nodeInfoLinksResponse = nodeInfoLinksCall.execute();
|
||||
if (nodeInfoLinksResponse.isSuccessful() && nodeInfoLinksResponse.body() != null) {
|
||||
WellKnownNodeinfo wellKnownNodeinfo = nodeInfoLinksResponse.body();
|
||||
Call<WellKnownNodeinfo.NodeInfo> wellKnownNodeinfoCall = nodeInfoService.getNodeinfo(wellKnownNodeinfo.links.get(0).href);
|
||||
if (wellKnownNodeinfoCall != null) {
|
||||
try {
|
||||
Response<WellKnownNodeinfo.NodeInfo> response = wellKnownNodeinfoCall.execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
nodeInfo = response.body();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
WellKnownNodeinfo.NodeInfo finalNodeInfo = nodeInfo;
|
||||
Runnable myRunnable = () -> nodeInfoMutableLiveData.setValue(finalNodeInfo);
|
||||
mainHandler.post(myRunnable);
|
||||
}).start();
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
WellKnownNodeinfo.NodeInfo finalNodeInfo = nodeInfo;
|
||||
Runnable myRunnable = () -> nodeInfoMutableLiveData.setValue(finalNodeInfo);
|
||||
mainHandler.post(myRunnable);
|
||||
}).start();
|
||||
} else {
|
||||
nodeInfoMutableLiveData.setValue(null);
|
||||
}
|
||||
return nodeInfoMutableLiveData;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue