Skip to content

Instantly share code, notes, and snippets.

View hongbeomi's full-sized avatar
🏃‍♂️
Slowly And Steadily

ian.0701(이안) hongbeomi

🏃‍♂️
Slowly And Steadily
View GitHub Profile
@hongbeomi
hongbeomi / GlobalErrorHandler.kt
Last active December 13, 2022 03:32
Firebase Crashlytics 사용 & 글로벌 에러 핸들링
// references : https://github.com/firebase/firebase-android-sdk/issues/1952#issuecomment-713094146
// error handling page
class ErrorActivity : AppCompatActivity() {
companion object {
private const val ERROR_TEXT = "ERROR_TEXT"
fun start(context: Context, errorText: String) = with(context) {
val intent = Intent(this, ErrorActivity::class.java).apply {
private void releaseWrapperAndLocalPosition(
WrapperAndLocalPosition wrapperAndLocalPosition
) {
wrapperAndLocalPosition.mInUse = false;
wrapperAndLocalPosition.mWrapper = null;
wrapperAndLocalPosition.mLocalPosition = -1;
mReusableHolder = wrapperAndLocalPosition;
}
@NonNull
private WrapperAndLocalPosition findWrapperAndLocalPosition(
int globalPosition
) {
WrapperAndLocalPosition result;
if (mReusableHolder.mInUse) {
result = new WrapperAndLocalPosition();
} else {
mReusableHolder.mInUse = true;
class ConcatAdapterController implements NestedAdapterWrapper.Callback {
private WrapperAndLocalPosition mReusableHolder = new WrapperAndLocalPosition();
static class WrapperAndLocalPosition {
NestedAdapterWrapper mWrapper;
int mLocalPosition;
boolean mInUse;
}
class ConcatAdapterController implements NestedAdapterWrapper.Callback {
..
public long getItemId(int globalPosition) {
WrapperAndLocalPosition wrapperAndPos = findWrapperAndLocalPosition(globalPosition);
Long globalItemId = wrapperAndPos.mWrapper.getItemId(wrapperAndPos.mLocalPosition);
releaseWrapperAndLocalPosition(wrapperAndPos);
return globalItemId;
}
..
class ConcatAdapterController implements NestedAdapterWrapper.Callback {
..
public int getItemViewType(int globalPosition) {
WrapperAndLocalPosition wrapperAndPos = findWrapperAndLocalPosition(globalPosition);
int itemViewType = wrapperAndPos.mWrapper.getItemViewType(wrapperAndPos.mLocalPosition);
releaseWrapperAndLocalPosition(wrapperAndPos);
return itemViewType;
}
..
class NestedAdapterWrapper {
@NonNull
private final StableIdStorage.StableIdLookup mStableIdLookup;
public long getItemId(int localPosition) {
long localItemId = adapter.getItemId(localPosition);
return mStableIdLookup.localToGlobal(localItemId);
}
class NestedAdapterWrapper {
@NonNull
private final ViewTypeStorage.ViewTypeLookup mViewTypeLookup;
NestedAdapterWrapper(
Adapter<ViewHolder> adapter,
final Callback callback,
ViewTypeStorage viewTypeStorage,
StableIdStorage.StableIdLookup stableIdLookup
) {
class NestedAdapterWrapper {
int getItemViewType(int localPosition) {
return mViewTypeLookup.localToGlobal(
adapter.getItemViewType(localPosition)
);
}
}
class ConcatAdapterController implements NestedAdapterWrapper.Callback {
...
@NonNull
private final ConcatAdapter.Config.StableIdMode mStableIdMode;
...
}