@TargetApi(8) private void load() { final String uri = getPath(); final WebSettings settings = wv.getSettings(); if (uri.endsWith(".swf") && ActivityUtil.isGreaterThan_2_1()) // android 2.2 { wv.setWebChromeClient(new WebChromeClient()); // settings.setPluginState(PluginState.ON); wv.loadUrl(uri); getSupportActionBar().setTitle("查看视频"); } else { // images settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setUseWideViewPort(true); if (ActivityUtil.isGreaterThan_2_1()) settings.setLoadWithOverviewMode(true); // settings.setUserAgentString(IPHONE_UA); wv.setWebViewClient( new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub return false; } }); wv.loadUrl(uri); getSupportActionBar().setTitle("查看图片"); } }
@Override protected void onResume() { if (action.equals("new")) { if (StringUtil.isEmpty(toText.getText().toString())) { toText.requestFocus(); } else { titleText.requestFocus(); } } else { bodyText.requestFocus(); } if (uploadTask != null) { FileUploadTask temp = uploadTask; uploadTask = null; if (ActivityUtil.isGreaterThan_2_3_3()) { RunParallel(temp); } else { temp.execute(); } } if (PhoneConfiguration.getInstance().fullscreen) { ActivityUtil.getInstance().setFullScreen(v); } super.onResume(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item_refresh: load(); break; case R.id.save_image: final String path = getPath(); DownloadImageTask task = new DownloadImageTask(this); if (ActivityUtil.isGreaterThan_2_3_3()) { runOnExecutor(task, path); } else { task.execute(path); } break; case R.id.item_share: Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(getPath())); intent.setType("image/jpeg"); String text = getResources().getString(R.string.share); startActivity(Intent.createChooser(intent, text)); break; default: /*Intent MyIntent = new Intent(Intent.ACTION_MAIN); MyIntent.setClass(this, ArticleListActivity.class); MyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(MyIntent);*/ this.finish(); } return super.onOptionsItemSelected(item); }
@Override protected void onResume() { load(); if (PhoneConfiguration.getInstance().fullscreen) { ActivityUtil.getInstance().setFullScreen(wv); } super.onResume(); }
@Override protected void onCancelled(String result) { synchronized (commit_lock) { loading = false; } ActivityUtil.getInstance().dismiss(); super.onCancelled(); }
// private final String IPHONE_UA = "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) // AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3"; @Override protected void onCreate(Bundle arg0) { if (ActivityUtil.isGreaterThan_2_3_3()) requestWindowFeature(Window.FEATURE_PROGRESS); super.onCreate(arg0); View view = LayoutInflater.from(this).inflate(R.layout.webview_layout, null, false); this.setContentView(view); wv = (WebView) findViewById(R.id.webview); wv.getSettings() .setUserAgentString(getString(R.string.clientua) + ((MyApp) getApplication()).version); if (ActivityUtil.isGreaterThan_2_3_3()) wv.setWebChromeClient( new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { ImageViewerActivity.this.setProgress(progress * 100); } }); }
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); this.setContentView(R.layout.topiclist_activity); PullToRefreshAttacher.Options options = new PullToRefreshAttacher.Options(); options.refreshScrollDistance = 0.3f; options.refreshOnUp = true; mPullToRefreshAttacher = PullToRefreshAttacher.get(this, options); if (ActivityUtil.isNotLessThan_4_0()) setNfcCallBack(); if (null == findViewById(R.id.item_detail_container)) { dualScreen = false; } FragmentManager fm = getSupportFragmentManager(); Fragment f1 = fm.findFragmentById(R.id.item_list); if (f1 == null) { f1 = new TopiclistContainer(); Bundle args = new Bundle(); // (getIntent().getExtras()); if (null != getIntent().getExtras()) { args.putAll(getIntent().getExtras()); } args.putString("url", getIntent().getDataString()); f1.setArguments(args); FragmentTransaction ft = fm.beginTransaction().add(R.id.item_list, f1); // .add(R.id.item_detail_container, f); ft.commit(); } Fragment f2 = fm.findFragmentById(R.id.item_detail_container); if (null == f2) { f1.setHasOptionsMenu(true); } else if (!dualScreen) { this.setTitle(R.string.app_name); fm.beginTransaction().remove(f2).commit(); f1.setHasOptionsMenu(true); } else { f1.setHasOptionsMenu(false); f2.setHasOptionsMenu(true); } int fid = getIntent().getIntExtra("fid", 0); if (fid != 0) { String boardName = BoardHolder.boardNameMap.get(fid); if (null != boardName) { strs[0] = boardName; } } int favor = getIntent().getIntExtra("favor", 0); int authorid = getIntent().getIntExtra("authorid", 0); if (favor == 0 && authorid == 0) { setNavigation(); } else { flags = ThemeManager.ACTION_BAR_FLAG; } }
@Override protected void onPostExecute(String result) { ActivityUtil.getInstance().dismiss(); if (StringUtil.isEmpty(result)) return; String msg = StringUtil.getStringBetween(result, 0, "{\"0\":\"", "\"},\"time\"").result; // android.R.drawable.ic_search_category_default if (!StringUtil.isEmpty(msg)) { Toast.makeText(context, msg.trim(), Toast.LENGTH_SHORT).show(); } }
private void loadPage() { if (needLoad) { Activity activity = getActivity(); JsonThreadLoadTask task = new JsonThreadLoadTask(activity, this); String url = HttpUtil.Server + "/read.php?" + "&page=" + page + "&lite=js&noprefix&v2"; if (tid != 0) url = url + "&tid=" + tid; if (pid != 0) { url = url + "&pid=" + pid; } if (authorid != 0) { url = url + "&authorid=" + authorid; } if (ActivityUtil.isGreaterThan_2_3_3()) RunParallen(task, url); else task.execute(url); } else { ActivityUtil.getInstance().dismiss(); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.article_menuitem_reply: // if(articleAdpater.getData() == null) // return false; String tid = String.valueOf(this.tid); Intent intent = new Intent(); intent.putExtra("prefix", ""); intent.putExtra("tid", tid); intent.putExtra("action", "reply"); intent.setClass(this, PhoneConfiguration.getInstance().postActivityClass); startActivity(intent); if (PhoneConfiguration.getInstance().showAnimation) overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); break; case R.id.article_menuitem_refresh: int current = mViewPager.getCurrentItem(); ActivityUtil.getInstance().noticeSaying(this); mViewPager.setAdapter(mTabsAdapter); mViewPager.setCurrentItem(current); break; case R.id.article_menuitem_addbookmark: BookmarkTask bt = new BookmarkTask(this); bt.execute(String.valueOf(this.tid)); break; case R.id.article_menuitem_lock: handleLockOrientation(item); break; case R.id.goto_floor: createGotoDialog(); break; case R.id.article_menuitem_back: default: if (0 == fid) { finish(); } else { Intent intent2 = new Intent(this, PhoneConfiguration.getInstance().topicActivityClass); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent2.putExtra("fid", fid); startActivity(intent2); } break; } return true; }
@Override protected void onPostExecute(String result) { String success_results[] = {"发送完毕 ...", " @提醒每24小时不能超过50个", "操作成功"}; if (keepActivity == false) { boolean success = false; for (int i = 0; i < success_results.length; ++i) { if (result.contains(success_results[i])) { success = true; break; } } if (!success) keepActivity = true; } if (toast != null) { toast.setText(result); toast.setDuration(Toast.LENGTH_SHORT); toast.show(); } else { toast = Toast.makeText(MessagePostActivity.this, result, Toast.LENGTH_SHORT); toast.show(); } ActivityUtil.getInstance().dismiss(); if (!keepActivity) { if (!action.equals("new")) { MessagePostActivity.this.setResult(123); } else { MessagePostActivity.this.setResult(321); } MessagePostActivity.this.finish(); } synchronized (commit_lock) { loading = false; } super.onPostExecute(result); }
@Override protected void onCancelled() { ActivityUtil.getInstance().dismiss(); super.onCancelled(); }
@Override protected void onPostExecute(MeiziTopicMData result) { ActivityUtil.getInstance().dismiss(); if (null != notifier) notifier.datafinishLoad(result); super.onPostExecute(result); }
/* * (non-Javadoc) * * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { int orentation = ThemeManager.getInstance().screenOrentation; if (orentation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orentation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(orentation); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } super.onCreate(savedInstanceState); v = this.getLayoutInflater().inflate(R.layout.messagereply, null); v.setBackgroundColor(getResources().getColor(ThemeManager.getInstance().getBackgroundColor())); this.setContentView(v); if (PhoneConfiguration.getInstance().uploadLocation && PhoneConfiguration.getInstance().location == null) { ActivityUtil.reflushLocation(this); } Intent intent = this.getIntent(); prefix = intent.getStringExtra("prefix"); // if(prefix!=null){ // prefix=prefix.replaceAll("\\n\\n", "\n"); // } tousername = intent.getStringExtra("to"); action = intent.getStringExtra("action"); mid = intent.getIntExtra("mid", 0); String title = intent.getStringExtra("title"); titleText = (EditText) findViewById(R.id.reply_titile_edittext); toText = (EditText) findViewById(R.id.reply_titile_edittext_to); bodyText = (EditText) findViewById(R.id.reply_body_edittext); if (action.equals("new")) { getSupportActionBar().setTitle(R.string.new_message); } else if (action.equals("reply")) { getSupportActionBar().setTitle(R.string.reply_message); } titleText.setSelected(true); act = new MessagePostAction(mid, "", ""); act.setAction_(action); this.act.set__ngaClientChecksum(FunctionUtil.getngaClientChecksum(this)); loading = false; if (!StringUtil.isEmpty(tousername)) { toText.setText(tousername); if (!StringUtil.isEmpty(title)) { titleText.setText(title); } } else { if (!StringUtil.isEmpty(title)) { titleText.setText(title); } } if (prefix != null) { if (prefix.startsWith("[quote][pid=") && prefix.endsWith("[/quote]\n")) { SpannableString spanString = new SpannableString(prefix); spanString.setSpan( new BackgroundColorSpan(-1513240), 0, prefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); spanString.setSpan( new StyleSpan(android.graphics.Typeface.BOLD), prefix.indexOf("[b]Post by"), prefix.indexOf("):[/b]") + 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); bodyText.append(spanString); } else { bodyText.append(prefix); } bodyText.setSelection(prefix.length()); } ThemeManager tm = ThemeManager.getInstance(); if (tm.getMode() == ThemeManager.MODE_NIGHT) { bodyText.setBackgroundResource(tm.getBackgroundColor()); toText.setBackgroundResource(tm.getBackgroundColor()); titleText.setBackgroundResource(tm.getBackgroundColor()); int textColor = this.getResources().getColor(tm.getForegroundColor()); bodyText.setTextColor(textColor); titleText.setTextColor(textColor); toText.setTextColor(textColor); } }
@Override protected void onPreExecute() { ActivityUtil.getInstance().noticeSaying(c); super.onPreExecute(); }
@Override public boolean onContextItemSelected(MenuItem item) { Log.d(TAG, "onContextItemSelected,tid=" + tid + ",page=" + page); PagerOwnner father = null; try { father = (PagerOwnner) getActivity(); } catch (ClassCastException e) { Log.e(TAG, "father activity does not implements interface " + PagerOwnner.class.getName()); return true; } if (father == null) return false; if (father.getCurrentPage() != page) { return false; } AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int position = this.listview.getCheckedItemPosition(); if (info != null) { position = info.position; } if (position < 0 || position >= listview.getAdapter().getCount()) { Toast.makeText(getActivity(), R.string.floor_error, Toast.LENGTH_LONG).show(); position = 0; } StringBuffer postPrefix = new StringBuffer(); String tidStr = String.valueOf(this.tid); ThreadRowInfo row = (ThreadRowInfo) listview.getItemAtPosition(position); if (row == null) { Toast.makeText(getActivity(), R.string.unknow_error, Toast.LENGTH_LONG).show(); return true; } String content = row.getContent(); final String name = row.getAuthor(); String mention = null; Intent intent = new Intent(); switch (item.getItemId()) // if( REPLY_POST_ORDER ==item.getItemId()) { case R.id.quote_subject: final String quote_regex = "\\[quote\\]([\\s\\S])*\\[/quote\\]"; final String replay_regex = "\\[b\\]Reply to \\[pid=\\d+,\\d+,\\d+\\]Reply\\[/pid\\] Post by .+?\\[/b\\]"; content = content.replaceAll(quote_regex, ""); content = content.replaceAll(replay_regex, ""); final String postTime = row.getPostdate(); if (!content.trim().endsWith("[/url]")) { if (content.length() > 100) content = content.substring(0, 99) + "......."; } content = StringUtil.unEscapeHtml(content); if (row.getPid() != 0) { mention = name; postPrefix.append("[quote][pid="); postPrefix.append(row.getPid()); postPrefix.append(',').append(tidStr).append(",").append(page); postPrefix.append("]"); // Topic postPrefix.append("Reply"); postPrefix.append("[/pid] [b]Post by "); postPrefix.append(name); postPrefix.append(" ("); postPrefix.append(postTime); postPrefix.append("):[/b]\n"); postPrefix.append(content); postPrefix.append("[/quote]\n"); } // case R.id.r: if (!StringUtil.isEmpty(mention)) intent.putExtra("mention", mention); intent.putExtra("prefix", StringUtil.removeBrTag(postPrefix.toString())); intent.putExtra("tid", tidStr); intent.putExtra("action", "reply"); intent.setClass(getActivity(), PostActivity.class); startActivity(intent); if (PhoneConfiguration.getInstance().showAnimation) getActivity().overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); break; case R.id.edit: if (isComment(row)) { Toast.makeText(getActivity(), R.string.cannot_eidt_comment, Toast.LENGTH_SHORT).show(); break; } Intent intentModify = new Intent(); intentModify.putExtra("prefix", StringUtil.unEscapeHtml(StringUtil.removeBrTag(content))); intentModify.putExtra("tid", tidStr); String pid = String.valueOf(row.getPid()); // getPid(map.get("url")); intentModify.putExtra("pid", pid); intentModify.putExtra("title", StringUtil.unEscapeHtml(row.getSubject())); intentModify.putExtra("action", "modify"); intentModify.setClass(getActivity(), PostActivity.class); startActivity(intentModify); if (PhoneConfiguration.getInstance().showAnimation) getActivity().overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); break; case R.id.copy_to_clipboard: // if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB ) // { android.text.ClipboardManager cbm = (android.text.ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); cbm.setText(StringUtil.removeBrTag(content)); // }else{ // android.content.ClipboardManager cbm = (android.content.ClipboardManager) // getSystemService(CLIPBOARD_SERVICE); // cbm.setPrimaryClip(ClipData.newPlainText("content", content)); // } Toast.makeText(getActivity(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); break; case R.id.show_this_person_only: Intent intentThis = new Intent(); intentThis.putExtra("tab", "1"); intentThis.putExtra("tid", tid); intentThis.putExtra("authorid", row.getAuthorid()); intentThis.setClass(getActivity(), PhoneConfiguration.getInstance().articleActivityClass); startActivity(intentThis); if (PhoneConfiguration.getInstance().showAnimation) getActivity().overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); // restNotifier.reset(0, row.getAuthorid()); // ActivityUtil.getInstance().noticeSaying(getActivity()); break; case R.id.show_whole_thread: ResetableArticle restNotifier = null; try { restNotifier = (ResetableArticle) getActivity(); } catch (ClassCastException e) { Log.e( TAG, "father activity does not implements interface " + ResetableArticle.class.getName()); return true; } restNotifier.reset(0, 0, row.getLou()); ActivityUtil.getInstance().noticeSaying(getActivity()); break; case R.id.post_comment: final String dialog_tag = "post comment"; FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); Fragment prev = getActivity().getSupportFragmentManager().findFragmentByTag(dialog_tag); if (prev != null) { ft.remove(prev); } DialogFragment df = new PostCommentDialogFragment(); Bundle b = new Bundle(); b.putInt("pid", row.getPid()); b.putInt("tid", this.tid); df.setArguments(b); df.show(ft, dialog_tag); break; case R.id.report: handleReport(row); break; case R.id.search_post: intent.putExtra("searchpost", 1); case R.id.search_subject: intent.putExtra("authorid", row.getAuthorid()); intent.setClass(getActivity(), PhoneConfiguration.getInstance().topicActivityClass); startActivity(intent); if (PhoneConfiguration.getInstance().showAnimation) getActivity().overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); break; case R.id.item_share: intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); String shareUrl = "http://bbs.ngacn.cc/read.php?"; if (row.getPid() != 0) { shareUrl = shareUrl + "pid=" + row.getPid(); } else { shareUrl = shareUrl + "tid=" + tid; } intent.putExtra(Intent.EXTRA_TEXT, shareUrl); String text = getResources().getString(R.string.share); getActivity().startActivity(Intent.createChooser(intent, text)); break; } return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getViewId()); if (PhoneConfiguration.getInstance().uploadLocation && PhoneConfiguration.getInstance().location == null) { ActivityUtil.reflushLocation(this); } /*PullToRefreshViewPager refreshPager = (PullToRefreshViewPager) findViewById(R.id.pull_refresh_viewpager); refreshPager.setMode(Mode.PULL_FROM_START); refreshPager.setOnRefreshListener(new OnRefreshListener<ViewPager>(){ @Override public void onRefresh(PullToRefreshBase<ViewPager> refreshView) { finish(); } }); mViewPager = refreshPager.getRefreshableView(); */ mViewPager = (ViewPager) findViewById(R.id.pager); if (ActivityUtil.isNotLessThan_4_0()) { setNfcCallBack(); } tid = 7; int pageFromUrl = 0; String url = this.getIntent().getDataString(); if (null != url) { tid = this.getUrlParameter(url, "tid"); pid = this.getUrlParameter(url, "pid"); authorid = this.getUrlParameter(url, "authorid"); pageFromUrl = this.getUrlParameter(url, "page"); } else { tid = this.getIntent().getIntExtra("tid", 0); pid = this.getIntent().getIntExtra("pid", 0); authorid = this.getIntent().getIntExtra("authorid", 0); } View v = findViewById(android.R.id.content); // .getChildAt(0); tabhost = (TabHost) findViewById(android.R.id.tabhost); if (tabhost != null) { tabhost.setup(); mTabsAdapter = new TabsAdapter(this, tabhost, mViewPager, ArticleListFragment.class); } else { mTabsAdapter = new ThreadFragmentAdapter( this, getSupportFragmentManager(), mViewPager, ArticleListFragment.class); } mTabsAdapter.setArgument("id", tid); mTabsAdapter.setArgument("pid", pid); mTabsAdapter.setArgument("authorid", authorid); ActivityUtil.getInstance().noticeSaying(this); if (savedInstanceState != null) { int pageCount = savedInstanceState.getInt("pageCount"); if (pageCount != 0) { mTabsAdapter.setCount(pageCount); mViewPager.setCurrentItem(savedInstanceState.getInt("tab")); } } else if (0 != getUrlParameter(url, "page")) { mTabsAdapter.setCount(pageFromUrl); mViewPager.setCurrentItem(pageFromUrl); } }
public View getView(int position, View view, ViewGroup parent) { final ThreadRowInfo row = data.getRowList().get(position); int lou = -1; if (row != null) lou = row.getLou(); ViewHolder holder = null; boolean needin = false; SoftReference<View> ref = viewCache.get(position); View cachedView = null; if (ref != null) { cachedView = ref.get(); } if (cachedView != null) { if (((ViewHolder) cachedView.getTag()).position == position) { Log.d(TAG, "get view from cache ,floor " + lou); return cachedView; } else { view = LayoutInflater.from(activity).inflate(R.layout.relative_aritclelist, parent, false); holder = initHolder(view); holder.position = position; view.setTag(holder); viewCache.put(position, new SoftReference<View>(view)); } } else { view = LayoutInflater.from(activity).inflate(R.layout.relative_aritclelist, parent, false); holder = initHolder(view); holder.position = position; view.setTag(holder); viewCache.put(position, new SoftReference<View>(view)); } if (!PhoneConfiguration.getInstance().showReplyButton) { holder.viewBtn.setVisibility(View.GONE); } else { MyListenerForReply myListenerForReply = new MyListenerForReply(position, data, activity); holder.viewBtn.setOnClickListener(myListenerForReply); } ThemeManager theme = ThemeManager.getInstance(); int colorId = theme.getBackgroundColor(position); view.setBackgroundResource(colorId); // colorId = theme.getBackgroundColor(2); if (row == null) { return view; } handleAvatar(holder.avatarIV, row); int fgColorId = ThemeManager.getInstance().getForegroundColor(); final int fgColor = parent.getContext().getResources().getColor(fgColorId); FunctionUtil.handleNickName(row, fgColor, holder.nickNameTV, activity); final int bgColor = parent.getContext().getResources().getColor(colorId); final WebView contentTV = holder.contentTV; final String floor = String.valueOf(lou); TextView floorTV = holder.floorTV; floorTV.setText("[" + floor + " 楼]"); floorTV.setTextColor(fgColor); if (!StringUtil.isEmpty(row.getFromClientModel())) { MyListenerForClient myListenerForClient = new MyListenerForClient(position, data, activity, parent); String from_client_model = row.getFromClientModel(); if (from_client_model.equals("ios")) { holder.clientBtn.setImageResource(R.drawable.ios); // IOS } else if (from_client_model.equals("wp")) { holder.clientBtn.setImageResource(R.drawable.wp); // WP } else if (from_client_model.equals("unknown")) { holder.clientBtn.setImageResource(R.drawable.unkonwn); // 未知orBB } holder.clientBtn.setVisibility(View.VISIBLE); holder.clientBtn.setOnClickListener(myListenerForClient); } if (ActivityUtil.isLessThan_4_3()) { new Thread( new Runnable() { public void run() { FunctionUtil.handleContentTV( contentTV, row, bgColor, fgColor, activity, null, client); } }) .start(); } else if (ActivityUtil.isLessThan_4_4()) { ((Activity) parent.getContext()) .runOnUiThread( new Runnable() { public void run() { FunctionUtil.handleContentTV( contentTV, row, bgColor, fgColor, activity, null, client); } }); } else { FunctionUtil.handleContentTV(contentTV, row, bgColor, fgColor, activity, null, client); } TextView postTimeTV = holder.postTimeTV; postTimeTV.setText(row.getPostdate()); postTimeTV.setTextColor(fgColor); if (needin) { view.invalidate(); } return view; }