-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2ab275
commit 1e6c261
Showing
17 changed files
with
295 additions
and
47 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
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
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGo.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,28 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.pokemongo; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface PokemonGo { | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContext.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,33 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.pokemongo; | ||
|
||
import android.content.Context; | ||
import android.content.ContextWrapper; | ||
|
||
@SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) | ||
final class PokemonGoContext extends ContextWrapper { | ||
|
||
PokemonGoContext(Context base) { | ||
super(base); | ||
} | ||
|
||
@Override | ||
public Context getApplicationContext() { | ||
return this; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextFactory.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,32 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.pokemongo; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
|
||
@SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) | ||
final class PokemonGoContextFactory { | ||
|
||
static PokemonGoContext create(Context from) throws PackageManager.NameNotFoundException { | ||
return new PokemonGoContext(from); | ||
} | ||
|
||
private PokemonGoContextFactory() { | ||
throw new AssertionError("No instances"); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/icecream/snorlax/module/context/pokemongo/PokemonGoContextModule.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,51 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.pokemongo; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import android.app.Application; | ||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
@Module | ||
@SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) | ||
public final class PokemonGoContextModule { | ||
|
||
@Provides | ||
@PokemonGo | ||
@Singleton | ||
static Context provideContext(Application application) { | ||
try { | ||
return PokemonGoContextFactory.create(application); | ||
} | ||
catch (PackageManager.NameNotFoundException e) { | ||
throw new RuntimeException("Pokemon Go package not found... Cannot continue"); | ||
} | ||
} | ||
|
||
@Provides | ||
@PokemonGo | ||
@Singleton | ||
static NotificationManager provideNotificationManager(@PokemonGo Context context) { | ||
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/icecream/snorlax/module/context/snorlax/Snorlax.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,28 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.snorlax; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Snorlax { | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContext.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,33 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.snorlax; | ||
|
||
import android.content.Context; | ||
import android.content.ContextWrapper; | ||
|
||
@SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) | ||
final class SnorlaxContext extends ContextWrapper { | ||
|
||
SnorlaxContext(Context base) { | ||
super(base); | ||
} | ||
|
||
@Override | ||
public Context getApplicationContext() { | ||
return this; | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/icecream/snorlax/module/context/snorlax/SnorlaxContextModule.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,51 @@ | ||
/* | ||
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com> | ||
* | ||
* 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 com.icecream.snorlax.module.context.snorlax; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
import android.content.res.Resources; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
@Module | ||
@SuppressWarnings({"unused", "FieldCanBeLocal", "WeakerAccess"}) | ||
public final class SnorlaxContextModule { | ||
|
||
@Provides | ||
@Snorlax | ||
@Singleton | ||
static Context provideContext(Application application) { | ||
try { | ||
return SnorlaxContextFactory.create(application); | ||
} | ||
catch (PackageManager.NameNotFoundException e) { | ||
throw new RuntimeException("Snorlax package not found... Cannot continue"); | ||
} | ||
} | ||
|
||
@Provides | ||
@Snorlax | ||
@Singleton | ||
static Resources provideResources(@Snorlax Context context) { | ||
return context.getResources(); | ||
} | ||
} |
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
Oops, something went wrong.