Skip to content

Commit

Permalink
feat: add guard for true time initialization in sample
Browse files Browse the repository at this point in the history
  • Loading branch information
KG committed Jul 30, 2016
1 parent 3689b50 commit d9a385d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
Expand Down Expand Up @@ -33,6 +34,11 @@ protected void onCreate(Bundle savedInstanceState) {

@OnClick(R.id.tt_btn_refresh)
public void onBtnRefresh() {
if (!TrueTime.isInitialized()) {
Toast.makeText(this, "Sorry TrueTime not yet initialized", Toast.LENGTH_SHORT).show();
return;
}

Log.d("kg", String.format(" [now: %d] [new Date: %d]", TrueTime.now().getTime(), new Date().getTime()));
timePST.setText(_formatDate(TrueTime.now(), "yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("GMT-07:00")) +
" [PST]");
Expand Down

0 comments on commit d9a385d

Please sign in to comment.