Fix some issues
This commit is contained in:
parent
c7a6390346
commit
5f5ed0ac95
|
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
|||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
buildToolsVersion "29.0.3"
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
|
|
|
@ -202,6 +202,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
private View dialogReleaseNoteView;
|
||||
private List<Account> developers;
|
||||
|
||||
public static boolean isAttached = false;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -2383,6 +2384,18 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
MASTALAB
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
isAttached = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
isAttached = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page Adapter for Mastodon & Peertube & PixelFed
|
||||
*/
|
||||
|
@ -2521,6 +2534,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
if (mPageReferenceMap != null) {
|
||||
|
|
|
@ -225,13 +225,15 @@ public class Account implements Parcelable {
|
|||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if (endPosition <= displayNameSpan.toString().length() && endPosition >= startPosition) {
|
||||
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
resource.setVisible(true, true);
|
||||
ImageSpan imageSpan = new ImageSpan(resource);
|
||||
displayNameSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (resource != null && endPosition <= displayNameSpan.toString().length() && endPosition >= startPosition) {
|
||||
try {
|
||||
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
resource.setVisible(true, true);
|
||||
ImageSpan imageSpan = new ImageSpan(resource);
|
||||
displayNameSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}catch (Exception ignored){}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -890,14 +890,16 @@ public class Status implements Parcelable {
|
|||
//emojis can be used several times so we have to loop
|
||||
for (int startPosition = -1; (startPosition = contentSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if (endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
|
||||
if (resource != null && endPosition <= contentSpan.toString().length() && endPosition >= startPosition) {
|
||||
ImageSpan imageSpan;
|
||||
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
resource.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(resource);
|
||||
contentSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
try {
|
||||
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
resource.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(resource);
|
||||
contentSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,6 +232,7 @@ import okhttp3.TlsVersion;
|
|||
|
||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.filters;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.isAttached;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.regex_home;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.regex_local;
|
||||
|
@ -647,6 +648,9 @@ public class Helper {
|
|||
editor.putString(Helper.PREF_INSTANCE, null);
|
||||
editor.putString(Helper.ID, null);
|
||||
editor.apply();
|
||||
Intent loginActivity = new Intent(activity, LoginActivity.class);
|
||||
activity.startActivity(loginActivity);
|
||||
activity.finish();
|
||||
} else {
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, newAccount.getToken());
|
||||
editor.putString(Helper.PREF_KEY_ID, newAccount.getId());
|
||||
|
@ -1788,38 +1792,40 @@ public class Helper {
|
|||
if (!accountChoice.getAvatar().startsWith("http"))
|
||||
accountChoice.setAvatar("https://" + accountChoice.getInstance() + accountChoice.getAvatar());
|
||||
ImageView itemIconAcc = new ImageView(activity);
|
||||
if( !activity.isFinishing()) {
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(270)))
|
||||
.load(!disableGif ? accountChoice.getAvatar() : accountChoice.getAvatar_static())
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
if( !activity.isFinishing() && isAttached) {
|
||||
try {
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(270)))
|
||||
.load(!disableGif ? accountChoice.getAvatar() : accountChoice.getAvatar_static())
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||
itemIconAcc.setImageResource(R.drawable.missing);
|
||||
else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
itemIconAcc.setImageResource(R.drawable.missing_peertube);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
itemIconAcc.setImageDrawable(resource);
|
||||
}
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||
itemIconAcc.setImageResource(R.drawable.missing);
|
||||
else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
itemIconAcc.setImageResource(R.drawable.missing_peertube);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
itemIconAcc.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
|
||||
if (accounts.size() > 2) {
|
||||
|
@ -1927,27 +1933,31 @@ public class Helper {
|
|||
}
|
||||
if (!urlHeader.contains("missing.png")) {
|
||||
ImageView backgroundImage = headerLayout.findViewById(R.id.back_ground_image);
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.load(urlHeader)
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
if( !activity.isFinishing() && isAttached) {
|
||||
try {
|
||||
Glide.with(activity)
|
||||
.asDrawable()
|
||||
.load(urlHeader)
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, Transition<? super Drawable> transition) {
|
||||
|
||||
backgroundImage.setImageDrawable(resource);
|
||||
if (theme == THEME_LIGHT) {
|
||||
backgroundImage.setImageAlpha(80);
|
||||
} else {
|
||||
backgroundImage.setImageAlpha(60);
|
||||
}
|
||||
backgroundImage.setImageDrawable(resource);
|
||||
if (theme == THEME_LIGHT) {
|
||||
backgroundImage.setImageAlpha(80);
|
||||
} else {
|
||||
backgroundImage.setImageAlpha(60);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
}
|
||||
profilePicture.setOnClickListener(null);
|
||||
|
|
Loading…
Reference in New Issue