11package com .duy .ide .editor .theme ;
22
3+ import android .content .SharedPreferences ;
34import android .os .Bundle ;
45import android .support .annotation .Nullable ;
56import android .support .v7 .widget .LinearLayoutManager ;
67import android .support .v7 .widget .RecyclerView ;
78import android .support .v7 .widget .Toolbar ;
89
910import com .duy .ide .editor .editor .R ;
11+ import com .jecelyin .editor .v2 .Preferences ;
1012import com .jecelyin .editor .v2 .ThemeSupportActivity ;
1113
12- public class ThemeActivity extends ThemeSupportActivity {
14+ public class EditorThemeActivity extends ThemeSupportActivity {
1315 private RecyclerView mRecyclerView ;
1416 private ThemeAdapter mThemeAdapter ;
1517
1618 @ Override
1719 protected void onCreate (@ Nullable Bundle savedInstanceState ) {
1820 super .onCreate (savedInstanceState );
19- setContentView (R .layout .activity_themes );
21+ setContentView (R .layout .activity_editor_theme );
2022 setSupportActionBar ((Toolbar ) findViewById (R .id .toolbar ));
2123 getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
2224
@@ -26,6 +28,22 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
2628 mRecyclerView .setLayoutManager (new LinearLayoutManager (this ));
2729 mThemeAdapter = new ThemeAdapter (this );
2830 mRecyclerView .setAdapter (mThemeAdapter );
31+
32+ Preferences .getInstance (this ).registerOnSharedPreferenceChangeListener (this );
2933 }
3034
35+ @ Override
36+ public void onSharedPreferenceChanged (SharedPreferences sharedPreferences , String key ) {
37+ if (key .equals (getString (R .string .pref_current_theme ))) {
38+
39+ } else {
40+ super .onSharedPreferenceChanged (sharedPreferences , key );
41+ }
42+ }
43+
44+ @ Override
45+ protected void onDestroy () {
46+ super .onDestroy ();
47+ Preferences .getInstance (this ).unregisterOnSharedPreferenceChangeListener (this );
48+ }
3149}
0 commit comments