public View getView(int position, View view, ViewGroup parent) { View convertView = view; // m.get(position); ViewHolder holder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.relative_topic_list, null); TextView num = (TextView) convertView.findViewById(R.id.num); TextView title = (TextView) convertView.findViewById(R.id.title); TextView author = (TextView) convertView.findViewById(R.id.author); TextView lastReply = (TextView) convertView.findViewById(R.id.last_reply); holder = new ViewHolder(); holder.num = num; holder.title = title; holder.author = author; holder.lastReply = lastReply; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } ThemeManager cfg = ThemeManager.getInstance(); int colorId = cfg.getBackgroundColor(position); if (position == this.selected) { if (cfg.mode == ThemeManager.MODE_NIGHT) colorId = R.color.topiclist_selected_color; else colorId = R.color.holo_blue_light; ; } convertView.setBackgroundResource(colorId); handleJsonList(holder, position); return convertView; }
/* * (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); } }
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; }