<commit_before>package org.adaptlab.chpir.android.participanttracker.tasks;

import org.adaptlab.chpir.android.activerecordcloudsync.ActiveRecordCloudSync;
import org.adaptlab.chpir.android.activerecordcloudsync.NetworkNotificationUtils;
import org.adaptlab.chpir.android.participanttracker.R;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

public class SyncTablesTask extends AsyncTask<Void, Void, Void> {		
	ProgressDialog mProgressDialog;
	private Context mContext;

	public SyncTablesTask(Context context) {
		mContext = context;
	}
	
	@Override
	protected void onPreExecute() {
	    if (! ((Activity) mContext).isFinishing()) {
    		mProgressDialog = ProgressDialog.show(
    				mContext, 
    				mContext.getString(R.string.participants_loading_header), 
    				mContext.getString(R.string.participants_loading_message)
    		);
	    }
	}
	
	@Override
    protected Void doInBackground(Void... params) {
        if (NetworkNotificationUtils.checkForNetworkErrors(mContext)) {
            ActiveRecordCloudSync.syncTables(mContext);
        }
        return null;
    }
    
    @Override
	protected void onPostExecute(Void param) {
    	new LogoutUserTask(mContext).execute();
    	((Activity) mContext).setResult(Activity.RESULT_OK);
    	if (mProgressDialog.isShowing()) {
    	    mProgressDialog.dismiss();
    	}
    	((Activity) mContext).finish();
    }
}

class LogoutUserTask extends AsyncTask<Void, Void, Void> {		
	Context lcontext;
	
	public LogoutUserTask(Context context) {
		lcontext = context;
	}
	
	@Override<commit_msg>check if ProgressDialog is null<commit_after>package org.adaptlab.chpir.android.participanttracker.tasks;

import org.adaptlab.chpir.android.activerecordcloudsync.ActiveRecordCloudSync;
import org.adaptlab.chpir.android.activerecordcloudsync.NetworkNotificationUtils;
import org.adaptlab.chpir.android.participanttracker.R;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

public class SyncTablesTask extends AsyncTask<Void, Void, Void> {		
	ProgressDialog mProgressDialog;
	private Context mContext;

	public SyncTablesTask(Context context) {
		mContext = context;
	}
	
	@Override
	protected void onPreExecute() {
	    if (! ((Activity) mContext).isFinishing()) {
    		mProgressDialog = ProgressDialog.show(
    				mContext, 
    				mContext.getString(R.string.participants_loading_header), 
    				mContext.getString(R.string.participants_loading_message)
    		);
	    }
	}
	
	@Override
    protected Void doInBackground(Void... params) {
        if (NetworkNotificationUtils.checkForNetworkErrors(mContext)) {
            ActiveRecordCloudSync.syncTables(mContext);
        }
        return null;
    }
    
    @Override
	protected void onPostExecute(Void param) {
    	new LogoutUserTask(mContext).execute();
    	((Activity) mContext).setResult(Activity.RESULT_OK);
    	if (mProgressDialog != null && mProgressDialog.isShowing()) {
    	    mProgressDialog.dismiss();
    	}
    	((Activity) mContext).finish();
    }
}

class LogoutUserTask extends AsyncTask<Void, Void, Void> {		
	Context lcontext;
	
	public LogoutUserTask(Context context) {
		lcontext = context;
	}
	
	@Override
{'fraction_non_alphanumeric': 0.09760533494998484, 'fraction_numerical': 0.0, 'mean_word_length': 3.9924357034795763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '832136', 'n_tokens_mistral': 1068, 'n_tokens_neox': 989, 'n_words': 171}