2023年7月13日发(作者:)
andorid实现pdf批注、笔记demoAndorid实现pdf批注、笔记demo1、兴建andorid项⽬2、导⼊pdf包implementation ‘pluto:pdf-viewer:1.0.5’1、创建页⾯和java类1.1创建OutlineAdapterpackage r;import t;import erView;import Inflater;import ;import oup;import ew;import eItem;import ication.R;/** * @Description: ⽂件⽬录adapter * @author: ZhangYW * @time: 2019/1/22 11:17 */public class OutlineAdapter extends r { private Context mContext; private OutlineItem mList[]; public OutlineAdapter(Context context, OutlineItem mList[]){ xt = context; = mList; } /** * 渲染具体的ViewHolder * @param parent ViewHolder的容器 * @param viewType ⼀个标志,我们根据该标志可以实现渲染不同类型的ViewHolder * @return */ @Override public lder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = (mContext).inflate(e_item,parent,false); return new OutlineViewHolder(itemView); } /** * 绑定ViewHolder的数据。 * @param holder * @param position 数据源list的下标 */ @Override public void onBindViewHolder(lder holder, final int position) { OutlineItem bean = mList[position]; if (null == bean) return; OutlineViewHolder viewHolder = (OutlineViewHolder) holder; int level = ; if (level > 8) level = 8; String space = ""; for (int i=0; i 1.3创建OnRecyclerItemClickListenerpackage ;import eDetectorCompat;import erView;import eDetector;import Event;import ;/** * RecyclerView监听事件 */public abstract class OnRecyclerItemClickListener implements TouchListener { private GestureDetectorCompat mGestureDetector; private RecyclerView recyclerView; public OnRecyclerItemClickListener(RecyclerView recyclerView) { erView = recyclerView; mGestureDetector = new GestureDetectorCompat(text(), new ItemTouchHelperGestureListener()); } @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { hEvent(e); return false; } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { hEvent(e); } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } private class ItemTouchHelperGestureListener extends OnGestureListener { @Override public boolean onSingleTapUp(MotionEvent e) { View child = ildViewUnder((), ()); if (child != null) { lder vh = ldViewHolder(child); onItemClick(vh); } return true; } @Override public void onLongPress(MotionEvent e) { View child = ildViewUnder((), ()); if (child != null) { lder vh = ldViewHolder(child); onItemLongClick(vh); } } } public abstract void onItemClick(lder vh); public abstract void onItemLongClick(lder vh);}1.4创建OutlineActivitypackage ty;import ;import patActivity;import LayoutManager;import erView;import eActivityData;import eItem;import ication.R;import eAdapter;import clerItemClickListener;/** * @Description: ⽬录 * @author: ZhangYW * @time: 2019/3/8 10:29 */public class OutlineActivity extends AppCompatActivity { private RecyclerView recyclerView; private OutlineAdapter adapter; private OutlineItem mItems[]; @Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); setContentView(ty_outline); initData(); initView(); setListener(); } /** * 初始化数据 */ private void initData(){ mItems = ().items; } /** * 初始化布局 */ private void initView(){ adapter = new OutlineAdapter(this,mItems); recyclerView = (RecyclerView)findViewById(e_rv); FixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); entation(AL);//HORIZONTAL ⽔平 outManager(linearLayoutManager); pter(adapter); } /** * 设置点击事件 */ private void setListener(){ temTouchListener(new OnRecyclerItemClickListener(recyclerView) { @Override public void onItemClick(lder vh) { ().position = outPosition(); setResult(mItems[outPosition()].page); finish(); } } @Override public void onItemLongClick(lder vh) { } }); }}1.5创建OutlineActivity的activity_页⾯ 1.6创建AllPDFActivitypackage ty;import ialog;import t;import Interface;import ;import ;import Factory;import ;import ;import le;import ask;import ;import ;import nment;import tCompat;import patActivity;import le;import tcher;import yMetrics;import ;import y;import nt;import Inflater;import ;import oup;import ion;import ateAnimation;import Info;import ethodManager;import ;import xt;import utton;import iew;import r;import r;import ew;import ;import imator;import tion;import ;import lert;import ore;import ageAdapter;import eaderView;import eaderViewListener;import iew;import eActivityData;import eItem;import View;import f;import Task;import TaskResult;import pLayout;import ication.R;import PreferencesUtil;import or;public class AllPDFActivity extends AppCompatActivity { private static final String TAG = pleName(); private final int OUTLINE_REQUEST = 0; private String filePath = ernalStorageDirectory() + "/pdf_"; // ⽂件路径// private String filePath = ernalStorageDirectory() + "/t"; // ⽂件路径 private String fileName;// ⽂件名 private r mAlertBuilder; static private r gAlertBuilder; private MuPDFCore muPDFCore;// 加载⽂件 private MuPDFReaderView muPDFReaderView;// 显⽰pdf的view private boolean mAlertsActive = false; private AsyncTask mAlertTask; private AlertDialog mAlertDialog; // tools private ViewAnimator mTopBarSwitcher;// ⼯具栏动画 private ImageButton mLinkButton;// 超链接 private ImageButton mOutlineButton;// ⽬录 private ImageButton mSearchButton;// 搜索 private ImageButton mAnnotButton;// 注释 // tools 搜索框 private EditText mSearchText;// 搜索内容输⼊框 private ImageButton mSearchBack;// 搜索内容上⼀个 private ImageButton mSearchFwd;// 搜索内容下⼀个 // tools 注释类型 private TextView mAnnotTypeText;// 注释类型 // tools 底部布局 private TextView mPageNumberView;// 页数 private SeekBar mPageSlider;// 底部拖动条 private int mPageSliderRes;// 拖动条的个数 private boolean mButtonsVisible;// 是否显⽰⼯具栏 private TopBarMode mTopBarMode = ;// ⼯具栏类型 private AcceptMode mAcceptMode;// ⼯具栏注释类型 private SearchTask mSearchTask;// 搜索线程 private boolean mLinkHighlight = false;// 是否⾼亮显⽰ private boolean mLinkHighlight = false;// 是否⾼亮显⽰ private Button btn_change_hv;// 切换横竖显⽰ private boolean ischangeHV = false;// 横竖切换 private Button btn_linkhighlightcolor;// 设置超链接颜⾊ private Button btn_searchtextcolor;// 设置搜索⽂字颜⾊ private Button btn_paintcolor;// 设置画笔颜⾊ private Button btn_paintstrokewidth;// 设置画笔粗细 private Button btn_sign;// 电⼦签章 private Button btn_save;// 保存 private VDHDeepLayout vdhDeepLayout; private ImageView iv_sign; private ImageView iv_test; private SavePdfTask savePdfTask; /* * ⽤于存储的异步,并上传更新 * */ class SavePdfTask extends AsyncTask { SavePdf savePdf; public SavePdfTask(SavePdf savePdf) { f = savePdf; } @Override protected Object doInBackground(Object[] params) { t(); return null; } @Override protected void onPostExecute(Object o) { Log.e(TAG, "存储完成"); try { } catch (Exception e) { tackTrace(); } } } @Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); setContentView(ty_all_pdf); initView(); } private void initView() { (getApplication()); muPDFReaderView = (MuPDFReaderView)findViewById(_pdf_mupdfreaderview); initToolsView(); mAlertBuilder = new r(this); // keep a static copy of this that other classes can use gAlertBuilder = mAlertBuilder; String path = filePath; String path = filePath; // 通过MuPDFCore打开pdf⽂件 muPDFCore = openFile(path); // 搜索设为空 (null); // 判断如果core为空,提⽰不能打开⽂件 if (muPDFCore == null) { AlertDialog alert = (); le(_open_document); ton(_POSITIVE, getString(s), new kListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); ancelListener(new elListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); (); return; } createUI(); //切换横竖显⽰ btn_change_hv = (Button)findViewById(_change_hv); btn_change_lickListener(new kListener() { @Override public void onClick(View v) { if (ischangeHV) { izontalScrolling(ischangeHV); btn_change_t("横"); ischangeHV = false; } else { izontalScrolling(ischangeHV); btn_change_t("竖"); ischangeHV = true; } } }); // 改变超链接颜⾊ btn_linkhighlightcolor = (Button)findViewById(_linkhighlightcolor); btn_lickListener(new kListener() { @Override public void onClick(View v) { setLinkHighlightColor(or(, _bg)); } }); // 改变搜索⽂字颜⾊ btn_searchtextcolor = (Button)findViewById(_searchtextcolor); btn_lickListener(new kListener() { @Override public void onClick(View v) { setSearchTextColor(or(, _bg)); } }); // 设置画笔颜⾊ btn_paintcolor = (Button)findViewById(_set_paint_color); btn_paintcolor = (Button)findViewById(_set_paint_color); btn_lickListener(new kListener() { @Override public void onClick(View v) { int c = or(, _item_line_bg); Log.e(TAG, "color = " + c); setColor(c); setInkColor(0xFF0000FF); } }); // 设置画笔粗细 btn_paintstrokewidth = (Button)findViewById(_set_paint_strokewidth); btn_lickListener(new kListener() { @Override public void onClick(View v) { setPaintStrockWidth(20.0f); } }); // 电⼦签章 btn_sign = (Button)findViewById(_sign); btn_lickListener(new kListener() { @Override public void onClick(View v) { Log.e(TAG, "btn_sign"); ibility(E); } }); // 保存 btn_save = (Button)findViewById(_save); btn_lickListener(new kListener() { @Override public void onClick(View v) { Log.e(TAG, "btn_save"); String in_path = filePath; String out_path = in_ing(0, in_() - 4) + "_"; SavePdf savePdf = new SavePdf(in_path, out_path); le(rentScale()); eNum(playedViewIndex() + 1); thScale(1.0f * leX() / playedView().getWidth());//计算宽偏移的百分⽐ ghtScale(1.0f * leY() / playedView().getHeight());//计算长偏移的百分⽐ Log.e(TAG, "scaleX = " + leX() + " " + playedView().getWidth()); (iv_(), iv_());// thScale(0);// ghtScale(0); //计算分辨率密度 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); float density = y; sity(density); Bitmap bitmap = getBitmap(, _launcher); map(bitmap);// Bitmap bitmap = Bitmap(th(), ght(),// _8888);// Canvas canvas = new Canvas(bitmap);// (canvas);// map(bitmap); Log.e(TAG, "iv_p = " + iv_() + " " + iv_()); Log.e(TAG, "屏幕 = " + th() + " " + ght()); savePdfTask = new SavePdfTask(savePdf); e(); } }); vdhDeepLayout = (VDHDeepLayout)findViewById(pLayout); iv_sign = (ImageView)findViewById(_sign); iv_test = (ImageView)findViewById(_test); } private static Bitmap getBitmap(Context context,int vectorDrawableId) { Bitmap bitmap=null; if (_INT>N_OP){ Drawable vectorDrawable = wable(vectorDrawableId); bitmap = Bitmap(rinsicWidth(), rinsicHeight(), _8888); Canvas canvas = new Canvas(bitmap); nds(0, 0, th(), ght()); (canvas); }else { bitmap = Resource(ources(), vectorDrawableId); } return bitmap; } public void setColor(int color) { int red = (color & 0xff0000) >> 16; int green = (color & 0x00ff00) >> 8; int blue = (color & 0x0000ff); Log.e(TAG, "r = " + red + " g = " + green + " b = " + blue); } /** * 初始化⼯具栏 */ private void initToolsView() { mTopBarSwitcher = (ViewAnimator) findViewById(er); mLinkButton = (ImageButton) findViewById(tton); mAnnotButton = (ImageButton) findViewById(Button); mOutlineButton = (ImageButton) findViewById(eButton); mSearchButton = (ImageButton) findViewById(Button); mSearchText = (EditText) findViewById(Text); mSearchBack = (ImageButton) findViewById(Back); mSearchFwd = (ImageButton) findViewById(Forward); mAnnotTypeText = (TextView) findViewById(ype); mPageNumberView = (TextView) findViewById(mber); mPageSlider = (SeekBar) findViewById(ider); ibility(BLE); ibility(BLE); ibility(BLE); } /** * 打开⽂件 * @param path ⽂件路径 * @return */ */ private MuPDFCore openFile(String path) { int lastSlashPos = dexOf('/'); fileName = new String(lastSlashPos == -1 path : ing(lastSlashPos + 1)); Log.e(TAG, "filename = " + fileName); Log.e(TAG, "Trying to open " + path); try { muPDFCore = new MuPDFCore(this, path); // 新建:删除旧的⽬录数据 (null); } catch (Exception e) { Log.e(TAG, "openFile catch:" + ng()); return null; } catch (OutOfMemoryError e) { // out of memory is not an Exception, so we catch it separately. Log.e(TAG, "openFile catch: OutOfMemoryError " + ng()); return null; } return muPDFCore; } private void createUI() { if (muPDFCore == null) return; // Set up the page slider int smax = (ages() - 1, 1); mPageSliderRes = ((10 + smax - 1) / smax) * 2; // Now create the UI. // First create the document view tener(new MuPDFReaderViewListener() { @Override public void onMoveToChild(int i) { if (muPDFCore == null) return; t(("%d / %d", i + 1, ages())); ((ages() - 1) * mPageSliderRes); gress(i * mPageSliderRes); } @Override public void onTapMainDocArea() { if (!mButtonsVisible) { showButtons(); } else { if (mTopBarMode == ) hideButtons(); } } @Override public void onDocMotion() { hideButtons(); } @Override public void onHit(Hit item) { switch (mTopBarMode) { case Annot: if (item == tion) { showButtons(); showButtons(); mTopBarMode = ; playedChild(l()); } break; case Delete: mTopBarMode = ; playedChild(l()); // fall through default: // Not in annotation editing mode, but the pageview will // still select and highlight hit annotations, so // deselect just in case. MuPDFView pageView = (MuPDFView) playedView(); if (pageView != null) ctAnnotation(); break; } } }); pter(new MuPDFPageAdapter(this, muPDFCore)); // 设置view的背景⾊ kgroundColor(or(this, eaderView_bg)); mSearchTask = new SearchTask(this, muPDFCore) { @Override protected void onTextFound(SearchTaskResult result) { (result); // Ask the ReaderView to move to the resulting page playedViewIndex(mber); // Make the ReaderView act on the change to SearchTaskResult // via overridden onChildSetup method. pChildren(); } }; eekBarChangeListener(new BarChangeListener() { public void onStopTrackingTouch(SeekBar seekBar) { playedViewIndex((gress() + mPageSliderRes / 2) / mPageSliderRes); } public void onStartTrackingTouch(SeekBar seekBar) { } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { updatePageNumView((progress + mPageSliderRes / 2) / mPageSliderRes); } }); // Activate the search-preparing button lickListener(new kListener() { public void onClick(View v) { searchModeOn(); } }); if (rmat().startsWith("PDF") && cryptedPDF() && !nedFromBuffer()) { lickListener(new kListener() { public void onClick(View v) { mTopBarMode = ; playedChild(l()); } }); }); } else { ibility(); } // Search invoking buttons are disabled while there is no text specified bled(false); bled(false); orFilter((0xFF, 250, 250, 250)); orFilter((0xFF, 250, 250, 250)); // React to interaction with the text widget tChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { boolean haveText = ng().length() > 0; setButtonEnabled(mSearchBack, haveText); setButtonEnabled(mSearchFwd, haveText); // Remove any previous search results if (() != null && !t().toString().equals(().txt)) { (null); pChildren(); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); //React to Done button on keyboard ditorActionListener(new orActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == _ACTION_DONE) search(1); return false; } }); eyListener(new istener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (ion() == _DOWN && keyCode == E_ENTER) search(1); return false; } }); // Activate search invoking buttons lickListener(new kListener() { public void onClick(View v) { search(-1); } }); lickListener(new kListener() { public void onClick(View v) { search(1); } }); lickListener(new kListener() { public void onClick(View v) { public void onClick(View v) { setLinkHighlight(!mLinkHighlight); } }); // 判断如果pdf⽂件有⽬录 if (line()) { // 点击⽬录按钮跳转到⽬录页 lickListener(new kListener() { public void onClick(View v) { OutlineItem outline[] = line(); if (outline != null) { ().items = outline; Intent intent = new Intent(, ); startActivityForResult(intent, OUTLINE_REQUEST); } } }); } else { ibility(); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case OUTLINE_REQUEST: if (resultCode >= 0) playedViewIndex(resultCode); break; } vityResult(requestCode, resultCode, data); } /** * 显⽰⼯具栏 */ private void showButtons() { if (muPDFCore == null) return; if (!mButtonsVisible) { mButtonsVisible = true; // Update page number text and slider int index = playedViewIndex(); updatePageNumView(index); ((ages() - 1) * mPageSliderRes); gress(index * mPageSliderRes); if (mTopBarMode == ) { tFocus(); showKeyboard(); } Animation anim = new TranslateAnimation(0, 0, -ght(), 0); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(E); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { } }); }); nimation(anim); anim = new TranslateAnimation(0, 0, ght(), 0); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(E); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(E); } }); nimation(anim); } } /** * 隐藏⼯具栏 */ private void hideButtons() { if (mButtonsVisible) { mButtonsVisible = false; hideKeyboard(); Animation anim = new TranslateAnimation(0, 0, 0, -ght()); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(BLE); } }); nimation(anim); anim = new TranslateAnimation(0, 0, 0, ght()); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(BLE); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(BLE); } }); nimation(anim); } } /** * 更新当前是第多少页 * @param index */ */ private void updatePageNumView(int index) { if (muPDFCore == null) return; t(("%d / %d", index + 1, ages())); } /** * 显⽰键盘 */ private void showKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(_METHOD_SERVICE); if (imm != null) ftInput(mSearchText, 0); } /** * 隐藏键盘 */ private void hideKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(_METHOD_SERVICE); if (imm != null) ftInputFromWindow(dowToken(), 0); } /** * ⼯具栏 - 注释点击事件 * @param v */ public void OnEditAnnotButtonClick(View v) { mTopBarMode = ; playedChild(l()); } /** * ⼯具栏 - 复制点击事件 * @param v */ public void OnCopyTextButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = xt; e(ing); t(getString(_text)); showInfo(getString(_text)); } /** * ⼯具栏 - 搜索框取消点击事件 * @param v */ public void OnCancelSearchButtonClick(View v) { searchModeOff(); } /** * ⼯具栏 - 注释取消点击事件 * @param v */ public void OnCancelMoreButtonClick(View v) { mTopBarMode = ; playedChild(l()); } /** * 开始搜索 * 开始搜索 */ private void searchModeOn() { if (mTopBarMode != ) { mTopBarMode = ; //Focus on EditTextWidget tFocus(); showKeyboard(); playedChild(l()); } } /** * 取消搜索 */ private void searchModeOff() { if (mTopBarMode == ) { mTopBarMode = ; hideKeyboard(); playedChild(l()); (null); // Make the ReaderView act on the change to mSearchTaskResult // via overridden onChildSetup method. pChildren(); } } /** * ⼯具栏 - 注释 - ⾼亮点击事件 * @param v */ public void OnHighlightButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ght; e(ing); t(_tools_highlight); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 底部画线点击事件 * @param v */ public void OnUnderlineButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ine; e(ing); t(_tools_underline); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 废弃线点击事件 * @param v */ public void OnStrikeOutButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = Out; e(ing); t(_tools_strike_out); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 签字点击事件 * @param v */ public void OnInkButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ; e(g); t(_tools_ink); showInfo(getString(_tools_draw_annotation)); } /** * ⼯具栏 - 注释 - 删除注释点击事件 * @param v */ public void OnDeleteButtonClick(View v) { MuPDFView pageView = (MuPDFView) playedView(); if (pageView != null) SelectedAnnotation(); mTopBarMode = ; playedChild(l()); } /** * ⼯具栏 - 注释 - 取消删除注释点击事件 * @param v */ public void OnCancelDeleteButtonClick(View v) { MuPDFView pageView = (MuPDFView) playedView(); if (pageView != null) ctAnnotation(); mTopBarMode = ; playedChild(l()); } /** * ⼯具栏 - 注释 - 取消点击事件 * @param v */ public void OnCancelAcceptButtonClick(View v) { MuPDFView pageView = (MuPDFView) playedView(); if (pageView != null) { ctText(); Draw(); } e(g); switch (mAcceptMode) { case CopyText: mTopBarMode = ; break; default: mTopBarMode = ; break; } playedChild(l()); } /** * ⼯具栏 - 注释 - 确定点击事件 * @param v */ public void OnAcceptButtonClick(View v) { MuPDFView pageView = (MuPDFView) playedView(); MuPDFView pageView = (MuPDFView) playedView(); boolean success = false; switch (mAcceptMode) { case CopyText: if (pageView != null) success = lection(); mTopBarMode = ; showInfo(success ? getString(_to_clipboard) : getString(_text_selected)); break; case Highlight: // ⾼亮 if (pageView != null) { success = Selection(GHT); } mTopBarMode = ; if (!success) { showInfo(getString(_text_selected)); } break; case Underline: if (pageView != null) success = Selection(INE); mTopBarMode = ; if (!success) showInfo(getString(_text_selected)); break; case StrikeOut: if (pageView != null) success = Selection(OUT); mTopBarMode = ; if (!success) showInfo(getString(_text_selected)); break; case Ink: if (pageView != null) success = aw(); mTopBarMode = ; if (!success) showInfo(getString(g_to_save)); break; } playedChild(l()); e(g); } /** * 设置按钮是否可点击 * @param button * @param enabled */ private void setButtonEnabled(ImageButton button, boolean enabled) { bled(enabled); orFilter(enabled ? (0xFF, 250, 250, 250) : (0xFF, 250, 250, 250)); } /** * 开始搜索 * @param direction 搜索内容 */ private void search(int direction) { hideKeyboard(); int displayPage = playedViewIndex(); SearchTaskResult r = (); SearchTaskResult r = (); int searchPage = r != null ? mber : -1; (t().toString(), direction, displayPage, searchPage); } /** * 设置超链接⾼亮显⽰ * @param highlight */ private void setLinkHighlight(boolean highlight) { mLinkHighlight = highlight; // LINK_COLOR tint orFilter(highlight ? (0xFF, 255, 160, 0) : (0xFF, 255, 255, 255)); // Inform pages of the change. ksEnabled(highlight); } /** * 设置超链接颜⾊ * @param color 颜⾊值 */ private void setLinkHighlightColor(int color) { kHighlightColor(color); } /** * 设置搜索⽂字颜⾊ * @param color 颜⾊值 */ private void setSearchTextColor(int color) { rchTextColor(color); } /** * 设置画笔颜⾊ * @param color 颜⾊值 */ private void setInkColor(int color) { Color(color); } /** * 设置画笔粗细 * @param inkThickness 粗细值 */ private void setPaintStrockWidth(float inkThickness) { ntStrockWidth(inkThickness); } /** * ⼯具栏弹出提⽰信息 * @param message 提⽰内容 */ private void showInfo(String message) { LayoutInflater inflater = getLayoutInflater(); View toastLayout = e(, (ViewGroup) findViewById(_root_view)); TextView header = (TextView) ewById(_message); t(message); Toast toast = new Toast(getApplicationContext()); vity(_HORIZONTAL | , 0, 0); ation(_LONG); w(toastLayout); w(toastLayout); (); } /** * 获取静态dialog * @return */ public static r getAlertBuilder() { return gAlertBuilder; } /** * 创建提⽰等待 */ public void createAlertWaiter() { mAlertsActive = true; // All mupdf library calls are performed on asynchronous tasks to avoid stalling // the UI. Some calls can lead to javascript-invoked requests to display an // alert dialog and collect a reply from the user. The task has to be blocked // until the user's reply is received. This method creates an asynchronous task, // the purpose of which is to wait of these requests and produce the dialog // in response, while leaving the core blocked. When the dialog receives the // user's response, it is sent to the core via replyToAlert, unblocking it. // Another alert-waiting task is then created to pick up the next alert. if (mAlertTask != null) { (true); mAlertTask = null; } if (mAlertDialog != null) { (); mAlertDialog = null; } mAlertTask = new AsyncTask() { @Override protected MuPDFAlert arg0) { if (!mAlertsActive) return null; return rAlert(); } @Override protected void onPostExecute(final MuPDFAlert result) { // rAlert may return null when shutting down if (result == null) return; final Pressed pressed[] = new Pressed[3]; for (int i = 0; i < 3; i++) pressed[i] = ; kListener listener = new kListener() { public void onClick(DialogInterface dialog, int which) { mAlertDialog = null; if (mAlertsActive) { int index = 0; switch (which) { case 1: index = 0; break; case 2: index = 1; break; case 3: index = 2; break; } Pressed = pressed[index]; // Send the user's response to the core, so that it can // continue processing. oAlert(result); // Create another alert-waiter to pick up the next alert. createAlertWaiter(); } } }; mAlertDialog = (); le(); sage(e); switch (pe) { case Error: break; case Warning: break; case Question: break; case Status: break; } switch (GroupType) { case OkCancel: ton(2, getString(), listener); pressed[1] = ; case Ok: ton(1, getString(), listener); pressed[0] = ; break; case YesNoCancel: ton(3, getString(), listener); pressed[2] = ; case YesNo: ton(1, getString(), listener); pressed[0] = ; ton(2, getString(), listener); pressed[1] = ; break; } ancelListener(new elListener() { public void onCancel(DialogInterface dialog) { mAlertDialog = null; if (mAlertsActive) { Pressed = ; oAlert(result); createAlertWaiter(); } } }); (); } }; eOnExecutor(new ThreadPerTaskExecutor()); } /** * 销毁提⽰等待 */ public void destroyAlertWaiter() { mAlertsActive = false; if (mAlertDialog != null) { (); mAlertDialog = null; } if (mAlertTask != null) { (true); mAlertTask = null; } } @Override protected void onStart() { if (muPDFCore != null) { lerts(); createAlertWaiter(); } t(); } @Override protected void onPause() { e(); if (mSearchTask != null) { (); }// if (mFileName != null && mDocView != null) {// SharedPreferences prefs = getPreferences(_PRIVATE);// edit = ();// ("page" + mFileName, playedViewIndex());// ();// } } @Override protected void onStop() { if (muPDFCore != null) { destroyAlertWaiter(); erts(); } (); } @Override protected void onDestroy() { if (muPDFReaderView != null) { oChildren(new pper() { public void applyToView(View view) { ((MuPDFView) view).releaseBitmaps(); } }); } if (muPDFCore != null) roy(); if (mAlertTask != null) { (true); mAlertTask = null; } muPDFCore = null; roy(); } @Override public void onBackPressed() { if (muPDFCore != null && nges()) { kListener listener = new kListener() { public void onClick(DialogInterface dialog, int which) { if (which == _POSITIVE) { (); } finish(); } }; AlertDialog alert = (); le(_title); sage(getString(nt_has_changes_save_them)); ton(_POSITIVE, getString(), listener); ton(_NEGATIVE, getString(), listener); (); } else { finish(); } } /** * 多线程类 */ class ThreadPerTaskExecutor implements Executor { public void execute(Runnable r) { new Thread(r).start(); } } /** * ⼯具栏类型 Search:搜索 Annot:注释 */ enum TopBarMode { Main, Search, Annot, Delete, Accept } /** * ⼯具栏注释类型 Highlight:⾼亮显⽰ ,Underline:底部画线 ,StrikeOut:废弃线 ,Ink:签字 ,CopyText:复制⽂字 */ enum AcceptMode { Highlight, Underline, StrikeOut, Ink, CopyText }}1.7创建AllPDFActivity的activity_all_页⾯ 1.8创建activity_all_pdf的依赖pdf_页⾯ android:src="@drawable/ic_format_color_fill_white_48dp" /> 1.9创建MainBeanpackage ;/** * @Description: 列表bean * @author: ZhangYW * @time: 2019/3/11 16:16 */public class MainBean { /** * 标题 */ private String title; /** * 描述 */ private String describe; public String getTitle() { return title; } public void setTitle(String title) { = title; } public String getDescribe() { return describe; } public void setDescribe(String describe) { be = describe; }}1.9创建MainAdapterpackage r;import t;import erView;import Inflater;import ;import oup;import ew;import ication.R;import an;import ;/** * @Description: ⽂件⽬录adapter * @author: ZhangYW * @time: 2019/1/22 11:17 */public class MainAdapter extends r { private Context mContext; private List mList; public MainAdapter(Context context, List list){ xt = context; = list; } /** * 渲染具体的ViewHolder * @param parent ViewHolder的容器 * @param viewType ⼀个标志,我们根据该标志可以实现渲染不同类型的ViewHolder * @return */ @Override public lder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = (mContext).inflate(_item,parent,false); return new MainViewHolder(itemView); } /** * 绑定ViewHolder的数据。 * @param holder * @param position 数据源list的下标 */ @Override public void onBindViewHolder(lder holder, final int position) { MainBean bean = (position); if (null == bean) return; MainViewHolder viewHolder = (MainViewHolder) holder; _t(le()); _t(cribe()); } @Override public int getItemCount() { return (); } public static class MainViewHolder extends lder{ public TextView tv_title; public TextView tv_describe; public MainViewHolder(View itemView){ super(itemView); tv_title = (TextView) ewById(_item_tv_title); tv_describe = (TextView) ewById(_item_tv_describe); } }}1.10创建MainAdapter的main_页⾯ 1.11创建MainActivitypackage ication;import st;import ;import eManager;import ;import tyCompat;import tCompat;import patActivity;import LayoutManager;import erView;import ;import apter;import an;import clerItemClickListener;import ist;import ;import p;import ;public class MainActivity extends AppCompatActivity { private static final String TAG = pleName(); private final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 101; private RecyclerView recyclerView; private MainAdapter adapter; private List list; @Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); setContentView(ty_main); checkPermissions(); initData(); initView(); setListener(); } /** * 初始化数据 */ private void initData(){ list = new ArrayList<>(); List list_title = (getResources().getStringArray(_title)); List list_describe = (getResources().getStringArray(_describe)); for (int i = 0; i < list_(); i++) { MainBean bean = new MainBean(); le(list_(i)); cribe(list_(i)); (bean); } } /** * 初始化布局 */ private void initView(){ adapter = new MainAdapter(this, list); recyclerView = (RecyclerView)findViewById(_rv); FixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); entation(AL);//HORIZONTAL ⽔平 outManager(linearLayoutManager); pter(adapter); } /** * 设置点击事件 */ private void setListener(){ temTouchListener(new OnRecyclerItemClickListener(recyclerView) { @Override public void onItemClick(lder vh) { switch (outPosition()) { case 0: // 基础功能仅显⽰pdf// startActivity(new Intent(, )); break; case 1: // MuPDF已有功能// startActivity(new Intent(, )); break; case 2: // ⼀些主要⽅法的设置 startActivity(new Intent(, )); break; case 3: // 电⼦签章// startActivity(new Intent(, )); break; } } @Override public void onItemLongClick(lder vh) { } }); } /** * 权限回调 * @param requestCode * @param permissions * @param grantResults */ @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case WRITE_EXTERNAL_STORAGE_REQUEST_CODE: perms = new HashMap<>(); (_EXTERNAL_STORAGE, SION_GRANTED); for (int i = 0; i < ; i++){ (permissions[i], grantResults[i]); } Boolean storage = (_EXTERNAL_STORAGE) == SION_GRANTED; if (storage) { xt(this, "允许存储权限", _SHORT).show(); } else { xt(this, "存储权限被拒绝", _SHORT).show(); } break; default: estPermissionsResult(requestCode, permissions, grantResults); } } /** * 申请读写权限 */ private void checkPermissions() { List permissions = new ArrayList<>(); if (elfPermission(this, _EXTERNAL_STORAGE) != SION_GRANTED) { (_EXTERNAL_STORAGE); } if (!y()) { String[] params = y(new String[()]); tPermissions(this, params, WRITE_EXTERNAL_STORAGE_REQUEST_CODE); } else { } }}1.12创建MainActivity的activity_页⾯ 1.13创建页⾯ - 基础pdf显⽰
- MuPDF⾃带功能
- 主要⽅法的设置
- pdf插⼊图⽚
- 最基本的显⽰⼀个pdf⽂件 BasePDFActivity
- MuPDF⾃带功能 MuPDFActivity
- 包括横竖滑动切换、超链接颜⾊、搜索颜⾊、画笔颜⾊、画笔粗细 SetVoidActivity
- 类似电⼦签章功能 SignActivity
1.13创建MoreSetActivitypackage ty;import ialog;import t;import Interface;import ;import ;import ask;import ;import nment;import tCompat;import patActivity;import le;import tcher;import ;import y;import nt;import Inflater;import ;import oup;import ion;import ateAnimation;import Info;import ethodManager;import ;import xt;import utton;import r;import ew;import ;import imator;import tion;import ;import lert;import ore;import ageAdapter;import eaderView;import eaderViewListener;import iew;import eActivityData;import eItem;import View;import Task;import TaskResult;import ication.R;import PreferencesUtil;import or;/** * @Description: ⼀些主要⽅法的设置,在已有功能的基础上增加了⼀些动态设置参数的⽅法 * @author: ZhangYW * @time: 2019/3/11 15:56 */public class MoreSetActivity extends AppCompatActivity { private static final String TAG = pleName(); private final int OUTLINE_REQUEST = 0;// ⽬录回调 private String filePath = ernalStorageDirectory() + "/Download/预通知.pdf"; // ⽂件路径 private r mAlertBuilder;// 弹出框 private MuPDFCore muPDFCore;// 加载⽂件 private MuPDFReaderView muPDFReaderView;// 显⽰pdf的view private boolean mAlertsActive = false; private AsyncTask mAlertTask; private AlertDialog mAlertDialog;// 初始加载pdf等待弹出框 // tools private ViewAnimator mTopBarSwitcher;// ⼯具栏动画 private ImageButton mLinkButton;// 超链接 private ImageButton mOutlineButton;// ⽬录 private ImageButton mSearchButton;// 搜索 private ImageButton mAnnotButton;// 注释 // tools 搜索框 private EditText et_searchText;// 搜索内容输⼊框 private ImageButton mSearchBack;// 搜索内容上⼀个 private ImageButton mSearchFwd;// 搜索内容下⼀个 // tools 注释类型 private TextView mAnnotTypeText;// 注释类型 // tools 底部布局 private TextView mPageNumberView;// 页数 private SeekBar mPageSlider;// 底部拖动条 private int mPageSliderRes;// 拖动条的个数 private boolean mButtonsVisible;// 是否显⽰⼯具栏 private TopBarMode mTopBarMode = ;// ⼯具栏类型 private AcceptMode mAcceptMode;// ⼯具栏注释类型 private SearchTask mSearchTask;// 搜索线程 private boolean mLinkHighlight = false;// 是否⾼亮显⽰ private Button btn_change_hv;// 切换横竖显⽰ private boolean ischangeHV = false;// 横竖切换 private Button btn_linkhighlightcolor;// 设置超链接颜⾊ private Button btn_searchtextcolor;// 设置搜索⽂字颜⾊ private Button btn_paintcolor;// 设置画笔颜⾊ private Button btn_paintstrokewidth;// 设置画笔粗细 @Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); setContentView(ty_more_set); initView(); } /** * 初始化 */ private void initView() { (getApplication()); muPDFReaderView = (MuPDFReaderView)findViewById(eaderview); initToolsView(); createPDF(); setPDFVoid(); } private void setPDFVoid(){ //切换横竖显⽰ btn_change_hv = (Button)findViewById(_change_hv); btn_change_lickListener(new kListener() { @Override public void onClick(View v) { if (ischangeHV) { izontalScrolling(ischangeHV); btn_change_t("横"); ischangeHV = false; } else { izontalScrolling(ischangeHV); btn_change_t("竖"); ischangeHV = true; } } }); // 改变超链接颜⾊ btn_linkhighlightcolor = (Button)findViewById(_linkhighlightcolor); btn_lickListener(new kListener() { @Override public void onClick(View v) { setLinkHighlightColor(or(, _bg)); } }); // 改变搜索⽂字颜⾊ btn_searchtextcolor = (Button)findViewById(_searchtextcolor); btn_lickListener(new kListener() { @Override public void onClick(View v) { setSearchTextColor(or(, _bg)); } }); // 设置画笔颜⾊ // 设置画笔颜⾊ btn_paintcolor = (Button)findViewById(_set_paint_color); btn_lickListener(new kListener() { @Override public void onClick(View v) { int c = or(, _item_line_bg); setInkColor(0xFF0000FF); } }); // 设置画笔粗细 btn_paintstrokewidth = (Button)findViewById(_set_paint_strokewidth); btn_lickListener(new kListener() { @Override public void onClick(View v) { setPaintStrockWidth(20.0f); } }); } /** * 初始化⼯具栏 */ private void initToolsView() { mTopBarSwitcher = (ViewAnimator) findViewById(er); mLinkButton = (ImageButton) findViewById(tton); mAnnotButton = (ImageButton) findViewById(Button); mOutlineButton = (ImageButton) findViewById(eButton); mSearchButton = (ImageButton) findViewById(Button); et_searchText = (EditText) findViewById(Text); mSearchBack = (ImageButton) findViewById(Back); mSearchFwd = (ImageButton) findViewById(Forward); mAnnotTypeText = (TextView) findViewById(ype); mPageNumberView = (TextView) findViewById(mber); mPageSlider = (SeekBar) findViewById(ider); ibility(BLE); ibility(BLE); ibility(BLE); } private void createPDF() { mAlertBuilder = new r(this); // 通过MuPDFCore打开pdf⽂件 muPDFCore = openFile(filePath); // 搜索设为空 (null); // 判断如果core为空,提⽰不能打开⽂件 if (muPDFCore == null) { AlertDialog alert = (); le(_open_document); ton(_POSITIVE, getString(s), new kListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); ancelListener(new elListener() { @Override public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) { finish(); } }); (); return; } // 显⽰ pter(new MuPDFPageAdapter(this, muPDFCore)); // Set up the page slider int smax = (ages() - 1, 1); mPageSliderRes = ((10 + smax - 1) / smax) * 2; // 创建搜索任务 mSearchTask = new SearchTask(this, muPDFCore) { @Override protected void onTextFound(SearchTaskResult result) { (result); // Ask the ReaderView to move to the resulting page playedViewIndex(mber); // Make the ReaderView act on the change to SearchTaskResult // via overridden onChildSetup method. pChildren(); } }; // Search invoking buttons are disabled while there is no text specified bled(false); bled(false); orFilter((0xFF, 250, 250, 250)); orFilter((0xFF, 250, 250, 250)); // 判断如果pdf⽂件有⽬录 if (line()) { // 点击⽬录按钮跳转到⽬录页 lickListener(new kListener() { public void onClick(View v) { OutlineItem outline[] = line(); if (outline != null) { ().items = outline; Intent intent = new Intent(, ); startActivityForResult(intent, OUTLINE_REQUEST); } } }); } else { ibility(); } // 设置监听事件 setListener(); } /** * 打开⽂件 * @param path ⽂件路径 * @return */ private MuPDFCore openFile(String path) { Log.e(TAG, "Trying to open " + path); try { muPDFCore = new MuPDFCore(this, path); // 新建:删除旧的⽬录数据 (null); } catch (Exception e) { } catch (Exception e) { Log.e(TAG, "openFile catch:" + ng()); return null; } catch (OutOfMemoryError e) { // out of memory is not an Exception, so we catch it separately. Log.e(TAG, "openFile catch: OutOfMemoryError " + ng()); return null; } return muPDFCore; } /** * 设置监听事件 */ private void setListener(){ // 设置MuPDFReaderView的监听事件 setMuPDFReaderViewListener(); // 设置页⾯拖动条监听事件 eekBarChangeListener(new BarChangeListener() { public void onStopTrackingTouch(SeekBar seekBar) { playedViewIndex((gress() + mPageSliderRes / 2) / mPageSliderRes); } public void onStartTrackingTouch(SeekBar seekBar) { } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { updatePageNumView((progress + mPageSliderRes / 2) / mPageSliderRes); } }); // 搜索按钮 lickListener(new kListener() { public void onClick(View v) { searchModeOn(); } }); // 注释按钮 if (rmat().startsWith("PDF") && cryptedPDF() && !nedFromBuffer()) { lickListener(new kListener() { public void onClick(View v) { mTopBarMode = ; playedChild(l()); } }); } else { ibility(); } // 搜索的输⼊框监听事件 et_tChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { boolean haveText = ng().length() > 0; setButtonEnabled(mSearchBack, haveText); setButtonEnabled(mSearchFwd, haveText); // Remove any previous search results if (() != null && !et_t().toString().equals(().txt)) { (null); pChildren(); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); //React to Done button on keyboard et_ditorActionListener(new orActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == _ACTION_DONE) search(1); return false; } }); et_eyListener(new istener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (ion() == _DOWN && keyCode == E_ENTER) search(1); return false; } }); // Activate search invoking buttons lickListener(new kListener() { public void onClick(View v) { search(-1); } }); lickListener(new kListener() { public void onClick(View v) { search(1); } }); lickListener(new kListener() { public void onClick(View v) { setLinkHighlight(!mLinkHighlight); } }); } /** * 设置MuPDFReaderView的监听事件 */ private void setMuPDFReaderViewListener(){ tener(new MuPDFReaderViewListener() { @Override public void onMoveToChild(int i) { if (muPDFCore == null) { return; } t(("%d / %d", i + 1, ages())); ((ages() - 1) * mPageSliderRes); gress(i * mPageSliderRes); } @Override public void onTapMainDocArea() { if (!mButtonsVisible) { showButtons(); } else { if (mTopBarMode == ) hideButtons(); hideButtons(); } } @Override public void onDocMotion() { hideButtons(); } @Override public void onHit(Hit item) { switch (mTopBarMode) { case Annot: if (item == tion) { showButtons(); mTopBarMode = ; playedChild(l()); } break; case Delete: mTopBarMode = ; playedChild(l()); // fall through default: // Not in annotation editing mode, but the pageview will // still select and highlight hit annotations, so // deselect just in case. MuPDFView pageView = (MuPDFView) playedView(); if (pageView != null) { ctAnnotation(); } break; } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { // ⽬录回调 case OUTLINE_REQUEST: if (resultCode >= 0) playedViewIndex(resultCode); break; } vityResult(requestCode, resultCode, data); } /** * 设置超链接颜⾊ * @param color 颜⾊值 */ private void setLinkHighlightColor(int color) { kHighlightColor(color); } /** * 设置搜索⽂字颜⾊ * @param color 颜⾊值 */ private void setSearchTextColor(int color) { rchTextColor(color); } /** * 设置画笔颜⾊ * @param color 颜⾊值 */ private void setInkColor(int color) { Color(color); } /** * 设置画笔粗细 * @param inkThickness 粗细值 */ private void setPaintStrockWidth(float inkThickness) { ntStrockWidth(inkThickness); } /** * 显⽰⼯具栏 */ private void showButtons() { if (muPDFCore == null) return; if (!mButtonsVisible) { mButtonsVisible = true; // Update page number text and slider int index = playedViewIndex(); updatePageNumView(index); ((ages() - 1) * mPageSliderRes); gress(index * mPageSliderRes); if (mTopBarMode == ) { et_tFocus(); showKeyboard(); } Animation anim = new TranslateAnimation(0, 0, -ght(), 0); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(E); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { } }); nimation(anim); anim = new TranslateAnimation(0, 0, ght(), 0); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(E); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(E); } }); nimation(anim); } } } /** * 隐藏⼯具栏 */ private void hideButtons() { if (mButtonsVisible) { mButtonsVisible = false; hideKeyboard(); Animation anim = new TranslateAnimation(0, 0, 0, -ght()); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(BLE); } }); nimation(anim); anim = new TranslateAnimation(0, 0, 0, ght()); ation(200); mationListener(new ionListener() { public void onAnimationStart(Animation animation) { ibility(BLE); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { ibility(BLE); } }); nimation(anim); } } /** * 更新当前是第多少页 * @param index */ private void updatePageNumView(int index) { if (muPDFCore == null) return; t(("%d / %d", index + 1, ages())); } /** * 显⽰键盘 */ private void showKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(_METHOD_SERVICE); if (imm != null) ftInput(et_searchText, 0); } /** * 隐藏键盘 */ */ private void hideKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(_METHOD_SERVICE); if (imm != null) ftInputFromWindow(et_dowToken(), 0); } /** * ⼯具栏 - 注释点击事件 * @param v */ public void OnEditAnnotButtonClick(View v) { mTopBarMode = ; playedChild(l()); } /** * ⼯具栏 - 复制点击事件 * @param v */ public void OnCopyTextButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = xt; e(ing); t(getString(_text)); showInfo(getString(_text)); } /** * ⼯具栏 - 搜索框取消点击事件 * @param v */ public void OnCancelSearchButtonClick(View v) { searchModeOff(); } /** * ⼯具栏 - 注释取消点击事件 * @param v */ public void OnCancelMoreButtonClick(View v) { mTopBarMode = ; playedChild(l()); } /** * 开始搜索 */ private void searchModeOn() { if (mTopBarMode != ) { mTopBarMode = ; //Focus on EditTextWidget et_tFocus(); showKeyboard(); playedChild(l()); } } /** * 取消搜索 */ private void searchModeOff() { if (mTopBarMode == ) { mTopBarMode = ; hideKeyboard(); hideKeyboard(); playedChild(l()); (null); // Make the ReaderView act on the change to mSearchTaskResult // via overridden onChildSetup method. pChildren(); } } /** * ⼯具栏 - 注释 - ⾼亮点击事件 * @param v */ public void OnHighlightButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ght; e(ing); t(_tools_highlight); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 底部画线点击事件 * @param v */ public void OnUnderlineButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ine; e(ing); t(_tools_underline); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 废弃线点击事件 * @param v */ public void OnStrikeOutButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = Out; e(ing); t(_tools_strike_out); showInfo(getString(_text)); } /** * ⼯具栏 - 注释 - 签字点击事件 * @param v */ public void OnInkButtonClick(View v) { mTopBarMode = ; playedChild(l()); mAcceptMode = ; e(g); t(_tools_ink); showInfo(getString(_tools_draw_annotation)); } /** * ⼯具栏 - 注释 - 删除注释点击事件 * @param v */ public void OnDeleteButtonClick(View v) {
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689216168a222297.html
评论列表(0条)