当前位置: 首页>>代码示例>>Java>>正文


Java GuardedAsyncTask类代码示例

本文整理汇总了Java中com.facebook.react.bridge.GuardedAsyncTask的典型用法代码示例。如果您正苦于以下问题:Java GuardedAsyncTask类的具体用法?Java GuardedAsyncTask怎么用?Java GuardedAsyncTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GuardedAsyncTask类属于com.facebook.react.bridge包,在下文中一共展示了GuardedAsyncTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCatalystInstanceDestroy

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@Override
public void onCatalystInstanceDestroy() {
    try {
        new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
            @Override
            protected void doInBackgroundGuarded(Void... params) {
                if (client != null) {
                    client.disconnect(false);
                }
                if (server != null) {
                    server.close();
                }
            }
        }.execute().get();
    } catch (InterruptedException ioe) {
        Log.e(eTag, "onCatalystInstanceDestroy", ioe);
    } catch (ExecutionException ee) {
        Log.e(eTag, "onCatalystInstanceDestroy", ee);
    }
}
 
开发者ID:davidstoneham,项目名称:react-native-sockets,代码行数:21,代码来源:SocketsModule.java

示例2: clear

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
/**
 * Clears the database.
 */
@ReactMethod
public void clear(final Callback callback) {
  new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
    @Override
    protected void doInBackgroundGuarded(Void... params) {
      if (!mReactDatabaseSupplier.ensureDatabase()) {
        callback.invoke(AsyncStorageErrorUtil.getDBError(null));
        return;
      }
      try {
        mReactDatabaseSupplier.clear();
        callback.invoke();
      } catch (Exception e) {
        FLog.w(ReactConstants.TAG, e.getMessage(), e);
        callback.invoke(AsyncStorageErrorUtil.getError(null, e.getMessage()));
      }
    }
  }.execute();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:23,代码来源:AsyncStorageModule.java

示例3: queryCache

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void queryCache(final ReadableArray uris, final Promise promise) {
  // perform cache interrogation in async task as disk cache checks are expensive
  new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
    @Override
    protected void doInBackgroundGuarded(Void... params) {
      WritableMap result = Arguments.createMap();
      ImagePipeline imagePipeline = Fresco.getImagePipeline();
      for (int i = 0; i < uris.size(); i++) {
        String uriString = uris.getString(i);
        final Uri uri = Uri.parse(uriString);
        if (imagePipeline.isInBitmapMemoryCache(uri)) {
          result.putString(uriString, "memory");
        } else if (imagePipeline.isInDiskCacheSync(uri)) {
          result.putString(uriString, "disk");
        }
      }
      promise.resolve(result);
    }
  }.executeOnExecutor(GuardedAsyncTask.THREAD_POOL_EXECUTOR);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:ImageLoaderModule.java

示例4: getLocale

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
/***
 * This method will expose all the available languages in TTS engine
 *
 * @param callback
 */
@ReactMethod
public void getLocale(final Callback callback) {
    new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
        @Override
        protected void doInBackgroundGuarded(Void... params) {
            try {
                if (tts == null) {
                    init();
                }
                Locale[] locales = Locale.getAvailableLocales();
                WritableArray data = Arguments.createArray();
                for (Locale locale : locales) {
                    int res = tts.isLanguageAvailable(locale);
                    if (res == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
                        data.pushString(locale.getLanguage());
                    }
                }
                callback.invoke(null, data);
            } catch (Exception e) {
                callback.invoke(e.getMessage());
            }
        }
    }.execute();
}
 
开发者ID:somonus,项目名称:react-native-speech,代码行数:30,代码来源:speechModule.java

示例5: isSpeaking

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void isSpeaking(final Callback callback) {
    new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
        @Override
        protected void doInBackgroundGuarded(Void... params) {
            try {
                if (tts.isSpeaking()) {
                    callback.invoke(null, true);
                } else {
                    callback.invoke(null, false);
                }
            } catch (Exception e) {
                callback.invoke(e.getMessage());
            }
        }
    }.execute();
}
 
开发者ID:somonus,项目名称:react-native-speech,代码行数:18,代码来源:speechModule.java

示例6: shutDown

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void shutDown(final Callback callBack) {
    new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
        @Override
        protected void doInBackgroundGuarded(Void... params) {
            if (tts == null) {
                callBack.invoke(true);
            }
            try {
                tts.shutdown();
                callBack.invoke(null, true);
            } catch (Exception e) {
                callBack.invoke(e.getMessage());
            }
        }
    }.execute();
}
 
开发者ID:somonus,项目名称:react-native-speech,代码行数:18,代码来源:speechModule.java

示例7: query

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void query(final String sql, final ReadableArray values, final Callback callback) {
	new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
		@Override
		protected void doInBackgroundGuarded(Void ...params) {
			WritableArray data = Arguments.createArray();

			// FLog.w(ReactConstants.TAG, "dbmanager.query.sql=%s", sql);
			// FLog.w(ReactConstants.TAG, "dbmanager.query.values.size()=%d", values.size());

			try {
				data = mDb.query(sql, values);
			} catch(Exception e) {
				FLog.w(ReactConstants.TAG, "Exception in database query: ", e);
				callback.invoke(ErrorUtil.getError(null, e.getMessage()), null);
			}

			callback.invoke(null, data);
		}
	}.execute();
}
 
