Browse Source

Dependency injection for ReadingActivity

master
Anthony Restaino 9 years ago
parent
commit
8b44ce12fa
  1. 6
      app/src/main/java/acr/browser/lightning/activity/MainActivity.java
  2. 22
      app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java
  3. 3
      app/src/main/java/acr/browser/lightning/app/AppComponent.java

6
app/src/main/java/acr/browser/lightning/activity/MainActivity.java

@ -22,12 +22,6 @@ public class MainActivity extends BrowserActivity { @@ -22,12 +22,6 @@ public class MainActivity extends BrowserActivity {
cookieManager.setAcceptCookie(mPreferences.getCookiesEnabled());
}
// @Override
// public synchronized void initializeTabs() {
// // restoreOrNewTab();
// // if incognito mode use newTab(null, true); instead
// }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);

22
app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java

@ -23,6 +23,8 @@ import android.widget.TextView; @@ -23,6 +23,8 @@ import android.widget.TextView;
import java.lang.ref.WeakReference;
import javax.inject.Inject;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants;
@ -31,14 +33,21 @@ import acr.browser.lightning.reading.HtmlFetcher; @@ -31,14 +33,21 @@ import acr.browser.lightning.reading.HtmlFetcher;
import acr.browser.lightning.reading.JResult;
import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.utils.Utils;
import butterknife.Bind;
import butterknife.ButterKnife;
public class ReadingActivity extends AppCompatActivity {
private TextView mTitle;
private TextView mBody;
@Bind(R.id.textViewTitle)
TextView mTitle;
@Bind(R.id.textViewBody)
TextView mBody;
@Inject PreferenceManager mPreferences;
private boolean mInvert;
private String mUrl = null;
private PreferenceManager mPreferences;
private int mTextSize;
private ProgressDialog mProgressDialog;
private PageLoader mLoaderReference;
@ -52,8 +61,9 @@ public class ReadingActivity extends AppCompatActivity { @@ -52,8 +61,9 @@ public class ReadingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
BrowserApp.getAppComponent().inject(this);
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
mPreferences = BrowserApp.getPreferenceManager();
mInvert = mPreferences.getInvertColors();
final int color;
if (mInvert) {
@ -67,6 +77,7 @@ public class ReadingActivity extends AppCompatActivity { @@ -67,6 +77,7 @@ public class ReadingActivity extends AppCompatActivity {
}
super.onCreate(savedInstanceState);
setContentView(R.layout.reading_view);
ButterKnife.bind(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@ -74,9 +85,6 @@ public class ReadingActivity extends AppCompatActivity { @@ -74,9 +85,6 @@ public class ReadingActivity extends AppCompatActivity {
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mTitle = (TextView) findViewById(R.id.textViewTitle);
mBody = (TextView) findViewById(R.id.textViewBody);
mTextSize = mPreferences.getReadingTextSize();
mBody.setTextSize(getTextSize(mTextSize));
mTitle.setText(getString(R.string.untitled));

3
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -3,6 +3,7 @@ package acr.browser.lightning.app; @@ -3,6 +3,7 @@ package acr.browser.lightning.app;
import javax.inject.Singleton;
import acr.browser.lightning.activity.BrowserActivity;
import acr.browser.lightning.activity.ReadingActivity;
import acr.browser.lightning.activity.ThemableBrowserActivity;
import acr.browser.lightning.constant.BookmarkPage;
import acr.browser.lightning.dialog.LightningDialogBuilder;
@ -43,4 +44,6 @@ public interface AppComponent { @@ -43,4 +44,6 @@ public interface AppComponent {
void inject(ProxyUtils proxyUtils);
void inject(ReadingActivity activity);
}

Loading…
Cancel
Save