mirror of
https://github.com/etesync/android
synced 2025-01-23 14:10:54 +00:00
Import - Show calendars in expandable list view
This commit is contained in:
parent
466870ff50
commit
594c401038
@ -95,7 +95,7 @@ public class CalendarAccount {
|
||||
|
||||
eventsCur.close();
|
||||
}
|
||||
contentProviderClient.close();
|
||||
contentProviderClient.release();
|
||||
cur.close();
|
||||
return calendarAccounts;
|
||||
}
|
||||
@ -126,23 +126,4 @@ public class CalendarAccount {
|
||||
public String toString() {
|
||||
return accountName + " calendars:" + calendars.size();
|
||||
}
|
||||
|
||||
static class Factory implements AndroidEventFactory {
|
||||
static final LocalEvent.Factory INSTANCE = new LocalEvent.Factory();
|
||||
|
||||
@Override
|
||||
public AndroidEvent newInstance(AndroidCalendar calendar, long id, ContentValues baseInfo) {
|
||||
return new LocalEvent(calendar, id, baseInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndroidEvent newInstance(AndroidCalendar calendar, Event event) {
|
||||
return new LocalEvent(calendar, event, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndroidEvent[] newArray(int size) {
|
||||
return new LocalEvent[size];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,18 @@ import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.etesync.syncadapter.App;
|
||||
import com.etesync.syncadapter.R;
|
||||
@ -24,10 +25,9 @@ import com.etesync.syncadapter.resource.LocalCalendar;
|
||||
import com.etesync.syncadapter.resource.LocalEvent;
|
||||
import com.etesync.syncadapter.ui.ImportFragment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.etesync.syncadapter.resource.CalendarAccount.loadAll;
|
||||
|
||||
public class ImportActivity extends AppCompatActivity {
|
||||
public final static String EXTRA_ACCOUNT = "account",
|
||||
EXTRA_COLLECTION_INFO = "collectionInfo";
|
||||
@ -91,7 +91,6 @@ public class ImportActivity extends AppCompatActivity {
|
||||
Toast.LENGTH_SHORT).show();
|
||||
//todo import
|
||||
LocalCalendar localCalendar = (LocalCalendar) calendarAccountList.get(groupPosition).calendars.get(childPosition);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -125,4 +124,96 @@ public class ImportActivity extends AppCompatActivity {
|
||||
if (app.getCertManager() != null)
|
||||
app.getCertManager().appInForeground = false;
|
||||
}
|
||||
|
||||
public class ExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
private Context context;
|
||||
private List<CalendarAccount> calendarAccounts;
|
||||
|
||||
public ExpandableListAdapter(Context context, List<CalendarAccount> calendarAccounts) {
|
||||
this.context = context;
|
||||
this.calendarAccounts = calendarAccounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosititon) {
|
||||
return calendarAccounts.get(groupPosition).calendars
|
||||
.get(childPosititon).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, final int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
|
||||
final String childText = (String) getChild(groupPosition, childPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.list_item, null);
|
||||
}
|
||||
//Todo add viewholder after we decide about the UI
|
||||
|
||||
TextView txtListChild = (TextView) convertView
|
||||
.findViewById(R.id.lblListItem);
|
||||
|
||||
txtListChild.setText(childText);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
return calendarAccounts.get(groupPosition).calendars
|
||||
.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return calendarAccounts.get(groupPosition).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return calendarAccounts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return groupPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
String headerTitle = (String) getGroup(groupPosition);
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.list_group, null);
|
||||
}
|
||||
//Todo add viewholder after we decide about the UI
|
||||
|
||||
TextView lblListHeader = (TextView) convertView
|
||||
.findViewById(R.id.lblListHeader);
|
||||
lblListHeader.setTypeface(null, Typeface.BOLD);
|
||||
lblListHeader.setText(headerTitle);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
@ -17,4 +19,36 @@
|
||||
android:id="@+id/import_button_account"
|
||||
android:text="@string/import_button_account"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/caldav_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/toolbar_theme"
|
||||
style="@style/toolbar_style"
|
||||
app:navigationIcon="@drawable/ic_event_light"
|
||||
app:title="@string/settings_caldav"
|
||||
android:elevation="2dp" tools:ignore="UnusedAttribute"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/caldav_refreshing"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:indeterminate="true"/>
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/calendars"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:choiceMode="singleChoice"
|
||||
android:descendantFocusability="beforeDescendants"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
18
app/src/main/res/layout/list_group.xml
Normal file
18
app/src/main/res/layout/list_group.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:background="#000000">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblListHeader"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
|
||||
android:textSize="17dp"
|
||||
android:textColor="#f9f93d" />
|
||||
|
||||
</LinearLayout>
|
16
app/src/main/res/layout/list_item.xml
Normal file
16
app/src/main/res/layout/list_item.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dip"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblListItem"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="17dip"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user