mirror of https://github.com/readrops/Readrops.git
Use an unique key for feeds
This commit is contained in:
parent
bb4308e01f
commit
35d520169f
|
@ -42,6 +42,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
import static com.readrops.app.utils.ReadropsKeys.FEEDS;
|
||||||
|
|
||||||
public class AddFeedActivity extends AppCompatActivity implements View.OnClickListener {
|
public class AddFeedActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
|
||||||
private AccountArrayAdapter arrayAdapter;
|
private AccountArrayAdapter arrayAdapter;
|
||||||
|
@ -311,7 +313,7 @@ public class AddFeedActivity extends AppCompatActivity implements View.OnClickLi
|
||||||
public void finish() {
|
public void finish() {
|
||||||
if (!feedsToUpdate.isEmpty()) {
|
if (!feedsToUpdate.isEmpty()) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putParcelableArrayListExtra("feedIds", feedsToUpdate);
|
intent.putParcelableArrayListExtra(FEEDS, feedsToUpdate);
|
||||||
|
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static com.readrops.app.utils.ReadropsKeys.ACCOUNT;
|
import static com.readrops.app.utils.ReadropsKeys.ACCOUNT;
|
||||||
|
import static com.readrops.app.utils.ReadropsKeys.FEEDS;
|
||||||
import static com.readrops.app.utils.ReadropsKeys.IMAGE_URL;
|
import static com.readrops.app.utils.ReadropsKeys.IMAGE_URL;
|
||||||
import static com.readrops.app.utils.ReadropsKeys.ITEM_ID;
|
import static com.readrops.app.utils.ReadropsKeys.ITEM_ID;
|
||||||
import static com.readrops.app.utils.ReadropsKeys.SETTINGS;
|
import static com.readrops.app.utils.ReadropsKeys.SETTINGS;
|
||||||
|
@ -502,7 +503,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
if (requestCode == ADD_FEED_REQUEST && resultCode == RESULT_OK) {
|
if (requestCode == ADD_FEED_REQUEST && resultCode == RESULT_OK) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
ArrayList<Feed> feeds = data.getParcelableArrayListExtra("feedIds");
|
ArrayList<Feed> feeds = data.getParcelableArrayListExtra(FEEDS);
|
||||||
|
|
||||||
if (feeds != null && feeds.size() > 0 && viewModel.isAccountLocal()) {
|
if (feeds != null && feeds.size() > 0 && viewModel.isAccountLocal()) {
|
||||||
refreshLayout.setRefreshing(true);
|
refreshLayout.setRefreshing(true);
|
||||||
|
|
|
@ -13,6 +13,8 @@ import com.readrops.app.utils.feedscolors.FeedsColorsIntentService;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static com.readrops.app.utils.ReadropsKeys.FEEDS;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +30,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
database.feedDao().getAllFeeds().observe(getActivity(), feeds -> {
|
database.feedDao().getAllFeeds().observe(getActivity(), feeds -> {
|
||||||
if (!serviceStarted.get()) {
|
if (!serviceStarted.get()) {
|
||||||
Intent intent = new Intent(getContext(), FeedsColorsIntentService.class);
|
Intent intent = new Intent(getContext(), FeedsColorsIntentService.class);
|
||||||
intent.putParcelableArrayListExtra(FeedsColorsIntentService.FEEDS, new ArrayList<>(feeds));
|
intent.putParcelableArrayListExtra(FEEDS, new ArrayList<>(feeds));
|
||||||
|
|
||||||
getContext().startService(intent);
|
getContext().startService(intent);
|
||||||
serviceStarted.set(true);
|
serviceStarted.set(true);
|
||||||
|
|
|
@ -26,6 +26,8 @@ import io.reactivex.Completable;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
|
|
||||||
|
import static com.readrops.app.utils.ReadropsKeys.FEEDS;
|
||||||
|
|
||||||
public abstract class ARepository<T> {
|
public abstract class ARepository<T> {
|
||||||
|
|
||||||
protected Application application;
|
protected Application application;
|
||||||
|
@ -156,7 +158,7 @@ public abstract class ARepository<T> {
|
||||||
|
|
||||||
protected void setFeedsColors(List<Feed> feeds) {
|
protected void setFeedsColors(List<Feed> feeds) {
|
||||||
Intent intent = new Intent(application, FeedsColorsIntentService.class);
|
Intent intent = new Intent(application, FeedsColorsIntentService.class);
|
||||||
intent.putParcelableArrayListExtra(FeedsColorsIntentService.FEEDS, new ArrayList<>(feeds));
|
intent.putParcelableArrayListExtra(FEEDS, new ArrayList<>(feeds));
|
||||||
|
|
||||||
application.startService(intent);
|
application.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,6 @@ object ReadropsKeys {
|
||||||
|
|
||||||
const val WEB_URL = "WEB_URL_KEY"
|
const val WEB_URL = "WEB_URL_KEY"
|
||||||
const val ACTION_BAR_COLOR = "ACTION_BAR_COLOR_KEY"
|
const val ACTION_BAR_COLOR = "ACTION_BAR_COLOR_KEY"
|
||||||
|
|
||||||
|
const val FEEDS = "FEEDS"
|
||||||
}
|
}
|
|
@ -6,14 +6,15 @@ import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.readrops.app.R
|
import com.readrops.app.R
|
||||||
|
import com.readrops.app.ReadropsApp
|
||||||
import com.readrops.app.database.Database
|
import com.readrops.app.database.Database
|
||||||
import com.readrops.app.database.entities.Feed
|
import com.readrops.app.database.entities.Feed
|
||||||
import com.readrops.app.ReadropsApp
|
import com.readrops.app.utils.ReadropsKeys.FEEDS
|
||||||
|
|
||||||
class FeedsColorsIntentService : IntentService("FeedsColorsIntentService") {
|
class FeedsColorsIntentService : IntentService("FeedsColorsIntentService") {
|
||||||
|
|
||||||
override fun onHandleIntent(intent: Intent?) {
|
override fun onHandleIntent(intent: Intent?) {
|
||||||
val feeds: List<Feed> = intent!!.getParcelableArrayListExtra(FEEDS)
|
val feeds: List<Feed> = intent!!.getParcelableArrayListExtra(FEEDS)!!
|
||||||
val database = Database.getInstance(this)
|
val database = Database.getInstance(this)
|
||||||
|
|
||||||
val notificationBuilder = NotificationCompat.Builder(this, ReadropsApp.FEEDS_COLORS_CHANNEL_ID)
|
val notificationBuilder = NotificationCompat.Builder(this, ReadropsApp.FEEDS_COLORS_CHANNEL_ID)
|
||||||
|
@ -42,7 +43,6 @@ class FeedsColorsIntentService : IntentService("FeedsColorsIntentService") {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val NOTIFICATION_ID = 1
|
private const val NOTIFICATION_ID = 1
|
||||||
const val FEEDS = "feeds"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue