find activity even if wrapped in context wrapper. fixes #3396

This commit is contained in:
Daniel Gultsch 2019-03-03 08:31:46 +01:00
parent f406631512
commit 875f0b9943
1 changed files with 7 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender.SendIntentException; import android.content.IntentSender.SendIntentException;
@ -1000,10 +1001,13 @@ public abstract class XmppActivity extends ActionBarActivity {
} }
public static XmppActivity find(@NonNull final View view) { public static XmppActivity find(@NonNull final View view) {
final Context context = view.getContext(); Context context = view.getContext();
while (context instanceof ContextWrapper) {
if (context instanceof XmppActivity) { if (context instanceof XmppActivity) {
return (XmppActivity) context; return (XmppActivity) context;
} }
context = ((ContextWrapper)context).getBaseContext();
}
return null; return null;
} }
} }