Android Open Source - scrumchatter Meetings






From Project

Back to project page scrumchatter.

License

The source code is released under:

GNU General Public License

If you think the Android project scrumchatter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright 2013 Carmen Alvarez//from w ww.j  a  v a2  s  . co m
 *
 * This file is part of Scrum Chatter.
 *
 * Scrum Chatter 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.
 *
 * Scrum Chatter 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 Scrum Chatter. If not, see <http://www.gnu.org/licenses/>.
 */
package ca.rmen.android.scrumchatter.meeting;

import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.Toast;
import ca.rmen.android.scrumchatter.Constants;
import ca.rmen.android.scrumchatter.R;
import ca.rmen.android.scrumchatter.dialog.DialogFragmentFactory;
import ca.rmen.android.scrumchatter.export.MeetingExport;
import ca.rmen.android.scrumchatter.meeting.detail.Meeting;
import ca.rmen.android.scrumchatter.meeting.detail.MeetingActivity;
import ca.rmen.android.scrumchatter.provider.MemberColumns;
import ca.rmen.android.scrumchatter.util.TextUtils;

/**
 * Provides UI and DB logic regarding the management of meetings: creating and deleting meetings.
 */
public class Meetings {
    private static final String TAG = Constants.TAG + "/" + Meetings.class.getSimpleName();
    public static final String EXTRA_MEETING_ID = "meeting_id";
    public static final String EXTRA_MEETING_STATE = "meeting_state";
    private final FragmentActivity mActivity;

    public Meetings(FragmentActivity activity) {
        mActivity = activity;
    }

    /**
     * Checks if there are any team members in the given team id. If not, an error dialog is shown. If the team does have members, then we start
     * the MeetingActivity class for a new meeting.
     */
    public void createMeeting(final int teamId) {
        Log.v(TAG, "createMeeting in team " + teamId);
        AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {

            @Override
            protected Boolean doInBackground(Void... params) {
                Cursor c = mActivity.getContentResolver().query(MemberColumns.CONTENT_URI, new String[] { "count(*)" },
                        MemberColumns.TEAM_ID + "=? AND " + MemberColumns.DELETED + "= 0", new String[] { String.valueOf(teamId) }, null);
                try {
                    c.moveToFirst();
                    int memberCount = c.getInt(0);
                    return memberCount > 0;
                } finally {
                    c.close();
                }
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if (result) {
                    Intent intent = new Intent(mActivity, MeetingActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    mActivity.startActivity(intent);
                } else {
                    DialogFragmentFactory.showInfoDialog(mActivity, R.string.dialog_error_title_one_member_required,
                            R.string.dialog_error_message_one_member_required);

                }
            }

        };
        task.execute();


    }

    /**
     * Shows a confirmation dialog to delete the given meeting.
     */
    public void confirmDelete(final Meeting meeting) {
        Log.v(TAG, "confirm delete meeting: " + meeting);
        // Let's ask him if he's sure first.
        Bundle extras = new Bundle(1);
        extras.putLong(EXTRA_MEETING_ID, meeting.getId());
        DialogFragmentFactory.showConfirmDialog(mActivity, mActivity.getString(R.string.action_delete_meeting),
                mActivity.getString(R.string.dialog_message_delete_meeting_confirm, TextUtils.formatDateTime(mActivity, meeting.getStartDate())),
                R.id.action_delete_meeting, extras);
    }

    /**
     * Deletes the given meeting from the DB.
     */
    public void delete(final long meetingId) {
        Log.v(TAG, "delete meeting " + meetingId);
        // Delete the meeting in a background thread.
        AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                Meeting meeting = Meeting.read(mActivity, meetingId);
                if (meeting == null) {
                    Log.v(TAG, "Tried to delete non-existing meeting " + meetingId);
                    return null;
                }
                meeting.delete();
                return null;
            }
        };
        task.execute();

    }

    /**
     * Read the data for the given meeting, then show an intent chooser to export this data as text.
     */
    public void export(long meetingId) {
        Log.v(TAG, "export meeting " + meetingId);
        // Export the meeting in a background thread.
        AsyncTask<Long, Void, Boolean> asyncTask = new AsyncTask<Long, Void, Boolean>() {

            @Override
            protected Boolean doInBackground(Long... meetingId) {
                MeetingExport export = new MeetingExport(mActivity);
                return export.exportMeeting(meetingId[0]);
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if (!result) Toast.makeText(mActivity, R.string.error_sharing_meeting, Toast.LENGTH_LONG).show();
            }

        };
        asyncTask.execute(meetingId);
    }

}




Java Source Code List

ca.rmen.android.scrumchatter.Constants.java
ca.rmen.android.scrumchatter.about.AboutActivity.java
ca.rmen.android.scrumchatter.dialog.ChoiceDialogFragment.java
ca.rmen.android.scrumchatter.dialog.ConfirmDialogFragment.java
ca.rmen.android.scrumchatter.dialog.DialogFragmentFactory.java
ca.rmen.android.scrumchatter.dialog.DialogStyleHacks.java
ca.rmen.android.scrumchatter.dialog.InfoDialogFragment.java
ca.rmen.android.scrumchatter.dialog.InputDialogFragment.java
ca.rmen.android.scrumchatter.dialog.ProgressDialogFragment.java
ca.rmen.android.scrumchatter.export.DBExport.java
ca.rmen.android.scrumchatter.export.FileExport.java
ca.rmen.android.scrumchatter.export.MeetingExport.java
ca.rmen.android.scrumchatter.export.MeetingsExport.java
ca.rmen.android.scrumchatter.main.MainActivity.java
ca.rmen.android.scrumchatter.meeting.Meetings.java
ca.rmen.android.scrumchatter.meeting.detail.MeetingActivity.java
ca.rmen.android.scrumchatter.meeting.detail.MeetingCursorAdapter.java
ca.rmen.android.scrumchatter.meeting.detail.MeetingFragment.java
ca.rmen.android.scrumchatter.meeting.detail.MeetingPagerAdapter.java
ca.rmen.android.scrumchatter.meeting.detail.Meeting.java
ca.rmen.android.scrumchatter.meeting.list.MeetingsCursorAdapter.java
ca.rmen.android.scrumchatter.meeting.list.MeetingsListFragment.java
ca.rmen.android.scrumchatter.member.list.MembersCursorAdapter.java
ca.rmen.android.scrumchatter.member.list.MembersListFragment.java
ca.rmen.android.scrumchatter.member.list.Members.java
ca.rmen.android.scrumchatter.provider.DBImport.java
ca.rmen.android.scrumchatter.provider.MeetingColumns.java
ca.rmen.android.scrumchatter.provider.MeetingCursorWrapper.java
ca.rmen.android.scrumchatter.provider.MeetingMemberColumns.java
ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper.java
ca.rmen.android.scrumchatter.provider.MemberColumns.java
ca.rmen.android.scrumchatter.provider.MemberCursorWrapper.java
ca.rmen.android.scrumchatter.provider.MemberStatsColumns.java
ca.rmen.android.scrumchatter.provider.ScrumChatterDatabase.java
ca.rmen.android.scrumchatter.provider.ScrumChatterProvider.java
ca.rmen.android.scrumchatter.provider.TeamColumns.java
ca.rmen.android.scrumchatter.team.TeamArrayAdapter.java
ca.rmen.android.scrumchatter.team.Teams.java
ca.rmen.android.scrumchatter.util.IOUtils.java
ca.rmen.android.scrumchatter.util.TextUtils.java
ca.rmen.android.scrumchatter.util.ViewHolder.java