Prevent crash

This commit is contained in:
M66B 2018-07-09 06:40:27 +00:00
parent 52af92f512
commit 9383277f84
1 changed files with 15 additions and 8 deletions

View File

@ -414,13 +414,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
llSupport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Util.isPlayStoreInstall(ActivityMain.this))
startActivity(new Intent(ActivityMain.this, ActivityPro.class));
else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://contact.faircode.eu/?product=netguardstandalone"));
startActivity(intent);
}
startActivity(getIntentPro(ActivityMain.this));
}
});
@ -461,8 +455,11 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
if (adapter != null)
adapter.notifyDataSetChanged();
PackageManager pm = getPackageManager();
LinearLayout llSupport = findViewById(R.id.llSupport);
llSupport.setVisibility(IAB.isPurchasedAny(this) ? View.GONE : View.VISIBLE);
llSupport.setVisibility(
IAB.isPurchasedAny(this) || getIntentPro(this).resolveActivity(pm) == null
? View.GONE : View.VISIBLE);
super.onResume();
}
@ -1212,6 +1209,16 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
startActivity(getIntentApps(this));
}
private static Intent getIntentPro(Context context) {
if (Util.isPlayStoreInstall(context))
return new Intent(context, ActivityPro.class);
else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://contact.faircode.eu/?product=netguardstandalone"));
return intent;
}
}
private static Intent getIntentInvite(Context context) {
Intent intent = new Intent("com.google.android.gms.appinvite.ACTION_APP_INVITE");
intent.setPackage("com.google.android.gms");