android:fadingEdgeLength="0dip"
android:scrollbars="vertical"
>
+ <HorizontalScrollView
+ android:id="@+id/candview_hscroll"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:fadingEdgeLength="0dip"
+ android:scrollbars="horizontal"
+ >
<LinearLayout
android:id="@+id/candview_base"
android:orientation="vertical"
android:layout_height="wrap_content"
android:background="@color/candidate_back"
>
- <HorizontalScrollView
- android:id="@+id/candview_scroll"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:fadingEdgeLength="0dip"
- android:scrollbars="vertical"
- >
<RelativeLayout
android:id="@+id/candidates_2nd_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/candidate_back"
/>
- </HorizontalScrollView>
</LinearLayout>
+ </HorizontalScrollView>
</ScrollView>
</FrameLayout>
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
+import android.widget.HorizontalScrollView;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.RelativeLayout;
/** Width of the view */
private static final int CANDIDATE_MINIMUM_WIDTH = 48;
/** Height of the view */
- private static final int CANDIDATE_MINIMUM_HEIGHT = 35;
+ private static final int CANDIDATE_MINIMUM_HEIGHT = 44;
/** Align the candidate left if the width of the string exceeds this threshold */
private static final int CANDIDATE_LEFT_ALIGN_THRESHOLD = 120;
/** Maximum number of displaying candidates par one line (full view mode) */
/** Body view of the candidates list */
private ViewGroup mViewBody;
/** Scroller of {@code mViewBodyText} */
- private ScrollView mViewBodyScroll;
+ private ScrollView mViewBodyScroll;
private boolean mIsScroll;
/** Base of {@code mViewCandidateList1st}, {@code mViewCandidateList2nd} */
private int mTotalLastId;
/** List of candidates */
private ArrayList<WnnWord> mWnnWordArray;
+ private ArrayList<Integer> mWnnWordTextLength;
+ private ArrayList<Integer> mWnnWordOccupyCount;
/** Gesture detector */
private GestureDetector mGestureDetector;
public TextCandidatesViewManager(int displayLimit) {
this.mDisplayLimit = displayLimit;
this.mWnnWordArray = new ArrayList<WnnWord>();
+ this.mWnnWordTextLength = new ArrayList<Integer>();
+ this.mWnnWordOccupyCount = new ArrayList<Integer>();
this.mAutoHideMode = true;
mMetrics.setToDefaults();
}
} else {
if (type == CandidatesViewManager.VIEW_TYPE_NORMAL) {
mIsFullView = false;
- if (mDisplayEndOffset > 0) {
- int maxLine = getMaxLine();
- displayCandidates(this.mConverter, false, maxLine);
- }
+ /*
+ if (mDisplayEndOffset > 0) {
+ int maxLine = getMaxLine();
+ displayCandidates(this.mConverter, false, maxLine);
+ }
+ */
} else {
mIsFullView = true;
if (mViewBody.isShown()) {
clearCandidates();
mConverter = converter;
+
+ createWnnWordArray();
setViewLayout(CandidatesViewManager.VIEW_TYPE_NORMAL);
displayCandidates(converter, true, getMaxLine());
}
+ /*
+ *
+ */
+ private void createWnnWordArray() {
+ WnnEngine converter = mConverter;
+ if (null == converter) {
+ return;
+ }
+ WnnWord result = null;
+ int index = 0;
+ int indentWidth = mViewWidth / FULL_VIEW_DIV;
+ int maxindex = DISPLAY_LINE_MAX_COUNT * FULL_VIEW_DIV;
+
+ do {
+ result = converter.getNextCandidate();
+ if (result == null) {
+ break;
+ }
+ Integer textLength = measureText(result.candidate, 0, result.candidate.length());
+ Integer occupyCount = Math.min((textLength + indentWidth) / indentWidth, FULL_VIEW_DIV);
+
+ mWnnWordArray.add(index, result);
+ mWnnWordTextLength.add(index, textLength);
+ mWnnWordOccupyCount.add(index, occupyCount);
+ index++;
+ } while (index < maxindex);
+ }
/** @see CandidatesViewManager#getMaxLine */
private int getMaxLine() {
if (converter == null) {
return;
}
-
/* Concatenate the candidates already got and the last one in dispFirst mode */
int displayLimit = mDisplayLimit;
/* Get candidates */
WnnWord result = null;
- while ((displayLimit == -1 || mWordCount < displayLimit)) {
- result = converter.getNextCandidate();
- if (result == null) {
- break;
- }
-
- setCandidate(result);
-
+ int size = mWnnWordArray.size();
+ while (mWordCount < size) {
+ result = mWnnWordArray.get(mWordCount);
+ setCandidate(result, mWnnWordTextLength.get(mWordCount), mWnnWordOccupyCount.get(mWordCount));
if (dispFirst && (maxLine < mLineCount)) {
mCanReadMore = true;
isBreak = true;
* Add a candidate into the list.
* @param word A candidate word
*/
- private void setCandidate(WnnWord word) {
- int textLength = measureText(word.candidate, 0, word.candidate.length());
+ private void setCandidate(WnnWord word, int textLength, int occupyCount) {
int maxWidth = mViewWidth;
TextView textView;
int indentWidth = mViewWidth / FULL_VIEW_DIV;
- int occupyCount = Math.min((textLength + indentWidth) / indentWidth, FULL_VIEW_DIV);
RelativeLayout layout = mViewCandidateList2nd;
} else {
params.addRule(RelativeLayout.BELOW, mFullViewPrevLineTopId);
}
-
+
if (mFullViewOccupyCount == 0) {
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
} else {
textView.setId(textId);
textView.setVisibility(View.VISIBLE);
textView.setPressed(false);
+ textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setOnClickListener(mCandidateOnClick);
textView.setOnLongClickListener(mCandidateOnLongClick);
textView.setOnTouchListener(mCandidateOnTouch);
- if (maxWidth < textLength) {
- textView.setEllipsize(TextUtils.TruncateAt.END);
- } else {
- textView.setEllipsize(null);
- }
checkImageSpan(textView, word);
- mWnnWordArray.add(mWordCount, word);
mWordCount++;
mTotalLastId = textId;
mToplineLastId = 0;
mTotalLastId = 0;
mWnnWordArray.clear();
+ mWnnWordTextLength.clear();
+ mWnnWordOccupyCount.clear();
mLineLength = 0;
mToplineLastId = 0;
mTotalLastId = 0;
mWnnWordArray.clear();
+ mWnnWordTextLength.clear();
+ mWnnWordOccupyCount.clear();
mLineLength = 0;