-
Notifications
You must be signed in to change notification settings - Fork 14
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
Arjun
committed
Oct 19, 2017
1 parent
3f122eb
commit 87d2adb
Showing
10 changed files
with
142 additions
and
34 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 was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
app/src/main/java/in/arjsna/mapsalarm/alarm/AlarmActivity.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,62 @@ | ||
package in.arjsna.mapsalarm.alarm; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.PowerManager; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.view.WindowManager; | ||
import com.jakewharton.rxbinding2.view.RxView; | ||
import in.arjsna.mapsalarm.R; | ||
import in.arjsna.mapsalarm.bgservice.LocationAwareService; | ||
import in.arjsna.mapsalarm.mvpbase.BaseActivity; | ||
import javax.inject.Inject; | ||
|
||
public class AlarmActivity extends BaseActivity implements AlarmMVPContract.IAlarmView { | ||
private PowerManager.WakeLock mWakeLock; | ||
|
||
@Inject | ||
AlarmMVPContract.IAlarmPresenter<AlarmMVPContract.IAlarmView> alarmPresenter; | ||
private View dismissButton; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); | ||
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | | ||
PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "AlarmActivity"); | ||
mWakeLock.acquire(); | ||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); | ||
|
||
setContentView(R.layout.activity_alarm); | ||
if (getActivityComponent() != null) { | ||
getActivityComponent().inject(this); | ||
alarmPresenter.onAttach(this); | ||
} | ||
initViews(); | ||
bindEvents(); | ||
} | ||
|
||
private void bindEvents() { | ||
RxView.clicks(dismissButton) | ||
.subscribe(__ -> alarmPresenter.onDismissButtonClicked()); | ||
} | ||
|
||
private void initViews() { | ||
dismissButton = findViewById(R.id.alarm_dismiss_view); | ||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
alarmPresenter.onViewInitialised(); | ||
} | ||
|
||
@Override public void stopService() { | ||
Intent stopIntent = new Intent(AlarmActivity.this, LocationAwareService.class); | ||
stopService(stopIntent); | ||
} | ||
|
||
@Override protected void onDestroy() { | ||
super.onDestroy(); | ||
mWakeLock.release(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/in/arjsna/mapsalarm/alarm/AlarmMVPContract.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,17 @@ | ||
package in.arjsna.mapsalarm.alarm; | ||
|
||
import in.arjsna.mapsalarm.mvpbase.IMVPPresenter; | ||
import in.arjsna.mapsalarm.mvpbase.IMVPView; | ||
|
||
public interface AlarmMVPContract { | ||
interface IAlarmView extends IMVPView { | ||
|
||
void stopService(); | ||
} | ||
|
||
interface IAlarmPresenter<V extends IAlarmView> extends IMVPPresenter<V> { | ||
void onViewInitialised(); | ||
|
||
void onDismissButtonClicked(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/in/arjsna/mapsalarm/alarm/AlarmPresenter.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,25 @@ | ||
package in.arjsna.mapsalarm.alarm; | ||
|
||
import android.content.Context; | ||
import in.arjsna.mapsalarm.db.CheckPointDataSource; | ||
import in.arjsna.mapsalarm.di.qualifiers.ActivityContext; | ||
import in.arjsna.mapsalarm.mvpbase.BasePresenter; | ||
import javax.inject.Inject; | ||
|
||
public class AlarmPresenter<V extends AlarmMVPContract.IAlarmView> extends BasePresenter<V> | ||
implements AlarmMVPContract.IAlarmPresenter<V> { | ||
|
||
@Inject | ||
public AlarmPresenter(@ActivityContext Context context, | ||
CheckPointDataSource checkPointDataSource) { | ||
super(context, checkPointDataSource); | ||
} | ||
|
||
@Override public void onViewInitialised() { | ||
|
||
} | ||
|
||
@Override public void onDismissButtonClicked() { | ||
getView().stopService(); | ||
} | ||
} |
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
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
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