private void RefreshLogButton_Click(object sender, System.EventArgs e) { mAdapter = new LogListAdapter(checkBoxTracView?.Checked ?? Preferences.Get(Resources.GetResourceEntryName(Resource.Id.checkBoxTracView), true), checkBoxInfoView?.Checked ?? Preferences.Get(Resources.GetResourceEntryName(Resource.Id.checkBoxInfoView), true), checkBoxWarnView?.Checked ?? Preferences.Get(Resources.GetResourceEntryName(Resource.Id.checkBoxWarnView), true), checkBoxErrView?.Checked ?? Preferences.Get(Resources.GetResourceEntryName(Resource.Id.checkBoxErrView), true)); mRecyclerView.SetAdapter(mAdapter); if (sender != null) { Toast.MakeText(this, "reload logs", ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.log_activity_layout); listLogView = FindViewById <ListView>(Resource.Id.log); logEntry = GetCurrentLog(FormatType.HTML, LogTime.LOCAL); logListAdapter = new LogListAdapter(this, logEntry); listLogView.Adapter = logListAdapter; btnShare = FindViewById <ImageButton>(Resource.Id.btn_share); unixEpochTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks / TimeSpan.TicksPerSecond; btnShare.Click += delegate { SimpleDateFormat dateFormatter = null; Date logCurrenTimeZone = null; Calendar calendar = null; List <string> exportLog = null; string logText = "", logSubject = ""; long utcTimeStamp = 0; calendar = Calendar.Instance; dateFormatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss"); utcTimeStamp = (DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) - unixEpochTime; calendar.TimeInMillis = utcTimeStamp * 1000; logCurrenTimeZone = (Date)calendar.Time; dateFormatter.TimeZone = Java.Util.TimeZone.GetTimeZone("GMT"); logSubject = string.Format(Resources.GetString(Resource.String.log_subject), dateFormatter.Format(logCurrenTimeZone)); exportLog = GetCurrentLog(FormatType.PLAIN_TEXT, LogTime.UTC); foreach (string entry in exportLog) { logText += entry + "\n"; } Intent shareIntent = new Intent(global::Android.Content.Intent.ActionSend); shareIntent.SetType("text/plain"); shareIntent.PutExtra(global::Android.Content.Intent.ExtraTitle, Resources.GetString(Resource.String.log_title)); shareIntent.PutExtra(global::Android.Content.Intent.ExtraSubject, logSubject); shareIntent.PutExtra(global::Android.Content.Intent.ExtraText, logText); StartActivity(Intent.CreateChooser(shareIntent, Resources.GetString(Resource.String.log_share_with))); }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.fragment_exercise_detail_log, container, false); _logs = JsonConvert.DeserializeObject <List <ExerciseLog> >(Arguments.GetString("logs")); _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerLogs); _layoutManager = new LinearLayoutManager(this.Context); _recyclerView.SetLayoutManager(_layoutManager); _adapter = new LogListAdapter(base.Activity, _logs); _recyclerView.SetAdapter(_adapter); _adapter.RowClick += _adapter_RowClick; // Use this to return your custom view for this Fragment return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Bundle extras = Intent.Extras; EddieLogger.Init(this); viewMode = (ViewMode)extras.GetInt("ViewMode"); if (viewMode == ViewMode.ListView) { SetContentView(Resource.Layout.log_activity_layout); listLogView = FindViewById <ListView>(Resource.Id.log); } else { SetContentView(Resource.Layout.log_activity_weblayout); webLogView = FindViewById <WebView>(Resource.Id.logwebview); } unixEpochTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks / TimeSpan.TicksPerSecond; btnCommand = FindViewById <ImageButton>(Resource.Id.btn_command); btnCommand.Click += delegate { ConsoleCommand(); }; btnShare = FindViewById <ImageButton>(Resource.Id.btn_share); btnShare.Click += delegate { SimpleDateFormat dateFormatter = null; Date logCurrenTimeZone = null; Calendar calendar = null; List <string> exportLog = null; string logText = "", logSubject = ""; long utcTimeStamp = 0; calendar = Calendar.Instance; dateFormatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss"); utcTimeStamp = (DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) - unixEpochTime; calendar.TimeInMillis = utcTimeStamp * 1000; logCurrenTimeZone = (Date)calendar.Time; dateFormatter.TimeZone = Java.Util.TimeZone.GetTimeZone("GMT"); logSubject = string.Format(Resources.GetString(Resource.String.log_subject), dateFormatter.Format(logCurrenTimeZone)); logText = logSubject + "\n\nEddie for Android "; try { string pkgName = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName; int pkgVersionCode = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode; logText += string.Format("{0} Version Code {1}", pkgName, pkgVersionCode); } catch { logText += "n.d."; } logText += "\n\n"; exportLog = GetCurrentLog(FormatType.PLAIN_TEXT, LogTime.UTC); if (exportLog == null) { return; } foreach (string entry in exportLog) { logText += entry + "\n"; } Intent shareIntent = new Intent(global::Android.Content.Intent.ActionSend); shareIntent.SetType("text/plain"); shareIntent.PutExtra(global::Android.Content.Intent.ExtraTitle, Resources.GetString(Resource.String.log_title)); shareIntent.PutExtra(global::Android.Content.Intent.ExtraSubject, logSubject); shareIntent.PutExtra(global::Android.Content.Intent.ExtraText, logText); StartActivity(Intent.CreateChooser(shareIntent, Resources.GetString(Resource.String.log_share_with))); }; logEntry = GetCurrentLog(FormatType.HTML, LogTime.LOCAL); if (viewMode == ViewMode.ListView) { logListAdapter = new LogListAdapter(this, GetSpannedLog()); listLogView.Adapter = logListAdapter; } else { webLogView.Settings.JavaScriptEnabled = false; webLogView.SetWebViewClient(new WebViewClient()); webLogView.Settings.BuiltInZoomControls = true; webLogView.Settings.DisplayZoomControls = false; LoadLogWebView(); } }