Code clean up
This commit is contained in:
parent
36a64e4ad3
commit
362cb4f1bc
|
@ -162,6 +162,52 @@ public class MainActivity extends AppCompatActivity {
|
|||
});
|
||||
return true;
|
||||
case R.id.settings_language:
|
||||
selectLanguageLogic();
|
||||
return true;
|
||||
case R.id.settings_translation_service:
|
||||
selectTranslateServiceLogic();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
manager.flushConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void selectTranslateServiceLogic() {
|
||||
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_translation_service).items(R.array.translators).itemsCallback((dialog, itemView, position, text) -> {
|
||||
DaoSession daoSession = ((MainApplication)this.getApplication()).getDaoSession();
|
||||
AppConfigDao appConfigDao = daoSession.getAppConfigDao();
|
||||
AppConfig activeTranslator = appConfigDao.queryBuilder().where(AppConfigDao.Properties.Name.eq(AppConfigKey.ACTIVE_TRANSLATOR)).build().unique();
|
||||
switch (position) {
|
||||
case 0:
|
||||
if(activeTranslator != null) {
|
||||
appConfigDao.delete(activeTranslator);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(activeTranslator == null) {
|
||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.GOOGLE);
|
||||
} else {
|
||||
activeTranslator.setValue(TranslateUtil.GOOGLE);
|
||||
}
|
||||
appConfigDao.insertOrReplace(activeTranslator);
|
||||
break;
|
||||
case 2:
|
||||
if(activeTranslator == null) {
|
||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.YOU_DAO);
|
||||
} else {
|
||||
activeTranslator.setValue(TranslateUtil.YOU_DAO);
|
||||
}
|
||||
appConfigDao.insertOrReplace(activeTranslator);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}).show());
|
||||
}
|
||||
|
||||
private void selectLanguageLogic() {
|
||||
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_set_language).items(R.array.languages).itemsCallback((dialog, itemView, position, text) -> {
|
||||
boolean restart;
|
||||
switch (position) {
|
||||
|
@ -205,44 +251,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
finish();
|
||||
}
|
||||
}).show());
|
||||
return true;
|
||||
case R.id.settings_translation_service:
|
||||
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_translation_service).items(R.array.translators).itemsCallback((dialog, itemView, position, text) -> {
|
||||
DaoSession daoSession = ((MainApplication)this.getApplication()).getDaoSession();
|
||||
AppConfigDao appConfigDao = daoSession.getAppConfigDao();
|
||||
AppConfig activeTranslator = appConfigDao.queryBuilder().where(AppConfigDao.Properties.Name.eq(AppConfigKey.ACTIVE_TRANSLATOR)).build().unique();
|
||||
switch (position) {
|
||||
case 0:
|
||||
if(activeTranslator != null) {
|
||||
appConfigDao.delete(activeTranslator);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(activeTranslator == null) {
|
||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.GOOGLE);
|
||||
} else {
|
||||
activeTranslator.setValue(TranslateUtil.GOOGLE);
|
||||
}
|
||||
appConfigDao.insertOrReplace(activeTranslator);
|
||||
break;
|
||||
case 2:
|
||||
if(activeTranslator == null) {
|
||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.YOU_DAO);
|
||||
} else {
|
||||
activeTranslator.setValue(TranslateUtil.YOU_DAO);
|
||||
}
|
||||
appConfigDao.insertOrReplace(activeTranslator);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}).show());
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
manager.flushConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,6 @@ import lombok.Data;
|
|||
/**
|
||||
* SMAPI的配置
|
||||
*/
|
||||
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
|
||||
@Data
|
||||
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility= JsonAutoDetect.Visibility.NONE)
|
||||
public class FrameworkConfig {
|
||||
|
|
|
@ -7,7 +7,6 @@ import lombok.Data;
|
|||
/**
|
||||
* Mod信息
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@Data
|
||||
public class ModManifestEntry {
|
||||
/**
|
||||
|
|
|
@ -63,7 +63,11 @@ public class HelpItemAdapter extends RecyclerView.Adapter<HelpItemAdapter.ViewHo
|
|||
void setHelpItem(HelpItem item) {
|
||||
textTitle.setText(item.getTitle());
|
||||
textAuthor.setText(item.getAuthor());
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
textContent.setText(Html.fromHtml(item.getContent(), Html.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
textContent.setText(Html.fromHtml(item.getContent()));
|
||||
}
|
||||
textContent.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue