-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOtherUtil.java
More file actions
executable file
·69 lines (59 loc) · 2.56 KB
/
OtherUtil.java
File metadata and controls
executable file
·69 lines (59 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.example.utils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.facebook.accountkit.AccountKit;
import example.base.store.UserPreference;
import example.base.util.LogUtil;
import pl.droidsonroids.gif.GifDrawable;
import com.example.BuildConfig;
import com.example.R;
import com.example.configs.VersionChecker;
/**
* Created by Silver on 11/11/2016.
*/
public class OtherUtil {
public static GifDrawable getGifDrawable(Context context) {
try {
return new GifDrawable(context.getResources(), R.mipmap.loading);
} catch (Exception e) {
LogUtil.e(e);
}
return null;
}
public static void checkVersion(final Context context) {
try {
VersionChecker versionChecker = new VersionChecker(context);
String latestStoreVersion = versionChecker.execute().get();
String currentVersion = BuildConfig.VERSION_NAME;
if (Integer.valueOf(currentVersion.replace(".", ""))
< Integer.valueOf(latestStoreVersion.replace(".", ""))) {
new MaterialDialog.Builder(context)
.title(context.getString(R.string.new_version))
.content(context.getString(R.string.prompt_play_store))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog,
@NonNull DialogAction which) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + context.getPackageName())));
} catch (Exception e) {
context.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName())));
}
}
})
.positiveText(R.string.update)
.negativeText(R.string.no)
.show();
}
} catch (Exception e) {
LogUtil.e(e);
}
}
}