mirror of https://github.com/readrops/Readrops.git
Add feedWithFolder argument to the add feed dialog to display and edit feed data
This commit is contained in:
parent
3b4f6fe9f0
commit
50ede215fb
|
@ -57,8 +57,12 @@ public class ManageFeedsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void openEditFeedDialog(FeedWithFolder feedWithFolder) {
|
private void openEditFeedDialog(FeedWithFolder feedWithFolder) {
|
||||||
EditFeedDialog editFeedDialog = new EditFeedDialog();
|
EditFeedDialog editFeedDialog = new EditFeedDialog();
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable("feedWithFolder", feedWithFolder);
|
||||||
|
editFeedDialog.setArguments(bundle);
|
||||||
|
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
transaction.add(editFeedDialog, "").commit();
|
transaction.add(editFeedDialog, "").commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.readrops.app.database.entities;
|
||||||
|
|
||||||
|
|
||||||
import android.arch.persistence.room.*;
|
import android.arch.persistence.room.*;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -11,7 +13,7 @@ import com.readrops.readropslibrary.localfeed.rss.RSSChannel;
|
||||||
import com.readrops.readropslibrary.localfeed.rss.RSSFeed;
|
import com.readrops.readropslibrary.localfeed.rss.RSSFeed;
|
||||||
|
|
||||||
@Entity(foreignKeys = @ForeignKey(entity = Folder.class, parentColumns = "id", childColumns = "folder_id"))
|
@Entity(foreignKeys = @ForeignKey(entity = Folder.class, parentColumns = "id", childColumns = "folder_id"))
|
||||||
public class Feed {
|
public class Feed implements Parcelable {
|
||||||
|
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
private int id;
|
private int id;
|
||||||
|
@ -54,6 +56,33 @@ public class Feed {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Feed(Parcel in) {
|
||||||
|
id = in.readInt();
|
||||||
|
name = in.readString();
|
||||||
|
description = in.readString();
|
||||||
|
url = in.readString();
|
||||||
|
siteUrl = in.readString();
|
||||||
|
lastUpdated = in.readString();
|
||||||
|
textColor = in.readInt();
|
||||||
|
backgroundColor = in.readInt();
|
||||||
|
iconUrl = in.readString();
|
||||||
|
etag = in.readString();
|
||||||
|
lastModified = in.readString();
|
||||||
|
folderId = in.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<Feed> CREATOR = new Creator<Feed>() {
|
||||||
|
@Override
|
||||||
|
public Feed createFromParcel(Parcel in) {
|
||||||
|
return new Feed(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Feed[] newArray(int size) {
|
||||||
|
return new Feed[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -203,4 +232,26 @@ public class Feed {
|
||||||
|
|
||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeInt(id);
|
||||||
|
dest.writeString(name);
|
||||||
|
dest.writeString(description);
|
||||||
|
dest.writeString(url);
|
||||||
|
dest.writeString(siteUrl);
|
||||||
|
dest.writeString(lastUpdated);
|
||||||
|
dest.writeInt(textColor);
|
||||||
|
dest.writeInt(backgroundColor);
|
||||||
|
dest.writeString(iconUrl);
|
||||||
|
dest.writeString(etag);
|
||||||
|
dest.writeString(lastModified);
|
||||||
|
dest.writeInt(folderId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,11 @@ package com.readrops.app.database.entities;
|
||||||
import android.arch.persistence.room.Entity;
|
import android.arch.persistence.room.Entity;
|
||||||
import android.arch.persistence.room.Ignore;
|
import android.arch.persistence.room.Ignore;
|
||||||
import android.arch.persistence.room.PrimaryKey;
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Folder {
|
public class Folder implements Parcelable {
|
||||||
|
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
private int id;
|
private int id;
|
||||||
|
@ -21,6 +23,13 @@ public class Folder {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Folder(Parcel in) {
|
||||||
|
id = in.readInt();
|
||||||
|
name = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -36,4 +45,27 @@ public class Folder {
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final Creator<Folder> CREATOR = new Creator<Folder>() {
|
||||||
|
@Override
|
||||||
|
public Folder createFromParcel(Parcel in) {
|
||||||
|
return new Folder(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Folder[] newArray(int size) {
|
||||||
|
return new Folder[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeInt(id);
|
||||||
|
dest.writeString(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.readrops.app.database.pojo;
|
package com.readrops.app.database.pojo;
|
||||||
|
|
||||||
import android.arch.persistence.room.Embedded;
|
import android.arch.persistence.room.Embedded;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.readrops.app.database.entities.Feed;
|
import com.readrops.app.database.entities.Feed;
|
||||||
import com.readrops.app.database.entities.Folder;
|
import com.readrops.app.database.entities.Folder;
|
||||||
|
|
||||||
public class FeedWithFolder {
|
public class FeedWithFolder implements Parcelable {
|
||||||
|
|
||||||
@Embedded(prefix = "feed_")
|
@Embedded(prefix = "feed_")
|
||||||
private Feed feed;
|
private Feed feed;
|
||||||
|
@ -13,6 +15,38 @@ public class FeedWithFolder {
|
||||||
@Embedded(prefix = "folder_")
|
@Embedded(prefix = "folder_")
|
||||||
private Folder folder;
|
private Folder folder;
|
||||||
|
|
||||||
|
public FeedWithFolder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FeedWithFolder(Parcel in) {
|
||||||
|
feed = in.readParcelable(Feed.class.getClassLoader());
|
||||||
|
folder = in.readParcelable(Folder.class.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeParcelable(feed, flags);
|
||||||
|
dest.writeParcelable(folder, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<FeedWithFolder> CREATOR = new Creator<FeedWithFolder>() {
|
||||||
|
@Override
|
||||||
|
public FeedWithFolder createFromParcel(Parcel in) {
|
||||||
|
return new FeedWithFolder(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeedWithFolder[] newArray(int size) {
|
||||||
|
return new FeedWithFolder[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public Feed getFeed() {
|
public Feed getFeed() {
|
||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
@ -28,4 +62,6 @@ public class FeedWithFolder {
|
||||||
public void setFolder(Folder folder) {
|
public void setFolder(Folder folder) {
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,20 +35,30 @@ public class EditFeedDialog extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||||
viewModel = ViewModelProviders.of(getActivity()).get(ManageFeedsViewModel.class);
|
viewModel = ViewModelProviders.of(getActivity()).get(ManageFeedsViewModel.class);
|
||||||
|
|
||||||
|
feedWithFolder = getArguments().getParcelable("feedWithFolder");
|
||||||
|
|
||||||
View v = getActivity().getLayoutInflater().inflate(R.layout.edit_feed_layout, null);
|
View v = getActivity().getLayoutInflater().inflate(R.layout.edit_feed_layout, null);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(getString(R.string.edit_feed))
|
.setTitle(getString(R.string.edit_feed))
|
||||||
.setPositiveButton(getString(R.string.validate), (dialog, which) -> {
|
.setPositiveButton(getString(R.string.validate), (dialog, which) -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setView(v);
|
builder.setView(v);
|
||||||
|
fillData(v);
|
||||||
|
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillData(View v) {
|
||||||
feedName = v.findViewById(R.id.edit_feed_name_edit_text);
|
feedName = v.findViewById(R.id.edit_feed_name_edit_text);
|
||||||
feedUrl = v.findViewById(R.id.edit_feed_url_edit_text);
|
feedUrl = v.findViewById(R.id.edit_feed_url_edit_text);
|
||||||
folder = v.findViewById(R.id.edit_feed_folder_spinner);
|
folder = v.findViewById(R.id.edit_feed_folder_spinner);
|
||||||
return builder.create();
|
|
||||||
|
feedName.setText(feedWithFolder.getFeed().getName());
|
||||||
|
feedUrl.setText(feedWithFolder.getFeed().getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue