예제 #1
0
파일: confirmQ.cs 프로젝트: dscarr94/Loup
        public static confirmQ newInstance()
        {
            confirmQ fragment = new confirmQ();

            return(fragment);
        }
예제 #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            row = convertView;

            string dbPath_attributes = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "attributes.db3");
            var    db_attributes     = new SQLiteConnection(dbPath_attributes);

            var myAttributes = db_attributes.Get <MyAttributes>(1);
            int myCFID       = myAttributes.cfid;

            companyid = (position + 1).ToString();

            favoritesFileName = "fav_" + myCFID.ToString() + "_" + myAttributes.loginid.ToString();

            if (row == null)
            {
                row = LayoutInflater.From(mContext).Inflate(Resource.Layout.companieslistview_row, null, false);
            }

            TextView     companyName = row.FindViewById <TextView>(Resource.Id.companyName);
            ImageView    companyLogo = row.FindViewById <ImageView>(Resource.Id.companyLogo);
            LinearLayout companyInfo = row.FindViewById <LinearLayout>(Resource.Id.companyInfo);
            LinearLayout favorite    = row.FindViewById <LinearLayout>(Resource.Id.favorite);
            LinearLayout q_ll        = row.FindViewById <LinearLayout>(Resource.Id.q_ll);
            ImageView    star        = row.FindViewById <ImageView>(Resource.Id.star);

            companyName.Text = mItems[position];
            string fileName   = companyName.Text.ToLower().Replace(" ", "");
            int    resourceId = (int)typeof(Resource.Drawable).GetField(fileName).GetValue(null);

            companyLogo.SetImageResource(resourceId);

            isFavorite = mFavs[position];

            if (isFavorite == true)
            {
                star.SetImageResource(Resource.Drawable.starfilled);
            }
            else if (isFavorite == false)
            {
                star.SetImageResource(Resource.Drawable.starunfilled);
            }

            q_ll.Click += (sender, e) =>
            {
                Android.Support.V4.App.FragmentTransaction trans = ((FragmentActivity)mContext).SupportFragmentManager.BeginTransaction();
                Fragments.confirmQ fragment  = new Fragments.confirmQ();
                Bundle             arguments = new Bundle();
                arguments.PutInt("CompanyInt", position + 1);
                fragment.Arguments = arguments;
                trans.Replace(Resource.Id.companies_root_frame, fragment);
                trans.Commit();
            };

            favorite.Click += (sender, e) =>
            {
                if (isFavorite == true)
                {
                    star.SetImageResource(Resource.Drawable.starunfilled);
                    isFavorite      = false;
                    mFavs[position] = false;
                    UpdateIsFavorite(isFavorite, position + 1);
                }
                else if (isFavorite == false)
                {
                    star.SetImageResource(Resource.Drawable.starfilled);
                    isFavorite      = true;
                    mFavs[position] = true;
                    UpdateIsFavorite(isFavorite, position + 1);
                }
            };

            companyInfo.Click += (sender, e) =>
            {
                Android.Support.V4.App.FragmentTransaction trans = ((FragmentActivity)mContext).SupportFragmentManager.BeginTransaction();

                CompanyInfoFragment fragment = new CompanyInfoFragment();

                Bundle arguments = new Bundle();

                arguments.PutInt("CompanyInt", position + 1);

                arguments.PutString("Sender", "Companies");
                fragment.Arguments = arguments;
                trans.Replace(Resource.Id.companies_root_frame, fragment);

                trans.Commit();
            };

            return(row);
        }