fix id-load logic & location suggestions

This commit is contained in:
Austin Huang 2020-09-26 21:02:31 -04:00
parent 192d91f877
commit 6393bbc02b
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
8 changed files with 9 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.cursoradapter.widget.CursorAdapter;
import awais.instagrabber.R;
import awais.instagrabber.databinding.ItemSuggestionBinding;
import awais.instagrabber.models.enums.SuggestionType;
@ -38,7 +39,7 @@ public final class SuggestionsAdapter extends CursorAdapter {
// 0, 1 , 2 , 3 , 4 , 5
final String fullName = cursor.getString(2);
String username = cursor.getString(1);
final String picUrl = cursor.getString(4);
String picUrl = cursor.getString(4);
final boolean verified = cursor.getString(5).charAt(0) == 't';
final String type = cursor.getString(3);
@ -61,6 +62,7 @@ public final class SuggestionsAdapter extends CursorAdapter {
break;
case TYPE_LOCATION:
query = fullName;
picUrl = "res:/" + R.drawable.ic_location;
break;
default:
return; // will never come here

View File

@ -233,7 +233,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (postModels == null || postModels.size() == 0) return;
if (postModels.get(0) == null) return;
final String postId = postModels.get(0).getPostId();
final boolean isId = postId != null;
final boolean isId = postId != null && isLoggedIn;
final String[] idsOrShortCodes = new String[postModels.size()];
for (int i = 0; i < postModels.size(); i++) {
idsOrShortCodes[i] = isId ? postModels.get(i).getPostId()

View File

@ -236,7 +236,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
if (postModels == null || postModels.size() == 0) return;
if (postModels.get(0) == null) return;
final String postId = postModels.get(0).getPostId();
final boolean isId = postId != null;
final boolean isId = postId != null && isLoggedIn;
final String[] idsOrShortCodes = new String[postModels.size()];
for (int i = 0; i < postModels.size(); i++) {
idsOrShortCodes[i] = isId ? postModels.get(i).getPostId()

View File

@ -168,8 +168,7 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment {
if (context == null) return null;
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
preference.setKey(Constants.DOWNLOAD_USER_FOLDER);
preference.setTitle("Download to username folder");
preference.setSummary(R.string.download_user_folder);
preference.setTitle(R.string.download_user_folder);
preference.setIconSpaceReserved(false);
return preference;
}

View File

@ -69,6 +69,7 @@ public final class CookieUtils {
@Nullable
private static String getCookieValue(final String cookies, final String name) {
if (cookies == null) return null;
final Pattern pattern = Pattern.compile(name + "=(.+?);");
final Matcher matcher = pattern.matcher(cookies);
if (matcher.find()) {

View File

@ -66,7 +66,7 @@ public class NavigationExtensions {
// throw new RuntimeException("null cannot be cast to non-null NavHostFragment");
}
final NavHostFragment selectedFragment = (NavHostFragment) fragment;
if (!firstFragmentTag.equals(newlySelectedItemTag)) {
if (firstFragmentTag != null && !firstFragmentTag.equals(newlySelectedItemTag)) {
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction()
.setCustomAnimations(

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -34,7 +34,7 @@
<string name="title_changelog">Changelog</string>
<string name="bottom_toolbar">Show toolbar at bottom</string>
<string name="update_check">Check for updates at startup</string>
<string name="download_user_folder">Download posts to username folder in Downloads</string>
<string name="download_user_folder">Download posts to username folders</string>
<string name="autoload_posts">Auto-load all posts from user</string>
<string name="mark_as_seen_setting">Mark stories as seen after viewing</string>
<string name="mark_as_seen_setting_summary">Story author will know you viewed it</string>