last static analysis fixes
This commit is contained in:
parent
a0062bf1a8
commit
ed4792d3b8
|
|
@ -30,7 +30,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import rx.functions.Func1;
|
||||
import org.roboswag.components.utils.UiUtils;
|
||||
|
||||
/**
|
||||
* Created by Gavriil Sitnikov on 21/10/2015.
|
||||
|
|
@ -63,7 +63,7 @@ public abstract class AbstractBaseActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final @Nullable Bundle savedInstanceState) {
|
||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ public abstract class AbstractBaseActivity extends AppCompatActivity
|
|||
/* Raises when device back button pressed */
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!tryForeachChild(AbstractBaseFragment::onBackPressed)) {
|
||||
if (!UiUtils.tryForeachFragment(getSupportFragmentManager(), AbstractBaseFragment::onBackPressed)) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
@ -184,11 +184,12 @@ public abstract class AbstractBaseActivity extends AppCompatActivity
|
|||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
|
||||
if (tryForeachChild(AbstractBaseFragment::onHomePressed)) {
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (UiUtils.tryForeachFragment(fragmentManager, AbstractBaseFragment::onHomePressed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
final int stackSize = fragmentManager.getBackStackEntryCount();
|
||||
|
||||
switch (stackSize) {
|
||||
|
|
@ -221,24 +222,6 @@ public abstract class AbstractBaseActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
private boolean tryForeachChild(final Func1<AbstractBaseFragment, Boolean> actionOnChild) {
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.getFragments() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = false;
|
||||
for (@Nullable final Fragment fragment : fragmentManager.getFragments()) {
|
||||
if (fragment != null
|
||||
&& fragment.isResumed()
|
||||
&& fragment instanceof AbstractBaseFragment) {
|
||||
result = result || actionOnChild.call((AbstractBaseFragment) fragment);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Hides device keyboard */
|
||||
public void hideSoftInput() {
|
||||
if (getCurrentFocus() != null) {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@ import android.os.Handler;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.View;
|
||||
|
||||
import rx.functions.Func1;
|
||||
import org.roboswag.components.utils.UiUtils;
|
||||
|
||||
/**
|
||||
* Created by Gavriil Sitnikov on 21/10/2015.
|
||||
|
|
@ -103,32 +102,14 @@ public abstract class AbstractBaseFragment<TViewController extends AbstractBaseF
|
|||
//do nothing
|
||||
}
|
||||
|
||||
private boolean tryForeachChild(final Func1<AbstractBaseFragment, Boolean> actionOnChild) {
|
||||
final FragmentManager fragmentManager = getChildFragmentManager();
|
||||
|
||||
if (fragmentManager.getFragments() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = false;
|
||||
for (@Nullable final Fragment fragment : fragmentManager.getFragments()) {
|
||||
if (fragment != null
|
||||
&& fragment.isResumed()
|
||||
&& fragment instanceof AbstractBaseFragment) {
|
||||
result = result || actionOnChild.call((AbstractBaseFragment) fragment);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Raises when device back button pressed */
|
||||
public boolean onBackPressed() {
|
||||
return tryForeachChild(AbstractBaseFragment::onBackPressed);
|
||||
return UiUtils.tryForeachFragment(getFragmentManager(), AbstractBaseFragment::onBackPressed);
|
||||
}
|
||||
|
||||
/* Raises when ActionBar home button pressed */
|
||||
public boolean onHomePressed() {
|
||||
return tryForeachChild(AbstractBaseFragment::onHomePressed);
|
||||
return UiUtils.tryForeachFragment(getFragmentManager(), AbstractBaseFragment::onHomePressed);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
|||
|
|
@ -2,10 +2,16 @@ package org.roboswag.components.utils;
|
|||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.roboswag.components.navigation.AbstractBaseFragment;
|
||||
|
||||
import rx.functions.Func1;
|
||||
|
||||
/**
|
||||
* Created by Gavriil Sitnikov on 13/11/2015.
|
||||
* TODO: fill description
|
||||
|
|
@ -17,6 +23,23 @@ public final class UiUtils {
|
|||
return LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
|
||||
}
|
||||
|
||||
public static boolean tryForeachFragment(@NonNull final FragmentManager fragmentManager,
|
||||
@NonNull final Func1<AbstractBaseFragment, Boolean> actionOnChild) {
|
||||
if (fragmentManager.getFragments() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = false;
|
||||
for (final Fragment fragment : fragmentManager.getFragments()) {
|
||||
if (fragment != null
|
||||
&& fragment.isResumed()
|
||||
&& fragment instanceof AbstractBaseFragment) {
|
||||
result = result || actionOnChild.call((AbstractBaseFragment) fragment);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private UiUtils() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ public class TypefacedEditText extends EditText implements TypefacedText {
|
|||
Typefaces.initialize(this, context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(final String name, final int style) {
|
||||
Typefaces.setTypeface(this, getContext(), name, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(final String name) {
|
||||
Typefaces.setTypeface(this, getContext(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(final String name, final int style) {
|
||||
Typefaces.setTypeface(this, getContext(), name, style);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue