mirror of https://github.com/readrops/Readrops.git
Improve read items alpha visibility
This commit is contained in:
parent
51764a189e
commit
533294dbdb
|
@ -51,6 +51,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
|
@ -136,7 +137,6 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
}
|
||||
|
||||
private void handleDrawerClick(IDrawerItem drawerItem) {
|
||||
|
||||
if (drawerItem instanceof PrimaryDrawerItem) {
|
||||
drawer.closeDrawer();
|
||||
int id = (int)drawerItem.getIdentifier();
|
||||
|
@ -166,9 +166,9 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
viewModel.getFoldersWithFeeds()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new DisposableSingleObserver<HashMap<Folder, List<Feed>>>() {
|
||||
.subscribe(new DisposableSingleObserver<Map<Folder, List<Feed>>>() {
|
||||
@Override
|
||||
public void onSuccess(HashMap<Folder, List<Feed>> folderListHashMap) {
|
||||
public void onSuccess(Map<Folder, List<Feed>> folderListHashMap) {
|
||||
drawerManager.updateDrawer(getApplicationContext(), folderListHashMap);
|
||||
}
|
||||
|
||||
|
@ -323,8 +323,6 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
feedNb = feeds.size();
|
||||
sync(feeds);
|
||||
}
|
||||
|
||||
updateDrawerFeeds();
|
||||
} else if (requestCode == MANAGE_FEEDS_REQUEST) {
|
||||
updateDrawerFeeds();
|
||||
}
|
||||
|
@ -369,7 +367,9 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
|
||||
syncProgressLayout.setVisibility(View.GONE);
|
||||
refreshLayout.setRefreshing(false);
|
||||
|
||||
adapter.submitList(allItems);
|
||||
updateDrawerFeeds(); // update drawer after syncing feeds
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.os.Parcel;
|
|||
import android.os.Parcelable;
|
||||
|
||||
@Entity
|
||||
public class Folder implements Parcelable {
|
||||
public class Folder implements Parcelable, Comparable<Folder> {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
|
@ -68,4 +68,9 @@ public class Folder implements Parcelable {
|
|||
dest.writeInt(id);
|
||||
dest.writeString(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Folder o) {
|
||||
return this.getName().compareTo(o.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.readrops.app.utils.ParsingResult;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Observable;
|
||||
|
@ -45,10 +47,10 @@ public class MainViewModel extends AndroidViewModel {
|
|||
return repository.getFeedCount();
|
||||
}
|
||||
|
||||
public Single<HashMap<Folder, List<Feed>>> getFoldersWithFeeds() {
|
||||
public Single<Map<Folder, List<Feed>>> getFoldersWithFeeds() {
|
||||
return Single.create(emitter -> {
|
||||
List<Folder> folders = db.folderDao().getFolders();
|
||||
HashMap<Folder, List<Feed>> foldersWithFeeds = new HashMap<>();
|
||||
Map<Folder, List<Feed>> foldersWithFeeds = new TreeMap<>(Folder::compareTo);
|
||||
|
||||
for (Folder folder : folders) {
|
||||
List<Feed> feeds = db.feedDao().getFeedsByFolder(folder.getId());
|
||||
|
|
|
@ -98,6 +98,17 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
|
|||
ItemWithFeed itemWithFeed = getItem(i);
|
||||
viewHolder.bind(itemWithFeed);
|
||||
|
||||
View[] alphaViews = new View[] {
|
||||
viewHolder.dateLayout,
|
||||
viewHolder.itemFolderName,
|
||||
viewHolder.feedIcon,
|
||||
viewHolder.feedName,
|
||||
viewHolder.itemDescription,
|
||||
viewHolder.itemTitle,
|
||||
viewHolder.itemImage,
|
||||
viewHolder.itemReadTime,
|
||||
};
|
||||
|
||||
if (itemWithFeed.getItem().hasImage()) {
|
||||
viewHolder.itemImage.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -146,7 +157,10 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
|
|||
viewHolder.itemFolderName.setText(resources.getString(R.string.no_folder));
|
||||
|
||||
float alpha = itemWithFeed.getItem().isRead() ? 0.5f : 1.0f;
|
||||
viewHolder.itemView.setAlpha(alpha);
|
||||
for (View view : alphaViews) {
|
||||
view.setAlpha(alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue