Browse Source

Fix some codefactor warnings

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
732153f8bb
  1. 2
      app/src/main/java/awais/instagrabber/fragments/search/SearchCategoryFragment.java
  2. 3
      app/src/main/java/awais/instagrabber/fragments/search/SearchFragment.java
  3. 84
      app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java

2
app/src/main/java/awais/instagrabber/fragments/search/SearchCategoryFragment.java

@ -169,6 +169,8 @@ public class SearchCategoryFragment extends Fragment {
swipeRefreshLayout.setRefreshing(true); swipeRefreshLayout.setRefreshing(true);
} }
break; break;
default:
break;
} }
} }

3
app/src/main/java/awais/instagrabber/fragments/search/SearchFragment.java

@ -213,6 +213,8 @@ public class SearchFragment extends Fragment implements SearchCategoryFragment.O
bundle.putLong("locationId", searchItem.getPlace().getLocation().getPk()); bundle.putLong("locationId", searchItem.getPlace().getLocation().getPk());
navController.navigate(R.id.action_global_locationFragment, bundle); navController.navigate(R.id.action_global_locationFragment, bundle);
break; break;
default:
break;
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "onSearchItemClick: ", e); Log.e(TAG, "onSearchItemClick: ", e);
@ -237,6 +239,7 @@ public class SearchFragment extends Fragment implements SearchCategoryFragment.O
liveData.removeObserver(this); liveData.removeObserver(this);
break; break;
case LOADING: case LOADING:
default:
break; break;
} }
} }

84
app/src/main/java/awais/instagrabber/repositories/responses/search/SearchItem.java

@ -148,48 +148,6 @@ public class SearchItem {
return null; return null;
} }
@NonNull
private static User getUser(@NonNull final RecentSearch recentSearch) {
return new User(
Long.parseLong(recentSearch.getIgId()),
recentSearch.getUsername(),
recentSearch.getName(),
false,
recentSearch.getPicUrl(),
null, null, false, false, false, false, false,
null, null, 0, 0, 0, 0, null, null,
0, null, null, null, null, null, null
);
}
@NonNull
private static Hashtag getHashtag(@NonNull final RecentSearch recentSearch) {
return new Hashtag(
recentSearch.getIgId(),
recentSearch.getName(),
0,
null,
null
);
}
@NonNull
private static Place getPlace(@NonNull final RecentSearch recentSearch) {
final Location location = new Location(
Long.parseLong(recentSearch.getIgId()),
recentSearch.getName(),
recentSearch.getName(),
null, null, 0, 0
);
return new Place(
location,
recentSearch.getName(),
null,
null,
null
);
}
public static List<SearchItem> fromFavorite(final List<Favorite> favorites) { public static List<SearchItem> fromFavorite(final List<Favorite> favorites) {
if (favorites == null) { if (favorites == null) {
return Collections.emptyList(); return Collections.emptyList();
@ -225,6 +183,20 @@ public class SearchItem {
return searchItem; return searchItem;
} }
@NonNull
private static User getUser(@NonNull final RecentSearch recentSearch) {
return new User(
Long.parseLong(recentSearch.getIgId()),
recentSearch.getUsername(),
recentSearch.getName(),
false,
recentSearch.getPicUrl(),
null, null, false, false, false, false, false,
null, null, 0, 0, 0, 0, null, null,
0, null, null, null, null, null, null
);
}
@NonNull @NonNull
private static User getUser(@NonNull final Favorite favorite) { private static User getUser(@NonNull final Favorite favorite) {
return new User( return new User(
@ -239,6 +211,17 @@ public class SearchItem {
); );
} }
@NonNull
private static Hashtag getHashtag(@NonNull final RecentSearch recentSearch) {
return new Hashtag(
recentSearch.getIgId(),
recentSearch.getName(),
0,
null,
null
);
}
@NonNull @NonNull
private static Hashtag getHashtag(@NonNull final Favorite favorite) { private static Hashtag getHashtag(@NonNull final Favorite favorite) {
return new Hashtag( return new Hashtag(
@ -250,6 +233,23 @@ public class SearchItem {
); );
} }
@NonNull
private static Place getPlace(@NonNull final RecentSearch recentSearch) {
final Location location = new Location(
Long.parseLong(recentSearch.getIgId()),
recentSearch.getName(),
recentSearch.getName(),
null, null, 0, 0
);
return new Place(
location,
recentSearch.getName(),
null,
null,
null
);
}
@Nullable @Nullable
private static Place getPlace(@NonNull final Favorite favorite) { private static Place getPlace(@NonNull final Favorite favorite) {
try { try {

Loading…
Cancel
Save