private async void getVocabularyList() { progress.Show(); try { VocabularyAPI_Response response = await vocabularyapi.GetVocabularyList(); vocabularyList = response.res_data; // Toast.MakeText(this.Activity, "-->" + myFinalList[0].name,ToastLength.Short).Show(); for (int i = 0; i < vocabularyList.Count; i++) { Vocabulary_List.Add(vocabularyList[i].content_id); Vocabulary_List.Add(vocabularyList[i].content_title); Vocabulary_List.Add(vocabularyList[i].content_date); Vocabulary_List.Add(vocabularyList[i].content_file); Voc_Id = vocabularyList[i].content_id; Voc_Title = vocabularyList[i].content_title; Voc_Date = vocabularyList[i].content_date; Voc_File = vocabularyList[i].content_file; dba.insertVocabularyData(Voc_Id, Voc_Title, Voc_Date, Voc_File); } ISharedPreferencesEditor edit = pref.Edit(); edit.PutString("FinalVocabulary", "true"); edit.Apply(); mLayoutManager = new LinearLayoutManager(this.Activity); MyListWeeklyVocabulary.SetLayoutManager(mLayoutManager); VocabularyAdapter mAdapter = new VocabularyAdapter(Activity, vocabularyList, MyListWeeklyVocabulary); mAdapter.ItemClick += MAdapter_ItemClick; MyListWeeklyVocabulary.SetAdapter(mAdapter); progress.Dismiss(); } catch (Exception e) { progress.Dismiss(); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.Inflate(Resource.Layout.Vocabulary_ListView_Layout, container, false); MyListWeeklyVocabulary = v.FindViewById <RecyclerView>(Resource.Id.vocab); Button btnrefresh = v.FindViewById <Button>(Resource.Id.refresh); btnrefresh.Click += delegate { vocabularyList = new List <Vocabulary_Model>(); getVocabularyList(); }; //==================================Fetch api==========================// JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = { new StringEnumConverter() } }; // String apiurl = string.Format("http://mg.mahendras.org); vocabularyapi = RestService.For <Vacabulary_API>("http://mg.mahendras.org"); // getBookMarkList(); //=====================================================================// if (VocabularyDetails.Equals("false")) { getVocabularyList(); } else { //getAboutExam(); vocabularyList = dba.Get_VocabularyData(); mLayoutManager = new LinearLayoutManager(this.Activity); MyListWeeklyVocabulary.SetLayoutManager(mLayoutManager); VocabularyAdapter mAdapter = new VocabularyAdapter(Activity, vocabularyList, MyListWeeklyVocabulary); mAdapter.ItemClick += MAdapter_ItemClick; MyListWeeklyVocabulary.SetAdapter(mAdapter); } return(v); }