Android Open Source - blink Edit Name Dialog Fragment From Project Back to project page blink .
License The source code is released under:
Apache License
If you think the Android project blink 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.nashlincoln.blink.ui;
/ / f r o m w w w . j a v a 2 s . c o m
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.nashlincoln.blink.R;
import com.nashlincoln.blink.app.BlinkApp;
import com.nashlincoln.blink.content.Syncro;
import com.nashlincoln.blink.model.Device;
/**
* Created by nash on 11/10/14.
*/
public class EditNameDialogFragment extends DialogFragment {
private String mName;
private long mId;
private Device mDevice;
private EditText nameView;
public static DialogFragment newInstance(Long id) {
EditNameDialogFragment fragment = new EditNameDialogFragment();
Bundle args = new Bundle();
args.putLong(BlinkApp.EXTRA_ID, id);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null && getArguments().containsKey(BlinkApp.EXTRA_ID)) {
mId = getArguments().getLong(BlinkApp.EXTRA_ID);
mDevice = BlinkApp.getDaoSession().getDeviceDao().load(mId);
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View header = View.inflate(getActivity(), R.layout.edit_text_dialog, null);
nameView = (EditText) header.findViewById(R.id.edit_text);
if (mDevice != null) {
nameView.setText(mDevice.getName());
}
builder.setTitle("Name" )
.setView(header)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = nameView.getText().toString();
if (mDevice != null && !TextUtils.isEmpty(name)) {
mDevice.setName(name, true);
Syncro.getInstance().syncDevices();
}
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
return builder.create();
}
}
Java Source Code List com.nashlincoln.blink.ApplicationTest.java com.nashlincoln.blink.app.BlinkApp.java com.nashlincoln.blink.app.FragmentPagerAdapter.java com.nashlincoln.blink.app.NetworkReceiver.java com.nashlincoln.blink.app.PreferenceUtils.java com.nashlincoln.blink.content.Command.java com.nashlincoln.blink.content.DeviceLoader.java com.nashlincoln.blink.content.DeviceTypeLoader.java com.nashlincoln.blink.content.GroupLoader.java com.nashlincoln.blink.content.ModelLoader.java com.nashlincoln.blink.content.SceneLoader.java com.nashlincoln.blink.content.Syncro.java com.nashlincoln.blink.event.Event.java com.nashlincoln.blink.event.Status.java com.nashlincoln.blink.event.Type.java com.nashlincoln.blink.model.AttributeDao.java com.nashlincoln.blink.model.AttributeTypeDao.java com.nashlincoln.blink.model.AttributeType.java com.nashlincoln.blink.model.Attribute.java com.nashlincoln.blink.model.DaoMaster.java com.nashlincoln.blink.model.DaoSession.java com.nashlincoln.blink.model.DeviceDao.java com.nashlincoln.blink.model.DeviceTypeDao.java com.nashlincoln.blink.model.DeviceType.java com.nashlincoln.blink.model.Device.java com.nashlincoln.blink.model.GroupDao.java com.nashlincoln.blink.model.GroupDeviceDao.java com.nashlincoln.blink.model.GroupDevice.java com.nashlincoln.blink.model.Group.java com.nashlincoln.blink.model.SceneDao.java com.nashlincoln.blink.model.SceneDeviceDao.java com.nashlincoln.blink.model.SceneDevice.java com.nashlincoln.blink.model.Scene.java com.nashlincoln.blink.model.TimerDao.java com.nashlincoln.blink.model.Timer.java com.nashlincoln.blink.network.BlinkApiInterface.java com.nashlincoln.blink.network.BlinkApi.java com.nashlincoln.blink.nfc.NfcCommand.java com.nashlincoln.blink.nfc.NfcUtils.java com.nashlincoln.blink.ui.AddDeviceFragment.java com.nashlincoln.blink.ui.BlinkActivity.java com.nashlincoln.blink.ui.BlinkListFragment.java com.nashlincoln.blink.ui.DeviceListFragment.java com.nashlincoln.blink.ui.EditListActivity.java com.nashlincoln.blink.ui.EditListFragment.java com.nashlincoln.blink.ui.EditNameDialogFragment.java com.nashlincoln.blink.ui.GroupListFragment.java com.nashlincoln.blink.ui.SceneListFragment.java com.nashlincoln.blink.ui.SettingsActivity.java com.nashlincoln.blink.widget.DeviceSummary.java com.nashlincoln.blink.widget.SlidingTabLayout.java com.nashlincoln.blink.widget.SlidingTabStrip.java com.nashlincoln.dao.Generator.java