1
0
mirror of https://gitee.com/51danju/workclock.git synced 2025-06-08 11:54:05 +08:00

增加UI设置时的初始状态保存,恢复功能

This commit is contained in:
wushunlian 2019-06-27 08:33:25 +08:00
parent 134499e589
commit 78e56b54ba
20 changed files with 230 additions and 106 deletions

View File

@ -45,8 +45,6 @@ public class AnimatorManager {
SawtoothAnimator.NAME, SawtoothAnimator.NAME,
WindmillAnimator.NAME, WindmillAnimator.NAME,
VorolayAnimator.NAME, VorolayAnimator.NAME,
EZLedAnimator.NAME,
EvaporateTextAnimator.NAME,
PhaserBallAnimator.NAME, PhaserBallAnimator.NAME,
CarrouselAnimator.NAME, CarrouselAnimator.NAME,
Wave3DAnimator.NAME, Wave3DAnimator.NAME,

View File

@ -4,6 +4,7 @@ package clock.socoolby.com.clock;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
@ -572,7 +573,22 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
if(isScreenLock()) if(isScreenLock())
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL); if(!isFullScreen()){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setTitle("温馨提示");
builder.setMessage("确定要退出吗");
builder.setCancelable(true);
builder.setPositiveButton("确定", (dialog, which) -> {
MainActivity.this.finish();
});
builder.setNegativeButton("取消", (dialog, which) -> {
dialog.dismiss();
});
builder.create().show();
}
//changeThemeUI();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
return true; return true;
} else if (keyCode == KeyEvent.KEYCODE_MENU) { } else if (keyCode == KeyEvent.KEYCODE_MENU) {

View File

@ -1,5 +1,7 @@
package clock.socoolby.com.clock; package clock.socoolby.com.clock;
import android.util.Log;
import com.openbravo.data.basic.BasicException; import com.openbravo.data.basic.BasicException;
import org.json.JSONException; import org.json.JSONException;
@ -28,6 +30,8 @@ public class ThemeUIManager{
SharePerferenceModel model; SharePerferenceModel model;
private String tempThemeStr=null;
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model) { public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.model=model; this.model=model;
@ -137,17 +141,23 @@ public class ThemeUIManager{
return entityManager.isExistByFields(ThemeUI.class,new String[]{ThemeUI.NAME,ThemeUI.CLOCK_TYPE},new Object[]{name,type}); return entityManager.isExistByFields(ThemeUI.class,new String[]{ThemeUI.NAME,ThemeUI.CLOCK_TYPE},new Object[]{name,type});
} }
public String clobToString(Clob sc) throws SQLException, IOException { public void saveTempThemeUI(int type){
String reString = ""; Log.d(TAG,"save temp ThemeUI type:"+type);
Reader is = sc.getCharacterStream(); if(type==ClockInterfaceTypeEnum.Digit.code)
BufferedReader br = new BufferedReader(is); this.tempThemeStr=makeSaveDigitThemeString(model.getDigitPerferenceModel());
String s = br.readLine(); else
StringBuffer sb = new StringBuffer(); this.tempThemeStr=makeSaveSimulateThemeString(model.getSimulatePerferenceModel());
while (s != null) { }
sb.append(s);
s = br.readLine(); public void recoverTempThemeUI(int type)throws BasicException{
Log.d(TAG,"recover temp ThemeUI type"+type);
if(tempThemeStr==null)
return;
if(type==ClockInterfaceTypeEnum.Digit.code) {
loadDigitTheme(tempThemeStr);
}
else {
loadSimulateTheme(tempThemeStr);
} }
reString = sb.toString();
return reString;
} }
} }

View File

@ -83,6 +83,19 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
MainActivity mainActivity; MainActivity mainActivity;
private SharePerferenceModel model;
private boolean autoFullScreen=false;
private int runDelaySecond=10000;
private boolean running=false;
private Timer timer=null;
private ClockStateMachine clockStateMachine;
public AbstractThemeUIFragment(int layoutId){ public AbstractThemeUIFragment(int layoutId){
this.layoutId=layoutId; this.layoutId=layoutId;
} }
@ -176,7 +189,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() { tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
//hand_time_visable=false;
tv_hand_time.setVisibility(View.GONE); tv_hand_time.setVisibility(View.GONE);
return true; return true;
} }
@ -258,17 +270,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
return themeRootView; return themeRootView;
} }
private SharePerferenceModel model;
private boolean autoFullScreen=false;
private int runDelaySecond=10000;
private boolean running=false;
Timer timer=null;
ClockStateMachine clockStateMachine;
private void autoFullScreenCheck(){ private void autoFullScreenCheck(){
if(!autoFullScreen) if(!autoFullScreen)
@ -293,13 +294,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
private void bindViewModel() { private void bindViewModel() {
/*themeUIViewModel.getThemeName().observe(mainActivity, new Observer<String>() {
@Override
public void onChanged(String s) {
switchThemeType(s);
}
});*/
themeUIViewModel.getClockUITypeEnum().observe(mainActivity, new Observer<ClockThemeUITypeEnum>() { themeUIViewModel.getClockUITypeEnum().observe(mainActivity, new Observer<ClockThemeUITypeEnum>() {
@Override @Override
public void onChanged(ClockThemeUITypeEnum uiTypeEnum) { public void onChanged(ClockThemeUITypeEnum uiTypeEnum) {
@ -389,6 +383,8 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
tv_day.setText(s); tv_day.setText(s);
} }
}); });
globalViewModel.getSrceenLock().observe(mainActivity,locked->screenLock(locked));
} }
@ -481,7 +477,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (isScreenLock() && view.getId() != R.id.tv_screen_lock && view.getId() != R.id.tv_handup_image) { if (isScreenLock() && view.getId() != R.id.tv_screen_lock) {
return; return;
} }
switch (view.getId()) { switch (view.getId()) {
@ -511,18 +507,17 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
calendarPopup.setCurrentDay(); calendarPopup.setCurrentDay();
break; break;
case R.id.tv_weather: case R.id.tv_weather:
if (weatherPopup == null)
weatherPopup = new WeatherPopup(mainActivity);
if(mainActivity.weatherAdape==null) { if(mainActivity.weatherAdape==null) {
Toast.makeText(getActivity(),"天气数据获取失败,请检查网络",Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(),"天气数据获取失败,请检查网络",Toast.LENGTH_SHORT).show();
return; return;
} }
if (weatherPopup == null)
weatherPopup = new WeatherPopup(mainActivity);
weatherPopup.init(mainActivity.weatherAdape.getWeatherList(), model.getCity() + " PM2.5 : " + mainActivity.weatherAdape.getmPM25()); weatherPopup.init(mainActivity.weatherAdape.getWeatherList(), model.getCity() + " PM2.5 : " + mainActivity.weatherAdape.getmPM25());
weatherPopup.showPopupWindow(); weatherPopup.showPopupWindow();
break; break;
case R.id.tv_screen_lock: case R.id.tv_screen_lock:
globalViewModel.setSrceenLock(!isScreenLock()); globalViewModel.setSrceenLock(!globalViewModel.getSrceenLock().getValue());
screenLock(!isScreenLock());
break; break;
case R.id.tv_break: case R.id.tv_break:
clockStateMachine.countingCheck(); clockStateMachine.countingCheck();

View File

@ -13,6 +13,7 @@ import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
@ -27,6 +28,7 @@ import clock.socoolby.com.clock.ThemeUIManager;
import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment; import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment;
import clock.socoolby.com.clock.pop.ColorPickerPop; import clock.socoolby.com.clock.pop.ColorPickerPop;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum; import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.DigitViewModel; import clock.socoolby.com.clock.viewmodel.DigitViewModel;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel; import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
import clock.socoolby.com.clock.viewmodel.ViewModelFactory; import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
@ -110,6 +112,8 @@ public class DigitClockConfigFragment extends Fragment {
Button tvThemeUIStyle4; Button tvThemeUIStyle4;
@BindView(R.id.tv_textAnim_tabDigit_up) @BindView(R.id.tv_textAnim_tabDigit_up)
RadioButton tvTextAnimTabDigitUp; RadioButton tvTextAnimTabDigitUp;
@BindView(R.id.tv_theme_config_recover)
Button tvThemeConfigRecover;
public DigitClockConfigFragment(ThemeUIManager themeUIManager) { public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
this.themeUIManager = themeUIManager; this.themeUIManager = themeUIManager;
@ -120,6 +124,7 @@ public class DigitClockConfigFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class); digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
} }
private Unbinder unbinder; private Unbinder unbinder;
@ -244,6 +249,15 @@ public class DigitClockConfigFragment extends Fragment {
tvThemeUIStyle4.setOnLongClickListener(v -> configThemeUIStyle(4)); tvThemeUIStyle4.setOnLongClickListener(v -> configThemeUIStyle(4));
tvThemeConfigRecover.setOnClickListener(v -> {
try {
themeUIManager.recoverTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
reloadViewModel();
} catch (BasicException e) {
e.printStackTrace();
}
});
return view; return view;
} }
@ -252,10 +266,14 @@ public class DigitClockConfigFragment extends Fragment {
try { try {
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Digit.code, styleName)) { if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Digit.code, styleName)) {
themeUIManager.loadDigitThemeFromDB(styleName); themeUIManager.loadDigitThemeFromDB(styleName);
globalViewModel.loadFromModel(); reloadViewModel();
digitViewModel.loadFromModel(); } else {
} else DialogUtils.show(getActivity(),"温馨提示","当前主题还未设置,是否以当前主题保存.",ok->{
Toast.makeText(getActivity(), "当前主题是空的,你可长按来保存一个主题", Toast.LENGTH_SHORT).show(); if(ok)
configThemeUIStyle(order);
});
Toast.makeText(getActivity(), "你可长按来保存一个主题", Toast.LENGTH_SHORT).show();
}
} catch (BasicException e) { } catch (BasicException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -291,7 +309,11 @@ public class DigitClockConfigFragment extends Fragment {
colorPickerDialog.show(confColors[order]); colorPickerDialog.show(confColors[order]);
} }
private void reloadViewModel() {
globalViewModel.loadFromModel();
digitViewModel.loadFromModel();
loadForViewModel();
}
/** /**
* onDestroyView中进行解绑操作 * onDestroyView中进行解绑操作
*/ */

