Commit 6164ed48 authored by Donald's avatar Donald

coming back?

parent 56ddcc60
......@@ -48,12 +48,16 @@ android {
resValue "string", "app_name", "LeafPic (debug)"
}
}
flavorDimensions "default"
productFlavors {
noGPlay {
//versionNameSuffix '-fdroid'
dimension "default"
}
withGPlay {
//signingConfig signingConfigs.GPlayConfig
dimension "default"
}
}
}
......
......@@ -58,12 +58,14 @@ public class AlbumsAdapter extends RecyclerView.Adapter<AlbumsAdapter.ViewHolder
private ThemeHelper theme;
private BitmapDrawable placeholder;
private CardViewStyle cvs;
Context context;
public AlbumsAdapter(Context context, SortingMode sortingMode, SortingOrder sortingOrder) {
albums = new ArrayList<>();
updateTheme(ThemeHelper.getThemeHelper(context));
this.sortingMode = sortingMode;
this.sortingOrder = sortingOrder;
this.context = context;
}
public void sort() {
......@@ -268,12 +270,16 @@ public class AlbumsAdapter extends RecyclerView.Adapter<AlbumsAdapter.ViewHolder
notifyDataSetChanged();
}
public void add(Album album) {
public int add(Album album) {
int i = Collections.binarySearch(
albums, album, AlbumsComparators.getComparator(sortingMode, sortingOrder));
if (i < 0) i = ~i;
albums.add(i, album);
notifyItemInserted(i);
//notifyDataSetChanged();
//int finalI = i;
//((ThemedActivity) context).runOnUiThread(() -> notifyItemInserted(finalI));
return i;
}
private void reverseOrder() {
......
......@@ -62,6 +62,7 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.ViewHolder>
updateTheme(ThemeHelper.getThemeHelper(context));
this.sortingMode = sortingMode;
this.sortingOrder = sortingOrder;
setHasStableIds(true);
}
public void sort() {
......@@ -76,6 +77,11 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.ViewHolder>
notifyDataSetChanged();
}
@Override
public long getItemId(int position) {
return media.get(position).getPath().hashCode() ^ 1312;
}
public SortingOrder sortingOrder() {
return sortingOrder;
}
......@@ -294,12 +300,16 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.ViewHolder>
notifyDataSetChanged();
}
public void add(Media album) {
public int add(Media album) {
int i = Collections.binarySearch(
media, album, MediaComparators.getComparator(sortingMode, sortingOrder));
if (i < 0) i = ~i;
media.add(i, album);
notifyItemInserted(i);
//notifyItemRangeInserted(0, media.size()-1);
//notifyItemInserted(i);
//notifyDataSetChanged();
return i;
}
@Override
......
......@@ -96,7 +96,10 @@ public class AlbumsFragment extends BaseFragment{
.subscribe(
album::setLastMedia,
throwable -> {},
() -> adapter.add(album)),
() ->{
int pos = adapter.add(album);
getActivity().runOnUiThread(() -> adapter.notifyItemInserted(pos));
}),
throwable -> refresh.setRefreshing(false),
() -> {
db.close();
......
......@@ -7,7 +7,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -101,10 +100,14 @@ public class RvMediaFragment extends BaseFragment {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.filter(media -> MediaFilter.getFilter(album.filterMode()).accept(media))
.subscribe(media -> adapter.add(media),
.subscribe(media ->{
int pos = adapter.add(media);
getActivity().runOnUiThread(() -> adapter.notifyItemInserted(pos));
},
throwable -> refresh.setRefreshing(false),
() -> {
act.nothingToShow(getCount() == 0);
//adapter.notifyItemRangeInserted(0, adapter.getItemCount());
refresh.setRefreshing(false);
});
......@@ -123,7 +126,8 @@ public class RvMediaFragment extends BaseFragment {
rv.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
rv.setHasFixedSize(true);
rv.setItemAnimator(new DefaultItemAnimator());
//rv.setItemAnimator(new DefaultItemAnimator());
rv.setItemAnimator(null);
adapter = new MediaAdapter(
getContext(), sortingMode(), sortingOrder());
......@@ -152,6 +156,8 @@ public class RvMediaFragment extends BaseFragment {
display();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
......
......@@ -5,16 +5,16 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha5'
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
project.ext {
supportVersion = "25.3.0"
sdkVersion = 25
buildToolsVersion = '25.0.2'
supportVersion = "25.3.1"
sdkVersion = 26
buildToolsVersion = '26.0.0'
}
allprojects {
......
#Sun Jan 29 21:20:49 CET 2017
#Sat Jun 24 22:18:35 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment