Changed from DialogFragment to MaterialDialog

This commit is contained in:
José Padarian 2020-04-14 09:35:00 +10:00
parent f70a0551b4
commit 6b56e914b3
2 changed files with 4 additions and 46 deletions

View File

@ -1,7 +1,6 @@
package com.readrops.app.activities; package com.readrops.app.activities;
import android.Manifest; import android.Manifest;
import android.app.DialogFragment;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -40,7 +39,6 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.readrops.app.R; import com.readrops.app.R;
import com.readrops.app.fragments.ImageCaptionFragment;
import com.readrops.readropsdb.entities.Item; import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.pojo.ItemWithFeed; import com.readrops.readropsdb.pojo.ItemWithFeed;
import com.readrops.app.utils.DateUtils; import com.readrops.app.utils.DateUtils;
@ -315,9 +313,10 @@ public class ItemActivity extends AppCompatActivity {
imageTitle = ""; imageTitle = "";
} }
} }
MaterialDialog.Builder captionBuilder = new MaterialDialog.Builder(this);
DialogFragment newFragment = ImageCaptionFragment.newInstance(urlToDownload, imageTitle); captionBuilder.title(urlToDownload);
newFragment.show(getFragmentManager(), "dialog"); captionBuilder.content(imageTitle);
captionBuilder.show();
break; break;
default: default:
throw new IllegalStateException("Unexpected value: " + position); throw new IllegalStateException("Unexpected value: " + position);

View File

@ -1,41 +0,0 @@
package com.readrops.app.fragments;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import com.readrops.app.R;
public class ImageCaptionFragment extends DialogFragment {
public static ImageCaptionFragment newInstance(CharSequence title, CharSequence message) {
ImageCaptionFragment f = new ImageCaptionFragment();
Bundle args = new Bundle();
args.putCharSequence("title", title);
args.putCharSequence("message", message);
f.setArguments(args);
return f;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
CharSequence title = getArguments().getCharSequence("title");
CharSequence message = getArguments().getCharSequence("message");
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(title);
builder.setMessage(message);
builder.setNegativeButton(R.string.back, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
return builder.create();
}
}