Android Open Source - CallLog Hotline Setting Activity






From Project

Back to project page CallLog.

License

The source code is released under:

GNU General Public License

If you think the Android project CallLog 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 com.kaosh.calllog;
//  www  . j  a  v a2s  .  c  o m
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class HotlineSettingActivity extends Activity {
  
  HotlineAdapter mAdapter;
  ArrayList<HotlineObj> mData;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hotline_setting);
    
    mData = new ArrayList<HotlineObj>();
    Hotline.get_hotlines(this, mData);
    mAdapter = new HotlineAdapter(this, mData, R.layout.hotline_item);
    
    ListView listView = (ListView) findViewById (R.id.listView);
    listView.setAdapter(mAdapter);
    
    Button addButton = (Button) findViewById (R.id.addButton);
    final EditText numberText = (EditText) findViewById (R.id.number);
    final EditText rateText = (EditText) findViewById (R.id.rate);
    
    addButton.setOnClickListener(new Button.OnClickListener(){

      @Override
      public void onClick(View arg0) {
        float rate = Float.parseFloat(rateText.getText().toString());
        String number = numberText.getText().toString();
        
        Hotline.add(HotlineSettingActivity.this, number, rate);
        numberText.setText("");
        rateText.setText("");

        Hotline.get_hotlines(HotlineSettingActivity.this, mData);
        mAdapter.notifyDataSetChanged();
      }
      
    });

        registerForContextMenu (listView);
  }


    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, v, menuInfo);
      getMenuInflater().inflate(R.menu.context_menu, menu);
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      switch (item.getItemId()) {
        case R.id.delete:
          Hotline.delete(this, mData.get(info.position).mNumber);
        Hotline.get_hotlines(HotlineSettingActivity.this, mData);
          mAdapter.notifyDataSetChanged();
          return true;
        default:
          return super.onContextItemSelected(item);
      }
    }
}




Java Source Code List

com.kaosh.calllog.CallLogActivity.java
com.kaosh.calllog.CallLogWidget.java
com.kaosh.calllog.DatabaseOpenHelper.java
com.kaosh.calllog.HotlineAdapter.java
com.kaosh.calllog.HotlineObj.java
com.kaosh.calllog.HotlineSettingActivity.java
com.kaosh.calllog.Hotline.java
com.kaosh.calllog.NPAdapter.java
com.kaosh.calllog.NPObj.java
com.kaosh.calllog.NPSettingActivity.java
com.kaosh.calllog.NP.java
com.kaosh.calllog.PhoneLog.java
com.kaosh.calllog.PhoneUtils.java
com.kaosh.calllog.RateSettingActivity.java
com.kaosh.calllog.SMSLog.java
com.kaosh.calllog.Utils.java