aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-03-04 21:52:26 -0800
committerScott Jackson <daneren2005@gmail.com>2013-03-04 21:52:26 -0800
commit4848668247161273b64ec69a90bbd594e68ecb5c (patch)
treea0ebfb506f774d968ef09439ece8547a1949d483
parenta31c08a45adc84e9b6b7954f91eaa3d049964c45 (diff)
downloaddsub-4848668247161273b64ec69a90bbd594e68ecb5c.tar.gz
dsub-4848668247161273b64ec69a90bbd594e68ecb5c.tar.bz2
dsub-4848668247161273b64ec69a90bbd594e68ecb5c.zip
Get working refresh on MainFragment
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java48
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java2
2 files changed, 31 insertions, 19 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
index cdde2e77..1836bc9c 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -17,7 +17,10 @@ import github.daneren2005.dsub.util.MergeAdapter;
import github.daneren2005.dsub.util.Util;
import java.util.Arrays;
-public class MainFragment extends SubsonicTabFragment {
+public class MainFragment extends SubsonicTabFragment {
+ private View rootView;
+ private LayoutInflater inflater;
+
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
@@ -25,10 +28,31 @@ public class MainFragment extends SubsonicTabFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.main, container, false);
+ this.inflater = inflater;
+ this.rootView = inflater.inflate(R.layout.main, container, false);
loadSettings();
+ createLayout();
+
+ return rootView;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ protected void refresh() {
+ createLayout();
+ }
+
+ private void createLayout() {
View buttons = inflater.inflate(R.layout.main_buttons, null);
final View serverButton = buttons.findViewById(R.id.main_select_server);
@@ -44,13 +68,13 @@ public class MainFragment extends SubsonicTabFragment {
final View albumsFrequentButton = buttons.findViewById(R.id.main_albums_frequent);
final View albumsStarredButton = buttons.findViewById(R.id.main_albums_starred);
- final View dummyView = view.findViewById(R.id.main_dummy);
+ final View dummyView = rootView.findViewById(R.id.main_dummy);
int instance = Util.getActiveServer(context);
String name = Util.getServerName(context, instance);
serverTextView.setText(name);
- ListView list = (ListView) view.findViewById(R.id.main_list);
+ ListView list = (ListView) rootView.findViewById(R.id.main_list);
MergeAdapter adapter = new MergeAdapter();
if (!Util.isOffline(context)) {
@@ -86,18 +110,6 @@ public class MainFragment extends SubsonicTabFragment {
}
}
});
-
- return view;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
}
private void loadSettings() {
@@ -118,7 +130,7 @@ public class MainFragment extends SubsonicTabFragment {
}
private void toggleOffline() {
- Util.setOffline(this, !Util.isOffline(context));
- restart();
+ Util.setOffline(context, !Util.isOffline(context));
+ refresh();
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
index df98c710..7db43db5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
@@ -89,7 +89,7 @@ public class SubsonicTabFragment extends SherlockFragment {
context = activity;
}
- protected void restart() {
+ protected void refresh() {
}
}