use of me.yluo.ruisiapp.widget.MySpinner in project Ruisi by freedom10086.
the class EditActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_topic);
Bundle b = getIntent().getExtras();
if (b != null) {
pid = b.getString("PID");
tid = b.getString("TID");
} else {
showToast("参数异常无法编辑");
}
myColorPicker = new MyColorPicker(this);
smileyPicker = new MySmileyPicker(this);
initToolBar(true, "编辑帖子");
typeidSpinner = new MySpinner(this);
View btnDone = addToolbarMenu(R.drawable.ic_done_black_24dp);
btnDone.setOnClickListener(view -> {
if (checkPostInput()) {
dialog = new ProgressDialog(EditActivity.this);
dialog.setMessage("提交中,请稍后......");
dialog.show();
startPost();
}
});
findViewById(R.id.forum_container).setVisibility(View.GONE);
typeIdContainer = findViewById(R.id.type_id_container);
typeIdContainer.setVisibility(View.GONE);
tvSelectType = findViewById(R.id.tv_select_type);
tvSelectType.setOnClickListener(this);
edTitle = findViewById(R.id.ed_title);
edContent = findViewById(R.id.ed_content);
typeidSpinner.setListener((pos, v) -> {
typeId = typeiddatas.get(pos).fid;
tvSelectType.setText(typeiddatas.get(pos).name);
});
final LinearLayout edit_bar = findViewById(R.id.edit_bar);
for (int i = 0; i < edit_bar.getChildCount(); i++) {
View c = edit_bar.getChildAt(i);
if (c instanceof ImageView) {
c.setOnClickListener(this);
}
}
Spinner setSize = findViewById(R.id.action_text_size);
setSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// [size=7][/size]
if (edContent == null || (edContent.getText().length() <= 0 && i == 0)) {
return;
}
handleInsert("[size=" + (i + 1) + "][/size]");
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
myColorPicker.setListener((pos, v, color) -> handleInsert("[color=" + color + "][/color]"));
EmotionInputHandler handler = new EmotionInputHandler(edContent, (enable, s) -> {
if (enable) {
btnDone.setVisibility(View.VISIBLE);
} else {
btnDone.setVisibility(View.INVISIBLE);
}
});
smileyPicker.setListener(handler::insertSmiley);
start_edit();
}
use of me.yluo.ruisiapp.widget.MySpinner in project Ruisi by freedom10086.
the class NewPostActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_topic);
initToolBar(true, "发表新帖");
if (getIntent().getExtras() != null) {
fid = getIntent().getExtras().getInt("FID");
title = getIntent().getExtras().getString("TITLE");
}
addToolbarMenu(R.drawable.ic_send_white_24dp).setOnClickListener(this);
myColorPicker = new MyColorPicker(this);
smileyPicker = new MySmileyPicker(this);
forumSpinner = new MySpinner(this);
typeidSpinner = new MySpinner(this);
typeIdContainer = findViewById(R.id.type_id_container);
typeIdContainer.setVisibility(View.GONE);
tvSelectForum = findViewById(R.id.tv_select_forum);
tvSelectType = findViewById(R.id.tv_select_type);
tvSelectForum.setOnClickListener(this);
tvSelectType.setOnClickListener(this);
edTitle = findViewById(R.id.ed_title);
edContent = findViewById(R.id.ed_content);
List<Category> categories = RuisUtils.getForums(this, true);
if (categories == null) {
showLongToast("读取板块列表出错,请确保assets目录有forums.json文件");
finish();
return;
}
for (Category c : categories) {
if (c.canPost) {
datas.addAll(c.forums);
}
}
if (TextUtils.isEmpty(title) || fid <= 0) {
title = datas.get(0).name;
fid = datas.get(0).fid;
}
tvSelectForum.setText(title);
forumSpinner.setData(datas);
forumSpinner.setListener((pos, v) -> {
fid = datas.get(pos).fid;
tvSelectForum.setText(datas.get(pos).name);
switchFid(fid);
});
typeidSpinner.setListener((pos, v) -> {
typeId = typeiddatas.get(pos).fid;
tvSelectType.setText(typeiddatas.get(pos).name);
});
final LinearLayout edit_bar = findViewById(R.id.edit_bar);
for (int i = 0; i < edit_bar.getChildCount(); i++) {
View c = edit_bar.getChildAt(i);
if (c instanceof ImageView) {
c.setOnClickListener(this);
}
}
Spinner setSize = findViewById(R.id.action_text_size);
setSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// [size=7][/size]
if (edContent == null || (edContent.getText().length() <= 0 && i == 0)) {
return;
}
handleInsert("[size=" + (i + 1) + "][/size]");
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
myColorPicker.setListener((pos, v, color) -> handleInsert("[color=" + color + "][/color]"));
handler = new EmotionInputHandler(edContent, (enable, s) -> {
});
smileyPicker.setListener((str, a) -> {
handler.insertSmiley(str, a);
});
findViewById(R.id.action_backspace).setOnLongClickListener(v -> {
int start = edContent.getSelectionStart();
int end = edContent.getSelectionEnd();
if (start == 0) {
return false;
}
if ((start == end) && start > 0) {
start = start - 5;
}
if (start < 0) {
start = 0;
}
edContent.getText().delete(start, end);
return true;
});
switchFid(fid);
checkValid();
}
Aggregations