fix current fragment detection
This commit is contained in:
parent
798a43906f
commit
2c4504bad3
|
@ -8,6 +8,8 @@ import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import org.joinmastodon.android.api.ObjectValidationException;
|
import org.joinmastodon.android.api.ObjectValidationException;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
|
@ -28,8 +30,6 @@ import androidx.annotation.Nullable;
|
||||||
import me.grishka.appkit.FragmentStackActivity;
|
import me.grishka.appkit.FragmentStackActivity;
|
||||||
|
|
||||||
public class MainActivity extends FragmentStackActivity implements ProvidesAssistContent {
|
public class MainActivity extends FragmentStackActivity implements ProvidesAssistContent {
|
||||||
private Fragment currentFragment;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState){
|
protected void onCreate(@Nullable Bundle savedInstanceState){
|
||||||
UiUtils.setUserPreferredTheme(this);
|
UiUtils.setUserPreferredTheme(this);
|
||||||
|
@ -200,15 +200,20 @@ public class MainActivity extends FragmentStackActivity implements ProvidesAssis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Fragment getCurrentFragment() {
|
||||||
public void showFragment(Fragment fragment) {
|
for (int i = fragmentContainers.size() - 1; i >= 0; i--) {
|
||||||
super.showFragment(fragment);
|
FrameLayout fl = fragmentContainers.get(i);
|
||||||
this.currentFragment = fragment;
|
if (fl.getVisibility() == View.VISIBLE) {
|
||||||
|
return getFragmentManager().findFragmentById(fl.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProvideAssistContent(AssistContent assistContent) {
|
public void onProvideAssistContent(AssistContent assistContent) {
|
||||||
super.onProvideAssistContent(assistContent);
|
super.onProvideAssistContent(assistContent);
|
||||||
callFragmentToProvideAssistContent(currentFragment, assistContent);
|
Fragment fragment = getCurrentFragment();
|
||||||
|
if (fragment != null) callFragmentToProvideAssistContent(fragment, assistContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue