Android Open Source - lunatick Info






From Project

Back to project page lunatick.

License

The source code is released under:

Copyright (c) 2014, a. bellenir All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1....

If you think the Android project lunatick listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bellenir.lunatick;
/*  w ww .ja v  a  2 s . com*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.graphics.*;
import java.util.Calendar;
import android.widget.*;

import android.content.pm.*;
import android.content.*;
import android.view.View;
import android.view.View.*;
import android.os.*;

public class Info extends Activity {
  ImageView imgLT;
  Handler handler = new Handler();
  Runnable refresh;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.widget);
    imgLT = (ImageView)findViewById(R.id.Lunatick);
    openClockOnClick();
    refresh = new Runnable(){
      public void run(){
        drawImage();
        long sleep = 1000-Calendar.getInstance().get(Calendar.MILLISECOND);
        handler.postDelayed(refresh, sleep);
      }
    };
    handler.post(refresh);
  }
  
  private void drawImage(){
    try{
      Bitmap bmp = LunaTick.getLunaTickBmp(true);
      imgLT.setImageBitmap(bmp);
    }catch(Exception e){
      toast(e.getMessage());
    }
  }
  private void openClockOnClick(){
    imgLT.setOnClickListener(new OnClickListener(){
        public void onClick(View v){
          PackageManager packageManager = v.getContext().getPackageManager();
          if (packageManager != null) {

            Intent AlarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(
              Intent.CATEGORY_LAUNCHER).setComponent(
              new ComponentName("com.android.deskclock", "com.android.deskclock.DeskClock"));

            ResolveInfo resolved = packageManager.resolveActivity(AlarmClockIntent, PackageManager.MATCH_DEFAULT_ONLY);
            if (resolved != null) {
              startActivity(AlarmClockIntent);
              //finish();
              //return;
            } else {
              Toast.makeText(v.getContext(), "failed to launch", Toast.LENGTH_LONG);
              // required activity can not be located!
            }
          }

        }});
  }
  private void toast(String s){
    Toast.makeText(this, s, Toast.LENGTH_LONG).show();
  }
}




Java Source Code List

com.bellenir.lunatick.Info.java
com.bellenir.lunatick.LunaTick.java
com.bellenir.lunatick.Luna.java
com.bellenir.lunatick.Tick.java
com.bellenir.lunatick.Widget.java