Android Open Source - Scanner-For-Zotero Bib Item D B Handler






From Project

Back to project page Scanner-For-Zotero.

License

The source code is released under:

GNU General Public License

If you think the Android project Scanner-For-Zotero 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 2011 John M. Schanck/*  w w  w  .ja  va 2  s . c  o m*/
 * 
 * ScannerForZotero 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.
 * 
 * ScannerForZotero 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 ScannerForZotero.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.ale.scanner.zotero.data;

import java.util.ArrayList;

import org.ale.scanner.zotero.BibItemListAdapter;

import android.os.Handler;
import android.os.Message;

/**
 * BibItemDBHandler is for those cases where a database operation is made, the
 * parent activity which initiated it is paused (orientation change, etc),
 * and the parent activity is resumed before the db operation is finished.
 *
 * This happens a lot.
 */
public class BibItemDBHandler extends Handler {

    public static final int BIBITEM_ACTION_ID = 1000;

    private static BibItemDBHandler mInstance = null;

    public static BibItemDBHandler getInstance(){
        if(mInstance == null)
            mInstance = new BibItemDBHandler();
        return mInstance;
    }

    private BibItemListAdapter mAdapter = null;

    public void bindAdapter(BibItemListAdapter adapter){
        if(mAdapter != null || adapter == null)
            return;
        mAdapter = adapter;
    }

    public void unbindAdapter(){
        mAdapter = null;
    }

    @SuppressWarnings("unchecked")
    public void handleMessage(Message msg){
        if(mAdapter != null){
            switch(msg.what) {
            case BibItemListAdapter.FOUND_SAVED_ITEMS:
                mAdapter.finishAddItems((ArrayList<BibItem>) msg.obj);
                break;
            case BibItemListAdapter.INSERTED_ITEM:
                mAdapter.finishAddItem((BibItem) msg.obj);
                break;
            case BibItemListAdapter.REMOVED_ITEM:
                mAdapter.finishDeleteItem((BibItem) msg.obj);
                break;
            case BibItemListAdapter.REPLACED_ITEM:
                mAdapter.finishReplaceItem((BibItem) msg.obj);
                break;
            }
        }
    }
}




Java Source Code List

org.ale.scanner.zotero.BibDetailJSONAdapter.java
org.ale.scanner.zotero.BibItemListAdapter.java
org.ale.scanner.zotero.Dialogs.java
org.ale.scanner.zotero.EditItemActivity.java
org.ale.scanner.zotero.LoginActivity.java
org.ale.scanner.zotero.MainActivity.java
org.ale.scanner.zotero.ManageAccountsActivity.java
org.ale.scanner.zotero.PString.java
org.ale.scanner.zotero.PendingListAdapter.java
org.ale.scanner.zotero.SafeViewFlipper.java
org.ale.scanner.zotero.Util.java
org.ale.scanner.zotero.data.Access.java
org.ale.scanner.zotero.data.Account.java
org.ale.scanner.zotero.data.BibItemDBHandler.java
org.ale.scanner.zotero.data.BibItem.java
org.ale.scanner.zotero.data.Collection.java
org.ale.scanner.zotero.data.CreatorType.java
org.ale.scanner.zotero.data.Database.java
org.ale.scanner.zotero.data.Group.java
org.ale.scanner.zotero.data.ItemField.java
org.ale.scanner.zotero.data.ItemType.java
org.ale.scanner.zotero.web.APIHandler.java
org.ale.scanner.zotero.web.APIRequest.java
org.ale.scanner.zotero.web.HttpsClient.java
org.ale.scanner.zotero.web.RequestQueue.java
org.ale.scanner.zotero.web.googlebooks.GoogleBooksAPIClient.java
org.ale.scanner.zotero.web.googlebooks.GoogleBooksHandler.java
org.ale.scanner.zotero.web.worldcat.WorldCatAPIClient.java
org.ale.scanner.zotero.web.worldcat.WorldCatHandler.java
org.ale.scanner.zotero.web.zotero.ZoteroAPIClient.java
org.ale.scanner.zotero.web.zotero.ZoteroHandler.java