protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (Activities.ContainsKey("MainActivity")) { Activities["MainActivity"].Finish(); Activities.Remove("MainActivity"); Activities.Add("MainActivity", this); } else { Activities.Add("MainActivity", this); } Data_Parking.DIC_PARKINGLOT_OVERALL_INFO.Clear(); Data_Parking.DIC_PARKINGLOTSTRING.Clear(); Data_ShopInfo.DIC_SHOPINFO_OVERALL_INFO.Clear(); Data_ShopInfo.DIC_SHOP_XML_INFO_OVERALL_INFO.Clear(); Data_ShopInfo.DIC_SHOPMAP.Clear(); Data_ShopInfo.DIC_SHOP_DB_INFO_OVERALL_INFO.Clear(); if (Data_Parking.DIC_PARKINGLOT_OVERALL_INFO.Count == 0) { Data_Parking.SaveURL(Ulgiro3, GetString(Resource.String.sogonddong), GetString(Resource.String.kawncheldong), GetString(Resource.String.sanlimdong), GetString(Resource.String.inhyendong), GetString(Resource.String.jukyodong), GetString(Resource.String.bangsandong)); Data_Parking.SaveURL(Ulgiro4, GetString(Resource.String.sogonddong), GetString(Resource.String.kawncheldong), GetString(Resource.String.sanlimdong), GetString(Resource.String.inhyendong), GetString(Resource.String.jukyodong), GetString(Resource.String.bangsandong)); Data_Parking.SaveURL(UlgiEnterance, GetString(Resource.String.sogonddong), GetString(Resource.String.kawncheldong), GetString(Resource.String.sanlimdong), GetString(Resource.String.inhyendong), GetString(Resource.String.jukyodong), GetString(Resource.String.bangsandong)); Data_Parking.SaveURL(CityHall, GetString(Resource.String.seosomundong), GetString(Resource.String.sogonddong), GetString(Resource.String.taepyeongro)); Data_Parking.SaveURL(InHyeon, GetString(Resource.String.sanlimdong), GetString(Resource.String.inhyendong), GetString(Resource.String.yeekhawndong), GetString(Resource.String.chungmuro)); Data_Parking.SaveURL(Sindang, GetString(Resource.String.heongindong), GetString(Resource.String.sangwangsipli)); Data_Parking.SaveURL(JongKak, GetString(Resource.String.kawncheldong), GetString(Resource.String.insadong)); Data_Parking.SaveURL(Jongro4, GetString(Resource.String.yejidong), GetString(Resource.String.hunjeongdong), GetString(Resource.String.sanlimdong), GetString(Resource.String.jukyodong), GetString(Resource.String.inoedong)); Data_Parking.SaveURL(Majeon, GetString(Resource.String.bangsandong), GetString(Resource.String.jukyodong), GetString(Resource.String.yejidong), GetString(Resource.String.hunjeongdong)); Data_Parking.SaveURL(ChongGye5, GetString(Resource.String.bangsandong), GetString(Resource.String.jukyodong), GetString(Resource.String.yejidong), GetString(Resource.String.hunjeongdong)); Data_Parking.SaveURL(Jongoh, GetString(Resource.String.yejidong), GetString(Resource.String.inoedong)); Data_Parking.SaveURL(DongDaeMun, GetString(Resource.String.bangsandong), GetString(Resource.String.jongro5), GetString(Resource.String.jongro6), GetString(Resource.String.eulgiro6)); Data_Parking.SaveURL(ChongGye6, GetString(Resource.String.jongro5), GetString(Resource.String.jongro6), GetString(Resource.String.bangsandong)); Data_Parking.SaveURL(MyeongDong, GetString(Resource.String.sogonddong), GetString(Resource.String.chungmuro1)); Data_Parking.SaveURL(MyeongDongStation, GetString(Resource.String.namdaemoonro4), GetString(Resource.String.hoehyeondong2ga), GetString(Resource.String.chungmuro1)); Data_Parking.SaveURL(Sogong, GetString(Resource.String.sogonddong), GetString(Resource.String.chungmuro1)); Data_Parking.SaveURL(NamDaeMun, GetString(Resource.String.namdaemoonro4), GetString(Resource.String.bongraedong1)); Data_Parking.SaveURL(HoeHyeon, GetString(Resource.String.namdaemoonro3), GetString(Resource.String.chungmuro1)); Data_Parking.SaveURL(Gangnam, GetString(Resource.String.yeoksamdong), GetString(Resource.String.seochodong)); Data_Parking.SaveURL(Jamsil, GetString(Resource.String.sincheondong)); Data_Parking.SaveURL(GangNamTerminalPart1, GetString(Resource.String.banpodong)); Data_Parking.SaveURL(GangNamTerminalPart2, GetString(Resource.String.banpodong)); Data_Parking.SaveURL(GangNamTerminalPart3, GetString(Resource.String.banpodong)); Data_Parking.SaveURL(YeongDeungPoStation, GetString(Resource.String.yeongdeungpo)); Data_Parking.SaveURL(YeongDeungPoRotary, GetString(Resource.String.yeongdeungpo)); Data_Parking.SaveURL(YeongDeungPoMarketNewtown, GetString(Resource.String.yeongdeungpo)); } //배율구하기 { float defalt_dpi = 160.0f; float basic_dpix; float basic_dpiy; float dpixScaleSurplus = 0f; float dpiyScaleSurplus = 0f; basic_dpix = Resources.DisplayMetrics.Xdpi; basic_dpiy = Resources.DisplayMetrics.Ydpi; if (basic_dpix > 320) { dpixScaleSurplus = basic_dpix % defalt_dpi; dpiyScaleSurplus = basic_dpiy % defalt_dpi; } dpixScale = (float)Math.Round(basic_dpix / defalt_dpi + dpixScaleSurplus / defalt_dpi); dpiyScale = (float)Math.Round(basic_dpiy / defalt_dpi + dpiyScaleSurplus / defalt_dpi); //dpixScale = Resources.DisplayMetrics.ScaledDensity; //dpiyScale = Resources.DisplayMetrics.ScaledDensity; } if (Data_ShopInfo.DIC_SHOPINFO_OVERALL_INFO.Count == 0) { using (System.IO.StreamReader sr = new System.IO.StreamReader(Assets.Open("UnderShopInfo.xml"))) { System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); xml.Load(sr); Data_ShopInfo.AddShopXMLInfo(Ulgiro3, xml); Data_ShopInfo.AddShopXMLInfo(Ulgiro4, xml); Data_ShopInfo.AddShopXMLInfo(UlgiEnterance, xml); Data_ShopInfo.AddShopXMLInfo(CityHall, xml); Data_ShopInfo.AddShopXMLInfo(InHyeon, xml); Data_ShopInfo.AddShopXMLInfo(Sindang, xml); Data_ShopInfo.AddShopXMLInfo(JongKak, xml); Data_ShopInfo.AddShopXMLInfo(Jongro4, xml); Data_ShopInfo.AddShopXMLInfo(Majeon, xml); Data_ShopInfo.AddShopXMLInfo(ChongGye5, xml); Data_ShopInfo.AddShopXMLInfo(Jongoh, xml); Data_ShopInfo.AddShopXMLInfo(DongDaeMun, xml); Data_ShopInfo.AddShopXMLInfo(ChongGye6, xml); Data_ShopInfo.AddShopXMLInfo(MyeongDong, xml); Data_ShopInfo.AddShopXMLInfo(MyeongDongStation, xml); Data_ShopInfo.AddShopXMLInfo(NamDaeMun, xml); Data_ShopInfo.AddShopXMLInfo(Sogong, xml); Data_ShopInfo.AddShopXMLInfo(HoeHyeon, xml); Data_ShopInfo.AddShopXMLInfo(Gangnam, xml); Data_ShopInfo.AddShopXMLInfo(Jamsil, xml); Data_ShopInfo.AddShopXMLInfo(GangNamTerminalPart1, xml); Data_ShopInfo.AddShopXMLInfo(GangNamTerminalPart2, xml); Data_ShopInfo.AddShopXMLInfo(GangNamTerminalPart3, xml); Data_ShopInfo.AddShopXMLInfo(YeongDeungPoStation, xml); Data_ShopInfo.AddShopXMLInfo(YeongDeungPoRotary, xml); Data_ShopInfo.AddShopXMLInfo(YeongDeungPoMarketNewtown, xml); } } // Data_ShopInfo.InsertShopInfoData(); Data_ShopInfo.SHOP_DB.GetDicShopInfo(); Data_ShopInfo.DIC_SHOPMAP.Clear(); if (Data_ShopInfo.DIC_SHOPMAP.Count == 0) { Data_ShopInfo.DIC_SHOPMAP.Add(Ulgiro3, Resource.Drawable.UGR3_final); Data_ShopInfo.DIC_SHOPMAP.Add(Ulgiro4, Resource.Drawable.UGR4_final); Data_ShopInfo.DIC_SHOPMAP.Add(UlgiEnterance, Resource.Drawable.UlgiEntranceFin); Data_ShopInfo.DIC_SHOPMAP.Add(CityHall, Resource.Drawable.CityHallFin); Data_ShopInfo.DIC_SHOPMAP.Add(InHyeon, Resource.Drawable.InHyeonFin); Data_ShopInfo.DIC_SHOPMAP.Add(Sindang, Resource.Drawable.SindangFinal); Data_ShopInfo.DIC_SHOPMAP.Add(JongKak, Resource.Drawable.jongak_final); Data_ShopInfo.DIC_SHOPMAP.Add(Jongro4, Resource.Drawable.jongro4_final); Data_ShopInfo.DIC_SHOPMAP.Add(Majeon, Resource.Drawable.majeongyo_final); Data_ShopInfo.DIC_SHOPMAP.Add(ChongGye5, Resource.Drawable.chungye5_final); Data_ShopInfo.DIC_SHOPMAP.Add(Jongoh, Resource.Drawable.jongO_final); Data_ShopInfo.DIC_SHOPMAP.Add(DongDaeMun, Resource.Drawable.Dongdaemoon_final); Data_ShopInfo.DIC_SHOPMAP.Add(ChongGye6, Resource.Drawable.chungye6_final); Data_ShopInfo.DIC_SHOPMAP.Add(MyeongDong, Resource.Drawable.Myeongdong_final); Data_ShopInfo.DIC_SHOPMAP.Add(MyeongDongStation, Resource.Drawable.myeongdongstaition_final); Data_ShopInfo.DIC_SHOPMAP.Add(NamDaeMun, Resource.Drawable.namdaemoon_final); Data_ShopInfo.DIC_SHOPMAP.Add(Sogong, Resource.Drawable.sogong_final); Data_ShopInfo.DIC_SHOPMAP.Add(HoeHyeon, Resource.Drawable.huihyun_final); Data_ShopInfo.DIC_SHOPMAP.Add(GangNamTerminalPart1, Resource.Drawable.Express1); Data_ShopInfo.DIC_SHOPMAP.Add(GangNamTerminalPart2, Resource.Drawable.Express2); Data_ShopInfo.DIC_SHOPMAP.Add(GangNamTerminalPart3, Resource.Drawable.Express3_fin); Data_ShopInfo.DIC_SHOPMAP.Add(Gangnam, Resource.Drawable.GangNamFinal); Data_ShopInfo.DIC_SHOPMAP.Add(Jamsil, Resource.Drawable.JamsilFinal); Data_ShopInfo.DIC_SHOPMAP.Add(YeongDeungPoStation, Resource.Drawable.YDPstaiton_final); Data_ShopInfo.DIC_SHOPMAP.Add(YeongDeungPoRotary, Resource.Drawable.YDProtary_final); Data_ShopInfo.DIC_SHOPMAP.Add(YeongDeungPoMarketNewtown, Resource.Drawable.YDPnewtown_final); } //Finish(); System.Threading.Thread.Sleep(2000); StartActivity(typeof(LocalSelectActivity)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (MainActivity.Activities.ContainsKey("ShopInfoActivity")) { MainActivity.Activities["ShopInfoActivity"].Finish(); MainActivity.Activities.Remove("ShopInfoActivity"); MainActivity.Activities.Add("ShopInfoActivity", this); } else { MainActivity.Activities.Add("ShopInfoActivity", this); } // Create your application here SetContentView(Resource.Layout.ShopInfoLayout2); shopID = Intent.GetStringExtra("SHOP_ID_NUMBER"); local = Intent.GetStringExtra("Local"); ShopDBInformation DBShopContext = null; if (Data_ShopInfo.DIC_SHOP_DB_INFO_OVERALL_INFO.ContainsKey(shopID)) { DBShopContext = Data_ShopInfo.DIC_SHOP_DB_INFO_OVERALL_INFO[shopID]; } else { ShopDBInformation shopData = new ShopDBInformation() { BookMark = 0, Comment = "", Rating = 0f, IdentificationNumber = shopID }; Data_ShopInfo.DIC_SHOP_DB_INFO_OVERALL_INFO.Add(shopData.IdentificationNumber, shopData); DBShopContext = Data_ShopInfo.DIC_SHOP_DB_INFO_OVERALL_INFO[shopID]; Data_ShopInfo.InsertShopInfoData(shopData); } ShopInformation XMLShopContext = Data_ShopInfo.DIC_SHOP_XML_INFO_OVERALL_INFO[shopID]; TextView tv_ShopName = FindViewById <TextView>(Resource.Id.tv_ShopName); tv_ShopName.Text = XMLShopContext.ShopName; TextView tv_ShopAddress = FindViewById <TextView>(Resource.Id.tv_ShopAddress); tv_ShopAddress.Text = XMLShopContext.LocalNam; TextView tv_SaleKind = FindViewById <TextView>(Resource.Id.tv_SaleKind); tv_SaleKind.Text = XMLShopContext.Category; RatingBar ratingbar = FindViewById <RatingBar>(Resource.Id.ratingbar); ratingbar.Rating = DBShopContext.Rating; ratingbar.RatingBarChange += (o, e) => { Toast.MakeText(this, "New Rating: " + ratingbar.Rating.ToString(), ToastLength.Short).Show(); DBShopContext.Rating = ratingbar.Rating; Data_ShopInfo.SHOP_DB.UpdateShopData("Rating", DBShopContext.Rating, DBShopContext.IdentificationNumber); }; RatingBar bookmark = FindViewById <RatingBar>(Resource.Id.BookMark); bookmark.Rating = DBShopContext.BookMark; bookmark.Touch += (o, e) => { if (e.Event.ActionMasked == MotionEventActions.Up) { count++; if (count % 2 == 0) { bookmark.Rating = 0; DBShopContext.BookMark = 0; Data_ShopInfo.SHOP_DB.UpdateShopData("BookMark", DBShopContext.BookMark, DBShopContext.IdentificationNumber); } else { bookmark.Rating = 1; DBShopContext.BookMark = 1; Data_ShopInfo.SHOP_DB.UpdateShopData("BookMark", DBShopContext.BookMark, DBShopContext.IdentificationNumber); } } }; EditText et = FindViewById <EditText>(Resource.Id.et_comment); et.Text = DBShopContext.Comment.ToString(); et.TextChanged += (o, e) => { DBShopContext.Comment = et.Text; Data_ShopInfo.SHOP_DB.UpdateShopData("Comment", DBShopContext.Comment, DBShopContext.IdentificationNumber); }; int tweetcount = ("#" + XMLShopContext.ShopName + "(#" + XMLShopContext.LocalNam + GetString(Resource.String.UnderShopdddd) + "\n" + GetString(Resource.String.SaleKind) + " " + XMLShopContext.Category + "\n" + GetString(Resource.String.MyRating) + " " + ratingbar.Rating.ToString() + "\n" + GetString(Resource.String.MyComment) + " ").Length; global::Android.Text.IInputFilter[] fA = new Android.Text.IInputFilter[1]; fA[0] = new Android.Text.InputFilterLengthFilter(139 - tweetcount); et.SetFilters(fA); LinearLayout twit_sharing = FindViewById <LinearLayout>(Resource.Id.twit_sharing); LinearLayout twit_others_opinion = FindViewById <LinearLayout>(Resource.Id.twit_others_opinion); twit_sharing.Click += (o, e) => { Android.Net.ConnectivityManager connectivityManager = (Android.Net.ConnectivityManager)GetSystemService(ConnectivityService); Android.Net.NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; bool isOnline = (activeConnection != null) && activeConnection.IsConnected; if (isOnline) { if (loggedInAccount == null) { Toast.MakeText(this, GetString(Resource.String.acquireLogin), ToastLength.Short).Show(); var auth = new OAuth1Authenticator( consumerKey: "qjXcnuCmZKPLU9Mupr0nkEcCv", consumerSecret: "q3c4nxTk1jqsLowujLxTmugsmdaLZFVq5cLI4SmWA1pRSlPcaD", requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"), accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"), callbackUrl: new Uri("http://www.hansei.ac.kr/")); //save the account data in the authorization completed even handler auth.Completed += (sender, eventArgs) => { if (eventArgs.IsAuthenticated) { loggedInAccount = eventArgs.Account; AccountStore.Create(this).Save(loggedInAccount, "UndertheShopTwitApp"); var cred = new LinqToTwitter.InMemoryCredentialStore(); cred.ConsumerKey = loggedInAccount.Properties["oauth_consumer_key"]; cred.ConsumerSecret = loggedInAccount.Properties["oauth_consumer_secret"]; cred.OAuthToken = loggedInAccount.Properties["oauth_token"]; cred.OAuthTokenSecret = loggedInAccount.Properties["oauth_token_secret"]; var auth0 = new LinqToTwitter.PinAuthorizer() { CredentialStore = cred, }; var TwitterCtx = new LinqToTwitter.TwitterContext(auth0); TwitterCtx.TweetAsync("#" + XMLShopContext.ShopName + "(#" + XMLShopContext.LocalNam + GetString(Resource.String.UnderShopdddd) + "\n" + GetString(Resource.String.SaleKind) + " " + XMLShopContext.Category + "\n" + GetString(Resource.String.MyRating) + " " + ratingbar.Rating.ToString() + "\n" + GetString(Resource.String.MyComment) + " " + et.Text); Toast.MakeText(this, GetString(Resource.String.TwitSharingComment), ToastLength.Short).Show(); } }; auth.Error += (sender, eventArgs) => { Toast.MakeText(this, GetString(Resource.String.authfail), ToastLength.Short).Show(); var next = new Intent(this.ApplicationContext, typeof(ShopInfoActivity)); next.PutExtra("SHOP_ID_NUMBER", shopID); next.PutExtra("Local", local); StartActivity(next); Finish(); }; var ui = auth.GetUI(this); StartActivityForResult(ui, -1); } else { var cred = new LinqToTwitter.InMemoryCredentialStore(); cred.ConsumerKey = loggedInAccount.Properties["oauth_consumer_key"]; cred.ConsumerSecret = loggedInAccount.Properties["oauth_consumer_secret"]; cred.OAuthToken = loggedInAccount.Properties["oauth_token"]; cred.OAuthTokenSecret = loggedInAccount.Properties["oauth_token_secret"]; var auth0 = new LinqToTwitter.PinAuthorizer() { CredentialStore = cred, }; var TwitterCtx = new LinqToTwitter.TwitterContext(auth0); TwitterCtx.TweetAsync("#" + XMLShopContext.ShopName + "(#" + XMLShopContext.LocalNam + GetString(Resource.String.UnderShopdddd) + "\n" + GetString(Resource.String.SaleKind) + " " + XMLShopContext.Category + "\n" + GetString(Resource.String.MyRating) + " " + ratingbar.ToString() + "\n" + GetString(Resource.String.MyComment) + " " + et.Text); Toast.MakeText(this, GetString(Resource.String.TwitSharingComment), ToastLength.Short).Show(); } } else { AlertDialog.Builder dlg = new AlertDialog.Builder(this); dlg.SetTitle(GetString(Resource.String.InternetCheck)); dlg.SetMessage(GetString(Resource.String.InternetCheckMessage)); dlg.SetIcon(Resource.Drawable.AppIcon); dlg.SetPositiveButton(GetString(Resource.String.confirm), (s, o2) => { }); dlg.Show(); } }; twit_others_opinion.Click += (o, e) => { Android.Net.ConnectivityManager connectivityManager = (Android.Net.ConnectivityManager)GetSystemService(ConnectivityService); Android.Net.NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; bool isOnline = (activeConnection != null) && activeConnection.IsConnected; if (isOnline) { if (loggedInAccount == null) { Toast.MakeText(this, GetString(Resource.String.acquireLogin), ToastLength.Short).Show(); var auth = new OAuth1Authenticator( consumerKey: "qjXcnuCmZKPLU9Mupr0nkEcCv", consumerSecret: "q3c4nxTk1jqsLowujLxTmugsmdaLZFVq5cLI4SmWA1pRSlPcaD", requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"), accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"), callbackUrl: new Uri("http://www.hansei.ac.kr/")); //save the account data in the authorization completed even handler auth.Completed += (sender, eventArgs) => { if (eventArgs.IsAuthenticated) { loggedInAccount = eventArgs.Account; AccountStore.Create(this).Save(loggedInAccount, "UndertheShopTwitApp"); } if (loggedInAccount != null) { var ne = new Intent(this, typeof(SearchTwitter)); ne.PutExtra("keyword", "#" + XMLShopContext.ShopName); StartActivity(ne); } else { Toast.MakeText(this, GetString(Resource.String.authfail), ToastLength.Short).Show(); var next = new Intent(this.ApplicationContext, typeof(ShopInfoActivity)); next.PutExtra("SHOP_ID_NUMBER", shopID); next.PutExtra("Local", local); StartActivity(next); Finish(); } }; var ui = auth.GetUI(this); StartActivityForResult(ui, -1); } else { var ne = new Intent(this, typeof(SearchTwitter)); ne.PutExtra("keyword", "#" + XMLShopContext.ShopName); ne.PutExtra("SHOP_ID_NUMBER", shopID); ne.PutExtra("Local", local); StartActivity(ne); } } else { AlertDialog.Builder dlg = new AlertDialog.Builder(this); dlg.SetTitle(GetString(Resource.String.InternetCheck)); dlg.SetMessage(GetString(Resource.String.InternetCheckMessage)); dlg.SetIcon(Resource.Drawable.AppIcon); dlg.SetPositiveButton(GetString(Resource.String.confirm), (s, o2) => { }); dlg.Show(); } }; //twit_sharing.Click += (o, e) => { Tweet("#" + shopContext.ShopName + "(#"+shopContext.LocalNam+ GetString(Resource.String.UnderShopdddd) + "\n" + // GetString(Resource.String.SaleKind) +" " + shopContext.Category + "\n" + // GetString(Resource.String.MyRating) + " " + myRate.ToString() + "\n" + // GetString(Resource.String.MyComment) + " " + tv.Text , "Nothing"); }; //twit_others_opinion.Click += (o, e) => { // var next = new Intent(this, typeof(OthersOpinionActivity)); // next.PutExtra("ShopName", shopContext.ShopName); // StartActivity(next); //}; LinearLayout shopLoca = FindViewById <LinearLayout>(Resource.Id.shopLoca); shopLoca.Click += ShopLoca_Click; }