Browse Source

fix shortcode null problem

legacy
Austin Huang 4 years ago
parent
commit
ac8ccec703
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 68
      app/src/main/java/awais/instagrabber/activities/PostViewer.java

68
app/src/main/java/awais/instagrabber/activities/PostViewer.java

@ -206,21 +206,6 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.mediaList.setVisibility(View.VISIBLE); viewerBinding.mediaList.setVisibility(View.VISIBLE);
} }
final View viewStoryPost = findViewById(R.id.viewStoryPost);
if (viewStoryPost != null) {
viewStoryPost.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (profileModel.isPrivate())
Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+postModel.getShortCode());
startActivity(Intent.createChooser(sharingIntent,
(profileModel.isPrivate()) ? getString(R.string.share_private_post) : getString(R.string.share_public_post)));
}
});
}
viewerCaptionParent.setOnTouchListener(gestureTouchListener); viewerCaptionParent.setOnTouchListener(gestureTouchListener);
viewerBinding.playerView.setOnTouchListener(gestureTouchListener); viewerBinding.playerView.setOnTouchListener(gestureTouchListener);
viewerBinding.imageViewer.setOnSingleFlingListener((e1, e2, velocityX, velocityY) -> { viewerBinding.imageViewer.setOnSingleFlingListener((e1, e2, velocityX, velocityY) -> {
@ -237,7 +222,7 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.bottomPanel.commentsCount.setText(String.valueOf(commentsCount)); viewerBinding.bottomPanel.commentsCount.setText(String.valueOf(commentsCount));
viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE); viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE);
postShortCode = postModel.getShortCode();
postShortCode = result[0].getShortCode();
viewerBinding.bottomPanel.btnComments.setOnClickListener(v -> viewerBinding.bottomPanel.btnComments.setOnClickListener(v ->
startActivityForResult(new Intent(this, CommentsViewer.class) startActivityForResult(new Intent(this, CommentsViewer.class)
@ -291,21 +276,6 @@ public final class PostViewer extends BaseLanguageActivity {
resources = getResources(); resources = getResources();
final View viewStoryPost = findViewById(R.id.viewStoryPost);
if (viewStoryPost != null) {
viewStoryPost.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (profileModel.isPrivate())
Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+postShortCode);
startActivity(Intent.createChooser(sharingIntent,
(profileModel.isPrivate()) ? getString(R.string.share_private_post) : getString(R.string.share_public_post)));
}
});
}
viewerBinding.topPanel.title.setMovementMethod(new LinkMovementMethod()); viewerBinding.topPanel.title.setMovementMethod(new LinkMovementMethod());
viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag) -> viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag) ->
onClickListener.onClick(viewerBinding.topPanel.ivProfilePic)); onClickListener.onClick(viewerBinding.topPanel.ivProfilePic));
@ -332,7 +302,6 @@ public final class PostViewer extends BaseLanguageActivity {
new String[]{resources.getString(R.string.open_profile), resources.getString(R.string.view_pfp)}); new String[]{resources.getString(R.string.open_profile), resources.getString(R.string.view_pfp)});
postModel.setPosition(intent.getIntExtra(Constants.EXTRAS_INDEX, -1)); postModel.setPosition(intent.getIntExtra(Constants.EXTRAS_INDEX, -1));
postShortCode = postModel.getShortCode();
final boolean postIdNull = postModel.getPostId() == null; final boolean postIdNull = postModel.getPostId() == null;
if (!postIdNull) if (!postIdNull)
@ -442,12 +411,14 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.playerView.setVisibility(View.VISIBLE); viewerBinding.playerView.setVisibility(View.VISIBLE);
viewerBinding.bottomPanel.btnDownload.setVisibility(View.VISIBLE); viewerBinding.bottomPanel.btnDownload.setVisibility(View.VISIBLE);
viewerBinding.bottomPanel.btnMute.setVisibility(View.VISIBLE); viewerBinding.bottomPanel.btnMute.setVisibility(View.VISIBLE);
viewsContainer.setVisibility(View.VISIBLE);
viewerBinding.progressView.setVisibility(View.GONE); viewerBinding.progressView.setVisibility(View.GONE);
viewerBinding.imageViewer.setVisibility(View.GONE); viewerBinding.imageViewer.setVisibility(View.GONE);
viewerBinding.imageViewer.setImageDrawable(null); viewerBinding.imageViewer.setImageDrawable(null);
viewerBinding.bottomPanel.tvVideoViews.setText(String.valueOf(viewerPostModel.getVideoViews()));
if (viewerPostModel.getVideoViews() > -1) {
viewsContainer.setVisibility(View.VISIBLE);
viewerBinding.bottomPanel.tvVideoViews.setText(String.valueOf(viewerPostModel.getVideoViews()));
}
player = new SimpleExoPlayer.Builder(this).build(); player = new SimpleExoPlayer.Builder(this).build();
viewerBinding.playerView.setPlayer(player); viewerBinding.playerView.setPlayer(player);
@ -588,7 +559,6 @@ public final class PostViewer extends BaseLanguageActivity {
} }
private void refreshPost() { private void refreshPost() {
postShortCode = postModel.getShortCode();
if (containerLayoutParams.weight != 3.3f) { if (containerLayoutParams.weight != 3.3f) {
containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f; containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f;
viewerBinding.container.setLayoutParams(containerLayoutParams); viewerBinding.container.setLayoutParams(containerLayoutParams);
@ -612,11 +582,7 @@ public final class PostViewer extends BaseLanguageActivity {
if (Utils.hasMentions(postCaption)) { if (Utils.hasMentions(postCaption)) {
viewerBinding.bottomPanel.viewerCaption.setText(Utils.getMentionText(postCaption), TextView.BufferType.SPANNABLE); viewerBinding.bottomPanel.viewerCaption.setText(Utils.getMentionText(postCaption), TextView.BufferType.SPANNABLE);
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener((view, text, isHashtag) ->
new AlertDialog.Builder(PostViewer.this).setTitle(text)
.setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok,
(dialog, which) -> searchUsername(text)).show());
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener((view, text, isHashtag) -> searchUsername(text));
} else { } else {
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener(null); viewerBinding.bottomPanel.viewerCaption.setMentionClickListener(null);
viewerBinding.bottomPanel.viewerCaption.setText(postCaption); viewerBinding.bottomPanel.viewerCaption.setText(postCaption);
@ -711,6 +677,21 @@ public final class PostViewer extends BaseLanguageActivity {
return false; return false;
} }
}).into(viewerBinding.topPanel.ivProfilePic); }).into(viewerBinding.topPanel.ivProfilePic);
final View viewStoryPost = findViewById(R.id.viewStoryPost);
if (viewStoryPost != null) {
viewStoryPost.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (result.isPrivate())
Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+postShortCode);
startActivity(Intent.createChooser(sharingIntent,
(result.isPrivate()) ? getString(R.string.share_private_post) : getString(R.string.share_public_post)));
}
});
}
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
prevUsername = from; prevUsername = from;
@ -735,12 +716,7 @@ public final class PostViewer extends BaseLanguageActivity {
else { else {
viewerBinding.topPanel.location.setVisibility(View.VISIBLE); viewerBinding.topPanel.location.setVisibility(View.VISIBLE);
viewerBinding.topPanel.location.setText(location.optString("name")); viewerBinding.topPanel.location.setText(location.optString("name"));
viewerBinding.topPanel.location.setOnClickListener(v ->
new AlertDialog.Builder(PostViewer.this).setTitle(location.optString("name"))
.setMessage(R.string.comment_view_mention_location_search)
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok,
(dialog, which) -> searchUsername(location.optString("id")+"/"+location.optString("slug"))).show()
);
viewerBinding.topPanel.location.setOnClickListener(v -> searchUsername(location.optString("id")+"/"+location.optString("slug")));
viewerBinding.topPanel.title.setLayoutParams(new RelativeLayout.LayoutParams( viewerBinding.topPanel.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT
)); ));

Loading…
Cancel
Save