开发者ID:jbrodriguez,项目名称:react-native-android-sqlite,代码行数:22,代码来源:DBManager.java

示例8: exec

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void exec(final String sql, final ReadableArray values, final Callback callback) {
	new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
		@Override
		protected void doInBackgroundGuarded(Void ...params) {
			try {
				mDb.exec(sql, values);
			} catch(Exception e) {
				FLog.w(ReactConstants.TAG, "Exception in database exec: ", e);
				callback.invoke(ErrorUtil.getError(null, e.getMessage()), null);
			}

			callback.invoke();
		}
	}.execute();
}
 
开发者ID:jbrodriguez,项目名称:react-native-android-sqlite,代码行数:17,代码来源:DBManager.java

示例9: close

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
@ReactMethod
public void close(final Callback callback) {
	new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
		@Override
		protected void doInBackgroundGuarded(Void ...params) {
			try {
				mDb.close();
			} catch(Exception e) {
				FLog.w(ReactConstants.TAG, "Exception in database close: ", e);
				callback.invoke(ErrorUtil.getError(null, e.getMessage()), null);
			}

			callback.invoke();
		}
	}.execute();
}
 
开发者ID:jbrodriguez,项目名称:react-native-android-sqlite,代码行数:17,代码来源:DBManager.java

示例10: executeDbCallsAsync

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void executeDbCallsAsync(final String tableName, final Promise promise, final String createQuery, final ContentValues contentValues) {
    new GuardedAsyncTask(reactContext) {
        @Override
        protected void doInBackgroundGuarded(Object[] params) {
            SQLiteDatabase db = rnRecordSQLiteHelper.getWritableDatabase();

            db.execSQL(createQuery);
            promise.resolve((double)db.insert(tableName, null, contentValues));

        }
    }.execute();
}
 
开发者ID:reneweb,项目名称:rnrecord,代码行数:13,代码来源:SaveCommand.java

示例11: executeDbCallsAsync

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void executeDbCallsAsync(final String tableName, final Promise promise) {
    new GuardedAsyncTask(reactContext) {
        @Override
        protected void doInBackgroundGuarded(Object[] params) {
            SQLiteDatabase db = rnRecordSQLiteHelper.getWritableDatabase();

            promise.resolve(transformQueryResults(db.rawQuery("select * from " + tableName, null)));

        }
    }.execute();
}
 
开发者ID:reneweb,项目名称:rnrecord,代码行数:12,代码来源:FindAllCommand.java

示例12: executeDbCallsAsync

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void executeDbCallsAsync(final String queryString, final ArrayList<String> queryArguments, final Promise promise) {
    new GuardedAsyncTask(reactContext) {
        @Override
        protected void doInBackgroundGuarded(Object[] params) {
            SQLiteDatabase db = rnRecordSQLiteHelper.getWritableDatabase();

            promise.resolve(transformQueryResults(db.rawQuery(queryString, queryArguments.toArray(new String[queryArguments.size()]) )));

        }
    }.execute();
}
 
开发者ID:reneweb,项目名称:rnrecord,代码行数:12,代码来源:FindCommand.java

示例13: executeDbCallsAsync

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void executeDbCallsAsync(final String tableName, final Promise promise, final int id) {
    new GuardedAsyncTask(reactContext) {
        @Override
        protected void doInBackgroundGuarded(Object[] params) {
            SQLiteDatabase db = rnRecordSQLiteHelper.getWritableDatabase();

            promise.resolve(db.delete(tableName, "id = ?", new String[] {String.valueOf(id)} ));

        }
    }.execute();
}
 
开发者ID:reneweb,项目名称:rnrecord,代码行数:12,代码来源:DeleteCommand.java

示例14: executeDbCallsAsync

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void executeDbCallsAsync(final String tableName, final Promise promise, final ContentValues contentValues) {
    new GuardedAsyncTask(reactContext) {
        @Override
        protected void doInBackgroundGuarded(Object[] params) {
            SQLiteDatabase db = rnRecordSQLiteHelper.getWritableDatabase();

            promise.resolve(db.update(tableName, contentValues, "id = ?", new String[] {contentValues.getAsString("id")} ));

        }
    }.execute();
}
 
开发者ID:reneweb,项目名称:rnrecord,代码行数:12,代码来源:UpdateCommand.java

示例15: runInBackground

import com.facebook.react.bridge.GuardedAsyncTask; //导入依赖的package包/类
private void runInBackground(final Runnable runnable) {
  new GuardedAsyncTask<Void, Void>(mContext) {
    @Override
    protected void doInBackgroundGuarded(Void... params) {
      runnable.run();
    }
  }.execute();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:ForwardingCookieHandler.java


注:本文中的com.facebook.react.bridge.GuardedAsyncTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。