Android Open Source - HomeMovies Rank Dialog






From Project

Back to project page HomeMovies.

License

The source code is released under:

MIT License

If you think the Android project HomeMovies listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package il.co.All4Students.homemovies.util.dialog;
//w  ww  . j  av a 2 s .c o  m
import static il.co.All4Students.homemovies.app.AppConstants.LOG_TAG_RankDialog;
import il.co.All4Students.homemovies.R;
import il.co.All4Students.homemovies.ScreenMain;
import il.co.All4Students.homemovies.core.Item;
import il.co.All4Students.homemovies.util.db.ItemsHandler;
import il.co.All4Students.homemovies.util.log.util.AppLog;
import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RatingBar;

/**
 * 
 * @author Arkadi Yoskovitz
 * @date 2013-02-08
 */
public class RankDialog {
  // Attributes
  private Context mContext;
  private RatingBar mRankBar;
  private Item mItem;

  // Constractors
  public RankDialog(Item item, Context context) {
    super();
    this.mItem = item;
    this.mContext = context;
  }

  // Additional Methods
  public void showRankDialog() {
    LayoutInflater li = LayoutInflater.from(mContext);

    View RankDialogView = li.inflate(R.layout.custom_dialog_rank, null);

    AlertDialog.Builder rankDialog = new AlertDialog.Builder(mContext);
    rankDialog.setView(RankDialogView);
    rankDialog.setTitle(mContext.getResources().getString(
        R.string.RankDialogTitle));
    rankDialog.setTitle(mContext.getResources().getString(
        R.string.RankDialogMsg));
    rankDialog.create();

    // Showing Alert Message
    final AlertDialog RDialog = rankDialog.show();

    mRankBar = (RatingBar) RankDialogView
        .findViewById(R.id.customDialogRankBar);
    mRankBar.setRating(((float) mItem.getRank()) / 10);
    View btnCancel = RankDialogView
        .findViewById(R.id.customDialogRankButtonCancel);
    btnCancel.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        RDialog.dismiss();
      }
    });

    View btnCommit = RankDialogView
        .findViewById(R.id.customDialogRankButtonCommit);

    btnCommit.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        mItem.setRank((int) (mRankBar.getRating() * 10));

        AppLog.log(mContext, LOG_TAG_RankDialog,
            Integer.valueOf(mItem.getRank()).toString());

        ItemsHandler itemHandler = new ItemsHandler(mContext);
        itemHandler.updateItem(mItem);

        if (mContext instanceof ScreenMain) {
          ((ScreenMain) mContext).refreshList();
        }
        RDialog.dismiss();
      }
    });
  }
}




Java Source Code List

il.co.All4Students.homemovies.OkCancelBar.java
il.co.All4Students.homemovies.ScreenEdit.java
il.co.All4Students.homemovies.ScreenGridDetail.java
il.co.All4Students.homemovies.ScreenGrid.java
il.co.All4Students.homemovies.ScreenMain.java
il.co.All4Students.homemovies.ScreenPreferences.java
il.co.All4Students.homemovies.ScreenWeb.java
il.co.All4Students.homemovies.app.AppConstants.java
il.co.All4Students.homemovies.app.ApplicationPreference.java
il.co.All4Students.homemovies.app.HomeProjectApplication.java
il.co.All4Students.homemovies.core.ItemCompareRTID.java
il.co.All4Students.homemovies.core.ItemCompareRank.java
il.co.All4Students.homemovies.core.ItemCompareSubject.java
il.co.All4Students.homemovies.core.Item.java
il.co.All4Students.homemovies.util.adapter.ItemListAdapter.java
il.co.All4Students.homemovies.util.adapter.ScreenGridAdapter.java
il.co.All4Students.homemovies.util.app.AppUtil.java
il.co.All4Students.homemovies.util.db.ItemsDbConstants.java
il.co.All4Students.homemovies.util.db.ItemsDbHelper.java
il.co.All4Students.homemovies.util.db.ItemsHandler.java
il.co.All4Students.homemovies.util.dialog.RankDialog.java
il.co.All4Students.homemovies.util.dialog.ShareDialog.java
il.co.All4Students.homemovies.util.email.EmailUtil.java
il.co.All4Students.homemovies.util.image.ExternalStorageLoader.java
il.co.All4Students.homemovies.util.imageWeb.FileCache.java
il.co.All4Students.homemovies.util.imageWeb.ImageLoader.java
il.co.All4Students.homemovies.util.imageWeb.MemoryCache.java
il.co.All4Students.homemovies.util.json.JSONHandler.java
il.co.All4Students.homemovies.util.json.JSONUtilWithTags.java
il.co.All4Students.homemovies.util.json.JSONUtil.java
il.co.All4Students.homemovies.util.log.db.LogDbConstants.java
il.co.All4Students.homemovies.util.log.db.LogDbHelper.java
il.co.All4Students.homemovies.util.log.db.LogHandler.java
il.co.All4Students.homemovies.util.log.util.AppLog.java