aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-10-22 17:52:46 -0700
committerScott Jackson <daneren2005@gmail.com>2015-10-22 17:52:46 -0700
commitdf00e0bfc68d6334908451f7e378b05accc535ea (patch)
tree757b7d42376797b77f942eea6cd644c487657037 /app/src/main/java/github
parent3574d83adec4e418ea71bf5721a1779e77c37ccb (diff)
downloaddsub-df00e0bfc68d6334908451f7e378b05accc535ea.tar.gz
dsub-df00e0bfc68d6334908451f7e378b05accc535ea.tar.bz2
dsub-df00e0bfc68d6334908451f7e378b05accc535ea.zip
Fix broken preference saving on Admin tab
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java7
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectGenreFragment.java6
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectVideoFragment.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectYearFragment.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SimilarArtistFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/UserFragment.java10
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/UserUtil.java25
13 files changed, 44 insertions, 37 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
index cd294161..70a8d190 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -11,13 +11,11 @@ import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
-import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.MenuItem;
-import android.widget.AdapterView;
import android.net.Uri;
import android.view.ViewGroup;
import github.daneren2005.dsub.R;
@@ -143,7 +141,7 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O
}
@Override
- public void onItemClicked(Serializable item) {
+ public void onItemClicked(UpdateView<Serializable> updateView, Serializable item) {
Log.d(TAG, item.getClass().getSimpleName());
if (item instanceof Artist) {
onArtistSelected((Artist) item, false);
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index 4599d3cb..db0aa9a8 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -3,15 +3,12 @@ package github.daneren2005.dsub.fragments;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
-import android.util.Log;
-import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
import android.widget.LinearLayout;
import github.daneren2005.dsub.R;
@@ -92,7 +89,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Artist> impleme
}
@Override
- public void onItemClicked(Artist artist) {
+ public void onItemClicked(UpdateView<Artist> updateView, Artist artist) {
SubsonicFragment fragment;
if((Util.isFirstLevelArtist(context) || Util.isOffline(context) || Util.isTagBrowsing(context)) || "root".equals(artist.getId()) || groupId != null) {
fragment = new SelectDirectoryFragment();
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index ceca2bff..5f3ca38b 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -18,13 +18,10 @@
*/
package github.daneren2005.dsub.fragments;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
+
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.adapter.SectionAdapter;
import github.daneren2005.dsub.domain.Bookmark;
@@ -86,7 +83,7 @@ public class SelectBookmarkFragment extends SelectRecyclerFragment<MusicDirector
}
@Override
- public void onItemClicked(final MusicDirectory.Entry bookmark) {
+ public void onItemClicked(UpdateView<MusicDirectory.Entry> updateView, final MusicDirectory.Entry bookmark) {
final DownloadService downloadService = getDownloadService();
if(downloadService == null) {
return;
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 2db10c2e..a1129a45 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -356,7 +356,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
@Override
- public void onItemClicked(Entry entry) {
+ public void onItemClicked(UpdateView<Entry> updateView, Entry entry) {
if (entry.isDirectory()) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectGenreFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectGenreFragment.java
index cb57c280..8cbc273c 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectGenreFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectGenreFragment.java
@@ -19,9 +19,7 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
+
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.adapter.SectionAdapter;
import github.daneren2005.dsub.domain.Genre;
@@ -57,7 +55,7 @@ public class SelectGenreFragment extends SelectRecyclerFragment<Genre> {
}
@Override
- public void onItemClicked(Genre genre) {
+ public void onItemClicked(UpdateView<Genre> updateView, Genre genre) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, "genres");
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 793e0877..6e2c9da5 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -5,8 +5,6 @@ import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
-import android.support.v7.widget.RecyclerView;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -173,7 +171,7 @@ public class SelectPlaylistFragment extends SelectRecyclerFragment<Playlist> {
}
@Override
- public void onItemClicked(Playlist playlist) {
+ public void onItemClicked(UpdateView<Playlist> updateView, Playlist playlist) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index 381453c0..815b3c41 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -17,7 +17,6 @@ package github.daneren2005.dsub.fragments;
import android.support.v7.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -123,7 +122,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<PodcastChanne
}
@Override
- public void onItemClicked(PodcastChannel channel) {
+ public void onItemClicked(UpdateView<PodcastChannel> updateView, PodcastChannel channel) {
if("error".equals(channel.getStatus())) {
Util.toast(context, context.getResources().getString(R.string.select_podcasts_invalid_podcast_channel, channel.getErrorMessage() == null ? "error" : channel.getErrorMessage()));
} else if("downloading".equals(channel.getStatus())) {
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java
index 65723618..cb0e48b9 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java
@@ -18,7 +18,6 @@ package github.daneren2005.dsub.fragments;
import android.support.v7.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -95,7 +94,7 @@ public class SelectShareFragment extends SelectRecyclerFragment<Share> {
}
@Override
- public void onItemClicked(Share share) {
+ public void onItemClicked(UpdateView<Share> updateView, Share share) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putSerializable(Constants.INTENT_EXTRA_NAME_SHARE, share);
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectVideoFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectVideoFragment.java
index 0a79b3d5..a09125ff 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectVideoFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectVideoFragment.java
@@ -15,12 +15,9 @@
package github.daneren2005.dsub.fragments;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
import java.util.List;
@@ -57,7 +54,7 @@ public class SelectVideoFragment extends SelectRecyclerFragment<MusicDirectory.E
}
@Override
- public void onItemClicked(MusicDirectory.Entry entry) {
+ public void onItemClicked(UpdateView<MusicDirectory.Entry> updateView, MusicDirectory.Entry entry) {
playVideo(entry);
}
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectYearFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectYearFragment.java
index 22676d8b..3e5883d6 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectYearFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectYearFragment.java
@@ -19,9 +19,6 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -69,7 +66,7 @@ public class SelectYearFragment extends SelectRecyclerFragment<String> {
}
@Override
- public void onItemClicked(String decade) {
+ public void onItemClicked(UpdateView<String> updateView, String decade) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, "years");
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SimilarArtistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SimilarArtistFragment.java
index 5677e445..93e3a93a 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SimilarArtistFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SimilarArtistFragment.java
@@ -92,7 +92,7 @@ public class SimilarArtistFragment extends SelectRecyclerFragment<Artist> {
}
@Override
- public void onItemClicked(Artist artist) {
+ public void onItemClicked(UpdateView<Artist> updateView, Artist artist) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/UserFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/UserFragment.java
index bdd0472b..dab104bd 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/UserFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/UserFragment.java
@@ -78,7 +78,7 @@ public class UserFragment extends SelectRecyclerFragment<User.Setting>{
@Override
public SectionAdapter<User.Setting> getAdapter(List<User.Setting> objs) {
- return new SettingsAdapter(context, user, getImageLoader(), UserUtil.isCurrentAdmin() && ServerInfo.checkServerVersion(context, "1.10"));
+ return new SettingsAdapter(context, user, getImageLoader(), UserUtil.isCurrentAdmin() && ServerInfo.checkServerVersion(context, "1.10"), this);
}
@Override
@@ -93,8 +93,12 @@ public class UserFragment extends SelectRecyclerFragment<User.Setting>{
}
@Override
- public void onItemClicked(User.Setting item) {
-
+ public void onItemClicked(UpdateView<User.Setting> updateView, User.Setting item) {
+ if(updateView.isCheckable()) {
+ boolean newValue = !item.getValue();
+ item.setValue(newValue);
+ updateView.setChecked(newValue);
+ }
}
@Override
diff --git a/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java b/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java
index d758c4c9..e5388d72 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java
@@ -24,6 +24,9 @@ import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
@@ -40,6 +43,7 @@ import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.service.OfflineException;
import github.daneren2005.dsub.service.ServerTooOldException;
import github.daneren2005.dsub.adapter.SettingsAdapter;
+import github.daneren2005.dsub.view.UpdateView;
public final class UserUtil {
private static final String TAG = UserUtil.class.getSimpleName();
@@ -385,7 +389,26 @@ public final class UserUtil {
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
- recyclerView.setAdapter(new SettingsAdapter(context, user, null, true));
+ recyclerView.setAdapter(new SettingsAdapter(context, user, null, true, new SectionAdapter.OnItemClickedListener<User.Setting>() {
+ @Override
+ public void onItemClicked(UpdateView<User.Setting> updateView, User.Setting item) {
+ if(updateView.isCheckable()) {
+ boolean newValue = !item.getValue();
+ item.setValue(newValue);
+ updateView.setChecked(newValue);
+ }
+ }
+
+ @Override
+ public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView<User.Setting> updateView, User.Setting item) {
+
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem menuItem, UpdateView<User.Setting> updateView, User.Setting item) {
+ return false;
+ }
+ }));
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.menu_add_user)