Merge pull request #718 from nextcloud/fix-search-crash

Fix crashes
This commit is contained in:
Andy Scherzinger 2017-03-05 18:55:24 +01:00 committed by GitHub
commit 20bb144533
3 changed files with 19 additions and 10 deletions

View file

@ -20,8 +20,8 @@
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owncloud.android" package="com.owncloud.android"
android:versionCode="10040202" android:versionCode="10040203"
android:versionName="1.4.2 RC2"> android:versionName="1.4.2 RC3">
<uses-sdk <uses-sdk
android:minSdkVersion="14" android:minSdkVersion="14"

View file

@ -466,12 +466,14 @@ public class FileDisplayActivity extends HookActivity
* @param fragment New second Fragment to set. * @param fragment New second Fragment to set.
*/ */
private void setSecondFragment(Fragment fragment) { private void setSecondFragment(Fragment fragment) {
searchView.post(new Runnable() { if (searchView != null) {
@Override searchView.post(new Runnable() {
public void run() { @Override
searchView.setQuery("", true); public void run() {
} searchView.setQuery("", true);
}); }
});
}
setDrawerIndicatorEnabled(false); setDrawerIndicatorEnabled(false);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.right_fragment_container, fragment, TAG_SECOND_FRAGMENT); transaction.replace(R.id.right_fragment_container, fragment, TAG_SECOND_FRAGMENT);

View file

@ -21,6 +21,7 @@
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
@ -268,8 +269,14 @@ public class ExtendedListFragment extends Fragment
searchView.clearFocus(); searchView.clearFocus();
} }
} else { } else {
if (getActivity() != null) { Activity activity;
((FileDisplayActivity) getActivity()).refreshListOfFilesFragment(true); if ((activity = getActivity()) != null) {
if (activity instanceof FileDisplayActivity) {
((FileDisplayActivity) activity).refreshListOfFilesFragment(true);
} else {
LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) mAdapter;
localFileListAdapter.filter(query);
}
} }
} }