-
Notifications
You must be signed in to change notification settings - Fork 370
/
Copy pathExampleActivity.java
58 lines (47 loc) · 1.41 KB
/
ExampleActivity.java
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
package com.example.activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.example.R;
import com.example.utility.Preferences;
import org.alfonz.utility.Logcat;
import org.alfonz.utility.VersionUtility;
public class ExampleActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_example);
checkNewVersion();
checkRateCounter();
}
private void checkNewVersion() {
Preferences preferences = new Preferences();
String currentVersion = VersionUtility.getVersionName(this);
String lastVersion = preferences.getVersion();
// new version is available
if (!currentVersion.equals(lastVersion)) {
// TODO: do something
// set new version in preferences
preferences.setVersion(currentVersion);
}
}
private void checkRateCounter() {
// get current rate counter
Preferences preferences = new Preferences();
final int rateCounter = preferences.getRateCounter();
Logcat.d("" + rateCounter);
// check rate counter
boolean showMessage = false;
if (rateCounter != -1) {
if (rateCounter >= 10 && rateCounter % 10 == 0) showMessage = true;
} else {
return;
}
// show rate message
if (showMessage) {
// TODO: show message
// TODO: set rate counter to -1
}
// increment rate counter
preferences.setRateCounter(rateCounter + 1);
}
}