Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Home);

            // get the userId
            Bundle bundleUser = Intent.Extras;

            userId = bundleUser.GetInt("userId");

            // initiate views
            initView();

            // get all the articles from database
            articleListData         = articleDB.GetAriticles();
            articleAdapter          = new ArticleListViewAdapter(this, articleListData);
            articleListView.Adapter = articleAdapter;

            // click event handler on each article item
            articleListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                Article article = articleListData[(int)e.Id];
                Intent  intent  = new Intent(this, typeof(ArticleDetailActivity));
                Bundle  bundle  = new Bundle();
                bundle.PutInt("Article", article.article_id);
                bundle.PutInt("User", userId);
                intent.PutExtras(bundle);
                StartActivity(intent);
            };

            // call menuBar method to handle menu buttons click events
            menuBar();
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MyProfile);

            // get the userId
            Bundle bundleUser = Intent.Extras;

            userId = bundleUser.GetInt("userId");

            // initiate the views
            initView();

            // get the username and show it
            var username = UsersDB.Users.GetUserById(userId).username;

            txtUsername.Text = username;

            // call the menuBar method to handle menu buttons click events
            menuBar();

            // logout button click event handler
            btnLogout.Click += (object sender, EventArgs e) => {
                Intent intent = new Intent(this, typeof(MainActivity));
                bundleUser.Clear();
                StartActivity(intent);
            };

            // get articles by user
            myPosts = ArticleDB.Articles.GetArticleByUser(userId);
            adapter = new ArticleListViewAdapter(this, myPosts);
            myPostListView.Adapter = adapter;

            myPostListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                Article article = myPosts[(int)e.Id];
                Intent  intent  = new Intent(this, typeof(ArticleDetailActivity));
                Bundle  bundle  = new Bundle();
                bundle.PutInt("Article", article.article_id);
                bundle.PutInt("User", userId);
                intent.PutExtras(bundle);
                StartActivity(intent);
            };
        }