瀏覽代碼

GooglePlayUtils: convert to Kotlin, fix spotbugs

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 年之前
父節點
當前提交
d63d22d066
共有 1 個文件被更改,包括 19 次插入25 次删除
  1. 19 25
      app/src/gplay/java/com/owncloud/android/utils/GooglePlayUtils.kt

+ 19 - 25
app/src/gplay/java/com/owncloud/android/utils/GooglePlayUtils.java → app/src/gplay/java/com/owncloud/android/utils/GooglePlayUtils.kt

@@ -15,38 +15,32 @@
  * GNU Affero General Public License for more details.
  *
  * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program.  If not, see <http:></http:>//www.gnu.org/licenses/>.
  */
+package com.owncloud.android.utils
 
-package com.owncloud.android.utils;
+import android.app.Activity
+import android.util.Log
+import com.google.android.gms.common.ConnectionResult
+import com.google.android.gms.common.GoogleApiAvailability
 
-import android.app.Activity;
-import android.util.Log;
+object GooglePlayUtils {
+    private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
+    private const val TAG = "GooglePlayUtils"
 
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GoogleApiAvailability;
-
-public final class GooglePlayUtils {
-    private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
-    private static final String TAG = "GooglePlayUtils";
-
-    private GooglePlayUtils() {
-    }
-
-    public static boolean checkPlayServices(Activity activity) {
-        GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
-        int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
+    @JvmStatic
+    fun checkPlayServices(activity: Activity): Boolean {
+        val apiAvailability = GoogleApiAvailability.getInstance()
+        val resultCode = apiAvailability.isGooglePlayServicesAvailable(activity)
         if (resultCode != ConnectionResult.SUCCESS) {
             if (apiAvailability.isUserResolvableError(resultCode)) {
-                apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
-                        .show();
+                apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)?.show()
             } else {
-                Log.i(TAG, "This device is not supported.");
-                activity.finish();
+                Log.i(TAG, "This device is not supported.")
+                activity.finish()
             }
-            return false;
+            return false
         }
-        return true;
+        return true
     }
-
-}
+}