Browse Source

Fix profile, location view when logged out

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
e1a13c7eee
  1. 6
      app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
  2. 11
      app/src/main/java/awais/instagrabber/utils/Utils.java
  3. 11
      app/src/main/res/navigation/profile_nav_graph.xml

6
app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java

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

11
app/src/main/java/awais/instagrabber/utils/Utils.java

@ -77,7 +77,6 @@ import awais.instagrabber.asyncs.PostFetcher;
import awais.instagrabber.customviews.CommentMentionClickSpan;
import awais.instagrabber.databinding.DialogImportExportBinding;
import awais.instagrabber.models.BasePostModel;
import awais.instagrabber.models.IntentModel;
import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.models.StoryModel;
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.DownloadMethod;
import awais.instagrabber.models.enums.InboxReadState;
import awais.instagrabber.models.enums.IntentModelType;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.NotificationType;
import awais.instagrabber.models.enums.RavenExpiringMediaType;
@ -1023,8 +1021,10 @@ public final class Utils {
try {
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 extension = displayUrl.substring(index - 4, index);
@ -1428,8 +1428,7 @@ public final class Utils {
u = random.nextLong() >>> 1) // retry
;
r += origin;
}
else { // range not representable as long
} else { // range not representable as long
while (r < origin || r >= bound)
r = random.nextLong();
}

11
app/src/main/res/navigation/profile_nav_graph.xml

@ -44,6 +44,17 @@
app:nullable="false" />
</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
android:id="@+id/profileFragment"
android:name="awais.instagrabber.fragments.main.ProfileFragment"

Loading…
Cancel
Save