-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bug when refreshing RealmResults #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
## 1.2.1 | ||
|
||
### Bug fixes | ||
|
||
* Fixed crash when auto-updating RealmResults (#25). | ||
|
||
|
||
## 1.2.0 | ||
|
||
### Enhancements | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2016 Realm Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.realm.examples.adapters; | ||
|
||
import android.app.Application; | ||
|
||
import io.realm.Realm; | ||
import io.realm.RealmConfiguration; | ||
|
||
public class MyApplication extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build(); | ||
Realm.deleteRealm(realmConfig); // Delete Realm between app restarts. | ||
Realm.setDefaultConfiguration(realmConfig); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (C) 2014 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. up up up ⬆️ 🆙 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
||
package io.realm.examples.adapters.ui; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.graphics.Canvas; | ||
import android.graphics.Rect; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
public class DividerItemDecoration extends RecyclerView.ItemDecoration { | ||
|
||
private static final int[] ATTRS = new int[]{ | ||
android.R.attr.listDivider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less indentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's is what the IntelliJ auto-formatter puts it at, so I'll rather keep it. |
||
}; | ||
|
||
public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; | ||
|
||
public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; | ||
|
||
private Drawable mDivider; | ||
|
||
private int mOrientation; | ||
|
||
public DividerItemDecoration(Context context, int orientation) { | ||
final TypedArray a = context.obtainStyledAttributes(ATTRS); | ||
mDivider = a.getDrawable(0); | ||
a.recycle(); | ||
setOrientation(orientation); | ||
} | ||
|
||
public void setOrientation(int orientation) { | ||
if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) { | ||
throw new IllegalArgumentException("invalid orientation"); | ||
} | ||
mOrientation = orientation; | ||
} | ||
|
||
@Override | ||
public void onDraw(Canvas c, RecyclerView parent) { | ||
if (mOrientation == VERTICAL_LIST) { | ||
drawVertical(c, parent); | ||
} else { | ||
drawHorizontal(c, parent); | ||
} | ||
} | ||
|
||
public void drawVertical(Canvas c, RecyclerView parent) { | ||
final int left = parent.getPaddingLeft(); | ||
final int right = parent.getWidth() - parent.getPaddingRight(); | ||
|
||
final int childCount = parent.getChildCount(); | ||
for (int i = 0; i < childCount; i++) { | ||
final View child = parent.getChildAt(i); | ||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child | ||
.getLayoutParams(); | ||
final int top = child.getBottom() + params.bottomMargin; | ||
final int bottom = top + mDivider.getIntrinsicHeight(); | ||
mDivider.setBounds(left, top, right, bottom); | ||
mDivider.draw(c); | ||
} | ||
} | ||
|
||
public void drawHorizontal(Canvas c, RecyclerView parent) { | ||
final int top = parent.getPaddingTop(); | ||
final int bottom = parent.getHeight() - parent.getPaddingBottom(); | ||
|
||
final int childCount = parent.getChildCount(); | ||
for (int i = 0; i < childCount; i++) { | ||
final View child = parent.getChildAt(i); | ||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child | ||
.getLayoutParams(); | ||
final int left = child.getRight() + params.rightMargin; | ||
final int right = left + mDivider.getIntrinsicHeight(); | ||
mDivider.setBounds(left, top, right, bottom); | ||
mDivider.draw(c); | ||
} | ||
} | ||
|
||
@Override | ||
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) { | ||
if (mOrientation == VERTICAL_LIST) { | ||
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); | ||
} else { | ||
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2016?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is straight copy from AOSP, so I'll rather keep the original.