コード例 #1
0
  /*
   * Save and continue click action
   */
  public void saveANDcontinue(View view) {
    selectedInterestIndices = new ArrayList<Integer>();
    for (int i = 0; i < interests.length; i++) {
      if (defaultRenderer.getSeriesRendererAt(i).isHighlighted()) {
        selectedInterestIndices.add(interests[i].id);
      }
    }

    new MemberProfile()
        .storeSpecialInterests(
            new ICallBack() {
              @Override
              public void callBackResultHandler(Object object) {
                Intent intent = new Intent(mContext, GenderSelectionActivity.class);
                startActivity(intent);
                finish();
              }

              @Override
              public void callBackErrorHandler(Object object) {}
            },
            SessionManager.getInstance().getUserId(),
            new JSONArray(selectedInterestIndices).toString());
  }
コード例 #2
0
ファイル: MyBlogActivity.java プロジェクト: bdlions/sonutuapp
  public void initUi() {

    userId = SessionManager.getInstance().getUserId();

    stk = (TableLayout) findViewById(R.id.table_main);
    pDiler = new ProgressDialog(mComtext);
    pDiler.setMessage("Loading data...");
    pDiler.setCancelable(false);
    pDiler.show();
    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();

    BlogsApp blogApp = new BlogsApp();
    blogApp.getMyBlogList(
        new ICallBack() {

          @Override
          public void callBackResultHandler(Object object) {
            JSONObject myBlogListObj = (JSONObject) object;
            try {
              pDiler.dismiss();
              JSONArray blogListJsonArray = myBlogListObj.getJSONArray("my_blog_list");
              Gson gson = new Gson();
              int total_blog = blogListJsonArray.length();
              for (int i = 0; i < total_blog; i++) {
                MyBlog myBlog = gson.fromJson(blogListJsonArray.get(i).toString(), MyBlog.class);

                tbrow = new TableRow(mComtext);
                tbrow.setLayoutParams(
                    new LayoutParams(
                        android.view.ViewGroup.LayoutParams.FILL_PARENT,
                        android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
                t1v = new TextView(mComtext);
                t2v = new TextView(mComtext);
                t3v = new TextView(mComtext);
                t4v = new TextView(mComtext);

                // add first column
                String title = myBlog.getTitle();
                if (title.length() > 10) {
                  title = title.substring(0, 10);
                }
                t1v.setText(title);
                t1v.setTextColor(Color.parseColor("#000000"));
                t1v.setGravity(Gravity.CENTER);
                tbrow.addView(t1v);

                // add second column
                t2v.setText(myBlog.getStatus_title());
                t2v.setTextColor(Color.parseColor("#000000"));
                t2v.setGravity(Gravity.CENTER);
                tbrow.addView(t2v);

                // add third column
                final int blogId = myBlog.getBlog_id();
                t3v.setText("Edit");
                t3v.setClickable(true);
                t3v.setTextColor(Color.parseColor("#00acea"));
                t3v.setGravity(Gravity.CENTER);
                tbrow.addView(t3v);
                t3v.setOnClickListener(
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        Intent i = new Intent(MyBlogActivity.this, EditBlogActivity.class);
                        i.putExtra("blog_id", blogId);
                        startActivity(i);
                      }
                    });

                // add fourth column
                t4v.setText("Delete");
                t4v.setTextColor(Color.parseColor("#00acea"));
                t4v.setGravity(Gravity.CENTER);

                t4v.setOnClickListener(
                    new OnClickListener() {
                      @SuppressWarnings("deprecation")
                      @Override
                      public void onClick(View v) {
                        alertDialog.setTitle("Delete Blog");
                        alertDialog.setMessage("Are you sure about deleting this blog?");
                        alertDialog.setButton2(
                            "YES",
                            new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                // Toast.makeText(getApplicationContext(),"well come", 1).show();
                                deleteBlog(blogId);
                              }
                            });
                        alertDialog.setButton(
                            "NO",
                            new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {}
                            });
                        // Set the Icon for the Dialog
                        alertDialog.setIcon(R.drawable.fail);
                        alertDialog.show();
                      }
                    });

                // table row dynamically
                tbrow.addView(t4v);
                stk.addView(tbrow);
              }
            } catch (JSONException e) { // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }

          @Override
          public void callBackErrorHandler(Object object) {
            System.out.print(object);
          }
          // here the user id will be dynamic according to logged-in user
        },
        userId);
  }