android.arch.lifecycle.MutableLiveData.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中android.arch.lifecycle.MutableLiveData.<init>()方法的一些代码示例,展示了MutableLiveData.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableLiveData.<init>()方法的具体详情如下:
包路径:android.arch.lifecycle.MutableLiveData
类名称:MutableLiveData
方法名:<init>

MutableLiveData.<init>介绍

暂无

代码示例

代码示例来源:origin: hidroh/materialistic

public LiveData<Pair<Item[], Item[]>> getStories(String filter, @ItemManager.CacheMode int cacheMode) {
  if (mItems == null) {
    mItems = new MutableLiveData<>();
    Observable.fromCallable(() -> mItemManager.getStories(filter, cacheMode))
        .subscribeOn(mIoThreadScheduler)
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(items -> setItems(items));
  }
  return mItems;
}

代码示例来源:origin: anitaa1990/PagingLibrary-Sample

public FeedDataSource(AppController appController) {
  this.appController = appController;
  networkState = new MutableLiveData();
  initialLoading = new MutableLiveData();
}

代码示例来源:origin: AliEsaAssadi/android-mvvm-sample-app

MainViewModel(MovieService movieService) {
  this.movieService = movieService;
  movieList = new MutableLiveData<>();
  isLoading = new MutableLiveData<>();
}

代码示例来源:origin: JBossOutreach/lead-management-android

public EditContactActivityViewModel(@NonNull Application application) {
  super(application);
  mContact = new MutableLiveData<>();
  mContactNumbers = new MutableLiveData<>();
}

代码示例来源:origin: aws-samples/aws-mobile-android-notes-tutorial

public NoteDetailViewModel() {
  this.notesRepository = Injection.getNotesRepository();
  this.mTitle = new MutableLiveData<>();
  this.mContent = new MutableLiveData<>();
}

代码示例来源:origin: ittianyu/MVVM

public LiveData<Lcee<User>> getUser() {
  if (null == ldUser) {
    ldUsername = new MutableLiveData<>();
    ldUser = Transformations.switchMap(ldUsername, new Function<String, LiveData<Lcee<User>>>() {
      @Override
      public LiveData<Lcee<User>> apply(String username) {
        return userRepository.getUser(username);
      }
    });
  }
  return ldUser;
}

代码示例来源:origin: ittianyu/MVVM

public LiveData<Lcee<Projects>> getProjects() {
  if (null == ldProjects) {
    ldPage = new MutableLiveData<>();
    ldProjects = Transformations.switchMap(ldPage, new Function<Integer, LiveData<Lcee<Projects>>>() {
      @Override
      public LiveData<Lcee<Projects>> apply(Integer page) {
        return projectsRepository.getProjects(page);
      }
    });
  }
  return ldProjects;
}

代码示例来源:origin: GoldenKappa/notSABS

public LiveData<List<BlockUrlProvider>> getBlockUrlProviders() {
  if (blockUrlProviders == null) {
    blockUrlProviders = new MutableLiveData<>();
    loadBlockUrlProviders();
  }
  return blockUrlProviders;
}

代码示例来源:origin: GoldenKappa/notSABS

public LiveData<List<AppInfo>> getSortedAppInfo() {
  if (appInfos == null) {
    appInfos = new MutableLiveData<>();
    loadAppInfos();
  }
  return appInfos;
}

代码示例来源:origin: leonardoxh/livedata-call-adapter

@SuppressWarnings("unchecked")
@Override
public LiveData<Resource<Response<R>>> adapt(Call<R> call) {
  final MutableLiveData<Resource<Response<R>>> liveDataResponse = new MutableLiveData<>();
  call.enqueue(new LiveDataResponseCallCallback(liveDataResponse));
  return liveDataResponse;
}

代码示例来源:origin: ittianyu/MVVM

public LiveData<Lcee<User>> getUser() {
  if (null == ldUser) {
    ldUsername = new MutableLiveData<>();
    ldUser = Transformations.switchMap(ldUsername, new Function<String, LiveData<Lcee<User>>>() {
      @Override
      public LiveData<Lcee<User>> apply(String username) {
        return userRepository.getUser(username);
      }
    });
  }
  return ldUser;
}

代码示例来源:origin: ittianyu/MVVM

public LiveData<Lcee<User>> getUser() {
  if (null == ldUser) {
    ldUsername = new MutableLiveData<>();
    ldUser = Transformations.switchMap(ldUsername, new Function<String, LiveData<Lcee<User>>>() {
      @Override
      public LiveData<Lcee<User>> apply(String username) {
        return userRepository.getUser(username);
      }
    });
  }
  return ldUser;
}

代码示例来源:origin: ittianyu/MVVM

public LiveData<Lcee<User>> getUser() {
  if (null == ldUser) {
    ldUsername = new MutableLiveData<>();
    ldUser = Transformations.switchMap(ldUsername, new Function<String, LiveData<Lcee<User>>>() {
      @Override
      public LiveData<Lcee<User>> apply(String username) {
        return userRepository.getUser(username);
      }
    });
  }
  return ldUser;
}

代码示例来源:origin: GoldenKappa/notSABS

public LiveData<PolicyPackage> getPolicyPackagesLiveData() {
  if (policyPackagesLiveData == null) {
    policyPackagesLiveData = new MutableLiveData<>();
    loadPolicyPackages();
  }
  return policyPackagesLiveData;
}

代码示例来源:origin: GoldenKappa/notSABS

public LiveData<List<ReportBlockedUrl>> getReportBlockedUrls() {
  reportBlockedUrls = new MutableLiveData<>();
  domainsToExport.clear();
  loadReportBlockedUrls();
  return reportBlockedUrls;
}

代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E

public LiveData<List<String>> getData() {
 if (data == null)
  data = new MutableLiveData<List<String>>();
 loadData();
 return data;
}

代码示例来源:origin: vogellacompany/codeexamples-android

public LiveData<List<Task>> getTasks() {
  if (tasks == null) {
    tasks = new MutableLiveData<List<Task>>();
    loadTasks();
  }
  return tasks;
}

代码示例来源:origin: Piwigo/Piwigo-Android

public UserManager(AccountManager accountManager, Resources resources, PreferencesRepository preferencesRepository) {
  this.accountManager = accountManager;
  this.resources = resources;
  this.preferencesRepository = preferencesRepository;
  this.mCurrentAccount = new MutableLiveData<>();
  this.mAllAccounts = new MutableLiveData<>();
  refreshAccounts();
  setActiveAccount(preferencesRepository.getActiveAccountName());
}

代码示例来源:origin: kioko/android-liveData-viewModel

public static <T> LiveData<ApiResponse<T>> createCall(Response<T> response) {
    MutableLiveData<ApiResponse<T>> data = new MutableLiveData<>();
    data.setValue(new ApiResponse<>(response));
    return data;
  }
}

代码示例来源:origin: Piwigo/Piwigo-Android

@Before @SuppressWarnings("Guava") public void setup() {
  MockitoAnnotations.initMocks(this);
  MutableLiveData<Account> ml = new MutableLiveData<>();
  ml.setValue(account);
  when(userManager.getActiveAccount()).thenReturn(ml);
  when(userManager.getUsername(account)).thenReturn("username");
  when(userManager.getSiteUrl(account)).thenReturn("http://piwigo.org/demo");
  viewModel = new MainViewModel(userManager, userRepository);
}

相关文章