Compare commits

...

19 Commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,161 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.RelativeLayout;
import net.micode.notes.R;
import net.micode.notes.model.SkinInfo;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class SkinActivity extends Activity {
private SharedPreferences mSharedPreferences;
private SkinListAdapter mListAdapter;
private GridView gridView;
private List<SkinInfo> mSkinInfoList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_skin);
gridView = (GridView) findViewById(R.id.gridView);
mSharedPreferences = getSharedPreferences("skin_info", MODE_PRIVATE);
//定义皮肤
mSkinInfoList.add(new SkinInfo(0, getResources().getColor(R.color.color_4963F4)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor( R.color.color_3372e4)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor(R.color.color_673AB7)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor( R.color.color_4CAF50)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor(R.color.color_00BCD4)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor( R.color.color_9C27B0)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor( R.color.color_3F51B5)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor(R.color.color_009688)));
mSkinInfoList.add(new SkinInfo(0, getResources().getColor(R.color.color_FF9800)));
//初始化适配器
mListAdapter =new SkinListAdapter(SkinActivity.this);
//设置adapter
gridView.setAdapter(mListAdapter);
//设置数据
mListAdapter.setList(mSkinInfoList);
//选中
int current_position = mSharedPreferences.getInt("current_position", 0);
if (current_position != 0) {
mListAdapter.setCurrentIndex(current_position);
}
//点击事件处理选中的颜色
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, final int position, long l) {
final SkinInfo skinInfo = (SkinInfo) gridView.getAdapter().getItem(position);
mListAdapter.setCurrentIndex(position);
AlertDialog.Builder builder =new AlertDialog.Builder(SkinActivity.this);
builder.setTitle("操作");
builder.setMessage("确定一键换肤吗?");
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//实现换肤
SharedPreferences.Editor edit = mSharedPreferences.edit();
edit.putInt("skin_mode", skinInfo.getColorId());
edit.putInt("current_position", position);
edit.commit();
setResult(2000);
finish();
}
});
builder.show();
}
});
}
class SkinListAdapter extends BaseAdapter{
private int currentIndex = 0;
private List<SkinInfo> mSkinInfoList=new ArrayList<>();
private LayoutInflater mLayoutInflater;
public SkinListAdapter(Context context){
mLayoutInflater =LayoutInflater.from(context);
}
public void setList(List<SkinInfo> list){
this.mSkinInfoList =list;
notifyDataSetChanged();
}
@Override
public int getCount() {
return mSkinInfoList.size();
}
@Override
public SkinInfo getItem(int i) {
return mSkinInfoList.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view =mLayoutInflater.inflate(R.layout.skin_list_item,viewGroup,false);
RelativeLayout checkbox = (RelativeLayout) view.findViewById(R.id.checkbox);
View color_line =view.findViewById(R.id.color_line);
SkinInfo item = getItem(i);
color_line.setBackgroundColor(item.getColorId());
if (currentIndex ==i){
checkbox.setVisibility(View.VISIBLE);
}else {
checkbox.setVisibility(View.GONE);
}
return view;
}
public void setCurrentIndex(int position) {
this.currentIndex = position;
notifyDataSetChanged();
}
}
}

@ -0,0 +1,29 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import net.micode.notes.R;
public class SplashActivity extends Activity {
Handler mHandler=new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// 当计时结束时跳转至NotesListActivity
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent();
intent.setClass(SplashActivity.this, NotesListActivity.class);
startActivity(intent);
finish(); //销毁欢迎页面
}
}, 2000); // 2 秒后跳转
}
}
Loading…
Cancel
Save