|
@@ -0,0 +1,915 @@
|
|
|
|
+package kr.co.icontrols.autopicture;
|
|
|
|
+
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Calendar;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import com.artncore.WallPadDataMgr.WallpadStatusData;
|
|
|
|
+import com.artncore.commons.define;
|
|
|
|
+import com.util.LogUtil;
|
|
|
|
+//import com.util.LogUtil;
|
|
|
|
+
|
|
|
|
+import android.Manifest;
|
|
|
|
+import android.content.pm.PackageManager;
|
|
|
|
+import android.graphics.Matrix;
|
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
|
+import android.media.ExifInterface;
|
|
|
|
+import android.os.Bundle;
|
|
|
|
+import android.os.CountDownTimer;
|
|
|
|
+import android.os.Handler;
|
|
|
|
+import android.os.Looper;
|
|
|
|
+import android.os.Message;
|
|
|
|
+import android.os.PowerManager;
|
|
|
|
+import android.app.Activity;
|
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
|
+import android.content.Context;
|
|
|
|
+import android.content.Intent;
|
|
|
|
+import android.content.IntentFilter;
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
|
+import android.graphics.Color;
|
|
|
|
+import android.graphics.Point;
|
|
|
|
+import android.util.Log;
|
|
|
|
+import android.view.Display;
|
|
|
|
+import android.view.MotionEvent;
|
|
|
|
+import android.view.View;
|
|
|
|
+import android.view.View.OnTouchListener;
|
|
|
|
+import android.view.WindowManager;
|
|
|
|
+import android.view.animation.AnimationUtils;
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
+import android.widget.ViewFlipper;
|
|
|
|
+
|
|
|
|
+import androidx.core.app.ActivityCompat;
|
|
|
|
+import androidx.core.content.ContextCompat;
|
|
|
|
+
|
|
|
|
+import kr.co.icontrols.v40ioctl.V40IF;
|
|
|
|
+import kr.co.icontrols.wallpadsupport.Version;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @description App 시작 방법<br>
|
|
|
|
+ * Intent intent = new Intent(Intent.ACTION_MAIN);<br>
|
|
|
|
+ * intent.setComponent(new ComponentName("kr.co.icontrols.autopicture",
|
|
|
|
+ * "kr.co.icontrols.autopicture.MainActivity"));<br>
|
|
|
|
+ * intent.putExtra("IMAGE_NEXTSHOW_TIME_UNIT_SEC", AUTOPIC_SETTING_VALUE_SEC);<br>
|
|
|
|
+ * intent.putExtra("IMAGE_NEXTSHOW_ANIMATION", AUTOPIC_SETTING_VALUE_TYPE); <br>
|
|
|
|
+ * startActivity(intent);<br><br>
|
|
|
|
+ * $AUTOPIC_SETTING_VALUE_SEC 은 이미지 전환 기준 초수<br>
|
|
|
|
+ * $AUTOPIC_SETTING_VALUE_TYPE 은 이미지 전환 에니메이션 효과<br>
|
|
|
|
+ *   $$1. 그 자리에서 서서히 사라지기<br>
|
|
|
|
+ *   $$2. 왼쪽에서 오른쪽으로<br>
|
|
|
|
+ *   $$3. 아래에서 위로 <br>
|
|
|
|
+ *   $$4. 위에서 아래로<br><br>
|
|
|
|
+ * App 종료 방법<br>
|
|
|
|
+ * Intent intent = new Intent();<br>
|
|
|
|
+ * intent.setAction("kr.co.icontrols.autopicture.BR_APP_FINISH");<br>
|
|
|
|
+ * sendBroadcast(intent);<br>
|
|
|
|
+ */
|
|
|
|
+public class MainActivity extends Activity implements OnTouchListener {
|
|
|
|
+
|
|
|
|
+ private final static String TAG = "AutoPictureApp";
|
|
|
|
+
|
|
|
|
+ private final boolean DEBUG_LOG_ON = true;
|
|
|
|
+
|
|
|
|
+ private void DebugLogOutput(String s) {
|
|
|
|
+ if (DEBUG_LOG_ON) Log.d(TAG, s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //[DB]
|
|
|
|
+ WallpadStatusData DBMGR;
|
|
|
|
+
|
|
|
|
+ //[Time]
|
|
|
|
+ Calendar mCal;
|
|
|
|
+
|
|
|
|
+ // [Show Picture]
|
|
|
|
+ ViewFlipper mFlipper;
|
|
|
|
+
|
|
|
|
+ ImageView View0;
|
|
|
|
+ ImageView View1;
|
|
|
|
+
|
|
|
|
+ Bitmap mPhotoBitmapNext;
|
|
|
|
+ Bitmap mPhotoBitmapCenter;
|
|
|
|
+
|
|
|
|
+ int mIntCenter;
|
|
|
|
+ int mIndexOfFillpper = 0;
|
|
|
|
+
|
|
|
|
+ List<String> filesList = new ArrayList<String>();
|
|
|
|
+
|
|
|
|
+ CounterDown timerAutoPicture = null;
|
|
|
|
+ TimerAutoPictureChanger mTimerAutoPictureChanger = null;
|
|
|
|
+
|
|
|
|
+ int AnimationSec;
|
|
|
|
+ int AnimationType;
|
|
|
|
+ boolean isTestShow = false;
|
|
|
|
+
|
|
|
|
+ int displayWidth;
|
|
|
|
+ int displayHeight;
|
|
|
|
+
|
|
|
|
+ Boolean PictureMorethanZero = false;
|
|
|
|
+ private BroadcastReceiver mWpadNotifyBR = null;
|
|
|
|
+ private final String BR_APP_FINISH = "kr.co.icontrols.wallpad.BR_APP_FINISH";
|
|
|
|
+
|
|
|
|
+ V40IF mV40IF;
|
|
|
|
+
|
|
|
|
+ // PopupActivityRun
|
|
|
|
+ private static boolean PopupActivityRun = false;
|
|
|
|
+
|
|
|
|
+ public static boolean getPopupActivityRun() {
|
|
|
|
+ return PopupActivityRun;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void setPopupActivityRun(boolean run) {
|
|
|
|
+ PopupActivityRun = run;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static final int REQUEST_EXTERNAL_STORAGE = 100;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
+
|
|
|
|
+ PopupActivityRun = false;
|
|
|
|
+
|
|
|
|
+ Log.d(TAG, "[START - AutoPictureApp] --------------------------------------------");
|
|
|
|
+ if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) mV40IF = new V40IF();
|
|
|
|
+ else Log.w(TAG, "[onCreate] Not Supported PLATFORM_TYPE [" + Version.getPlatformType() + "]");
|
|
|
|
+
|
|
|
|
+ // 9. Check Permission
|
|
|
|
+ DebugLogOutput("[Create] - Step1 : Permission Check");
|
|
|
|
+ boolean hasPermission = (ContextCompat.checkSelfPermission(this,
|
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
|
|
|
|
+ Log.d(TAG, "[onCreate] hasPermission: " + hasPermission);
|
|
|
|
+ if (!hasPermission) {
|
|
|
|
+ LogUtil.SetConsole();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Intent intent = getIntent();
|
|
|
|
+ if (intent != null) {
|
|
|
|
+ AnimationSec = intent.getIntExtra("IMAGE_NEXTSHOW_TIME_UNIT_SEC", -1);
|
|
|
|
+ if (AnimationSec < 0) {
|
|
|
|
+ AnimationSec = 5;
|
|
|
|
+ }
|
|
|
|
+ AnimationType = intent.getIntExtra("IMAGE_NEXTSHOW_ANIMATION", -1);
|
|
|
|
+ if (AnimationType < 0) {
|
|
|
|
+ AnimationType = 1;
|
|
|
|
+ }
|
|
|
|
+ isTestShow = intent.getBooleanExtra("TEST_SHOW", false);
|
|
|
|
+ Log.d(TAG, "isTestShow : " + isTestShow);
|
|
|
|
+ if (isTestShow == true) {
|
|
|
|
+ ctrlLCDOnOff(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ctrlLCDOnOff(true);
|
|
|
|
+
|
|
|
|
+ DBMGR = new WallpadStatusData(getApplicationContext());
|
|
|
|
+ mCal = Calendar.getInstance();
|
|
|
|
+
|
|
|
|
+ mWpadNotifyBR = new BroadcastReceiver() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
|
+ Log.d(TAG, "Receive BR " + intent.getAction());
|
|
|
|
+ String ActionName = intent.getAction();
|
|
|
|
+ if (ActionName.equals(BR_APP_FINISH)) {
|
|
|
|
+ Log.i(TAG, "AutoPicture finish - BR_APP_FINISH");
|
|
|
|
+ finish();
|
|
|
|
+ } else BrReceive(intent);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ IntentFilter filter = new IntentFilter(BR_APP_FINISH);
|
|
|
|
+ registerReceiver(mWpadNotifyBR, filter);
|
|
|
|
+
|
|
|
|
+ Display display = getWindowManager().getDefaultDisplay();
|
|
|
|
+ Point size = new Point();
|
|
|
|
+ display.getSize(size);
|
|
|
|
+
|
|
|
|
+ displayWidth = size.x;
|
|
|
|
+ displayHeight = size.y;
|
|
|
|
+
|
|
|
|
+ //사진 표시
|
|
|
|
+ mFlipper = new ViewFlipper(this);
|
|
|
|
+ mFlipper.setBackgroundColor(Color.BLACK);
|
|
|
|
+
|
|
|
|
+ View0 = new ImageView(this);
|
|
|
|
+ View1 = new ImageView(this);
|
|
|
|
+
|
|
|
|
+ File dirUsb = new File("/storage/usb0");
|
|
|
|
+ File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
|
|
|
|
+ if (!dirInternal.isDirectory()) dirInternal.mkdir();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if (dirInternal.isDirectory()) {
|
|
|
|
+ Log.d(TAG, dirInternal + " is Directory!!");
|
|
|
|
+ printfiles(dirInternal);
|
|
|
|
+ }
|
|
|
|
+ printfiles(dirUsb);
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, e.toString());
|
|
|
|
+ }
|
|
|
|
+ if (filesList.size() != 0) {
|
|
|
|
+ PictureMorethanZero = true;
|
|
|
|
+ mIntCenter = 0;
|
|
|
|
+ File FileCenter = new File(filesList.get(mIntCenter));
|
|
|
|
+ mPhotoBitmapCenter = decodeFile(FileCenter, displayWidth, displayHeight);
|
|
|
|
+
|
|
|
|
+ if (mPhotoBitmapCenter == null) {
|
|
|
|
+ Log.w(TAG, "[onCreate] mPhotoBitmapCenter is null");
|
|
|
|
+ PictureMorethanZero = false;
|
|
|
|
+ setAutoPictureAnimation(AnimationType);
|
|
|
|
+ startAutoPictureTimeThread();
|
|
|
|
+// SetInfoFromMainUI(1, 1);
|
|
|
|
+// timerAutoPicture.start();
|
|
|
|
+
|
|
|
|
+ setContentView(mFlipper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ View0.setImageBitmap(mPhotoBitmapCenter);
|
|
|
|
+ View0.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
+ mFlipper.addView(View0);
|
|
|
|
+ mPhotoBitmapCenter = null;
|
|
|
|
+
|
|
|
|
+ Log.i(TAG, "[onCreate] AnimationSec [" + AnimationSec + "], AnimationType [" + AnimationType + "]");
|
|
|
|
+ setAutoPictureAnimation(AnimationType);
|
|
|
|
+ startAutoPictureTimeThread();
|
|
|
|
+
|
|
|
|
+// SetInfoFromMainUI(AnimationSec, AnimationType);
|
|
|
|
+// timerAutoPicture.start();
|
|
|
|
+
|
|
|
|
+ setContentView(mFlipper);
|
|
|
|
+ mFlipper.setOnTouchListener((OnTouchListener) this);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Log.d(TAG, "[Finish!! (There is no Picture) - AutoPictureApp] --------------------------------------------");
|
|
|
|
+ PictureMorethanZero = false;
|
|
|
|
+ setAutoPictureAnimation(AnimationType);
|
|
|
|
+ startAutoPictureTimeThread();
|
|
|
|
+// SetInfoFromMainUI(1, 1);
|
|
|
|
+// timerAutoPicture.start();
|
|
|
|
+
|
|
|
|
+ setContentView(mFlipper);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 실제 Permission에 대한 체크가 필요
|
|
|
|
+ * @param requestCode
|
|
|
|
+ * @param permissions
|
|
|
|
+ * @param grantResults
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
|
|
|
+ Log.d(TAG, "[onRequestPermissionsResult] requestCode: " + requestCode);
|
|
|
|
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
+ switch (requestCode) {
|
|
|
|
+ case REQUEST_EXTERNAL_STORAGE: {
|
|
|
|
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
+ Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED");
|
|
|
|
+ } else {
|
|
|
|
+ Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED");
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onDestroy() {
|
|
|
|
+ super.onDestroy();
|
|
|
|
+ Log.d(TAG, "[onDestroy] ========== AutoPictureApp ==========");
|
|
|
|
+ stopAutoPictureTimeThread();
|
|
|
|
+// timerAutoPicture.cancel();
|
|
|
|
+
|
|
|
|
+ if (DBMGR != null) DBMGR.closeDB();
|
|
|
|
+
|
|
|
|
+ // 1. 등록된 ActionFilter 일괄 해제
|
|
|
|
+ unregisterReceiver(mWpadNotifyBR);
|
|
|
|
+
|
|
|
|
+ ctrlLCDOnOff(false);
|
|
|
|
+
|
|
|
|
+ if (mPhotoBitmapNext != null) {
|
|
|
|
+ mPhotoBitmapNext.recycle();
|
|
|
|
+ mPhotoBitmapNext = null;
|
|
|
|
+ }
|
|
|
|
+ if (mPhotoBitmapCenter != null) {
|
|
|
|
+ mPhotoBitmapCenter.recycle();
|
|
|
|
+ mPhotoBitmapCenter = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onResume() {
|
|
|
|
+ super.onResume();
|
|
|
|
+ Log.d(TAG, "[onResume] ========== AutoPictureApp ==========");
|
|
|
|
+// ctrlLCDOnOff(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * onPause<br>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ protected void onPause() {
|
|
|
|
+ super.onPause();
|
|
|
|
+ Log.d(TAG, "[onPause] ========== AutoPictureApp ==========");
|
|
|
|
+// stopAutoPictureTimeThread();
|
|
|
|
+// timerAutoPicture.cancel();
|
|
|
|
+ overridePendingTransition(0, 0); // 종료시 에니메이션 효과 삭제
|
|
|
|
+ ctrlLCDOnOff(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void finish() {
|
|
|
|
+ super.finish();
|
|
|
|
+ Log.d(TAG, "[finish] ========== AutoPictureApp ==========");
|
|
|
|
+ stopAutoPictureTimeThread();
|
|
|
|
+// timerAutoPicture.cancel();
|
|
|
|
+ ctrlLCDOnOff(false);
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
+ intent.putExtra("Finish_Kind", "HomeButton");
|
|
|
|
+ setResult(RESULT_OK, intent);
|
|
|
|
+
|
|
|
|
+ sendFinishBR();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
+
|
|
|
|
+ if (v != mFlipper)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
+
|
|
|
|
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
|
|
+ ctrlLCDOnOff(true);
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // =================================================================================================
|
|
|
|
+ // [[ BroadcastReceiver ]] region
|
|
|
|
+ // =================================================================================================
|
|
|
|
+ protected void onBrReceive(Intent intent) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * BrReceive
|
|
|
|
+ *
|
|
|
|
+ * @param intent - onReceive 시 수신받은 intent
|
|
|
|
+ */
|
|
|
|
+ private void BrReceive(Intent intent) {
|
|
|
|
+ try {
|
|
|
|
+ onBrReceive(intent);
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[ExceptionError] - onBrReceive : " + e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void sendFinishBR() {
|
|
|
|
+ try {
|
|
|
|
+ // 상태가 변경되었다면 상태 변경 BR을 송신한다.
|
|
|
|
+ Intent notiIntent = new Intent();
|
|
|
|
+ notiIntent.setAction(define.NOTIFY_ACNAME);
|
|
|
|
+ notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_AUTOPICTURE_FINISH);
|
|
|
|
+ getApplicationContext().sendBroadcast(notiIntent);
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] sendFinishBR()");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setAutoPictureAnimation(int nAniType) {
|
|
|
|
+ try {
|
|
|
|
+ Log.d(TAG, "[setAutoPictureAnimation] nAniType [" + nAniType + "]");
|
|
|
|
+ switch (AnimationType) {
|
|
|
|
+ case 1: //그 자리에서 서서히 사라지기
|
|
|
|
+ default:
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 2: //왼쪽에서 오른쪽으로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 3: //아래에서 위로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in_downup));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out_downup));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 4: //위에서 아래로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in_updown));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out_updown));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] setAutoPictureAnimation(int nAniType)");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean bAutoPictureTimerRun = false;
|
|
|
|
+ class TimerAutoPictureChanger extends Thread {
|
|
|
|
+ int nSec = 5;
|
|
|
|
+
|
|
|
|
+ public TimerAutoPictureChanger(int nChangeSec) {
|
|
|
|
+ nSec = nChangeSec;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ super.run();
|
|
|
|
+ try {
|
|
|
|
+ int sec = nSec;
|
|
|
|
+ Log.d(TAG, "[TimerAutoPictureChanger.run()] bAutoPictureTimerRun [" + bAutoPictureTimerRun + "], PictureMorethanZero [" + PictureMorethanZero + "], sec [" + sec + "]");
|
|
|
|
+ while (bAutoPictureTimerRun && PictureMorethanZero) {
|
|
|
|
+ if (sec > 0) {
|
|
|
|
+// Log.d(TAG, "[TimerAutoPictureChanger.run()] sec [" + sec +"]");
|
|
|
|
+ sec--;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (isTestShow == false) {
|
|
|
|
+ mCal = Calendar.getInstance();
|
|
|
|
+ if (DBMGR.DecideAutoPictureAppEndOrNot(mCal) == true) {
|
|
|
|
+ Log.d(TAG, "[TimerAutoPictureChanger.run()] DecideAutoPictureAppEndOrNot(mCal) == true");
|
|
|
|
+ Log.d(TAG, "[TimerAutoPictureChanger.run()] LCD will be Off!!!");
|
|
|
|
+ bAutoPictureTimerRun = false;
|
|
|
|
+ ctrlLCDOnOff(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Log.d(TAG, "[TimerAutoPictureChanger.run()] Show the next picture!!");
|
|
|
|
+ sec = nSec;
|
|
|
|
+ sendHandlerMsg(HANDLERMSG.SHOW_NEXT_PICTURE, 0, 0);
|
|
|
|
+ }
|
|
|
|
+// Log.d(TAG, "[TimerAutoPictureChanger.run()] 1 bAutoPictureTimerRun [" + bAutoPictureTimerRun + "], PictureMorethanZero [" + PictureMorethanZero + "], sec [" + sec + "]");
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ }
|
|
|
|
+// Log.d(TAG, "[TimerAutoPictureChanger.run()] 2 bAutoPictureTimerRun [" + bAutoPictureTimerRun + "], PictureMorethanZero [" + PictureMorethanZero + "], sec [" + sec + "]");
|
|
|
|
+ Log.d(TAG, "[TimerAutoPictureChanger.run()] TimerAutoPictureChanger is end!!!");
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] TimerAutoPictureChanger.run()");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void startAutoPictureTimeThread() {
|
|
|
|
+ try {
|
|
|
|
+ bAutoPictureTimerRun = true;
|
|
|
|
+ mTimerAutoPictureChanger = new TimerAutoPictureChanger(AnimationSec);
|
|
|
|
+ mTimerAutoPictureChanger.start();
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] startAutoPictureTimeThread()");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void stopAutoPictureTimeThread() {
|
|
|
|
+ try {
|
|
|
|
+ Log.w(TAG, "[stopAutoPictureTimeThread] ===== START =====");
|
|
|
|
+ if (mTimerAutoPictureChanger != null) {
|
|
|
|
+ Log.w(TAG, "[stopAutoPictureTimeThread] Stop mTimerAutoPictureChanger!!");
|
|
|
|
+ bAutoPictureTimerRun = false;
|
|
|
|
+ mTimerAutoPictureChanger = null;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Log.w(TAG, "[stopAutoPictureTimeThread] mTimerAutoPictureChanger is null!!");
|
|
|
|
+ }
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] stopAutoPictureTimeThread()");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void SetInfoFromMainUI(int Sec, int AnimationType) {
|
|
|
|
+ Log.d(TAG, "[SetInfoFromMainUI] Sec [" + Sec + "], AnimationType [" + AnimationType + "]");
|
|
|
|
+ timerAutoPicture = new CounterDown((long) (Sec * 1000), 1000); // 1초 = 1000, 1분 = 60000
|
|
|
|
+
|
|
|
|
+ switch (AnimationType) {
|
|
|
|
+ case 1: //그 자리에서 서서히 사라지기
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 2: //왼쪽에서 오른쪽으로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 3: //아래에서 위로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in_downup));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out_downup));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 4: //위에서 아래로
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_in_updown));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.anim_out_updown));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
|
|
|
|
+ mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public class CounterDown extends CountDownTimer {
|
|
|
|
+
|
|
|
|
+ public CounterDown(long millisInFuture, long countDownInterval) {
|
|
|
|
+ super(millisInFuture, countDownInterval);
|
|
|
|
+ Log.d(TAG, "[timerAutoPicture] millisInFuture [" + millisInFuture + "], countDownInterval [" + countDownInterval + "]");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFinish() {
|
|
|
|
+ if (PictureMorethanZero == false) {
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Log.d(TAG, "[timerAutoPicture.onFinish()] The timer expired!! Show the next picture!!");
|
|
|
|
+ mCal = Calendar.getInstance();
|
|
|
|
+
|
|
|
|
+ if (isTestShow == false) {
|
|
|
|
+ if (DBMGR.DecideAutoPictureAppEndOrNot(mCal) == true) {
|
|
|
|
+ Log.d(TAG, "[timerAutoPicture.onFinish()] DecideAutoPictureAppEndOrNot(mCal) == true");
|
|
|
|
+ Log.d(TAG, "[timerAutoPicture.onFinish()] LCD will be Off!!!");
|
|
|
|
+ ctrlLCDOnOff(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ShowNextImage();
|
|
|
|
+ timerAutoPicture.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
|
+ Log.d(TAG, "[timerAutoPicture.onTick(...)] Remain time(sec) [" + (millisUntilFinished/1000) + "]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description USB에 있는 이미지 파일의 목록을 생성하는 함수<br>
|
|
|
|
+ * 재귀함수로써 모든 폴더를 탐색한다.<br>
|
|
|
|
+ * USB와 Storage/Bestin/DownloadPicture 내에 있는 파일의 확장자를 검사<br>
|
|
|
|
+ * 파일 포맷 : jpg, JPG, jpeg, JPEG, png, PNG, bmp, BMP 지원
|
|
|
|
+ */
|
|
|
|
+ public void printfiles(File file) {
|
|
|
|
+ File[] list = file.listFiles();
|
|
|
|
+// Log.d(TAG, "[printfiles] list.length: " + list.length);
|
|
|
|
+
|
|
|
|
+ if (list == null) {
|
|
|
|
+ Log.d(TAG, "No File in " + file.getPath());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < list.length; i++) {
|
|
|
|
+ File temp_file = new File(file.getAbsolutePath(), list[i].getName());
|
|
|
|
+ if (!temp_file.isDirectory()) temp_file.mkdir();
|
|
|
|
+ if (temp_file.isDirectory() && temp_file.listFiles() != null) {
|
|
|
|
+ Log.d(TAG, "PATH folder" + temp_file.getAbsolutePath());
|
|
|
|
+ //I am inside The Directory... Searching:) So i am calling printfiles(File file) function to print the files in the directory
|
|
|
|
+ printfiles(temp_file);
|
|
|
|
+ } else {
|
|
|
|
+ String filename = temp_file.getName();
|
|
|
|
+ boolean isAccept = false;
|
|
|
|
+
|
|
|
|
+ if (filename.toLowerCase().endsWith(".jpg") == true) {
|
|
|
|
+ isAccept = true;
|
|
|
|
+ } else if (filename.toLowerCase().endsWith(".jpeg") == true) {
|
|
|
|
+ isAccept = true;
|
|
|
|
+ } else if (filename.toLowerCase().endsWith(".png") == true) {
|
|
|
|
+ isAccept = true;
|
|
|
|
+ } else if (filename.toLowerCase().endsWith(".bmp") == true) {
|
|
|
|
+ isAccept = true;
|
|
|
|
+ } else {
|
|
|
|
+ isAccept = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isAccept == true) {
|
|
|
|
+ filesList.add(temp_file.getAbsolutePath());
|
|
|
|
+ DebugLogOutput("PATH file" + temp_file.getAbsolutePath());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description 다음 이미지 보여주기 <br>
|
|
|
|
+ */
|
|
|
|
+ public void ShowNextImage() {
|
|
|
|
+ if (mFlipper.getCurrentView() == View0) {
|
|
|
|
+ LoadNextImage(View1);
|
|
|
|
+ mFlipper.showNext();
|
|
|
|
+ mFlipper.removeView(View0);
|
|
|
|
+ } else if (mFlipper.getCurrentView() == View1) {
|
|
|
|
+ LoadNextImage(View0);
|
|
|
|
+ mFlipper.showNext();
|
|
|
|
+ mFlipper.removeView(View1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description Next 이미지 로드<br>
|
|
|
|
+ */
|
|
|
|
+ public void LoadNextImage(View v) {
|
|
|
|
+ mIntCenter++;
|
|
|
|
+ if (mIntCenter == filesList.size()) {
|
|
|
|
+ mIntCenter = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Log.w(TAG, "[LoadNextImage] filesList.get(mIntCenter) = " + filesList.get(mIntCenter));
|
|
|
|
+ File TempFileNext = new File(filesList.get(mIntCenter));
|
|
|
|
+ mPhotoBitmapNext = decodeFile(TempFileNext, displayWidth, displayHeight);
|
|
|
|
+ if (mPhotoBitmapNext == null) {
|
|
|
|
+ Log.w(TAG, "[LoadNextImage] mPhotoBitmapNext is null");
|
|
|
|
+ ctrlLCDOnOff(true);
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ ((ImageView) v).setImageBitmap(mPhotoBitmapNext);
|
|
|
|
+ ((ImageView) v).setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
+ mFlipper.addView(v);
|
|
|
|
+ mPhotoBitmapNext = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description 사진 미리보기 화면에 표시될 이미지 크기 기반으로 이미지 스케일 및 샘플 사이즈를 조정
|
|
|
|
+ */
|
|
|
|
+ public static Bitmap decodeFile(File f, int reqWidth, int reqHeight) {
|
|
|
|
+ FileInputStream is = null;
|
|
|
|
+ FileInputStream is_ = null;
|
|
|
|
+ try {
|
|
|
|
+ // First decode with inJustDecodeBounds=true to check dimensions
|
|
|
|
+ final BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
|
+ options.inJustDecodeBounds = true;
|
|
|
|
+ is_ = new FileInputStream(f);
|
|
|
|
+ BitmapFactory.decodeStream(is_, null, options);
|
|
|
|
+
|
|
|
|
+ if (options.outMimeType == null) {
|
|
|
|
+ Log.e("[AutoPicture]", "[decodeStream] options.outMimeType is null");
|
|
|
|
+ int pos = f.getAbsoluteFile().toString().lastIndexOf(".");
|
|
|
|
+ String ext = f.getAbsoluteFile().toString().substring(pos + 1);
|
|
|
|
+ Log.d("[AutoPicture]", "[decodeStream] ext [" + ext + "]");
|
|
|
|
+ if (!ext.equalsIgnoreCase("bmp")) return null; // bmp파일은 options.outMimeType == null이므로
|
|
|
|
+ } else {
|
|
|
|
+ Log.d("[AutoPicture]", "[decodeStream] options.outMimeType [" + options.outMimeType + "]");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Calculate inSampleSize
|
|
|
|
+ options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
|
|
|
|
+// Log.d("[AutoPicture]", "[decodeStream] options.inSampleSize [" + options.inSampleSize + "]");
|
|
|
|
+
|
|
|
|
+ // Decode bitmap with inSampleSize set
|
|
|
|
+ options.inJustDecodeBounds = false;
|
|
|
|
+// Log.d("[AutoPicture]", "[decodeStream] options.inJustDecodeBounds [" + options.inJustDecodeBounds + "]");
|
|
|
|
+
|
|
|
|
+ is = new FileInputStream(f);
|
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeStream(is , null, options);
|
|
|
|
+ int degree = GetExifOrientation(f.getAbsolutePath());
|
|
|
|
+ Bitmap temp_bitmap = GetRotatedBitmap(bitmap, degree);
|
|
|
|
+ return temp_bitmap;
|
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
|
|
+ if(is !=null) {
|
|
|
|
+ try {
|
|
|
|
+ is.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ is = null;
|
|
|
|
+
|
|
|
|
+ if(is_!=null) {
|
|
|
|
+ try {
|
|
|
|
+ is_.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ is_ = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public synchronized static int GetExifOrientation(String filepath) {
|
|
|
|
+ int degree = 0;
|
|
|
|
+ ExifInterface exif = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ exif = new ExifInterface(filepath);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ Log.e(TAG, "[Exception] GetExifOrientation()");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (exif != null) {
|
|
|
|
+ int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
|
|
|
|
+
|
|
|
|
+ if (orientation != -1) {
|
|
|
|
+ // We only recognize a subset of orientation tag values.
|
|
|
|
+ switch (orientation) {
|
|
|
|
+ case ExifInterface.ORIENTATION_ROTATE_90:
|
|
|
|
+ degree = 90;
|
|
|
|
+ break;
|
|
|
|
+ case ExifInterface.ORIENTATION_ROTATE_180:
|
|
|
|
+ degree = 180;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case ExifInterface.ORIENTATION_ROTATE_270:
|
|
|
|
+ degree = 270;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Log.d(TAG, "[GetExifOrientation] degree [" + degree + "]");
|
|
|
|
+ return degree;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public synchronized static Bitmap GetRotatedBitmap(Bitmap bitmap, int degrees) {
|
|
|
|
+ if (degrees != 0 && bitmap != null) {
|
|
|
|
+ Matrix m = new Matrix();
|
|
|
|
+ m.setRotate(degrees, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
|
|
|
|
+ try {
|
|
|
|
+ Bitmap b2 = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
|
|
|
|
+ if (bitmap != b2) {
|
|
|
|
+ bitmap.recycle();
|
|
|
|
+ bitmap = b2;
|
|
|
|
+ }
|
|
|
|
+ else if(b2!=null)
|
|
|
|
+ {
|
|
|
|
+ b2.recycle();;
|
|
|
|
+ b2 = null;
|
|
|
|
+ }
|
|
|
|
+ } catch (OutOfMemoryError ex) {
|
|
|
|
+ Log.e(TAG, "[Exception] GetRotatedBitmap()");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return bitmap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description 이미지 Sampling size 확인
|
|
|
|
+ */
|
|
|
|
+ public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
|
|
|
+ // Raw height and width of image
|
|
|
|
+ final int height = options.outHeight;
|
|
|
|
+ final int width = options.outWidth;
|
|
|
|
+ int inSampleSize = 1;
|
|
|
|
+
|
|
|
|
+ if ((reqWidth > 1024) || (reqHeight > 600)) {
|
|
|
|
+ inSampleSize = 2; // 1280x800 예외처리 추가
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long tempFreeMemory = Runtime.getRuntime().freeMemory();
|
|
|
|
+
|
|
|
|
+ Log.d("AutoPictureApp", "freeMemory : " + tempFreeMemory);
|
|
|
|
+ if (tempFreeMemory < 100000) {
|
|
|
|
+ Log.w("AutoPictureApp", "freeMemory is low than 100000");
|
|
|
|
+ Log.w("AutoPictureApp", "inSampleSize will be * 2");
|
|
|
|
+ inSampleSize *= 2;
|
|
|
|
+ }
|
|
|
|
+ if (tempFreeMemory < 50000) {
|
|
|
|
+ Log.w("AutoPictureApp", "freeMemory is low than 50000");
|
|
|
|
+ Log.w("AutoPictureApp", "inSampleSize will be * 2");
|
|
|
|
+ inSampleSize *= 2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (height > reqHeight || width > reqWidth) {
|
|
|
|
+ final int halfHeight = height / 2;
|
|
|
|
+ final int halfWidth = width / 2;
|
|
|
|
+
|
|
|
|
+ // Calculate the largest inSampleSize value that is a power of 2 and
|
|
|
|
+ // keeps both
|
|
|
|
+ // height and width larger than the requested height and width.
|
|
|
|
+ while ((halfHeight / inSampleSize) >= reqHeight && (halfWidth / inSampleSize) >= reqWidth) {
|
|
|
|
+ inSampleSize *= 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Log.i("AutoPictureApp", "inSampleSize : " + inSampleSize);
|
|
|
|
+ return inSampleSize;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean ctrlLCDOnOff(boolean bOn) {
|
|
|
|
+ try {
|
|
|
|
+ // 절전모드 사용시 호출수신등의 이벤트로 LCD 화면을 ON한다.
|
|
|
|
+ // 모든 이벤트가 끝나고, 메인화면으로 전환시 절전모드를 다시 동작시킨다.
|
|
|
|
+ Log.d(TAG, "[ctrlLCDOnOff] bOn [" + bOn + "]");
|
|
|
|
+ if (bOn) {
|
|
|
|
+ PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
|
|
+ Log.d(TAG, "[ctrlLCDOnOff] Screen On: " + mPowerManager.isScreenOn());
|
|
|
|
+ mV40IF.WpdInterfaceOpen();
|
|
|
|
+ mV40IF.LcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
|
|
|
|
+ mV40IF.WpdInterfaceClose();
|
|
|
|
+
|
|
|
|
+ sendHandlerMsg(HANDLERMSG.FLAG_KEEP_SCREEN_ON, 0, 0);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ sendHandlerMsg(HANDLERMSG.FLAG_KEEP_SCREEN_ON, 0, 0);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ return false;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] ctrlLCDOnOff(bOn)");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // MainActivity Handler
|
|
|
|
+ public final class HANDLERMSG {
|
|
|
|
+ public final static int FLAG_KEEP_SCREEN_ON = 100;
|
|
|
|
+ public final static int SHOW_NEXT_PICTURE = 200;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Handler MainHandler = new Handler(Looper.getMainLooper()) {
|
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
|
+ Log.d(TAG, "[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
|
|
|
|
+ switch (msg.what) {
|
|
|
|
+ case HANDLERMSG.FLAG_KEEP_SCREEN_ON:
|
|
|
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case HANDLERMSG.SHOW_NEXT_PICTURE:
|
|
|
|
+ ShowNextImage();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ Log.d(TAG, "MainHandler : " + msg.what);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ public void sendHandlerMsg(int what, int arg1, int arg2) {
|
|
|
|
+ try {
|
|
|
|
+// Log.i(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
|
|
|
|
+ Message HandleMsg = MainHandler.obtainMessage();
|
|
|
|
+ HandleMsg.what = what;
|
|
|
|
+ HandleMsg.arg1 = arg1;
|
|
|
|
+ HandleMsg.arg2 = arg2;
|
|
|
|
+ MainHandler.sendMessage(HandleMsg);
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
|
|
|
|
+ try {
|
|
|
|
+// Log.i(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
|
|
|
|
+ Message HandleMsg = MainHandler.obtainMessage();
|
|
|
|
+ HandleMsg.what = what;
|
|
|
|
+ HandleMsg.arg1 = arg1;
|
|
|
|
+ HandleMsg.arg2 = arg2;
|
|
|
|
+ MainHandler.sendMessageDelayed(HandleMsg, delay);
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|