mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #245 from misaochan/prevent-orientation-crash
Prevent crash when screen config changes
This commit is contained in:
commit
7dd512b2d9
3 changed files with 23 additions and 5 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
# Wikimedia Commons for Android
|
# Wikimedia Commons for Android
|
||||||
|
|
||||||
|
##v1.27
|
||||||
|
- New feature: List of nearby places without photos
|
||||||
|
|
||||||
##v1.26
|
##v1.26
|
||||||
- Fixed bug with overwriting files when multiple images selected
|
- Fixed bug with overwriting files when multiple images selected
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="fr.free.nrw.commons"
|
package="fr.free.nrw.commons"
|
||||||
android:versionCode="44"
|
android:versionCode="45"
|
||||||
android:versionName="1.26" >
|
android:versionName="1.27" >
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -103,6 +105,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
lockScreenOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -120,11 +123,10 @@ public class NearbyListFragment extends ListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Place> result) {
|
protected void onPostExecute(List<Place> result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
unlockScreenOrientation();
|
||||||
|
|
||||||
mAdapter = new NearbyAdapter(getActivity(), places);
|
mAdapter = new NearbyAdapter(getActivity(), places);
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
ListView listview = (ListView) getView().findViewById(R.id.listview);
|
ListView listview = (ListView) getView().findViewById(R.id.listview);
|
||||||
listview.setAdapter(mAdapter);
|
listview.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
|
@ -153,6 +155,19 @@ public class NearbyListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void lockScreenOrientation() {
|
||||||
|
int currentOrientation = getResources().getConfiguration().orientation;
|
||||||
|
if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
|
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
} else {
|
||||||
|
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unlockScreenOrientation() {
|
||||||
|
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
}
|
||||||
|
|
||||||
private class NearbyAdapter extends ArrayAdapter<Place> {
|
private class NearbyAdapter extends ArrayAdapter<Place> {
|
||||||
|
|
||||||
public List<Place> placesList;
|
public List<Place> placesList;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue