I have changed the code to test more and found something strange, for some reason my annotation type is changing when I tried to edit, I have even tried with other variable and it's the same
private com.radaee.pdf.Page.Annotation m_annot;
public static com.radaee.pdf.Page.Annotation m_annot2;
public void OnAnnotClicked(PDFVPage vpage, Page.Annotation annot)
{
Log.d("Reader","Annotation Click "+annot);
m_annot_vpage = vpage;
if(annot!=null) {
m_annot = annot;
}
if(annot!=null){
if (annot.GetType() == 1) {//Popup note
m_reader.PDFPerformAnnot();
}else{
if (annot.GetType() == 3) {//EditText
m_annot=annot;
m_annot2=annot;
Log.d("Reader","Gettype==3 "+m_annot2.GetType());
Log.d("Reader","Gettype==3 "+m_annot2.SetEditText("aaa"));
onEdit2();
}
}
}
private void onEdit2()
{
final EditText input = new EditText(getActivity());
final AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setTitle("Edit Text")
.setView(input)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Editable value = input.getText();
String newValue = value.toString();
Log.d("Reader", "Annot text " + m_annot);
Log.d("Reader", "Annot text " + m_annot.GetType());
Log.d("Reader", "Annot text " + m_annot.SetEditText(newValue));
Log.d("Reader", "Annot text " + m_annot.GetEditText());
Log.d("Reader", "Annot text type " + m_annot.GetEditTextFormat());
Log.d("Reader", "Annot text " + m_annot2);
Log.d("Reader", "Annot text " + m_annot2.GetType());
Log.d("Reader", "Annot text " + m_annot2.SetEditText(newValue));
Log.d("Reader", "Annot text " + m_annot2.GetEditText());
Log.d("Reader", "Annot text type " + m_annot2.GetEditTextFormat());
m_reader.PDFEndAnnot();
m_reader.updatePage(m_annot_vpage);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing.
m_reader.PDFEndAnnot();
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
m_reader.PDFEndAnnot();
}
}).create();
input.setText(m_annot.GetEditText());
input.setSelection(input.getText().length());
input.setSingleLine(true);
input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
dialog.show();
}
12-10 17:36:44.459 23223-23223/com.radaee.reader D/Reader: Annotation Click com.radaee.pdf.Page$Annotation@42312ea8
12-10 17:36:44.459 23223-23223/com.radaee.reader D/Reader: Gettype==3 3
12-10 17:36:44.839 23223-23223/com.radaee.reader D/Reader: Gettype==3 true
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text com.radaee.pdf.Page$Annotation@42312ea8
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text 0
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text false
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text null
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text type null
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text com.radaee.pdf.Page$Annotation@42312ea8
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text 0
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text false
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text null
12-10 17:36:49.269 23223-23223/com.radaee.reader D/Reader: Annot text type null