Search in sources :

Example 6 with RestApi

use of com.nutomic.syncthingandroid.service.RestApi in project syncthing-android by syncthing.

the class FolderListFragment method updateList.

/**
 * Refreshes ListView by updating folders and info.
 *
 * Also creates adapter if it doesn't exist yet.
 */
private void updateList() {
    SyncthingActivity activity = (SyncthingActivity) getActivity();
    if (activity == null || getView() == null || activity.isFinishing()) {
        return;
    }
    RestApi restApi = activity.getApi();
    if (restApi == null || !restApi.isConfigLoaded()) {
        return;
    }
    List<Folder> folders = restApi.getFolders();
    if (folders == null) {
        return;
    }
    if (mAdapter == null) {
        mAdapter = new FoldersAdapter(activity);
        setListAdapter(mAdapter);
    }
    // Prevent scroll position reset due to list update from clear().
    mAdapter.setNotifyOnChange(false);
    mAdapter.clear();
    mAdapter.addAll(folders);
    mAdapter.updateFolderStatus(restApi);
    mAdapter.notifyDataSetChanged();
    setListShown(true);
}
Also used : FoldersAdapter(com.nutomic.syncthingandroid.views.FoldersAdapter) SyncthingActivity(com.nutomic.syncthingandroid.activities.SyncthingActivity) RestApi(com.nutomic.syncthingandroid.service.RestApi) Folder(com.nutomic.syncthingandroid.model.Folder)

Example 7 with RestApi

use of com.nutomic.syncthingandroid.service.RestApi in project syncthing-android by syncthing.

the class FolderActivity method createDeleteDialog.

private Dialog createDeleteDialog() {
    return Util.getAlertDialogBuilder(this).setMessage(R.string.remove_folder_confirm).setPositiveButton(android.R.string.yes, (dialogInterface, i) -> {
        RestApi restApi = getApi();
        if (restApi != null) {
            restApi.removeFolder(mFolder.id);
        }
        mFolderNeedsToUpdate = false;
        finish();
    }).setNegativeButton(android.R.string.no, null).create();
}
Also used : RestApi(com.nutomic.syncthingandroid.service.RestApi)

Aggregations

RestApi (com.nutomic.syncthingandroid.service.RestApi)7 SyncthingActivity (com.nutomic.syncthingandroid.activities.SyncthingActivity)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Configuration (android.content.res.Configuration)1 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Uri (android.net.Uri)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 IBinder (android.os.IBinder)1 PowerManager (android.os.PowerManager)1