1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-02 17:41:21 +01:00

fixed previous commit

This commit is contained in:
DrKLO 2014-03-23 04:24:19 +04:00
parent e538243062
commit 6be743c9c2
2 changed files with 21 additions and 10 deletions

View File

@ -77,6 +77,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public final static int recordProgressChanged = 50003;
public final static int recordStarted = 50004;
public final static int recordStartError = 50005;
public final static int recordStopped = 50006;
private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>>();
private HashMap<Integer, String> observersByTag = new HashMap<Integer, String>();
@ -894,7 +895,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
});
}
}, 100);
});
}
private void stopRecordingInternal(final boolean send) {
@ -972,6 +973,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} catch (Exception e) {
FileLog.e("tmessages", e);
}
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(recordStopped);
}
});
}
});
}

View File

@ -344,6 +344,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter.getInstance().addObserver(this, MediaController.recordProgressChanged);
NotificationCenter.getInstance().addObserver(this, MediaController.recordStarted);
NotificationCenter.getInstance().addObserver(this, MediaController.recordStartError);
NotificationCenter.getInstance().addObserver(this, MediaController.recordStopped);
NotificationCenter.getInstance().addObserver(this, 997);
loading = true;
@ -392,6 +393,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter.getInstance().removeObserver(this, MediaController.recordProgressChanged);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStarted);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStartError);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStopped);
NotificationCenter.getInstance().removeObserver(this, 997);
if (sizeNotifierRelativeLayout != null) {
sizeNotifierRelativeLayout.delegate = null;
@ -409,6 +411,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (mWakeLock != null) {
try {
mWakeLock.release();
mWakeLock = null;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -685,11 +688,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
updateAudioRecordIntefrace();
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
startedDraggingX = -1;
if (recordingAudio) {
MediaController.getInstance().stopRecording(true);
recordingAudio = false;
updateAudioRecordIntefrace();
}
MediaController.getInstance().stopRecording(true);
recordingAudio = false;
updateAudioRecordIntefrace();
} else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && recordingAudio) {
float x = motionEvent.getX();
if (x < -distCanMove) {
@ -889,9 +890,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
if (recordingAudio) {
try {
PowerManager pm = (PowerManager)parentActivity.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "audio record lock");
mWakeLock.acquire();
if (mWakeLock == null) {
PowerManager pm = (PowerManager) parentActivity.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "audio record lock");
mWakeLock.acquire();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -940,6 +943,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (mWakeLock != null) {
try {
mWakeLock.release();
mWakeLock = null;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -2233,7 +2237,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
mActionMode.finish();
mActionMode = null;
}
} else if (id == MediaController.recordStartError) {
} else if (id == MediaController.recordStartError || id == MediaController.recordStopped) {
if (recordingAudio) {
recordingAudio = false;
updateAudioRecordIntefrace();