Browse Source

add alert dialog for swipe up link - issue #1101

renovate/org.robolectric-robolectric-4.x
stamatiap 4 years ago
parent
commit
fdacd1b421
  1. 21
      app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

21
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

@ -3,6 +3,7 @@ package awais.instagrabber.fragments;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.DialogInterface;
import android.graphics.drawable.Animatable; import android.graphics.drawable.Animatable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -444,7 +445,27 @@ public class StoryViewerFragment extends Fragment {
binding.swipeUp.setOnClickListener(v -> { binding.swipeUp.setOnClickListener(v -> {
final Object tag = v.getTag(); final Object tag = v.getTag();
if (tag instanceof CharSequence) { if (tag instanceof CharSequence) {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
//Yes button clicked
Utils.openURL(context, tag.toString()); Utils.openURL(context, tag.toString());
break;
case DialogInterface.BUTTON_NEGATIVE:
//No button clicked
dialog.dismiss();
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Are you sure you want to open this link?");
builder.setMessage(tag.toString()).setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
} }
}); });
binding.viewStoryPost.setOnClickListener(v -> { binding.viewStoryPost.setOnClickListener(v -> {

Loading…
Cancel
Save