Fix orientation change bug in ItemDescriptionFragment
This commit is contained in:
parent
7ae8c906c3
commit
33711e1657
|
@ -60,8 +60,7 @@
|
||||||
android:value=".activity.SearchActivity" />
|
android:value=".activity.SearchActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="de.danoeh.antennapod.activity.ItemviewActivity"
|
android:name="de.danoeh.antennapod.activity.ItemviewActivity" android:configChanges="keyboard|orientation"/>
|
||||||
android:configChanges="keyboardHidden|orientation" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="de.danoeh.antennapod.activity.DownloadActivity"
|
android:name="de.danoeh.antennapod.activity.DownloadActivity"
|
||||||
android:label="@string/downloads_label" />
|
android:label="@string/downloads_label" />
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ItemviewActivity extends SherlockFragmentActivity {
|
||||||
.beginTransaction();
|
.beginTransaction();
|
||||||
ItemDescriptionFragment fragment = ItemDescriptionFragment.newInstance(
|
ItemDescriptionFragment fragment = ItemDescriptionFragment.newInstance(
|
||||||
item);
|
item);
|
||||||
fragmentTransaction.add(R.id.description_fragment, fragment);
|
fragmentTransaction.replace(R.id.description_fragment, fragment);
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,29 +48,30 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Creating view");
|
||||||
webvDescription = new WebView(getActivity());
|
webvDescription = new WebView(getActivity());
|
||||||
webvDescription.getSettings().setUseWideViewPort(false);
|
webvDescription.getSettings().setUseWideViewPort(false);
|
||||||
|
|
||||||
return webvDescription;
|
return webvDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
if (webViewLoader == null && item != null) {
|
if (AppConfig.DEBUG)
|
||||||
webViewLoader = createLoader();
|
Log.d(TAG, "Fragment attached");
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
|
||||||
webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
} else {
|
|
||||||
webViewLoader.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Fragment detached");
|
||||||
if (webViewLoader != null) {
|
if (webViewLoader != null) {
|
||||||
webViewLoader.cancel(true);
|
webViewLoader.cancel(true);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,8 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Fragment destroyed");
|
||||||
if (webViewLoader != null) {
|
if (webViewLoader != null) {
|
||||||
webViewLoader.cancel(true);
|
webViewLoader.cancel(true);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +91,8 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Creating fragment");
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
FeedManager manager = FeedManager.getInstance();
|
FeedManager manager = FeedManager.getInstance();
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
|
@ -96,6 +101,17 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
if (feedId != -1 && itemId != -1) {
|
if (feedId != -1 && itemId != -1) {
|
||||||
Feed feed = manager.getFeed(feedId);
|
Feed feed = manager.getFeed(feedId);
|
||||||
item = manager.getFeedItem(itemId, feed);
|
item = manager.getFeedItem(itemId, feed);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, TAG + " was called with invalid arguments");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
if (item != null) {
|
||||||
webViewLoader = createLoader();
|
webViewLoader = createLoader();
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||||
webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
webViewLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
@ -103,9 +119,13 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
webViewLoader.execute();
|
webViewLoader.execute();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, TAG + " was called with invalid arguments");
|
Log.e(TAG, "Error in onViewCreated: Item was null");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncTask<Void, Void, Void> createLoader() {
|
private AsyncTask<Void, Void, Void> createLoader() {
|
||||||
|
@ -159,8 +179,6 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue