mirror of
https://gitee.com/51danju/workclock.git
synced 2025-06-07 19:34:05 +08:00
增加UI设置时的初始状态保存,恢复功能
This commit is contained in:
parent
134499e589
commit
78e56b54ba
@ -45,8 +45,6 @@ public class AnimatorManager {
|
||||
SawtoothAnimator.NAME,
|
||||
WindmillAnimator.NAME,
|
||||
VorolayAnimator.NAME,
|
||||
EZLedAnimator.NAME,
|
||||
EvaporateTextAnimator.NAME,
|
||||
PhaserBallAnimator.NAME,
|
||||
CarrouselAnimator.NAME,
|
||||
Wave3DAnimator.NAME,
|
||||
|
@ -4,6 +4,7 @@ package clock.socoolby.com.clock;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
@ -572,7 +573,22 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
||||
if(isScreenLock())
|
||||
return super.onKeyDown(keyCode, event);
|
||||
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);
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package clock.socoolby.com.clock;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.openbravo.data.basic.BasicException;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -28,6 +30,8 @@ public class ThemeUIManager{
|
||||
|
||||
SharePerferenceModel model;
|
||||
|
||||
private String tempThemeStr=null;
|
||||
|
||||
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model) {
|
||||
this.entityManager = entityManager;
|
||||
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});
|
||||
}
|
||||
|
||||
public String clobToString(Clob sc) throws SQLException, IOException {
|
||||
String reString = "";
|
||||
Reader is = sc.getCharacterStream();
|
||||
BufferedReader br = new BufferedReader(is);
|
||||
String s = br.readLine();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (s != null) {
|
||||
sb.append(s);
|
||||
s = br.readLine();
|
||||
public void saveTempThemeUI(int type){
|
||||
Log.d(TAG,"save temp ThemeUI type:"+type);
|
||||
if(type==ClockInterfaceTypeEnum.Digit.code)
|
||||
this.tempThemeStr=makeSaveDigitThemeString(model.getDigitPerferenceModel());
|
||||
else
|
||||
this.tempThemeStr=makeSaveSimulateThemeString(model.getSimulatePerferenceModel());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,19 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
|
||||
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){
|
||||
this.layoutId=layoutId;
|
||||
}
|
||||
@ -176,7 +189,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//hand_time_visable=false;
|
||||
tv_hand_time.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
@ -258,17 +270,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
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(){
|
||||
if(!autoFullScreen)
|
||||
@ -293,13 +294,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
|
||||
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>() {
|
||||
@Override
|
||||
public void onChanged(ClockThemeUITypeEnum uiTypeEnum) {
|
||||
@ -389,6 +383,8 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
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)
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
switch (view.getId()) {
|
||||
@ -511,18 +507,17 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
||||
calendarPopup.setCurrentDay();
|
||||
break;
|
||||
case R.id.tv_weather:
|
||||
if (weatherPopup == null)
|
||||
weatherPopup = new WeatherPopup(mainActivity);
|
||||
if(mainActivity.weatherAdape==null) {
|
||||
Toast.makeText(getActivity(),"天气数据获取失败,请检查网络",Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (weatherPopup == null)
|
||||
weatherPopup = new WeatherPopup(mainActivity);
|
||||
weatherPopup.init(mainActivity.weatherAdape.getWeatherList(), model.getCity() + " PM2.5 : " + mainActivity.weatherAdape.getmPM25());
|
||||
weatherPopup.showPopupWindow();
|
||||
break;
|
||||
case R.id.tv_screen_lock:
|
||||
globalViewModel.setSrceenLock(!isScreenLock());
|
||||
screenLock(!isScreenLock());
|
||||
globalViewModel.setSrceenLock(!globalViewModel.getSrceenLock().getValue());
|
||||
break;
|
||||
case R.id.tv_break:
|
||||
clockStateMachine.countingCheck();
|
||||
|
@ -13,6 +13,7 @@ import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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.pop.ColorPickerPop;
|
||||
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.GlobalViewModel;
|
||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||
@ -110,6 +112,8 @@ public class DigitClockConfigFragment extends Fragment {
|
||||
Button tvThemeUIStyle4;
|
||||
@BindView(R.id.tv_textAnim_tabDigit_up)
|
||||
RadioButton tvTextAnimTabDigitUp;
|
||||
@BindView(R.id.tv_theme_config_recover)
|
||||
Button tvThemeConfigRecover;
|
||||
|
||||
public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
|
||||
this.themeUIManager = themeUIManager;
|
||||
@ -120,6 +124,7 @@ public class DigitClockConfigFragment extends Fragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
|
||||
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
|
||||
}
|
||||
|
||||
private Unbinder unbinder;
|
||||
@ -244,6 +249,15 @@ public class DigitClockConfigFragment extends Fragment {
|
||||
|
||||
tvThemeUIStyle4.setOnLongClickListener(v -> configThemeUIStyle(4));
|
||||
|
||||
tvThemeConfigRecover.setOnClickListener(v -> {
|
||||
try {
|
||||
themeUIManager.recoverTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
|
||||
reloadViewModel();
|
||||
} catch (BasicException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -252,10 +266,14 @@ public class DigitClockConfigFragment extends Fragment {
|
||||
try {
|
||||
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Digit.code, styleName)) {
|
||||
themeUIManager.loadDigitThemeFromDB(styleName);
|
||||
globalViewModel.loadFromModel();
|
||||
digitViewModel.loadFromModel();
|
||||
} else
|
||||
Toast.makeText(getActivity(), "当前主题是空的,你可长按来保存一个主题", Toast.LENGTH_SHORT).show();
|
||||
reloadViewModel();
|
||||
} else {
|
||||
DialogUtils.show(getActivity(),"温馨提示","当前主题还未设置,是否以当前主题保存.",ok->{
|
||||
if(ok)
|
||||
configThemeUIStyle(order);
|
||||
});
|
||||
Toast.makeText(getActivity(), "你可长按来保存一个主题", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (BasicException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -291,7 +309,11 @@ public class DigitClockConfigFragment extends Fragment {
|
||||
colorPickerDialog.show(confColors[order]);
|
||||
}
|
||||
|
||||
|
||||
private void reloadViewModel() {
|
||||
globalViewModel.loadFromModel();
|
||||
digitViewModel.loadFromModel();
|
||||
loadForViewModel();
|
||||
}
|
||||
/**
|
||||
* onDestroyView中进行解绑操作
|
||||
*/
|
||||
|
@ -49,7 +49,7 @@ public class HourAnimatorFragment extends Fragment {
|
||||
Log.d("hour Animator", "go in heartBeat Observer:"+animatorDialy);
|
||||
animatorDialy--;
|
||||
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);
|
||||
animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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.pop.ColorPickerPop;
|
||||
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.SimulateViewModel;
|
||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||
@ -93,6 +95,8 @@ public class SimulateClockConfigFragment extends Fragment {
|
||||
Button tvThemeUIStyle3;
|
||||
@BindView(R.id.tv_themeUI_style_4)
|
||||
Button tvThemeUIStyle4;
|
||||
@BindView(R.id.tv_theme_config_recover)
|
||||
Button tvThemeConfigRecover;
|
||||
|
||||
private Unbinder unbinder;
|
||||
|
||||
@ -107,6 +111,7 @@ public class SimulateClockConfigFragment extends Fragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
|
||||
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,45 +237,58 @@ public class SimulateClockConfigFragment extends Fragment {
|
||||
});
|
||||
});
|
||||
|
||||
tvThemeUIStyle1.setOnClickListener(v->changeThemeUIStyle(1));
|
||||
tvThemeUIStyle1.setOnClickListener(v -> changeThemeUIStyle(1));
|
||||
|
||||
tvThemeUIStyle2.setOnClickListener(v->changeThemeUIStyle(2));
|
||||
tvThemeUIStyle2.setOnClickListener(v -> changeThemeUIStyle(2));
|
||||
|
||||
tvThemeUIStyle3.setOnClickListener(v->changeThemeUIStyle(3));
|
||||
tvThemeUIStyle3.setOnClickListener(v -> changeThemeUIStyle(3));
|
||||
|
||||
tvThemeUIStyle4.setOnClickListener(v->changeThemeUIStyle(4));
|
||||
tvThemeUIStyle4.setOnClickListener(v -> changeThemeUIStyle(4));
|
||||
|
||||
tvThemeUIStyle1.setOnLongClickListener(v->configThemeUIStyle(1));
|
||||
tvThemeUIStyle1.setOnLongClickListener(v -> configThemeUIStyle(1));
|
||||
|
||||
tvThemeUIStyle2.setOnLongClickListener(v->configThemeUIStyle(2));
|
||||
tvThemeUIStyle2.setOnLongClickListener(v -> configThemeUIStyle(2));
|
||||
|
||||
tvThemeUIStyle3.setOnLongClickListener(v->configThemeUIStyle(3));
|
||||
tvThemeUIStyle3.setOnLongClickListener(v -> configThemeUIStyle(3));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void changeThemeUIStyle(int order){
|
||||
String styleName="simulate_style_"+order;
|
||||
private void changeThemeUIStyle(int order) {
|
||||
String styleName = "simulate_style_" + order;
|
||||
try {
|
||||
if(themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code,styleName)){
|
||||
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) {
|
||||
|
||||
themeUIManager.loadSimulateThemeFromDB(styleName);
|
||||
globalViewModel.loadFromModel();
|
||||
simulateViewModel.loadFromModel();
|
||||
}else
|
||||
Toast.makeText(getActivity(),"当前主题是空的,你可长按来保存一个主题",Toast.LENGTH_SHORT).show();
|
||||
reloadViewModel();
|
||||
} else {
|
||||
DialogUtils.show(getActivity(),"温馨提示","当前主题还未设置,是否以当前主题保存.", ok->{
|
||||
if(ok)
|
||||
configThemeUIStyle(order);
|
||||
});
|
||||
Toast.makeText(getActivity(), "你可长按来保存一个主题", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (BasicException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean configThemeUIStyle(int order){
|
||||
String styleName="simulate_style_"+order;
|
||||
private boolean configThemeUIStyle(int order) {
|
||||
String styleName = "simulate_style_" + order;
|
||||
try {
|
||||
themeUIManager.saveSimulateThemeFromModel(styleName);
|
||||
Toast.makeText(getActivity(),"当前主题已保存",Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), "当前主题已保存", Toast.LENGTH_SHORT).show();
|
||||
} catch (BasicException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -285,9 +303,13 @@ public class SimulateClockConfigFragment extends Fragment {
|
||||
colorPickerDialog.show(defColor);
|
||||
}
|
||||
|
||||
private void reloadViewModel(){
|
||||
globalViewModel.loadFromModel();
|
||||
simulateViewModel.loadFromModel();
|
||||
}
|
||||
|
||||
private void bindViewModel() {
|
||||
globalViewModel.getForegroundColor().observe(this,integer -> setTextColor(integer));
|
||||
globalViewModel.getForegroundColor().observe(this, integer -> setTextColor(integer));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,8 +353,8 @@ public class SimulateClockConfigFragment extends Fragment {
|
||||
textView4.setTextColor(color);
|
||||
textView5.setTextColor(color);
|
||||
|
||||
tvSimulateTextShowHide.setTextColor(color);
|
||||
tvSimulateTextShowAll.setTextColor(color);
|
||||
tvSimulateTextShowFour.setTextColor(color);
|
||||
tvSimulateTextShowHide.setTextColor(color);
|
||||
tvSimulateTextShowAll.setTextColor(color);
|
||||
tvSimulateTextShowFour.setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public class SimulateClockFragment extends Fragment {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
clockAnimator.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,6 +115,8 @@ public class SimulateClockFragment extends Fragment {
|
||||
clock= ClockFactory.build(clockStyle);
|
||||
clockAnimator.setClock(clock);
|
||||
clockAnimator.setClockPointer(PointerFactory.build(simulateViewModel.getPointerTypeName().getValue()));
|
||||
if(!clockAnimator.isRunning())
|
||||
clockAnimator.start();
|
||||
}
|
||||
|
||||
private void setClockPointer(String clockPointerStyle){
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -19,7 +19,15 @@ import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
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 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 int delayRunLoopTime =0;
|
||||
|
||||
protected int runDelay;
|
||||
|
||||
public AbstractAnimator(int entryQuantity) {
|
||||
this.entryQuantity = entryQuantity;
|
||||
}
|
||||
|
||||
public AbstractAnimator(int entryQuantity,int delayRunLoopTime) {
|
||||
this.entryQuantity = entryQuantity;
|
||||
this.delayRunLoopTime = delayRunLoopTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, final View main) {
|
||||
mainView=main;
|
||||
this.context=context;
|
||||
width=main.getWidth();
|
||||
height=main.getHeight();
|
||||
if(width==0||height==0)
|
||||
width=height=10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
runDelay =0;
|
||||
if(animator==null) {
|
||||
init();
|
||||
//初始化animator
|
||||
@ -89,18 +105,17 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
|
||||
list.add(createNewEntry());
|
||||
}
|
||||
|
||||
private int dialy=0;
|
||||
public boolean run(){
|
||||
if(dialy-->0)
|
||||
if(runDelay-->0)
|
||||
return false;
|
||||
dialy=dialyTime();
|
||||
runDelay = delayTime();
|
||||
for(T entry:list)
|
||||
entry.move(width,height);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int dialyTime(){
|
||||
return 0;
|
||||
public int delayTime(){
|
||||
return delayRunLoopTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,6 +128,7 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
|
||||
|
||||
public void setRandColor(boolean randColor){
|
||||
this.randColor=randColor;
|
||||
runDelay =0;
|
||||
}
|
||||
|
||||
protected void randomColorIfAble(){
|
||||
@ -185,6 +201,7 @@ public abstract class AbstractAnimator<T extends I_AnimatorEntry> implements I_A
|
||||
mPaint.setColor(color);
|
||||
for(T entry:list)
|
||||
entry.setAnimatorEntryColor(color);
|
||||
runDelay =0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ public class CarrouselAnimator extends AbstractAnimator<CarrouselAnimator.Carrou
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class DotsLineAnimator extends AbstractAnimator<DotsLineAnimator.Circle>
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return SLEEP_TIME;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,6 @@ public class FishAnimator extends AbstractAnimator<FishAnimator.Fish> {
|
||||
|
||||
@Override
|
||||
public Fish createNewEntry() {
|
||||
if(width<=0)
|
||||
width=height=100;
|
||||
return new Fish(rand.nextInt(width),rand.nextInt(height),0);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
|
||||
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@ -130,18 +130,18 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
|
||||
mRightTopCentre[Y] = (float) (paddingTop + validHeight * 0.102);
|
||||
|
||||
// 中上齿轮中心
|
||||
mTopCentre[X] = (float) (paddingLeft + validWidth * 0.5);
|
||||
mTopCentre[Y] = (float) (paddingTop + validHeight * 0.311);
|
||||
mTopCentre[X] = (float) (paddingLeft + validWidth * 0.2);
|
||||
mTopCentre[Y] = (float) (paddingTop + validHeight * 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
|
||||
mBottomBigCircleRadius = validWidth / 2 - mTopCircleRadius / 4 * 5;
|
||||
mBottomBigCircleRadius = validWidth / 5 - mTopCircleRadius / 4 * 5;
|
||||
mStrokePaint.setStrokeWidth(mTopCircleRadius / 4 * 5);
|
||||
|
||||
// 传送带stroke size
|
||||
@ -213,9 +213,9 @@ public class SawtoothAnimator extends AbstractAnimator<SawtoothAnimator.Sawtooth
|
||||
canvas.restore();
|
||||
|
||||
// 大齿轮扇形遮罩
|
||||
mDarkRedPaint.setXfermode(mClearXfermode);
|
||||
canvas.drawArc(mShadeRectF, 180, 130, true, mDarkRedPaint);
|
||||
mDarkRedPaint.setXfermode(null);
|
||||
//mDarkRedPaint.setXfermode(mClearXfermode);
|
||||
//canvas.drawArc(mShadeRectF, 180, 130, true, mDarkRedPaint);
|
||||
//mDarkRedPaint.setXfermode(null);
|
||||
|
||||
// 上方两个齿轮底下的斜向连杆
|
||||
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 / 4 * 3, mDarkRedPaint);
|
||||
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 4, mRedPaint);
|
||||
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 6 * 3, mDarkRedPaint);
|
||||
canvas.drawCircle(mTopCentre[X], mTopCentre[Y], mTopCircleRadius / 6, mRedPaint);
|
||||
canvas.save();
|
||||
canvas.rotate(mCurProgress * 225, mTopCentre[X], mTopCentre[Y]);
|
||||
for (int i = 0; i < 8; i ++) {
|
||||
|
@ -45,7 +45,6 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
|
||||
final static private boolean DEF_BORDER_CORNERS_ROUND = true;
|
||||
final static private int DEF_GENERATION_TYPE = GENERATION_TYPE_RANDOM;
|
||||
|
||||
int delay;
|
||||
int regionsCount;
|
||||
|
||||
public VorolayAnimator( ) {
|
||||
@ -53,9 +52,8 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
|
||||
}
|
||||
|
||||
public VorolayAnimator(int regionsCount,int delay) {
|
||||
super(1);
|
||||
super(1,delay);
|
||||
this.regionsCount=regionsCount;
|
||||
this.delay=delay;
|
||||
}
|
||||
|
||||
public VorolayAnimator(int regionsCount) {
|
||||
@ -63,8 +61,8 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
return delay;
|
||||
public int delayTime() {
|
||||
return delayRunLoopTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,7 +164,6 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
|
||||
mRegions = mVoronoi.getRegions();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Points generation methods
|
||||
@ -277,8 +274,7 @@ public class VorolayAnimator extends AbstractAnimator<VorolayAnimator.Vorolay> {
|
||||
|
||||
// then draw borders
|
||||
if (mBorderEnabled) {
|
||||
if (randColor)
|
||||
randomColorIfAble();
|
||||
randomColorIfAble();
|
||||
p.setColor(color);
|
||||
canvas.drawPath(region.path, p);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class EZLedAnimator extends AbstractAnimator<EZLedAnimator.EZLed> {
|
||||
private int textSize=10;
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class EvaporateTextAnimator extends AbstractAnimator<EvaporateTextAnimato
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class PathEffectTextAnimator extends AbstractAnimator<PathEffectTextAnima
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dialyTime() {
|
||||
public int delayTime() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,15 @@
|
||||
android:id="@+id/text_style_group1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/tv_hourSystem_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="5"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
@ -25,6 +26,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="时制" />
|
||||
|
||||
<RadioButton
|
||||
@ -32,6 +34,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="12时制" />
|
||||
|
||||
<RadioButton
|
||||
@ -39,6 +42,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="24时制" />
|
||||
</RadioGroup>
|
||||
|
||||
@ -46,16 +50,23 @@
|
||||
android:id="@+id/tv_secoundShow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="2"
|
||||
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
|
||||
android:id="@+id/text_style_group2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_below="@id/text_style_group1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
@ -71,6 +82,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="样式" />
|
||||
|
||||
<RadioButton
|
||||
|
@ -68,13 +68,15 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="文字显示" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/tv_simulate_text_show_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="3"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
@ -99,6 +101,12 @@
|
||||
android:text="四边" />
|
||||
</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>
|
||||
|
||||
<ScrollView
|
||||
|
Loading…
x
Reference in New Issue
Block a user