private int getAdapterPosition() { int index = 0; switch (mItemType) { case DrawingActivity.SYMBOL_POINT: if (mPointAdapter != null) index = mPointAdapter.getSelectedPos(); break; case DrawingActivity.SYMBOL_LINE: if (mLineAdapter != null) index = mLineAdapter.getSelectedPos(); break; case DrawingActivity.SYMBOL_AREA: if (mAreaAdapter != null) index = mAreaAdapter.getSelectedPos(); break; } return index; }
private void setItemAngle(int angle) { if (mItemType == DrawingActivity.SYMBOL_POINT && mPointAdapter != null) { int index = mPointAdapter.getSelectedPos(); // Log.v("DistoX", "set item " + index + " angle " + angle ); mPointAdapter.setPointOrientation(index, angle); // ItemSymbol item = mPointAdapter.get( index ); // if ( item != null ) { // SymbolInterface symbol = item.mSymbol; // if ( symbol != null && symbol.isOrientable() ) { // symbol.setAngle( angle ); // } // } } }
private void setSeekBarProgress() { boolean orientable = false; if (mItemType == DrawingActivity.SYMBOL_POINT && mPointAdapter != null) { int index = mPointAdapter.getSelectedPos(); ItemSymbol item = mPointAdapter.get(index); if (item != null) { SymbolInterface symbol = item.mSymbol; if (symbol != null && symbol.isOrientable()) { int progress = (180 + symbol.getAngle()) % 360; mSeekBar.setProgress(progress); // Log.v("DistoX", "set progress " + progress ); orientable = true; } } } mSeekBar.setEnabled(orientable); }
private void setRecent(int k) { Symbol p = null; if (mItemType == DrawingActivity.SYMBOL_POINT) { p = ItemDrawer.mRecentPoint[k]; } else if (mItemType == DrawingActivity.SYMBOL_LINE) { p = ItemDrawer.mRecentLine[k]; } else if (mItemType == DrawingActivity.SYMBOL_AREA) { p = ItemDrawer.mRecentArea[k]; } if (p != null) { if (mAdapter != null) mAdapter.setSelectedItem(p); } }
void setPointOrientation(int angle) { if (mPointAdapter == null) return; if ( /* TDSetting.mLevelOverBasic && */ mItemType == DrawingActivity.SYMBOL_POINT) { // Log.v( TopoDroidApp.TAG, "rotate point " + mParent.mCurrentPoint ); mPointAdapter.setPointOrientation(mParent.mCurrentPoint, angle); // ItemSymbol item = mPointAdapter.getSelectedItem(); // if ( item != null ) { // angle -= (int) item.mSymbol.getAngle(); // mPointAdapter.rotatePoint( mParent.mCurrentPoint, angle ); // } } }
// pos public void setTypeAndItem(int index) { // Log.v( TDLog.TAG, "setTypeAndItem type " + mItemType + " item " + index ); ItemSymbol is; switch (mItemType) { case DrawingActivity.SYMBOL_POINT: if (mPointAdapter != null /* && TDSetting.mLevelOverBasic */) { is = mPointAdapter.get(index); // Log.v( TDLog.TAG, "setTypeAndItem type point pos " + index + " index " + is.mIndex ); mParent.mCurrentPoint = is.mIndex; mParent.pointSelected(is.mIndex, false); // mPointAdapter.getSelectedItem() ); setSeekBarProgress(); } break; case DrawingActivity.SYMBOL_LINE: if (mLineAdapter != null) { is = mLineAdapter.get(index); // Log.v( TDLog.TAG, "setTypeAndItem type line pos " + index + " index " + is.mIndex ); if (mPlotType != PlotInfo.PLOT_SECTION || is.mIndex != DrawingBrushPaths.mLineLib.mLineSectionIndex) { mParent.mCurrentLine = is.mIndex; mParent.lineSelected(is.mIndex, false); // mLineAdapter.getSelectedItem() ); } else { } mSeekBar.setEnabled(false); } break; case DrawingActivity.SYMBOL_AREA: if (mAreaAdapter != null /* && TDSetting.mLevelOverBasic */) { // mAreaPos = index; is = mAreaAdapter.get(index); mParent.mCurrentArea = is.mIndex; mParent.areaSelected(is.mIndex, false); // mAreaAdapter.getSelectedItem() ); mSeekBar.setEnabled(false); } break; } // cancel(); }
private void createAdapters() { // if ( TDSetting.mLevelOverBasic ) { mPointAdapter = new ItemAdapter(mContext, this, R.layout.item, new ArrayList<ItemSymbol>()); int np = mPointLib.mSymbolNr; for (int i = 0; i < np; ++i) { SymbolPoint p = (SymbolPoint) mPointLib.getSymbolByIndex(i); if (p.isEnabled()) { mPointAdapter.add( new ItemSymbol(mContext, this, DrawingActivity.SYMBOL_POINT, i, p, mUseText)); } } mPointAdapter.setSelectedItem(mParent.mCurrentPoint); } mLineAdapter = new ItemAdapter(mContext, this, R.layout.item, new ArrayList<ItemSymbol>()); int nl = mLineLib.mSymbolNr; for (int j = 0; j < nl; ++j) { SymbolLine l = (SymbolLine) mLineLib.getSymbolByIndex(j); if (l.isEnabled()) { mLineAdapter.add( new ItemSymbol(mContext, this, DrawingActivity.SYMBOL_LINE, j, l, mUseText)); } } mLineAdapter.setSelectedItem(mParent.mCurrentLine); // if ( TDSetting.mLevelOverBasic ) { mAreaAdapter = new ItemAdapter(mContext, this, R.layout.item, new ArrayList<ItemSymbol>()); int na = mAreaLib.mSymbolNr; for (int k = 0; k < na; ++k) { SymbolArea a = (SymbolArea) mAreaLib.getSymbolByIndex(k); if (a.isEnabled()) { mAreaAdapter.add( new ItemSymbol(mContext, this, DrawingActivity.SYMBOL_AREA, k, a, mUseText)); } } mAreaAdapter.setSelectedItem(mParent.mCurrentArea); } }