| 12 | import com.kcode.lib.net.CheckUpdateTask; |
| 13 | |
| 14 | public class MainActivity extends AppCompatActivity { |
| 15 | |
| 16 | private static final String TAG = "MainActivity"; |
| 17 | private final static String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| 18 | |
| 19 | @Override |
| 20 | protected void onCreate(Bundle savedInstanceState) { |
| 21 | super.onCreate(savedInstanceState); |
| 22 | setContentView(R.layout.activity_main); |
| 23 | |
| 24 | } |
| 25 | |
| 26 | public void check(View view) { |
| 27 | checkUpdate(0, null); |
| 28 | } |
| 29 | |
| 30 | public void checkNow(View view) { |
| 31 | checkUpdate(5 * 60 * 1000, null); |
| 32 | } |
| 33 | |
| 34 | public void checkCustoms(View view) { |
| 35 | checkUpdate(0, CustomsUpdateActivity.class); |
| 36 | } |
| 37 | |
| 38 | private void checkUpdate(final long time, final Class<? extends FragmentActivity> cls) { |
| 39 | |
| 40 | UpdateWrapper.Builder builder = new UpdateWrapper.Builder(getApplicationContext()) |
| 41 | .setTime(time) |
| 42 | .setNotificationIcon(R.mipmap.ic_launcher_round) |
| 43 | .setUrl("http://45.78.52.169/app/update.json") |
| 44 | .setIsShowToast(false) |
| 45 | .setCallback(new CheckUpdateTask.Callback() { |
| 46 | @Override |
| 47 | public void callBack(VersionModel model, boolean hasNewVersion) { |
| 48 | L.d(TAG,"has new version:" + hasNewVersion + ";version info :" + model.getVersionName()); |
| 49 | } |
| 50 | }); |
| 51 | |
| 52 | if (cls != null) { |
| 53 | builder.setCustomsActivity(cls); |
| 54 | } |
| 55 | |
| 56 | builder.build().start(); |
| 57 | |
| 58 | |
| 59 | } |
| 60 | } |
nothing calls this directly
no outgoing calls
no test coverage detected