-
Notifications
You must be signed in to change notification settings - Fork 0
/
SixthActivity.java
143 lines (126 loc) · 5.79 KB
/
SixthActivity.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
package test.ojassoft.com.ys;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import de.hdodenhof.circleimageview.CircleImageView;
/**
* Created by ojas-20 on 12/7/18.
*/
public class SixthActivity extends AppCompatActivity {
Toolbar toolbar;
DrawerLayout drawerLayout;
CircleImageView circleImageView;
TextView textView;
TextView textView1;
ProgressDialog pd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sixth);
circleImageView=(CircleImageView) findViewById(R.id.circle);
textView=(TextView) findViewById(R.id.textview);
textView1=(TextView) findViewById(R.id.textview1);
pd=new ProgressDialog(SixthActivity.this);
pd.setTitle("Loading Activity");
pd.setMessage("Please Wait ...");
pd.setMax(5);
pd.setIndeterminate(false);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_dehaze_black_24dp);
toolbar.setTitle("SHOPPING.COM");
setSupportActionBar(toolbar);
try {
Fragment fr = new ThirdFragment();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.frame, fr);
transaction.commit();
} catch (Exception e) {
Log.i("", e.getMessage());
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
drawerLayout.openDrawer(Gravity.LEFT);
}
});
setNavigationDrawer();
}
private void setNavigationDrawer(){
drawerLayout=(DrawerLayout) findViewById(R.id.drawerLayout);
NavigationView navigationView=(NavigationView) findViewById(R.id.navigationView);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
new AsyncTask<Integer, Long, Boolean>() {
@Override
protected Boolean doInBackground(Integer... params) {
publishProgress(0L);
long start = System.currentTimeMillis();
long waitTime = params[0] * 1000;
try {
while (System.currentTimeMillis() - start < waitTime) {
Thread.sleep(500);
publishProgress(System.currentTimeMillis() - start);
}
} catch (Exception e) {
return false;
}
return true;
}
@Override
protected void onProgressUpdate(Long... values) {
if (values[0] == 0) {
pd.show();
} else {
pd.setProgress((int) (values[0] / 1000));
}
}
@Override
protected void onPostExecute(Boolean result) {
pd.dismiss();
int itemId=menuItem.getItemId();
switch (itemId) {
case R.id.first:
Intent intent = new Intent(getApplicationContext(), FourthActivity.class);
startActivity(intent);
break;
case R.id.second:
Intent intent1 = new Intent(getApplicationContext(), FifthActivity.class);
startActivity(intent1);
break;
case R.id.third:
Intent intent2 = new Intent(getApplicationContext(), SixthActivity.class);
startActivity(intent2);
break;
case R.id.fourth:
Intent intent3 = new Intent(getApplicationContext(), SeventhActivity.class);
startActivity(intent3);
break;
case R.id.fifth:
Intent intent4 = new Intent(getApplicationContext(), EigthActivity.class);
startActivity(intent4);
break;
case R.id.sixth:
Intent intent5 = new Intent(getApplicationContext(), NinthActivity.class);
startActivity(intent5);
break;
case R.id.seventh:
Intent intent6=new Intent(getApplicationContext(),LoginActivity.class);
startActivity(intent6);
break;
}}}.execute(5);return false;}});}}