From dec7da96551b295c29eed70f85578c86276fddda Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Thu, 9 Nov 2017 14:35:52 +0100 Subject: [PATCH] upgrade to API Level 27, fix nullability problems with new support library --- app/build.gradle | 6 +++--- .../tusky/fragment/AccountMediaFragment.kt | 17 ++++++++--------- build.gradle | 1 - 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index edc8806e..cb90ec86 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 26 + compileSdkVersion 27 buildToolsVersion '27.0.0' defaultConfig { applicationId "com.keylesspalace.tusky" minSdkVersion 15 - targetSdkVersion 26 + targetSdkVersion 27 versionCode 28 versionName "1.3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -35,7 +35,7 @@ android { } } -ext.supportLibraryVersion = '26.1.0' +ext.supportLibraryVersion = '27.0.0' dependencies { compile('com.mikepenz:materialdrawer:5.9.5@aar') { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt index 785710c8..6e18fa4c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountMediaFragment.kt @@ -15,7 +15,6 @@ package com.keylesspalace.tusky.fragment -import android.content.Context import android.content.Intent import android.graphics.Color import android.os.Bundle @@ -56,8 +55,9 @@ class AccountMediaFragment : BaseFragment() { @JvmStatic fun newInstance(accountId: String): AccountMediaFragment { val fragment = AccountMediaFragment() - fragment.arguments = Bundle() - fragment.arguments.putString(ACCOUNT_ID_ARG, accountId) + val args = Bundle() + args.putString(ACCOUNT_ID_ARG, accountId) + fragment.arguments = args return fragment } @@ -129,7 +129,7 @@ class AccountMediaFragment : BaseFragment() { savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_timeline, container, false) val recyclerView = view.findViewById(R.id.recycler_view) - val columnCount = context.resources.getInteger(R.integer.profile_media_column_count) + val columnCount = context?.resources?.getInteger(R.integer.profile_media_column_count) ?: 2 val layoutManager = GridLayoutManager(context, columnCount) val lightThemeEnabled = PreferenceManager.getDefaultSharedPreferences(context) @@ -141,7 +141,7 @@ class AccountMediaFragment : BaseFragment() { recyclerView.layoutManager = layoutManager recyclerView.adapter = adapter - val accountId = arguments.getString(ACCOUNT_ID_ARG) + val accountId = arguments?.getString(ACCOUNT_ID_ARG) swipeLayout = view.findViewById(R.id.swipe_refresh_layout) swipeLayout.setOnRefreshListener { @@ -182,7 +182,7 @@ class AccountMediaFragment : BaseFragment() { override fun setUserVisibleHint(isVisibleToUser: Boolean) { super.setUserVisibleHint(isVisibleToUser) if (!isVisibleToUser) return - val accountId = arguments.getString(ACCOUNT_ID_ARG) + val accountId = arguments?.getString(ACCOUNT_ID_ARG) if (fetchingStatus == FetchingStatus.NOT_FETCHING && statuses.isEmpty()) { fetchingStatus = FetchingStatus.INITIAL_FETCHING currentCall = api.accountStatuses(accountId, null, null, null, true) @@ -199,11 +199,10 @@ class AccountMediaFragment : BaseFragment() { val intent = Intent(context, ViewMediaActivity::class.java) intent.putExtra("urls", urls) intent.putExtra("urlIndex", currentIndex) - if (view != null) { + if (view != null && activity != null) { val url = urls[currentIndex] ViewCompat.setTransitionName(view, url) - val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, - view, url) + val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity!!, view, url) startActivity(intent, options.toBundle()) } else { startActivity(intent) diff --git a/build.gradle b/build.gradle index 3e8ee5aa..2bcbb1e7 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,6 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } - maven { url 'https://maven.google.com' } google() } }