Fix profile, location view when logged out

This commit is contained in:
Ammar Githam 2020-09-08 20:27:13 +09:00
parent 8ea82a1058
commit e1a13c7eee
3 changed files with 19 additions and 9 deletions

View File

@ -281,7 +281,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
username = fragmentArgs.getUsername(); username = fragmentArgs.getUsername();
setUsernameDelayed(); setUsernameDelayed();
} }
if (!isLoggedIn) { if (Utils.isEmpty(username) && !isLoggedIn) {
binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24); binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24);
binding.privatePage2.setText(R.string.no_acc); binding.privatePage2.setText(R.string.no_acc);
binding.privatePage.setVisibility(View.VISIBLE); binding.privatePage.setVisibility(View.VISIBLE);
@ -733,8 +733,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
final List<PostModel> postModels = postsViewModel.getList().getValue(); final List<PostModel> postModels = postsViewModel.getList().getValue();
if (postModels == null || postModels.size() == 0) return; if (postModels == null || postModels.size() == 0) return;
if (postModels.get(0) == null) return; if (postModels.get(0) == null) return;
final String postId = postModels.get(0).getPostId(); final String postId = isLoggedIn ? postModels.get(0).getPostId() : postModels.get(0).getShortCode();
final boolean isId = postId != null; final boolean isId = isLoggedIn && postId != null;
final String[] idsOrShortCodes = new String[postModels.size()]; final String[] idsOrShortCodes = new String[postModels.size()];
for (int i = 0; i < postModels.size(); i++) { for (int i = 0; i < postModels.size(); i++) {
idsOrShortCodes[i] = isId ? postModels.get(i).getPostId() idsOrShortCodes[i] = isId ? postModels.get(i).getPostId()

View File

@ -77,7 +77,6 @@ import awais.instagrabber.asyncs.PostFetcher;
import awais.instagrabber.customviews.CommentMentionClickSpan; import awais.instagrabber.customviews.CommentMentionClickSpan;
import awais.instagrabber.databinding.DialogImportExportBinding; import awais.instagrabber.databinding.DialogImportExportBinding;
import awais.instagrabber.models.BasePostModel; import awais.instagrabber.models.BasePostModel;
import awais.instagrabber.models.IntentModel;
import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.StoryModel;
import awais.instagrabber.models.direct_messages.DirectItemModel; import awais.instagrabber.models.direct_messages.DirectItemModel;
@ -86,7 +85,6 @@ import awais.instagrabber.models.direct_messages.InboxThreadModel;
import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.DownloadMethod;
import awais.instagrabber.models.enums.InboxReadState; import awais.instagrabber.models.enums.InboxReadState;
import awais.instagrabber.models.enums.IntentModelType;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.NotificationType; import awais.instagrabber.models.enums.NotificationType;
import awais.instagrabber.models.enums.RavenExpiringMediaType; import awais.instagrabber.models.enums.RavenExpiringMediaType;
@ -1023,8 +1021,10 @@ public final class Utils {
try { try {
final String displayUrl = model.getDisplayUrl(); final String displayUrl = model.getDisplayUrl();
final int index = displayUrl.indexOf('?'); int index = displayUrl.indexOf('?');
if (index < 0) {
return;
}
final String fileName = model.getPostId() + '_'; final String fileName = model.getPostId() + '_';
final String extension = displayUrl.substring(index - 4, index); final String extension = displayUrl.substring(index - 4, index);
@ -1428,8 +1428,7 @@ public final class Utils {
u = random.nextLong() >>> 1) // retry u = random.nextLong() >>> 1) // retry
; ;
r += origin; r += origin;
} } else { // range not representable as long
else { // range not representable as long
while (r < origin || r >= bound) while (r < origin || r >= bound)
r = random.nextLong(); r = random.nextLong();
} }

View File

@ -44,6 +44,17 @@
app:nullable="false" /> app:nullable="false" />
</action> </action>
<include app:graph="@navigation/location_nav_graph" />
<action
android:id="@+id/action_global_locationFragment"
app:destination="@id/location_nav_graph">
<argument
android:name="locationId"
app:argType="string"
app:nullable="false" />
</action>
<fragment <fragment
android:id="@+id/profileFragment" android:id="@+id/profileFragment"
android:name="awais.instagrabber.fragments.main.ProfileFragment" android:name="awais.instagrabber.fragments.main.ProfileFragment"