Browse Source

Fixed bug with recyclerview

master
Anthony Restaino 8 years ago
parent
commit
256b003c5d
  1. 6
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 4
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 6
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java
  4. 2
      app/src/main/java/acr/browser/lightning/browser/BrowserView.java
  5. 1
      app/src/main/java/acr/browser/lightning/browser/TabsView.java
  6. 17
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

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

@ -908,6 +908,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -908,6 +908,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mTabsView.tabChanged(position);
}
@Override
public void notifyTabViewInitialized() {
Log.d(TAG, "Notify Tabs Initialized");
mTabsView.tabsInitialized();
}
@Override
public void tabChanged(LightningView tab) {
mPresenter.tabChangeOccurred(tab);

4
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -484,7 +484,7 @@ public class TabsManager { @@ -484,7 +484,7 @@ public class TabsManager {
* @return Return the index of the current tab, or -1 if the
* current tab is null.
*/
public int indexOfCurrentTab() {
public synchronized int indexOfCurrentTab() {
return mTabList.indexOf(mCurrentTab);
}
@ -493,7 +493,7 @@ public class TabsManager { @@ -493,7 +493,7 @@ public class TabsManager {
*
* @return Return the index of the tab, or -1 if the tab isn't in the list.
*/
public int indexOfTab(LightningView tab) {
public synchronized int indexOfTab(LightningView tab) {
return mTabList.indexOf(tab);
}

6
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -7,6 +7,7 @@ import android.support.annotation.NonNull; @@ -7,6 +7,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.anthonycr.bonsai.Schedulers;
import com.squareup.otto.Bus;
import javax.inject.Inject;
@ -63,13 +64,14 @@ public class BrowserPresenter { @@ -63,13 +64,14 @@ public class BrowserPresenter {
*/
public void setupTabs(@Nullable Intent intent) {
mTabsModel.initializeTabs((Activity) mView, intent, mIsIncognito)
.subscribeOn(Schedulers.main())
.subscribe(new OnSubscribe<Void>() {
@Override
public void onComplete() {
// At this point we always have at least a tab in the tab manager
tabChanged(mTabsModel.last());
mView.notifyTabViewAdded();
mView.notifyTabViewInitialized();
mView.updateTabNumber(mTabsModel.size());
tabChanged(mTabsModel.last());
}
});
}

2
app/src/main/java/acr/browser/lightning/browser/BrowserView.java

@ -35,4 +35,6 @@ public interface BrowserView { @@ -35,4 +35,6 @@ public interface BrowserView {
void notifyTabViewChanged(int position);
void notifyTabViewInitialized();
}

1
app/src/main/java/acr/browser/lightning/browser/TabsView.java

@ -8,4 +8,5 @@ public interface TabsView { @@ -8,4 +8,5 @@ public interface TabsView {
void tabChanged(int position);
void tabsInitialized();
}

17
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -98,8 +98,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -98,8 +98,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
mColorMode = mPreferences.getColorModeEnabled();
mColorMode &= !mDarkTheme;
mIconColor = mDarkTheme ?
ThemeUtils.getIconDarkThemeColor(context) :
ThemeUtils.getIconLightThemeColor(context);
ThemeUtils.getIconDarkThemeColor(context) :
ThemeUtils.getIconLightThemeColor(context);
}
@Nullable
@ -184,6 +184,13 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -184,6 +184,13 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
mBus.unregister(this);
}
@Override
public void tabsInitialized() {
if (mTabsAdapter != null) {
mTabsAdapter.notifyDataSetChanged();
}
}
public void reinitializePreferences() {
Activity activity = getActivity();
if (activity == null) {
@ -193,8 +200,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -193,8 +200,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
mColorMode = mPreferences.getColorModeEnabled();
mColorMode &= !mDarkTheme;
mIconColor = mDarkTheme ?
ThemeUtils.getIconDarkThemeColor(activity) :
ThemeUtils.getIconLightThemeColor(activity);
ThemeUtils.getIconDarkThemeColor(activity) :
ThemeUtils.getIconLightThemeColor(activity);
if (mTabsAdapter != null) {
mTabsAdapter.notifyDataSetChanged();
}
@ -356,7 +363,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -356,7 +363,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) {
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(),
favicon.getHeight(), Bitmap.Config.ARGB_8888);
favicon.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(grayscaleBitmap);
if (mColorMatrix == null || mFilter == null || mPaint == null) {

Loading…
Cancel
Save