import com.ic.iclooger.ICLogger;
import com.ic.launcher.adapter.MainPageAdapter;
import com.ic.launcher.presenter.LauncherPresenter;
+import com.ic.launcher.presenter.MainPagePresenter;
import com.ic.launcher.view.SimpleStatusBarView;
import com.ic.launcher.view.StatusBarView;
if (mainPagePresenter != null) {
mainPagePresenter.initAppList();
//更新星期列表
- //TODO:
+ MainPagePresenter.getInstance(MainActivity.this).updateTime(null);
}
}
}
import androidx.annotation.Nullable;
-import com.ic.iclooger.ICLogger;
import com.ic.launcher.R;
+/**
+ * 对外只暴露三个方法:
+ * 是否有sim卡
+ * 更新状态,内容为无sim卡
+ * 设置信号级别
+ * 网路数据类型
+ */
public class SignalView extends View {
private Bitmap defaultSignalPic;
defaultSignalPic = BitmapFactory.decodeResource(getResources(), R.mipmap.top_signal_0, options);
targetHeight = defaultSignalPic.getHeight();
width = defaultSignalPic.getWidth();
- retestSize();
//绘制图片的画笔
picPaint = new Paint();
picPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
}
private void retestSize() {
- ICLogger.d("showText ==> " + showText);
+ //ICLogger.d("showText ==> " + showText);
//不同size
- if (noSimCard || showText.equals(getContext().getString(R.string.no_sim_service))) {
+ boolean justText = showText.equals(getContext().getString(R.string.no_sim_car)) || showText.equals
+ (getContext().getString(R.string.no_sim_service));
+ if (justText) {
textPaint.setTextSize(no_sim_card_size);
} else {
textPaint.setTextSize(type_size);
}
textWidth = textPaint.measureText(showText);
//如果没有信号的时候,宽度则为文字的宽度
- if (noSimCard) {
+ if (justText) {
totalWidth = (int) textWidth;
} else {
+ //图片宽度
totalWidth = width;
}
//ICLogger.d("textWidth == > " + textWidth + " totalWidth == > " + totalWidth);
+ requestLayout();
}
private final int[] picsResArray = new int[5];
}
if (!showText.equals(text)) {
showText = text;
- retestSize();
- invalidate();
}
+ retestSize();
+ invalidate();
}
public void updateLev(int lev) {
- //如果没有sim卡返回
- if (this.noSimCard) {
- return;
- }
- this.lastLev = lev;
- ICLogger.d("update level..." + lev);
+ //ICLogger.d("update level..." + lev);
if (lev < 0 || lev > 5 || noSimCard) {
return;
}
+ this.lastLev = lev;
//根据信号去显示对应的图标
//把lev转成Index
currentPic = picsResArray[lev - 1];
updateBitMap();
+ retestSize();
invalidate();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- ICLogger.d("onMeasure...");
+ //ICLogger.d("onMeasure..." + totalWidth);
int size = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(totalWidth, noSimCard ? size : targetHeight);
+ setMeasuredDimension(totalWidth, size);
}
private PaintFlagsDrawFilter mPaintFlagsFilter = new PaintFlagsDrawFilter(0,
public static final float type_size = 12.0f;
public static final float no_sim_card_size = 16.0f;
-
@Override
protected void onDraw(Canvas canvas) {
if (bitmap == null) {
this.currentPic = R.mipmap.top_no_sim_card;
//清空文字
this.showText = getContext().getString(R.string.no_sim_car);
- retestSize();
updateBitMap();
+ retestSize();
invalidate();
} else {
this.noSimCard = false;