-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#151 filtering parameter in history activity
- Loading branch information
Showing
14 changed files
with
274 additions
and
68 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
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
91 changes: 91 additions & 0 deletions
91
app/src/main/java/hrv/band/app/ui/view/activity/ParameterSelectionActivity.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,91 @@ | ||
package hrv.band.app.ui.view.activity; | ||
|
||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.v7.app.ActionBar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ListView; | ||
|
||
import hrv.band.app.R; | ||
import hrv.band.app.ui.view.adapter.ParameterValueAdapter; | ||
|
||
import static hrv.band.app.ui.view.activity.HistoryActivity.DATE_VALUE; | ||
import static hrv.band.app.ui.view.activity.HistoryActivity.PARAMETER_VALUE; | ||
import static hrv.band.app.ui.view.activity.HistoryActivity.SELECTION_VALUE; | ||
|
||
public class ParameterSelectionActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_parameter_selection); | ||
setupToolbar(); | ||
|
||
final long longDate = getIntent().getLongExtra(DATE_VALUE, 0); | ||
ListView listView = findViewById(R.id.parameter_values); | ||
listView.setAdapter(new ParameterValueAdapter(this)); | ||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
|
||
@Override | ||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { | ||
setHRVParameterValue(view, i); | ||
setActivityResult(i); | ||
finish(); | ||
} | ||
|
||
private void setActivityResult(int i) { | ||
Intent intent = new Intent(); | ||
intent.putExtra(DATE_VALUE, longDate); | ||
intent.putExtra(SELECTION_VALUE, i); | ||
setResult(RESULT_OK, intent); | ||
} | ||
|
||
private void setHRVParameterValue(View view, int i) { | ||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(view.getContext()); | ||
SharedPreferences.Editor prefsEditor = sharedPreferences.edit(); | ||
prefsEditor.putInt(PARAMETER_VALUE, i); | ||
prefsEditor.apply(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_hrv_parameters, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
int id = item.getItemId(); | ||
if (id == android.R.id.home) { | ||
onBackPressed(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
finish(); | ||
} | ||
private void setupToolbar() { | ||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
|
||
setSupportActionBar(toolbar); | ||
ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar != null) { | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setDisplayShowHomeEnabled(true); | ||
} | ||
} | ||
} |
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.