mirror of
https://github.com/readrops/Readrops.git
synced 2025-02-09 08:28:39 +01:00
change edit feed dialog to dialog fragment with an alert dialog
This commit is contained in:
parent
706861a825
commit
3b4f6fe9f0
@ -2,6 +2,7 @@ package com.readrops.app.activities;
|
||||
|
||||
import android.arch.lifecycle.ViewModelProvider;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -55,8 +56,10 @@ public class ManageFeedsActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void openEditFeedDialog(FeedWithFolder feedWithFolder) {
|
||||
EditFeedDialog editFeedDialog = new EditFeedDialog(this, feedWithFolder);
|
||||
editFeedDialog.show();
|
||||
EditFeedDialog editFeedDialog = new EditFeedDialog();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
transaction.add(editFeedDialog, "").commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,14 +1,18 @@
|
||||
package com.readrops.app.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.arch.lifecycle.ViewModelProvider;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
|
||||
@ -17,7 +21,7 @@ import com.readrops.app.database.entities.Feed;
|
||||
import com.readrops.app.database.pojo.FeedWithFolder;
|
||||
import com.readrops.app.viewmodels.ManageFeedsViewModel;
|
||||
|
||||
public class EditFeedDialog extends Dialog {
|
||||
public class EditFeedDialog extends DialogFragment {
|
||||
|
||||
private TextInputEditText feedName;
|
||||
private TextInputEditText feedUrl;
|
||||
@ -27,23 +31,25 @@ public class EditFeedDialog extends Dialog {
|
||||
private FeedWithFolder feedWithFolder;
|
||||
private ManageFeedsViewModel viewModel;
|
||||
|
||||
public EditFeedDialog(@NonNull Context context, FeedWithFolder feedWithFolder) {
|
||||
super(context);
|
||||
if (context instanceof Activity)
|
||||
setOwnerActivity((Activity) context);
|
||||
|
||||
this.feedWithFolder = feedWithFolder;
|
||||
viewModel = ViewModelProviders.of((FragmentActivity) getOwnerActivity()).get(ManageFeedsViewModel.class);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.edit_feed_layout);
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
viewModel = ViewModelProviders.of(getActivity()).get(ManageFeedsViewModel.class);
|
||||
View v = getActivity().getLayoutInflater().inflate(R.layout.edit_feed_layout, null);
|
||||
|
||||
feedName = findViewById(R.id.edit_feed_name_edit_text);
|
||||
feedUrl = findViewById(R.id.edit_feed_url_edit_text);
|
||||
folder = findViewById(R.id.edit_feed_folder_spinner);
|
||||
validate = findViewById(R.id.edit_feed_validate);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getString(R.string.edit_feed))
|
||||
.setPositiveButton(getString(R.string.validate), (dialog, which) -> {
|
||||
|
||||
});
|
||||
|
||||
builder.setView(v);
|
||||
|
||||
feedName = v.findViewById(R.id.edit_feed_name_edit_text);
|
||||
feedUrl = v.findViewById(R.id.edit_feed_url_edit_text);
|
||||
folder = v.findViewById(R.id.edit_feed_folder_spinner);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="?dialogPreferredPadding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/edit_feed_title"
|
||||
style="@style/RtlOverlay.DialogWindowTitle.AppCompat"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit_feed"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:padding="18dp">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/edit_feed_name_textinputlayout"
|
||||
android:layout_width="300dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_feed_title">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/edit_feed_name_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/feed_name" />
|
||||
android:hint="@string/feed_name"
|
||||
android:inputType="textUri"
|
||||
android:lines="1" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/edit_feed_url_textinputlayout"
|
||||
android:layout_width="300dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -45,27 +36,19 @@
|
||||
android:id="@+id/edit_feed_url_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/feed_url" />
|
||||
android:hint="@string/feed_url"
|
||||
android:inputType="textUri"
|
||||
android:lines="1"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/edit_feed_folder_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_feed_url_textinputlayout" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/edit_feed_validate"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/validate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edit_feed_folder_spinner" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user