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

View file

@ -9,6 +9,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
@ -1000,10 +1001,13 @@ public abstract class XmppActivity extends ActionBarActivity {
}
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) {
return (XmppActivity) context;
}
context = ((ContextWrapper)context).getBaseContext();
}
return null;
}
}