-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up TaskGroupPagerAdapter instantiation exception handling and s…
…ome unused code in TaskListActivity. #621
- Loading branch information
Gabor Keszthelyi
committed
Jan 8, 2018
1 parent
03f21a2
commit c3d1c52
Showing
2 changed files
with
57 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
opentasks/src/main/java/org/dmfs/tasks/utils/Unchecked.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2018 dmfs GmbH | ||
* | ||
* 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 org.dmfs.tasks.utils; | ||
|
||
import org.dmfs.jems.single.Single; | ||
|
||
|
||
/** | ||
* 'Unchecks' an Exception, i.e. turns a {@link Fragile} into a {@link Single} by rethrowing | ||
* the possible {@link Exception} as {@link RuntimeException}. | ||
* <p> | ||
* Note: This should be used with care for obvious reasons, only at appropriate places. | ||
* | ||
* @author Gabor Keszthelyi | ||
* @deprecated use it from jems when available | ||
*/ | ||
@Deprecated | ||
public final class Unchecked<T> implements Single<T> | ||
{ | ||
private final Fragile<T, Exception> mDelegate; | ||
|
||
|
||
public Unchecked(Fragile<T, Exception> delegate) | ||
{ | ||
mDelegate = delegate; | ||
} | ||
|
||
|
||
@Override | ||
public T value() | ||
{ | ||
try | ||
{ | ||
return mDelegate.value(); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new RuntimeException("Exception in Unchecked", e); | ||
} | ||
} | ||
} |