-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract and re-use details screen starting code. #589
- Loading branch information
Gabor Keszthelyi
committed
Jan 16, 2018
1 parent
8863bcd
commit 980c57a
Showing
5 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
49 changes: 49 additions & 0 deletions
49
opentasks/src/main/java/org/dmfs/tasks/detailsscreen/TaskDetailsUi.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,49 @@ | ||
/* | ||
* Copyright 2017 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.detailsscreen; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import org.dmfs.tasks.utils.Showable; | ||
|
||
|
||
/** | ||
* UI for showing the details of a task. | ||
* <p> | ||
* On {@link #show(Context)} it starts an Activity with action VIEW and with the task Uri as data. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class TaskDetailsUi implements Showable<Context> | ||
{ | ||
private final Uri mTaskUri; | ||
|
||
|
||
public TaskDetailsUi(Uri taskUri) | ||
{ | ||
mTaskUri = taskUri; | ||
} | ||
|
||
|
||
@Override | ||
public void show(Context context) | ||
{ | ||
context.startActivity(new Intent(Intent.ACTION_VIEW, mTaskUri)); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
opentasks/src/main/java/org/dmfs/tasks/utils/Showable.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,34 @@ | ||
/* | ||
* 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 android.content.Context; | ||
|
||
|
||
/** | ||
* Represents a meaningful UI component/part of the app that belongs to a use-case. | ||
* Can be a screen, notification, dialog, toast, etc. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public interface Showable<C extends Context> | ||
{ | ||
/** | ||
* Show the UI for the use-case this {@link Showable} represents. | ||
*/ | ||
void show(C context); | ||
} |