-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first, very basic sketch for the diary view, but at least the activit…
…y selection is stored, so let me close #19
- Loading branch information
Showing
7 changed files
with
216 additions
and
13 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
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
161 changes: 161 additions & 0 deletions
161
app/src/main/java/de/rampro/activitydiary/ui/HistoryActivity.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,161 @@ | ||
/* | ||
* ActivityDiary | ||
* | ||
* Copyright (C) 2017 Raphael Mack http://www.raphael-mack.de | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.rampro.activitydiary.ui; | ||
|
||
import android.app.LoaderManager; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.Loader; | ||
import android.content.CursorLoader; | ||
import android.database.Cursor; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ImageView; | ||
import android.widget.ListView; | ||
import android.widget.ResourceCursorAdapter; | ||
import android.widget.TextView; | ||
|
||
|
||
import java.util.Date; | ||
|
||
import de.rampro.activitydiary.R; | ||
import de.rampro.activitydiary.db.ActivityDiaryContract; | ||
|
||
|
||
/* | ||
* Show this history in the Diary. | ||
* | ||
* */ | ||
public class HistoryActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<Cursor> { | ||
private static final String TAG = ManageActivity.class.getName(); | ||
private static final String[] PROJECTION = new String[] { | ||
ActivityDiaryContract.Diary._ID, | ||
ActivityDiaryContract.Diary.ACT_ID, | ||
ActivityDiaryContract.Diary.START, | ||
ActivityDiaryContract.Diary.END | ||
}; | ||
private static final String SELECTION = ActivityDiaryContract.Diary._DELETED + "=0"; | ||
|
||
private ListView mList; | ||
private class DiaryActivityAdapter extends ResourceCursorAdapter { | ||
|
||
public DiaryActivityAdapter() { | ||
super(HistoryActivity.this, R.layout.activity_row, null, 0); | ||
} | ||
|
||
@Override | ||
public void bindView(View view, Context context, Cursor cursor){ | ||
long start = cursor.getLong(cursor.getColumnIndex(ActivityDiaryContract.Diary.START)); | ||
long end = cursor.getLong(cursor.getColumnIndex(ActivityDiaryContract.Diary.END)); | ||
|
||
TextView actName = (TextView) view.findViewById(R.id.activity_name); | ||
actName.setText(new Date(start).toString() + " - " + new Date(end).toString()); | ||
|
||
ImageView imageView = (ImageView) view.findViewById(R.id.activity_image); | ||
} | ||
} | ||
|
||
private DiaryActivityAdapter mActivitiyListAdapter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
|
||
/* TODO: change to different XML resource */ | ||
View contentView = inflater.inflate(R.layout.activity_manage_content, null, false); | ||
|
||
setContent(contentView); | ||
mList = (ListView)findViewById(R.id.manage_activity_list); | ||
mActivitiyListAdapter = new DiaryActivityAdapter(); | ||
mList.setAdapter(mActivitiyListAdapter); | ||
|
||
mList.setOnItemClickListener(mOnClickListener); | ||
|
||
// Prepare the loader. Either re-connect with an existing one, | ||
// or start a new one. | ||
getLoaderManager().initLoader(0, null, this); | ||
mDrawerToggle.setDrawerIndicatorEnabled(false); | ||
mNavigationView.getMenu().findItem(R.id.nav_diary).setChecked(true); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
MenuInflater inflater = getMenuInflater(); | ||
/* todo change menu */ | ||
inflater.inflate(R.menu.manage_menu, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle your other action bar items... | ||
switch(item.getItemId()) { | ||
case R.id.action_add_activity: | ||
Intent intentaddact = new Intent(HistoryActivity.this, EditActivity.class); | ||
startActivity(intentaddact); | ||
break; | ||
case android.R.id.home: | ||
finish(); | ||
break; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
// Called when a new Loader needs to be created | ||
public Loader<Cursor> onCreateLoader(int id, Bundle args) { | ||
// Now create and return a CursorLoader that will take care of | ||
// creating a Cursor for the data being displayed. | ||
return new CursorLoader(this, ActivityDiaryContract.Diary.CONTENT_URI, | ||
PROJECTION, SELECTION, null, null); | ||
} | ||
|
||
// Called when a previously created loader has finished loading | ||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { | ||
// Swap the new cursor in. (The framework will take care of closing the | ||
// old cursor once we return.) | ||
mActivitiyListAdapter.swapCursor(data); | ||
} | ||
|
||
// Called when a previously created loader is reset, making the data unavailable | ||
public void onLoaderReset(Loader<Cursor> loader) { | ||
// This is called when the last Cursor provided to onLoadFinished() | ||
// above is about to be closed. We need to make sure we are no | ||
// longer using it. | ||
mActivitiyListAdapter.swapCursor(null); | ||
} | ||
|
||
private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() { | ||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) | ||
{ | ||
Cursor c = (Cursor)parent.getItemAtPosition(position); | ||
/* TODO */ | ||
} | ||
}; | ||
|
||
/* TODO: implement swipe for parent / child navigation */ | ||
/* TODO: add number of child activities in view */ | ||
|
||
} |
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