Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Apr 15, 2023
1 parent 875a187 commit 7edef02
Show file tree
Hide file tree
Showing 133 changed files with 399 additions and 413 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LoginActivity extends WfcBaseNoToolbarActivity {
EditText accountEditText;
EditText passwordEditText;

private void bindClickImpl() {
private void bindEvents() {
findViewById(R.id.authCodeLoginTextView).setOnClickListener(v -> authCodeLogin());
findViewById(R.id.registerTextView).setOnClickListener(v -> register());
findViewById(R.id.loginButton).setOnClickListener(v -> login());
Expand All @@ -52,7 +52,7 @@ public void afterTextChanged(Editable s) {
});
}

private void bindViewImpl() {
private void bindViews() {
loginButton = findViewById(R.id.loginButton);
accountEditText = findViewById(R.id.phoneNumberEditText);
passwordEditText = findViewById(R.id.passwordEditText);
Expand All @@ -65,8 +65,8 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
bindViews();
bindEvents();
setStatusBarTheme(this, false);
setStatusBarColor(R.color.gray14);
if (getIntent().getBooleanExtra("isKickedOff", false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SMSLoginActivity extends WfcBaseNoToolbarActivity {
TextView requestAuthCodeButton;


private void bindClickImpl() {
private void bindEvents() {
findViewById(R.id.passwordLoginTextView).setOnClickListener(v -> authCodeLogin());
findViewById(R.id.loginButton).setOnClickListener(v -> login());
findViewById(R.id.requestAuthCodeButton).setOnClickListener(v -> requestAuthCode());
Expand All @@ -55,7 +55,7 @@ public void afterTextChanged(Editable s) {
});
}

private void bindViewImpl() {
private void bindViews() {
loginButton = findViewById(R.id.loginButton);
phoneNumberEditText = findViewById(R.id.phoneNumberEditText);
authCodeEditText = findViewById(R.id.authCodeEditText);
Expand All @@ -69,8 +69,8 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
bindViews();
bindEvents();
setStatusBarTheme(this, false);
setStatusBarColor(R.color.gray14);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ public class DiscoveryFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.main_fragment_discovery, container, false);
bindViewImpl(view);
bindClickImpl(view);
bindViews(view);
bindEvents(view);
initMoment();
if (!AVEngineKit.isSupportConference()) {
conferenceOptionItemView.setVisibility(View.GONE);
}
return view;
}

private void bindClickImpl(View view) {
private void bindEvents(View view) {
view.findViewById(R.id.chatRoomOptionItemView).setOnClickListener(v -> chatRoom());
view.findViewById(R.id.robotOptionItemView).setOnClickListener(v -> robot());
view.findViewById(R.id.channelOptionItemView).setOnClickListener(v -> channel());
Expand All @@ -61,7 +61,7 @@ private void bindClickImpl(View view) {
view.findViewById(R.id.conferenceOptionItemView).setOnClickListener(v -> conference());
}

private void bindViewImpl(View view) {
private void bindViews(View view) {
momentOptionItemView = view.findViewById(R.id.momentOptionItemView);
conferenceOptionItemView = view.findViewById(R.id.conferenceOptionItemView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public class MainActivity extends WfcBaseActivity implements ViewPager.OnPageCha
private ContactViewModel contactViewModel;
private ConversationListViewModel conversationListViewModel;

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
bottomNavigationView = findViewById(R.id.bottomNavigationView);
contentViewPager = findViewById(R.id.contentViewPager);
startingTextView = findViewById(R.id.startingTextView);
Expand Down Expand Up @@ -139,7 +140,6 @@ protected void onResume() {

@Override
protected void afterViews() {
bindViewImpl();
bottomNavigationView.setItemIconTintList(null);
if (TextUtils.isEmpty(Config.WORKSPACE_URL)) {
bottomNavigationView.getMenu().removeItem(R.id.workspace);
Expand Down
8 changes: 4 additions & 4 deletions chat/src/main/java/cn/wildfire/chat/app/main/MeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public void onChanged(@Nullable List<UserInfo> userInfos) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.main_fragment_me, container, false);
bindViewImpl(view);
bindClickImpl(view);
bindViews(view);
bindEvents(view);
init();
return view;
}

private void bindClickImpl(View view) {
private void bindEvents(View view) {
view.findViewById(R.id.meLinearLayout).setOnClickListener(v -> showMyInfo());
view.findViewById(R.id.favOptionItemView).setOnClickListener(v -> fav());
view.findViewById(R.id.accountOptionItemView).setOnClickListener(v -> account());
Expand All @@ -94,7 +94,7 @@ private void bindClickImpl(View view) {
view.findViewById(R.id.notificationOptionItemView).setOnClickListener(v -> msgNotifySetting());
}

private void bindViewImpl(View view) {
private void bindViews(View view) {
meLinearLayout = view.findViewById(R.id.meLinearLayout);
portraitImageView = view.findViewById(R.id.portraitImageView);
nameTextView = view.findViewById(R.id.nameTextView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ public class PCLoginActivity extends WfcBaseActivity {

private Platform platform;

private void bindClickImpl() {
protected void bindEvents() {
super.bindEvents();
findViewById(R.id.confirmButton).setOnClickListener(v -> confirmPCLogin());
findViewById(R.id.cancelButton).setOnClickListener(v -> cancelPCLogin());
}

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
confirmButton = findViewById(R.id.confirmButton);
descTextView = findViewById(R.id.descTextView);
}
Expand All @@ -56,8 +58,6 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
descTextView.setText("允许 " + platform.getPlatFormName() + " 登录");
if (isConfirmPcLogin) {
confirmButton.setEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public static WorkspaceFragment loadHtmlContent(String htmlContent) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_webview, container, false);
bindViewImpl(view);
bindViews(view);
init();
return view;
}

private void bindViewImpl(View view) {
private void bindViews(View view) {
webView = view.findViewById(R.id.webview);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ public class AboutActivity extends WfcBaseActivity {

TextView infoTextView;

private void bindClickImpl() {
protected void bindEvents() {
super.bindEvents();
findViewById(R.id.introOptionItemView).setOnClickListener(v -> intro());
findViewById(R.id.agreementOptionItemView).setOnClickListener(v -> agreement());
findViewById(R.id.privacyOptionItemView).setOnClickListener(v -> privacy());
}

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
infoTextView = findViewById(R.id.infoTextView);
}

Expand All @@ -36,8 +38,6 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
PackageManager packageManager = getPackageManager();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), PackageManager.GET_CONFIGURATIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ protected int contentLayout() {
return R.layout.account_activity;
}

private void bindClickImpl() {
protected void bindEvents() {
super.bindEvents();
findViewById(R.id.changePasswordOptionItemView).setOnClickListener(v -> changePassword());
}

@Override
protected void afterViews() {
bindClickImpl();
}

void changePassword() {
new MaterialDialog.Builder(this).items(R.array.change_password).itemsCallback(new MaterialDialog.ListCallback() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

private void bindClickImpl() {
protected void bindEvents() {
super.bindEvents();
findViewById(R.id.confirmButton).setOnClickListener(v -> resetPassword());
oldPasswordEditText.addTextChangedListener(new SimpleTextWatcher() {
@Override
Expand All @@ -55,7 +56,8 @@ public void afterTextChanged(Editable s) {
});
}

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
confirmButton = findViewById(R.id.confirmButton);
oldPasswordEditText = findViewById(R.id.oldPasswordEditText);
newPasswordEditText = findViewById(R.id.newPasswordEditText);
Expand All @@ -69,8 +71,6 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
// setStatusBarTheme(this, false);
// setStatusBarColor(R.color.gray14);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public class ResetPasswordActivity extends WfcBaseActivity {

private String resetCode;

private void bindClickImpl() {
findViewById(R.id.requestAuthCodeButton).setOnClickListener(v -> requestAuthCode());
findViewById(R.id.confirmButton).setOnClickListener(v -> resetPassword());
protected void bindEvents() {
super.bindEvents();
requestAuthCodeButton.setOnClickListener(v -> requestAuthCode());
confirmButton.setOnClickListener(v -> resetPassword());
authCodeEditText.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
Expand All @@ -59,7 +60,8 @@ public void afterTextChanged(Editable s) {
});
}

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
confirmButton = findViewById(R.id.confirmButton);
authCodeEditText = findViewById(R.id.authCodeEditText);
newPasswordEditText = findViewById(R.id.newPasswordEditText);
Expand All @@ -75,8 +77,6 @@ protected int contentLayout() {

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
resetCode = getIntent().getStringExtra("resetCode");
if (!TextUtils.isEmpty(resetCode)) {
authCodeFrameLayout.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public class SettingActivity extends WfcBaseActivity {
OptionItemView diagnoseOptionItemView;


private void bindClickImpl() {
protected void bindEvents() {
super.bindEvents();
findViewById(R.id.exitOptionItemView).setOnClickListener(v -> exit());
findViewById(R.id.privacySettingOptionItemView).setOnClickListener(v -> privacySetting());
findViewById(R.id.diagnoseOptionItemView).setOnClickListener(v -> diagnose());
Expand All @@ -43,7 +44,8 @@ private void bindClickImpl() {
findViewById(R.id.aboutOptionItemView).setOnClickListener(v -> about());
}

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
diagnoseOptionItemView = findViewById(R.id.diagnoseOptionItemView);
}

Expand All @@ -52,12 +54,6 @@ protected int contentLayout() {
return R.layout.setting_activity;
}

@Override
protected void afterViews() {
bindViewImpl();
bindClickImpl();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
switch (requestCode) {
Expand Down
9 changes: 7 additions & 2 deletions uikit/src/main/java/cn/wildfire/chat/kit/WfcBaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
beforeViews();
setContentView(contentLayout());
bindViewImpl();
bindViews();
bindEvents();
setSupportActionBar(toolbar);
SharedPreferences sp = getSharedPreferences("wfc_kit_config", Context.MODE_PRIVATE);
if (sp.getBoolean("darkTheme", true)) {
Expand All @@ -49,10 +50,14 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
afterViews();
}

private void bindViewImpl() {
protected void bindViews() {
toolbar = findViewById(R.id.toolbar);
}

protected void bindEvents() {

}

/**
* @param darkTheme 和toolbar.xml里面的 app:theme="@style/AppTheme.DarkAppbar" 相关
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class WfcWebViewActivity extends WfcBaseActivity {
DWebView webView;
private JsApi jsApi;

private void bindViewImpl() {
protected void bindViews() {
super.bindViews();
webView = findViewById(R.id.webview);
}

Expand Down Expand Up @@ -95,7 +96,6 @@ protected void onDestroy() {

@Override
protected void afterViews() {
bindViewImpl();
url = getIntent().getStringExtra("url");
String htmlContent = getIntent().getStringExtra("content");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public class ChannelInfoActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.channel_info_activity);
bindViewImpl();
bindViews();
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
init();
}

private void bindViewImpl() {
private void bindViews() {
portraitImageView = findViewById(R.id.portraitImageView);
channelTextView = findViewById(R.id.channelNameTextView);
channelDescTextView = findViewById(R.id.channelDescTextView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.channel_list_frament, container, false);
bindViewImpl(view);
bindViews(view);
init();
return view;
}

private void bindViewImpl(View view) {
private void bindViews(View view) {
recyclerView = view.findViewById(R.id.recyclerView);
}

Expand Down
Loading

0 comments on commit 7edef02

Please sign in to comment.