Compare commits

...

2 Commits

Author SHA1 Message Date
Jonas Kalderstam 1735899c9c Override both versions of onAttach
fixes #101
2016-08-03 19:16:32 +02:00
Jonas Kalderstam ce565e6e8a Update versions of support library and tools 2016-08-03 19:15:02 +02:00
3 changed files with 29 additions and 9 deletions

View File

@ -14,12 +14,12 @@ def gitCommitCount =
Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim()) Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
android { android {
compileSdkVersion 23 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion "23.0.3"
defaultConfig { defaultConfig {
minSdkVersion 9 minSdkVersion 9
targetSdkVersion 23 targetSdkVersion 24
versionCode gitCommitCount versionCode gitCommitCount
versionName gitTag versionName gitTag
} }
@ -27,9 +27,9 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0' compile 'com.android.support:recyclerview-v7:24.0.0'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
} }

View File

@ -6,9 +6,11 @@
package com.nononsenseapps.filepicker; package com.nononsenseapps.filepicker;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -350,9 +352,27 @@ public abstract class AbstractFilePickerFragment<T> extends Fragment
return checkable; return checkable;
} }
@SuppressWarnings("deprecation")
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
onAttachToContext(activity);
}
}
@TargetApi(23)
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);
onAttachToContext(context);
}
/**
* Called when attached to activity/context
* @param context we attached to
*/
protected void onAttachToContext(Context context) {
try { try {
mListener = (OnFilePickedListener) context; mListener = (OnFilePickedListener) context;
} catch (ClassCastException e) { } catch (ClassCastException e) {

View File

@ -11,8 +11,8 @@ def gitCommitCount =
Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim()) Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
android { android {
compileSdkVersion 23 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion "23.0.3"
packagingOptions { packagingOptions {
exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE.txt'
@ -25,7 +25,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 18 minSdkVersion 18
targetSdkVersion 23 targetSdkVersion 24
versionCode gitCommitCount versionCode gitCommitCount
versionName gitTag versionName gitTag
archivesBaseName = "nononsensefilepicker-sample-${gitTag}".toString() archivesBaseName = "nononsensefilepicker-sample-${gitTag}".toString()