-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathMainActivity.java
executable file
·152 lines (123 loc) · 6.15 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* Copyright 2015 Rudson Lima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.liveo.ndrawer.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
import br.liveo.interfaces.OnItemClickListener;
import br.liveo.interfaces.OnPrepareOptionsMenuLiveo;
import br.liveo.model.HelpLiveo;
import br.liveo.navigationliveo.NavigationLiveo;
import br.liveo.ndrawer.R;
import br.liveo.ndrawer.ui.fragment.MainFragment;
import br.liveo.ndrawer.ui.fragment.ViewPagerFragment;
public class MainActivity extends NavigationLiveo implements OnItemClickListener {
private HelpLiveo mHelpLiveo;
@Override
public void onInt(Bundle savedInstanceState) {
// User Information
this.userName.setText("Rudson Lima");
this.userEmail.setText("rudsonlive@gmail.com");
this.userPhoto.setImageResource(R.drawable.ic_rudsonlive);
this.userBackground.setImageResource(R.drawable.ic_user_background_first);
// Creating items navigation
mHelpLiveo = new HelpLiveo();
mHelpLiveo.add(getString(R.string.inbox), R.drawable.ic_inbox_black_24dp, 7);
mHelpLiveo.addSubHeader(getString(R.string.categories)); //Item subHeader
mHelpLiveo.add(getString(R.string.starred), R.drawable.ic_star_black_24dp);
mHelpLiveo.add(getString(R.string.sent_mail), R.drawable.ic_send_black_24dp);
mHelpLiveo.addNoCheck(getString(R.string.drafts), R.drawable.ic_drafts_black_24dp);
mHelpLiveo.addSeparator(); //Item separator
mHelpLiveo.add(getString(R.string.trash), R.drawable.ic_delete_black_24dp);
mHelpLiveo.add(getString(R.string.spam), R.drawable.ic_report_black_24dp, 120);
//{optional} - Header Customization - method customHeader
//View mCustomHeader = getLayoutInflater().inflate(R.layout.custom_header_user, this.getListView(), false);
//ImageView imageView = (ImageView) mCustomHeader.findViewById(R.id.imageView);
with(this).startingPosition(2) //Starting position in the list
.addAllHelpItem(mHelpLiveo.getHelp())
//{optional} - List Customization "If you remove these methods and the list will take his white standard color"
//.selectorCheck(R.drawable.selector_check) //Inform the background of the selected item color
//.colorItemDefault(R.color.nliveo_blue_colorPrimary) //Inform the standard color name, icon and counter
.colorItemSelected(R.color.nliveo_blue_colorPrimary) //State the name of the color, icon and meter when it is selected
//.backgroundList(R.color.nliveo_black_light) //Inform the list of background color
//.colorLineSeparator(R.color.nliveo_transparent) //Inform the color of the subheader line
//{optional} - SubHeader Customization
//.colorNameSubHeader(R.color.nliveo_blue_colorPrimary)
//.colorLineSeparator(R.color.nliveo_green_colorPrimaryDark)
//.removeFooter()
.footerItem(R.string.settings, R.drawable.ic_settings_black_24dp)
//{optional} - Second footer
//.footerSecondItem(R.string.settings, R.drawable.ic_settings_black_24dp)
//{optional} - Header Customization
//.customHeader(mCustomHeader)
//{optional} - Footer Customization
//.footerNameColor(R.color.nliveo_blue_colorPrimary)
//.footerIconColor(R.color.nliveo_blue_colorPrimary)
//.footerSecondNameColor(R.color.nliveo_blue_colorPrimary)
//.footerSecondIconColor(R.color.nliveo_blue_colorPrimary)
//.footerBackground(R.color.nliveo_white)
//{optional} - Remove color filter icon
//.removeColorFilter()
.setOnClickUser(onClickPhoto)
.setOnPrepareOptionsMenu(onPrepare)
.setOnClickFooter(onClickFooter)
//{optional} - Second footer
//.setOnClickFooterSecond(onClickFooter)
.build();
int position = this.getCurrentPosition();
this.setElevationToolBar(position != 2 ? 15 : 0);
}
@Override
public void onItemClick(int position) {
Fragment mFragment;
FragmentManager mFragmentManager = getSupportFragmentManager();
switch (position){
case 2:
mFragment = new ViewPagerFragment();
break;
default:
mFragment = MainFragment.newInstance(mHelpLiveo.get(position).getName());
break;
}
if (mFragment != null){
mFragmentManager.beginTransaction().replace(R.id.container, mFragment).commit();
}
setElevationToolBar(position != 2 ? 15 : 0);
}
private OnPrepareOptionsMenuLiveo onPrepare = new OnPrepareOptionsMenuLiveo() {
@Override
public void onPrepareOptionsMenu(Menu menu, int position, boolean visible) {
}
};
private View.OnClickListener onClickPhoto = new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "onClickPhoto :D", Toast.LENGTH_SHORT).show();
closeDrawer();
}
};
private View.OnClickListener onClickFooter = new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
closeDrawer();
}
};
}