View File

@ -49,7 +49,7 @@ public class HourAnimatorFragment extends Fragment {
Log.d("hour Animator", "go in heartBeat Observer:"+animatorDialy); Log.d("hour Animator", "go in heartBeat Observer:"+animatorDialy);
animatorDialy--; animatorDialy--;
if(animatorDialy==0) { if(animatorDialy==0) {
Log.d("hour Animator", "animator dialy is out ,end animator"); Log.d("hour Animator", "animator runDelay is out ,end animator");
globalViewModel.setTimeHourAnimatorStarting(false); globalViewModel.setTimeHourAnimatorStarting(false);
animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue(); animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue();
} }

View File

@ -11,6 +11,7 @@ import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
@ -24,6 +25,7 @@ import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.ThemeUIManager; import clock.socoolby.com.clock.ThemeUIManager;
import clock.socoolby.com.clock.pop.ColorPickerPop; import clock.socoolby.com.clock.pop.ColorPickerPop;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum; import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel; import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
import clock.socoolby.com.clock.viewmodel.SimulateViewModel; import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
import clock.socoolby.com.clock.viewmodel.ViewModelFactory; import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
@ -93,6 +95,8 @@ public class SimulateClockConfigFragment extends Fragment {
Button tvThemeUIStyle3; Button tvThemeUIStyle3;
@BindView(R.id.tv_themeUI_style_4) @BindView(R.id.tv_themeUI_style_4)
Button tvThemeUIStyle4; Button tvThemeUIStyle4;
@BindView(R.id.tv_theme_config_recover)
Button tvThemeConfigRecover;
private Unbinder unbinder; private Unbinder unbinder;
@ -107,6 +111,7 @@ public class SimulateClockConfigFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class); simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
} }
@Override @Override
@ -248,6 +253,14 @@ public class SimulateClockConfigFragment extends Fragment {
tvThemeUIStyle4.setOnLongClickListener(v -> configThemeUIStyle(4)); tvThemeUIStyle4.setOnLongClickListener(v -> configThemeUIStyle(4));
tvThemeConfigRecover.setOnClickListener(v-> {
try {
themeUIManager.recoverTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
reloadViewModel();
} catch (BasicException e) {
e.printStackTrace();
}
});
return view; return view;
} }
@ -256,11 +269,16 @@ public class SimulateClockConfigFragment extends Fragment {
String styleName = "simulate_style_" + order; String styleName = "simulate_style_" + order;
try { try {
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) { if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) {
themeUIManager.loadSimulateThemeFromDB(styleName); themeUIManager.loadSimulateThemeFromDB(styleName);
globalViewModel.loadFromModel(); reloadViewModel();
simulateViewModel.loadFromModel(); } else {
}else DialogUtils.show(getActivity(),"温馨提示","当前主题还未设置,是否以当前主题保存.", ok->{
Toast.makeText(getActivity(),"当前主题是空的,你可长按来保存一个主题",Toast.LENGTH_SHORT).show(); if(ok)
configThemeUIStyle(order);
});
Toast.makeText(getActivity(), "你可长按来保存一个主题", Toast.LENGTH_SHORT).show();
}
} catch (BasicException e) { } catch (BasicException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -285,6 +303,10 @@ public class SimulateClockConfigFragment extends Fragment {
colorPickerDialog.show(defColor); colorPickerDialog.show(defColor);
} }
private void reloadViewModel(){
globalViewModel.loadFromModel();
simulateViewModel.loadFromModel();
}
private void bindViewModel() { private void bindViewModel() {
globalViewModel.getForegroundColor().observe(this, integer -> setTextColor(integer)); globalViewModel.getForegroundColor().observe(this, integer -> setTextColor(integer));

View File

@ -65,7 +65,6 @@ public class SimulateClockFragment extends Fragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
clockAnimator.start(); clockAnimator.start();
} }
@Override @Override
@ -116,6 +115,8 @@ public class SimulateClockFragment extends Fragment {
clock= ClockFactory.build(clockStyle); clock= ClockFactory.build(clockStyle);
clockAnimator.setClock(clock); clockAnimator.setClock(clock);
clockAnimator.setClockPointer(PointerFactory.build(simulateViewModel.getPointerTypeName().getValue())); clockAnimator.setClockPointer(PointerFactory.build(simulateViewModel.getPointerTypeName().getValue()));
if(!clockAnimator.isRunning())
clockAnimator.start();
} }
private void setClockPointer(String clockPointerStyle){ private void setClockPointer(String clockPointerStyle){

View File

@ -0,0 +1,29 @@
package clock.socoolby.com.clock.utils;
import android.content.Context;
import androidx.appcompat.app.AlertDialog;
public class DialogUtils {
public interface OkCancelSelectedLinstener {
void onReturn(boolean ok);
}
public static void show(Context context, String title, String message, OkCancelSelectedLinstener linstener){
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setTitle(title);
builder.setMessage(message);
builder.setCancelable(true);
builder.setPositiveButton("确定", (dialog, which) -> {
linstener.onReturn(true);
dialog.dismiss();
});
builder.setNegativeButton("取消", (dialog, which) -> {
linstener.onReturn(false);
dialog.dismiss();
});
builder.create().show();
}
}

View File

@ -19,7 +19,15 @@ import java.util.ArrayList;
import java.util.Random; import java.util.Random;
public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_Animator{ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_Animator{
protected Random rand=new Random();
protected Random rand=new Random(){
@Override
public int nextInt(int bound) {
if(bound==0)
return 0;
return super.nextInt(bound);
}
};
protected boolean isRuning=false; protected boolean isRuning=false;
protected int color= Color.BLACK; protected int color= Color.BLACK;
@ -42,22 +50,30 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
protected Paint mPaint=new Paint(); protected Paint mPaint=new Paint();
protected int delayRunLoopTime =0;
protected int runDelay;
public AbstractAnimator(int entryQuantity) { public AbstractAnimator(int entryQuantity) {
this.entryQuantity = entryQuantity; this.entryQuantity = entryQuantity;
} }
public AbstractAnimator(int entryQuantity,int delayRunLoopTime) {
this.entryQuantity = entryQuantity;
this.delayRunLoopTime = delayRunLoopTime;
}
@Override @Override
public void init(Context context, final View main) { public void init(Context context, final View main) {
mainView=main; mainView=main;
this.context=context; this.context=context;
width=main.getWidth(); width=main.getWidth();
height=main.getHeight(); height=main.getHeight();
if(width==0||height==0)
width=height=10;
} }
@Override @Override
public void start() { public void start() {
runDelay =0;
if(animator==null) { if(animator==null) {
init(); init();
//初始化animator //初始化animator
@ -89,18 +105,17 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
list.add(createNewEntry()); list.add(createNewEntry());
} }
private int dialy=0;
public boolean run(){ public boolean run(){
if(dialy-->0) if(runDelay-->0)
return false; return false;
dialy=dialyTime(); runDelay = delayTime();
for(T entry:list) for(T entry:list)
entry.move(width,height); entry.move(width,height);
return true; return true;
} }
public int dialyTime(){ public int delayTime(){
return 0; return delayRunLoopTime;
} }
@Override @Override
@ -113,6 +128,7 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
public void setRandColor(boolean randColor){ public void setRandColor(boolean randColor){
this.randColor=randColor; this.randColor=randColor;
runDelay =0;
} }
protected void randomColorIfAble(){ protected void randomColorIfAble(){
@ -185,6 +201,7 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
mPaint.setColor(color); mPaint.setColor(color);
for(T entry:list) for(T entry:list)
entry.setAnimatorEntryColor(color); entry.setAnimatorEntryColor(color);
runDelay =0;
} }
@Override @Override

View File

@ -25,7 +25,7 @@ public class CarrouselAnimator extends AbstractAnimator<CarrouselAnimator.Carrou
} }
@Override @Override
public int dialyTime() { public int delayTime() {
return 5; return 5;
} }

View File

@ -23,7 +23,7 @@ public class DotsLineAnimator extends AbstractAnimator<DotsLineAnimator.Circle>
} }
@Override @Override
public int dialyTime() { public int delayTime() {
return SLEEP_TIME; return SLEEP_TIME;
} }

View File

@ -34,8 +34,6 @@ public class FishAnimator extends AbstractAnimator<FishAnimator.Fish> {
@Override @Override
public Fish createNewEntry() { public Fish createNewEntry() {
if(width<=0)
width=height=100;
return new Fish(rand.nextInt(width),rand.nextInt(height),0); return new Fish(rand.nextInt(width),rand.nextInt(height),0);
} }

View File

@ -27,7 +27,7 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
@Override @Override
public int dialyTime() { public int delayTime() {
return 20; return 20;
} }
@ -130,18 +130,18 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
mRightTopCentre[Y] = (float) (paddingTop + validHeight * 0.102); mRightTopCentre[Y] = (float) (paddingTop + validHeight * 0.102);
// 中上齿轮中心 // 中上齿轮中心
mTopCentre[X] = (float) (paddingLeft + validWidth * 0.5); mTopCentre[X] = (float) (paddingLeft + validWidth * 0.2);
mTopCentre[Y] = (float) (paddingTop + validHeight * 0.311); mTopCentre[Y] = (float) (paddingTop + validHeight * 0.5);
// 中下齿轮中心 // 中下齿轮中心
mBottomCentre[X] = (float) (paddingLeft + validWidth * 0.5); mBottomCentre[X] = (float) (paddingLeft + validWidth * 0.5);
mBottomCentre[Y] = (float) (paddingTop + validHeight * 0.597); mBottomCentre[Y] = (float) (paddingTop + validHeight * 0.5);
// 上部两个齿轮的半径 // 上部两个齿轮的半径
mTopCircleRadius = (float) (validWidth * 0.102); mTopCircleRadius = (float) (validWidth * 0.08);
// 最大的齿轮stroke size // 最大的齿轮stroke size
mBottomBigCircleRadius = validWidth / 2 - mTopCircleRadius / 4 * 5; mBottomBigCircleRadius = validWidth / 5 - mTopCircleRadius / 4 * 5;
mStrokePaint.setStrokeWidth(mTopCircleRadius / 4 * 5); mStrokePaint.setStrokeWidth(mTopCircleRadius / 4 * 5);
// 传送带stroke size // 传送带stroke size
@ -213,9 +213,9 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
canvas.restore(); canvas.restore();
// 大齿轮扇形遮罩 // 大齿轮扇形遮罩
mDarkRedPaint.setXfermode(mClearXfermode); //mDarkRedPaint.setXfermode(mClearXfermode);
canvas.drawArc(mShadeRectF, 180, 130, true, mDarkRedPaint); //canvas.drawArc(mShadeRectF, 180, 130, true, mDarkRedPaint);
mDarkRedPaint.setXfermode(null); //mDarkRedPaint.setXfermode(null);
// 上方两个齿轮底下的斜向连杆 // 上方两个齿轮底下的斜向连杆
canvas.drawPath(mBarPath, mTransitionPaint); canvas.drawPath(mBarPath, mTransitionPaint);
@ -256,8 +256,8 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
// 中上齿轮 // 中上齿轮
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius, mRedPaint); canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius, mRedPaint);
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 4 * 3, mDarkRedPaint); canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 6 * 3, mDarkRedPaint);
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 4, mRedPaint); canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 6, mRedPaint);
canvas.save(); canvas.save();
canvas.rotate(mCurProgress * 225, mTopCentre[X], mTopCentre[Y]); canvas.rotate(mCurProgress * 225, mTopCentre[X], mTopCentre[Y]);
for (int i = 0; i < 8; i ++) { for (int i = 0; i < 8; i ++) {

View File

@ -45,7 +45,6 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
final static private boolean DEF_BORDER_CORNERS_ROUND = true; final static private boolean DEF_BORDER_CORNERS_ROUND = true;
final static private int DEF_GENERATION_TYPE = GENERATION_TYPE_RANDOM; final static private int DEF_GENERATION_TYPE = GENERATION_TYPE_RANDOM;
int delay;
int regionsCount; int regionsCount;
public VorolayAnimator( ) { public VorolayAnimator( ) {
@ -53,9 +52,8 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
} }
public VorolayAnimator(int regionsCount,int delay) { public VorolayAnimator(int regionsCount,int delay) {
super(1); super(1,delay);
this.regionsCount=regionsCount; this.regionsCount=regionsCount;
this.delay=delay;
} }
public VorolayAnimator(int regionsCount) { public VorolayAnimator(int regionsCount) {
@ -63,8 +61,8 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
} }
@Override @Override
public int dialyTime() { public int delayTime() {
return delay; return delayRunLoopTime;
} }
@Override @Override
@ -166,7 +164,6 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
mRegions = mVoronoi.getRegions(); mRegions = mVoronoi.getRegions();
} }
/* /*
* *
* Points generation methods * Points generation methods
@ -277,7 +274,6 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
// then draw borders // then draw borders
if (mBorderEnabled) { if (mBorderEnabled) {
if (randColor)
randomColorIfAble(); randomColorIfAble();
p.setColor(color); p.setColor(color);
canvas.drawPath(region.path, p); canvas.drawPath(region.path, p);

View File

@ -55,7 +55,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
private int textSize=10; private int textSize=10;
@Override @Override
public int dialyTime() { public int delayTime() {
return 20; return 20;
} }

View File

@ -29,7 +29,7 @@ public class EvaporateTextAnimator extends AbstractAnimator<EvaporateTextAnimato
} }
@Override @Override
public int dialyTime() { public int delayTime() {
return 15; return 15;
} }

View File

@ -25,7 +25,7 @@ public class PathEffectTextAnimator extends AbstractAnimator<PathEffectTextAnima
} }
@Override @Override
public int dialyTime() { public int delayTime() {
return 10; return 10;
} }

View File

@ -10,14 +10,15 @@
android:id="@+id/text_style_group1" android:id="@+id/text_style_group1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="5dp"
android:orientation="horizontal"> android:orientation="horizontal">
<RadioGroup <RadioGroup
android:id="@+id/tv_hourSystem_group" android:id="@+id/tv_hourSystem_group"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="5"
android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -25,6 +26,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:text="时制" /> android:text="时制" />
<RadioButton <RadioButton
@ -32,6 +34,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:text="12时制" /> android:text="12时制" />
<RadioButton <RadioButton
@ -39,6 +42,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:text="24时制" /> android:text="24时制" />
</RadioGroup> </RadioGroup>
@ -46,16 +50,23 @@
android:id="@+id/tv_secoundShow" android:id="@+id/tv_secoundShow"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="2"
android:text="秒显" /> android:text="秒显" />
<Button
android:id="@+id/tv_theme_config_recover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="恢复" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/text_style_group2" android:id="@+id/text_style_group2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="5dp"
android:layout_below="@id/text_style_group1" android:layout_below="@id/text_style_group1"
android:orientation="horizontal"> android:orientation="horizontal">
@ -71,6 +82,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:text="样式" /> android:text="样式" />
<RadioButton <RadioButton

View File

@ -68,13 +68,15 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center"
android:text="文字显示" /> android:text="文字显示" />
<RadioGroup <RadioGroup
android:id="@+id/tv_simulate_text_show_group" android:id="@+id/tv_simulate_text_show_group"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<RadioButton <RadioButton
@ -99,6 +101,12 @@
android:text="四边" /> android:text="四边" />
</RadioGroup> </RadioGroup>
<Button
android:id="@+id/tv_theme_config_recover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="恢复" />
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView