[android] Warning fixes

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk 2022-06-10 01:08:56 +02:00 committed by Viktor Govako
parent 7d5506441f
commit 8ad687e27e
7 changed files with 17 additions and 92 deletions

View file

@ -78,7 +78,6 @@ import com.mapswithme.maps.search.SearchFragment;
import com.mapswithme.maps.settings.DrivingOptionsActivity;
import com.mapswithme.maps.settings.RoadType;
import com.mapswithme.maps.settings.SettingsActivity;
import com.mapswithme.maps.settings.StoragePathManager;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.widget.menu.MainMenu;
@ -124,14 +123,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
NoConnectionListener,
MapWidgetOffsetsProvider
{
private final Logger mLogger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = MwmActivity.class.getSimpleName();
public static final String EXTRA_TASK = "map_task";
public static final String EXTRA_LAUNCH_BY_DEEP_LINK = "launch_by_deep_link";
public static final String EXTRA_BACK_URL = "back_url";
private static final String EXTRA_CONSUMED = "mwm.extra.intent.processed";
private static final String EXTRA_ONBOARDING_TIP = "extra_onboarding_tip";
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),
DownloaderFragment.class.getName(),
@ -155,18 +150,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Nullable
private MapFragment mMapFragment;
@SuppressWarnings("NullableProblems")
@NonNull
private View mPositionChooser;
private RoutingPlanInplaceController mRoutingPlanInplaceController;
@SuppressWarnings("NullableProblems")
@NonNull
private NavigationController mNavigationController;
@SuppressWarnings("NullableProblems")
@NonNull
private MainMenu mMainMenu;
private PanelAnimator mPanelAnimator;
@ -183,7 +172,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private MenuBottomSheetFragment mMainMenuBottomSheet;
@Nullable
private NavigationButtonsAnimationController mNavAnimationController;
@SuppressWarnings("NullableProblems")
@SuppressWarnings("NotNullFieldNotInitialized")
@NonNull
private MapLayersController mToggleMapLayerController;
@ -202,10 +191,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
private Bundle mSavedForTabletState;
@NonNull
private final OnClickListener mOnMyPositionClickListener = new CurrentPositionClickListener();
@SuppressWarnings("NullableProblems")
@SuppressWarnings("NotNullFieldNotInitialized")
@NonNull
private PlacePageController mPlacePageController;
@SuppressWarnings("NullableProblems")
public interface LeftAnimationTrackListener
{
@ -427,10 +415,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return;
if (savedInstanceState == null && RoutingController.get().hasSavedRoute())
{
addTask(new Factory.RestoreRouteTask());
return;
}
}
private void initBottomSheets()
@ -661,12 +646,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (interceptBackPress())
return true;
if (removeCurrentFragment(true))
{
return true;
}
return false;
return removeCurrentFragment(true);
}
private void closeAllFloatingPanelsTablet()
@ -790,7 +770,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
@Override
protected void onSaveInstanceState(Bundle outState)
protected void onSaveInstanceState(@NonNull Bundle outState)
{
mPlacePageController.onSave(outState);
if (!mIsTabletLayout && RoutingController.get().isPlanning())
@ -1130,14 +1110,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return false;
if (animate)
mPanelAnimator.hide(new Runnable()
{
@Override
public void run()
{
removeFragmentImmediate(fragment);
}
});
mPanelAnimator.hide(() -> removeFragmentImmediate(fragment));
else
removeFragmentImmediate(fragment);
@ -1971,47 +1944,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
}
static abstract class AbstractClickMenuDelegate implements ClickMenuDelegate
{
@NonNull
private final MwmActivity mActivity;
@NonNull
private final MainMenu.Item mItem;
AbstractClickMenuDelegate(@NonNull MwmActivity activity, @NonNull MainMenu.Item item)
{
mActivity = activity;
mItem = item;
}
@NonNull
public MwmActivity getActivity()
{
return mActivity;
}
@NonNull
public MainMenu.Item getItem()
{
return mItem;
}
@Override
public final void onMenuItemClick()
{
onMenuItemClickInternal();
}
abstract void onMenuItemClickInternal();
}
private class ToolbarLayoutChangeListener implements ViewTreeObserver.OnGlobalLayoutListener
{
@Override
public void onGlobalLayout()
{
mSearchController.getToolbar().getViewTreeObserver()
.removeGlobalOnLayoutListener(this);
.removeOnGlobalLayoutListener(this);
adjustCompassAndTraffic(UiUtils.isVisible(mSearchController.getToolbar())
? calcFloatingViewsOffset()

View file

@ -63,10 +63,7 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
private final Object mMainQueueToken = new Object();
@NonNull
private final MapManager.StorageCallback mStorageCallbacks = new StorageCallbackImpl();
@SuppressWarnings("NullableProblems")
@NonNull
private MediaPlayerWrapper mPlayer;
private boolean mFirstLaunch;
@NonNull
public SubwayManager getSubwayManager()
@ -260,17 +257,11 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
Counters.resetAppSessionCounters(context);
}
// Called from jni
@SuppressWarnings("unused")
void forwardToMainThread(final long taskPointer)
{
Message m = Message.obtain(mMainLoopHandler, new Runnable()
{
@Override
public void run()
{
nativeProcessTask(taskPointer);
}
});
Message m = Message.obtain(mMainLoopHandler, () -> nativeProcessTask(taskPointer));
m.obj = mMainQueueToken;
mMainLoopHandler.sendMessage(m);
}
@ -290,11 +281,6 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
private static native void nativeAddLocalization(String name, String value);
private static native void nativeOnTransit(boolean foreground);
public boolean isFirstLaunch()
{
return mFirstLaunch;
}
@Override
public void onTransit(boolean foreground)
{

View file

@ -44,13 +44,13 @@ class AndroidNativeProvider extends BaseLocationProvider
{
LOGGER.d(TAG, "Status changed for location provider: " + provider + "; new status = " + status);
}
};
}
@NonNull
@NonNull
private final LocationManager mLocationManager;
private int mProviderCount = 0;
private boolean mActive = false;
static private int MIN_PROVIDER_COUNT = 2; // PASSIVE is always available
static private final int MIN_PROVIDER_COUNT = 2; // PASSIVE is always available
@NonNull
final private NativeLocationListener mNativeLocationListener = new NativeLocationListener();

View file

@ -46,9 +46,9 @@ public class StoragePathFragment extends BaseSettingsFragment
mAdapter = new StoragePathAdapter(mPathManager, requireActivity());
mHeader = root.findViewById(R.id.header);
ListView mList = root.findViewById(R.id.list);
mList.setOnItemClickListener((parent, view, position, id) -> changeStorage(position));
mList.setAdapter(mAdapter);
final ListView list = root.findViewById(R.id.list);
list.setOnItemClickListener((parent, view, position, id) -> changeStorage(position));
list.setAdapter(mAdapter);
return root;
}

View file

@ -71,7 +71,7 @@ public class PlacePhoneAdapter extends RecyclerView.Adapter<PlacePhoneAdapter.Vi
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener
{
private TextView mPhone;
private final TextView mPhone;
public ViewHolder(@NonNull View itemView)
{

View file

@ -100,7 +100,7 @@ public class SharingUtils
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
final String text = context.getString(R.string.share_bookmarks_email_body);
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
intent.putExtra(Intent.EXTRA_TEXT, text);
final Uri fileUri = StorageUtils.getUriForFilePath(context, fileName);
intent.putExtra(android.content.Intent.EXTRA_STREAM, fileUri);

View file

@ -108,7 +108,7 @@ public class StorageUtils
/**
* Copy data from a URI into a local file.
* @param resolve content resolver
* @param resolver content resolver
* @param from a source URI.
* @param to a destination file
* @return true on success and false if the provider recently crashed.