Skip to content

Commit

Permalink
validation advancments
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikrao committed Dec 1, 2016
2 parents e2a25f1 + a1422a2 commit 1a79b65
Show file tree
Hide file tree
Showing 31 changed files with 437 additions and 362 deletions.
17 changes: 4 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.neosoft.neostore">


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Expand All @@ -12,22 +11,15 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".ui.RegisterScreen"
android:label="@string/title_activity_register_screen"
android:theme="@style/AppTheme"/>

android:label="@string/title_activity_register_screen" />
<activity
android:name=".ui.HomePage"
android:label="HomePage"
android:theme="@style/AppTheme"/>

android:name=".ui.HomeScreen"
android:label="HomeScreen" />
<activity
android:name=".ui.LoginActivity"

android:label="@string/title_activity_login"
android:theme="@style/AppTheme">
android:label="@string/title_activity_login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -36,6 +28,5 @@
<activity android:name=".ui.RegisterScreen"
android:label="RegisterActivity"
android:theme="@style/AppTheme"/>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class HomepageAdapter extends FragmentPagerAdapter {
private List<Fragment> fragments;

public HomepageAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ public class HomepageFragment extends Fragment {
public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
private View v;
private boolean imageloaded;

public static final HomepageFragment newInstance(int message) {
HomepageFragment f = new HomepageFragment();
Bundle bdl = new Bundle();
bdl.putString(EXTRA_MESSAGE, String.valueOf(message));
f.setArguments(bdl);
return f;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
String message = getArguments().getString(EXTRA_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,13 @@ public void setUserMsg(String userMsg) {
this.userMsg = userMsg;
}

@Override public String toString() {
return "LoginResponseModel{" +
"status=" + status +
", data=" + data +
", message='" + message + '\'' +
", userMsg='" + userMsg + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.neosoft.neostore.serviceapi;

import android.util.Log;

import com.neosoft.neostore.model.login.LoginResponseModel;
import com.neosoft.neostore.model.register.RegisterResponseModel;

import okhttp3.FormBody;
import okhttp3.RequestBody;

Expand Down Expand Up @@ -31,8 +35,8 @@ public void register(String fname, String lname, String email, String pass, Stri
.add("gender",gender)
.add("phone_no",ph_no)
.build();
Services ser = new Services(REGISTER_URL, requestBody, responseListener, null);
ser.execute(requestBody);
Services<RegisterResponseModel> ser = new Services<>(REGISTER_URL, requestBody, responseListener, RegisterResponseModel.class);
ser.execute();
}

}
14 changes: 10 additions & 4 deletions app/src/main/java/com/neosoft/neostore/serviceapi/Services.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.neosoft.neostore.serviceapi;

import android.os.AsyncTask;
import android.util.Log;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONException;
import org.json.JSONObject;

public class Services<U> extends AsyncTask<Void, Void, String> {

Expand All @@ -31,7 +36,7 @@ public Services(String url, RequestBody requestBody, ApiResponse apiResponse,
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).post(requestBody).build();
Response response = client.newCall(request).execute();
responseString = response.body().string();
responseString = response.body().string().toString();
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -42,11 +47,12 @@ public Services(String url, RequestBody requestBody, ApiResponse apiResponse,
super.onPostExecute(response);
int status = 0;
try {
status = new JSONObject(response).getInt("status");
status = (new JSONObject(response)).getInt("status");
} catch (JSONException e) {
e.printStackTrace();
}
if (status != 200) {
Log.e("zzzz",status+"");
apiResponse.onError("Error");
} else {
Gson gson = new Gson();
Expand Down
35 changes: 0 additions & 35 deletions app/src/main/java/com/neosoft/neostore/ui/HomePage.java

This file was deleted.

80 changes: 80 additions & 0 deletions app/src/main/java/com/neosoft/neostore/ui/HomeScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.neosoft.neostore.ui;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.neosoft.neostore.R;
import com.neosoft.neostore.adapter.HomepageAdapter;
import com.neosoft.neostore.fragment.HomepageFragment;

import java.util.ArrayList;
import java.util.List;

import me.relex.circleindicator.CircleIndicator;

public class HomeScreen extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
TextView mycart;
LinearLayout badge_layout;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer);
NavigationView navigationView = (NavigationView) findViewById(R.id.navlayout);
navigationView.setNavigationItemSelectedListener(this);
badge_layout = (LinearLayout) MenuItemCompat.getActionView(navigationView.getMenu().findItem(R.id.nav_mycart));
badge_layout.setGravity(Gravity.CENTER);
mycart = new TextView(this);
mycart.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mycart.setText("3");
mycart.setBackgroundResource(R.drawable.roundtextview);
mycart.setGravity(Gravity.CENTER);
mycart.setTextColor(getResources().getColor(R.color.colorWhite));
badge_layout.addView(mycart);
List<Fragment> fragments = getFragments();
HomepageAdapter pageAdapter = new HomepageAdapter(getSupportFragmentManager(), fragments);
ViewPager pager = (ViewPager) findViewById(R.id.viewpager);
pager.setAdapter(pageAdapter);
CircleIndicator indicator = (CircleIndicator) findViewById(R.id.indicator);
indicator.setBackgroundColor(Color.parseColor("#00000000"));
indicator.setViewPager(pager);
}

@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}

private List<Fragment> getFragments() {
List<Fragment> fList = new ArrayList<Fragment>();
fList.add(HomepageFragment.newInstance(R.drawable.furniture1));
fList.add(HomepageFragment.newInstance(R.drawable.furniture));
fList.add(HomepageFragment.newInstance(R.drawable.furniture2));
return fList;
}
}
33 changes: 0 additions & 33 deletions app/src/main/java/com/neosoft/neostore/ui/HomepageFragment.java

This file was deleted.

25 changes: 17 additions & 8 deletions app/src/main/java/com/neosoft/neostore/ui/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.neosoft.neostore.R;
import com.neosoft.neostore.model.login.LoginResponseModel;
Expand All @@ -20,9 +21,8 @@ public class LoginActivity extends Activity implements View.OnClickListener{
String email, pass;
Validate valid = new Validate();



@Override protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

editEmail = (EditText) findViewById(R.id.edtEmail);
Expand All @@ -36,21 +36,30 @@ public class LoginActivity extends Activity implements View.OnClickListener{
setContentView(R.layout.activity_login);
Button signup = (Button) findViewById(R.id.btn_login_signup);
signup.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, RegisterScreen.class);
startActivity(intent);
}
});
Button login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
final EditText editPassword = (EditText) findViewById(R.id.edtPass);

final EditText editEmail = (EditText) findViewById(R.id.edtEmail);

login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
GetServices apiServices = new GetServices();
apiServices.login("[email protected]", "abhijeet", new ApiResponse<LoginResponseModel>() {
@Override public void onSuccess(LoginResponseModel response) {
apiServices.login(editEmail.getText().toString(),editPassword.getText().toString(), new ApiResponse<LoginResponseModel>() {
@Override
public void onSuccess(LoginResponseModel response) {
Toast.makeText(getApplicationContext(),response.getMessage().toString(),Toast.LENGTH_LONG).show();
Log.e("zzz", response.toString());
}
@Override public void onError(String message) {

@Override
public void onError(String message) {
Log.e("zzz", message);
}
});
Expand Down
Loading

0 comments on commit 1a79b65

Please sign in to comment.