-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add favorite list / recent issue list (#194)
* Add favorite list to connection * Add recent issue list to connection
- Loading branch information
in dow
authored
Mar 23, 2017
1 parent
0a50ca8
commit 79db0ed
Showing
8 changed files
with
215 additions
and
7 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
99 changes: 99 additions & 0 deletions
99
...mine/src/main/java/jp/redmine/redmineclient/adapter/RecentConnectionIssueListAdapter.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,99 @@ | ||
package jp.redmine.redmineclient.adapter; | ||
|
||
import android.content.Context; | ||
import android.text.TextUtils; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.j256.ormlite.stmt.QueryBuilder; | ||
|
||
import java.sql.SQLException; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
import jp.redmine.redmineclient.R; | ||
import jp.redmine.redmineclient.adapter.form.IssueForm; | ||
import jp.redmine.redmineclient.db.cache.DatabaseCacheHelper; | ||
import jp.redmine.redmineclient.db.cache.RedmineProjectModel; | ||
import jp.redmine.redmineclient.entity.RedmineConnection; | ||
import jp.redmine.redmineclient.entity.RedmineProject; | ||
import jp.redmine.redmineclient.entity.RedmineRecentIssue; | ||
import jp.redmine.redmineclient.form.helper.HtmlHelper; | ||
import jp.redmine.redmineclient.model.ConnectionModel; | ||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; | ||
|
||
public class RecentConnectionIssueListAdapter extends RedmineDaoAdapter<RedmineRecentIssue, Long, DatabaseCacheHelper> implements StickyListHeadersAdapter { | ||
private static final String TAG = RecentConnectionIssueListAdapter.class.getSimpleName(); | ||
private RedmineProjectModel mProject; | ||
private int mConnectionId; | ||
|
||
public RecentConnectionIssueListAdapter(DatabaseCacheHelper helper, Context context){ | ||
super(helper, context, RedmineRecentIssue.class); | ||
mProject = new RedmineProjectModel(helper); | ||
} | ||
public void setParameter(int connection_id){ | ||
mConnectionId = connection_id; | ||
} | ||
|
||
@Override | ||
public View getHeaderView(int i, View convertView, ViewGroup parent) { | ||
if (convertView == null) { | ||
convertView = infrator.inflate(R.layout.listheader_project, parent, false); | ||
if(convertView == null) | ||
return null; | ||
} | ||
RedmineProject project = null; | ||
TextView text = (TextView)convertView.findViewById(R.id.name); | ||
try { | ||
project = mProject.fetchById(getHeaderId(i)); | ||
} catch (SQLException e) { | ||
Log.e(TAG, "getHeaderView", e); | ||
} | ||
if(text != null) | ||
text.setText((project == null || TextUtils.isEmpty(project.getName())) ? "" : project.getName()); | ||
//fix background to hide transparent headers | ||
convertView.setBackgroundColor(HtmlHelper.getBackgroundColor(convertView.getContext())); | ||
return convertView; | ||
} | ||
|
||
@Override | ||
public long getHeaderId(int i) { | ||
RedmineRecentIssue proj = (RedmineRecentIssue)getItem(i); | ||
return proj == null ? 0 : proj.getProject().getId(); | ||
} | ||
|
||
@Override | ||
protected long getDbItemId(RedmineRecentIssue item) { | ||
return item.getId(); | ||
} | ||
|
||
@Override | ||
protected int getItemViewId() { | ||
return R.layout.listitem_issue; | ||
} | ||
|
||
@Override | ||
protected void setupView(View view, RedmineRecentIssue history) { | ||
IssueForm form = new IssueForm(view); | ||
form.setValue(history); | ||
} | ||
|
||
@Override | ||
protected QueryBuilder getQueryBuilder() throws SQLException { | ||
Calendar cal = Calendar.getInstance(); | ||
cal.setTime(new Date()); | ||
cal.add(Calendar.DAY_OF_YEAR, -14); | ||
QueryBuilder<RedmineRecentIssue, Long> builder = dao.queryBuilder(); | ||
builder.setWhere(builder.where() | ||
.ge(RedmineRecentIssue.MODIFIED, cal.getTime()) | ||
.and() | ||
.eq(RedmineRecentIssue.CONNECTION, mConnectionId) | ||
); | ||
builder.orderBy(RedmineRecentIssue.PROJECT, true); | ||
builder.orderBy(RedmineRecentIssue.MODIFIED, false); | ||
return builder; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="5dp"> | ||
|
||
<ImageView | ||
android:id="@+id/icon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:layout_centerVertical="true" | ||
android:contentDescription="@string/ticket_relations" | ||
android:src="@android:drawable/ic_menu_mapmode"/> | ||
<TextView | ||
android:id="@+id/name" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="10dp" | ||
android:layout_marginRight="10dp" | ||
android:layout_marginEnd="10dp" | ||
android:layout_marginTop="10dp" | ||
android:text="Project Name" | ||
tools:ignore="HardcodedText" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
android:layout_toRightOf="@+id/icon" | ||
android:layout_toEndOf="@+id/icon" | ||
android:layout_centerVertical="true"/> | ||
</RelativeLayout> |
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