Preyea Regmi
5 years ago
18 changed files with 81 additions and 1068 deletions
-
BIN.idea/caches/build_file_checksums.ser
-
3app/build.gradle
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/base/UIStateHandler.java
-
48app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/GMEBranchesContract.java
-
174app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/adapter/GmeBranchAdapter.java
-
37app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/model/GMEBranchesModel.java
-
51app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/model/data/Branch.java
-
45app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/model/data/PayoutLocationData.java
-
70app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/presenter/GmeBranchesPresenter.java
-
174app/src/main/java/com/gmeremit/online/gmeremittance_native/gme_branches/view/GmeBranchesActivity.java
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/gateway/HomeV2Gateway.java
-
94app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java
-
164app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeFragmentV2.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/reward_points/view/RewardPointsShippingActivity.java
-
40app/src/main/java/com/gmeremit/online/gmeremittance_native/socials/view/NewSocialPostActivity.java
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java
-
232app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/CreatePdf.java
-
2app/src/main/res/layout/activity_gme_branches.xml
@ -1,48 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.https.APIRequestErrorReturn; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
/** |
|
||||
* Created by surajshrestha on 2/7/18. |
|
||||
*/ |
|
||||
|
|
||||
public class GMEBranchesContract { |
|
||||
|
|
||||
public interface IBase { |
|
||||
void showGeneralDialog(String title, String message, String type); |
|
||||
} |
|
||||
|
|
||||
public interface GMEBranchesView extends IBase { |
|
||||
|
|
||||
void updateLayout(List<PayoutLocationData> body); |
|
||||
|
|
||||
void showProgressDialog(); |
|
||||
|
|
||||
void dismissProgressDialog(); |
|
||||
} |
|
||||
|
|
||||
public interface GMEBranchesPresenter { |
|
||||
|
|
||||
void gmeBranches(); |
|
||||
} |
|
||||
|
|
||||
public interface GMEBranchesModel { |
|
||||
|
|
||||
void requestGMEBranches(GMEBranchesListener gmeBranchesListener, Map<String, String> param); |
|
||||
} |
|
||||
|
|
||||
public interface GMEBranchesListener { |
|
||||
|
|
||||
void onSuccessReponse(List<PayoutLocationData> body); |
|
||||
|
|
||||
void onFailure(APIRequestErrorReturn statusErrorReturn); |
|
||||
|
|
||||
void onFailureException(Throwable t); |
|
||||
|
|
||||
void onNoInternetConnection(); |
|
||||
} |
|
||||
} |
|
@ -1,174 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.adapter; |
|
||||
|
|
||||
import android.content.Context; |
|
||||
import android.content.Intent; |
|
||||
import android.net.Uri; |
|
||||
import android.support.v7.widget.RecyclerView; |
|
||||
import android.view.LayoutInflater; |
|
||||
import android.view.View; |
|
||||
import android.view.ViewGroup; |
|
||||
import android.widget.Filter; |
|
||||
import android.widget.Filterable; |
|
||||
import android.widget.ImageView; |
|
||||
import android.widget.SectionIndexer; |
|
||||
import android.widget.Toast; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.R; |
|
||||
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.Branch; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.Arrays; |
|
||||
import java.util.List; |
|
||||
import java.util.Locale; |
|
||||
|
|
||||
import butterknife.BindView; |
|
||||
import butterknife.ButterKnife; |
|
||||
|
|
||||
/** |
|
||||
* Created by frantic on 1/24/18. |
|
||||
*/ |
|
||||
|
|
||||
public class GmeBranchAdapter extends RecyclerView.Adapter<GmeBranchAdapter.MyHolder> implements SectionIndexer, Filterable { |
|
||||
List<Branch> branchList = new ArrayList<>(); |
|
||||
List<Branch> searchList = new ArrayList<>(); |
|
||||
private ArrayList<Integer> mSectionPositions; |
|
||||
String[] alphabet = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z","#"}; |
|
||||
List<String> arr = Arrays.asList(alphabet); |
|
||||
BranchFilter branchFilter; |
|
||||
private Context context; |
|
||||
|
|
||||
public GmeBranchAdapter(List<Branch> branchList) { |
|
||||
this.branchList = branchList; |
|
||||
this.searchList = branchList; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
|
||||
this.context = parent.getContext(); |
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_gme_branch_item, null); |
|
||||
return new MyHolder(view); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onBindViewHolder(final MyHolder holder, int position) { |
|
||||
final Branch branch = branchList.get(position); |
|
||||
holder.tvTitle.setText(branch.title); |
|
||||
holder.tvAddress.setText(branch.address); |
|
||||
holder.tvTelephone.setText("Phone No. " + branch.telephone); |
|
||||
if (branch.info != null) { |
|
||||
holder.tvInfo.setText(" (" + branch.info + ")"); |
|
||||
} |
|
||||
holder.ivLocation.setOnClickListener(new View.OnClickListener() { |
|
||||
@Override |
|
||||
public void onClick(View view) { |
|
||||
// Toast.makeText(holder.itemView.getContext(), "CLicked"+branch.lat+" - "+branch.lng, Toast.LENGTH_SHORT).show(); |
|
||||
if (branch.lat != 0.0 && branch.lng != 0.0) { |
|
||||
openMap(holder.itemView.getContext(), branch.lat, branch.lng); |
|
||||
} else { |
|
||||
Toast.makeText(context, "No Location Available", Toast.LENGTH_LONG).show(); |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public int getItemCount() { |
|
||||
return branchList.size(); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
@Override |
|
||||
public long getItemId(int position) { |
|
||||
return position; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Object[] getSections() { |
|
||||
List<String> sections = new ArrayList<>(); |
|
||||
mSectionPositions = new ArrayList<>(); |
|
||||
for (int i = 0, size = arr.size(); i < size; i++) { |
|
||||
String section = String.valueOf(arr.get(i)).toUpperCase(); |
|
||||
if (!sections.contains(section)) { |
|
||||
sections.add(section); |
|
||||
mSectionPositions.add(i); |
|
||||
} |
|
||||
} |
|
||||
return sections.toArray(new String[0]); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public int getPositionForSection(int i) { |
|
||||
return mSectionPositions.get(i); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public int getSectionForPosition(int i) { |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public Filter getFilter() { |
|
||||
if (branchFilter == null) { |
|
||||
branchFilter = new BranchFilter(); |
|
||||
} |
|
||||
return branchFilter; |
|
||||
} |
|
||||
|
|
||||
private class BranchFilter extends Filter { |
|
||||
|
|
||||
@Override |
|
||||
protected FilterResults performFiltering(CharSequence charSequence) { |
|
||||
FilterResults results = new FilterResults(); |
|
||||
if (charSequence != null && charSequence.length() > 0) { |
|
||||
List<Branch> filterList = new ArrayList(); |
|
||||
for (int i = 0; i < searchList.size(); i++) { |
|
||||
if (searchList.get(i).address.toLowerCase().contains(charSequence.toString().toLowerCase())) { |
|
||||
filterList.add(searchList.get(i)); |
|
||||
} |
|
||||
} |
|
||||
results.count = filterList.size(); |
|
||||
results.values = filterList; |
|
||||
} else { |
|
||||
results.count = searchList.size(); |
|
||||
results.values = searchList; |
|
||||
} |
|
||||
return results; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected void publishResults(CharSequence charSequence, FilterResults filterResults) { |
|
||||
branchList = (List) filterResults.values; |
|
||||
notifyDataSetChanged(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public class MyHolder extends RecyclerView.ViewHolder { |
|
||||
@BindView(R.id.tv_title) |
|
||||
GmeTextView tvTitle; |
|
||||
@BindView(R.id.tv_address) |
|
||||
GmeTextView tvAddress; |
|
||||
@BindView(R.id.tv_telephone) |
|
||||
GmeTextView tvTelephone; |
|
||||
@BindView(R.id.tv_info) |
|
||||
GmeTextView tvInfo; |
|
||||
@BindView(R.id.iv_location) |
|
||||
ImageView ivLocation; |
|
||||
|
|
||||
public MyHolder(View itemView) { |
|
||||
super(itemView); |
|
||||
ButterKnife.bind(this, itemView); |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public void openMap(Context context, double lat, double lng) { |
|
||||
Uri gmmIntentUri = Uri.parse(String.format(Locale.ENGLISH, "geo:%f,%f", lat, lng)); |
|
||||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); |
|
||||
mapIntent.setPackage("com.google.android.apps.maps"); |
|
||||
if (mapIntent.resolveActivity(context.getPackageManager()) != null) { |
|
||||
context.startActivity(mapIntent); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,37 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.model; |
|
||||
|
|
||||
import android.content.Context; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.GMEBranchesContract; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.base.OnRefreshCallback; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.base.RefreshModal; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.https.APIRequestErrorReturn; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.https.RestApi; |
|
||||
import com.google.gson.Gson; |
|
||||
import com.google.gson.GsonBuilder; |
|
||||
|
|
||||
import java.io.IOException; |
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
import retrofit2.Call; |
|
||||
import retrofit2.Callback; |
|
||||
import retrofit2.Response; |
|
||||
|
|
||||
|
|
||||
|
|
||||
public class GMEBranchesModel implements GMEBranchesContract.GMEBranchesModel { |
|
||||
private Context context; |
|
||||
|
|
||||
public GMEBranchesModel(Context context) { |
|
||||
this.context = context; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
@Override |
|
||||
public void requestGMEBranches(GMEBranchesContract.GMEBranchesListener gmeBranchesListener, Map<String, String> param) { |
|
||||
|
|
||||
} |
|
||||
} |
|
@ -1,51 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.model.data; |
|
||||
|
|
||||
import java.util.Comparator; |
|
||||
|
|
||||
/** |
|
||||
* Created by frantic on 2/2/18. |
|
||||
*/ |
|
||||
|
|
||||
public class Branch { |
|
||||
public String title; |
|
||||
public String address; |
|
||||
public String telephone; |
|
||||
public String info; |
|
||||
public double lat,lng; |
|
||||
|
|
||||
public Branch() { |
|
||||
} |
|
||||
|
|
||||
public Branch(String title, String address, String telephone, String info, double lat, double lng) { |
|
||||
this.title = title; |
|
||||
this.address = address; |
|
||||
this.telephone = telephone; |
|
||||
this.info = info; |
|
||||
this.lat = lat; |
|
||||
this.lng = lng; |
|
||||
} |
|
||||
|
|
||||
public Branch(String title, String address, String telephone, double lat, double lng) { |
|
||||
this.title = title; |
|
||||
this.address = address; |
|
||||
this.telephone = telephone; |
|
||||
this.lat = lat; |
|
||||
this.lng = lng; |
|
||||
} |
|
||||
|
|
||||
public static Comparator<Branch> addressNameComparator = new Comparator<Branch>() { |
|
||||
|
|
||||
public int compare(Branch branch1, Branch branch2) { |
|
||||
|
|
||||
String d1 = branch1.title.toUpperCase(); |
|
||||
String d2 = branch2.title.toUpperCase(); |
|
||||
|
|
||||
//ascending order |
|
||||
return d1.compareTo(d2); |
|
||||
|
|
||||
//descending order |
|
||||
//return fruitName2.compareTo(fruitName1); |
|
||||
} |
|
||||
|
|
||||
}; |
|
||||
} |
|
@ -1,45 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.model.data; |
|
||||
|
|
||||
import com.google.gson.annotations.Expose; |
|
||||
import com.google.gson.annotations.SerializedName; |
|
||||
|
|
||||
/** |
|
||||
* Created by surajshrestha on 2/7/18. |
|
||||
*/ |
|
||||
|
|
||||
public class PayoutLocationData { |
|
||||
|
|
||||
@SerializedName("payoutId") |
|
||||
@Expose |
|
||||
public String payoutId; |
|
||||
@SerializedName("country") |
|
||||
@Expose |
|
||||
public String country; |
|
||||
@SerializedName("city") |
|
||||
@Expose |
|
||||
public String city; |
|
||||
@SerializedName("name") |
|
||||
@Expose |
|
||||
public String name; |
|
||||
@SerializedName("address") |
|
||||
@Expose |
|
||||
public String address; |
|
||||
@SerializedName("phone") |
|
||||
@Expose |
|
||||
public String phone; |
|
||||
@SerializedName("email") |
|
||||
@Expose |
|
||||
public String email; |
|
||||
@SerializedName("website") |
|
||||
@Expose |
|
||||
public String website; |
|
||||
@SerializedName("postalCode") |
|
||||
@Expose |
|
||||
public String postalCode; |
|
||||
@SerializedName("latitude") |
|
||||
@Expose |
|
||||
public String latitude; |
|
||||
@SerializedName("longitude") |
|
||||
@Expose |
|
||||
public String longitude; |
|
||||
} |
|
@ -1,70 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.presenter; |
|
||||
|
|
||||
import android.support.annotation.NonNull; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.GMEBranchesContract; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.https.APIRequestErrorReturn; |
|
||||
|
|
||||
import java.io.IOException; |
|
||||
import java.util.HashMap; |
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
import static com.gmeremit.online.gmeremittance_native.utils.Constants.ERROR; |
|
||||
import static com.gmeremit.online.gmeremittance_native.utils.Constants.INTERNET; |
|
||||
import static com.gmeremit.online.gmeremittance_native.utils.Constants.OTHER_ERROR; |
|
||||
|
|
||||
/** |
|
||||
* Created by surajshrestha on 2/7/18. |
|
||||
*/ |
|
||||
|
|
||||
public class GmeBranchesPresenter implements GMEBranchesContract.GMEBranchesPresenter, GMEBranchesContract.GMEBranchesListener { |
|
||||
|
|
||||
private GMEBranchesContract.GMEBranchesView gmeBranchesView; |
|
||||
private GMEBranchesContract.GMEBranchesModel gmeBranchesModel; |
|
||||
|
|
||||
public GmeBranchesPresenter(GMEBranchesContract.GMEBranchesView gmeBranchesView, GMEBranchesContract.GMEBranchesModel gmeBranchesModel) { |
|
||||
this.gmeBranchesModel = gmeBranchesModel; |
|
||||
this.gmeBranchesView = gmeBranchesView; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void gmeBranches() { |
|
||||
gmeBranchesView.showProgressDialog(); |
|
||||
Map<String, String> param = getParam(); |
|
||||
gmeBranchesModel.requestGMEBranches(this, param); |
|
||||
} |
|
||||
|
|
||||
@NonNull |
|
||||
private Map<String, String> getParam() { |
|
||||
Map<String, String> param = new HashMap<>(); |
|
||||
param.put("countryId", "118"); |
|
||||
param.put("constraint", "default"); |
|
||||
return param; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onSuccessReponse(List<PayoutLocationData> body) { |
|
||||
gmeBranchesView.dismissProgressDialog(); |
|
||||
gmeBranchesView.updateLayout(body); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onFailure(APIRequestErrorReturn statusErrorReturn) { |
|
||||
gmeBranchesView.dismissProgressDialog(); |
|
||||
gmeBranchesView.showGeneralDialog("Oops! Something went wrong", statusErrorReturn.message, OTHER_ERROR); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onFailureException(Throwable t) { |
|
||||
gmeBranchesView.dismissProgressDialog(); |
|
||||
gmeBranchesView.showGeneralDialog("ERROR", (t instanceof IOException) ? "Connection Lost" : t.getMessage(), ERROR); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onNoInternetConnection() { |
|
||||
gmeBranchesView.dismissProgressDialog(); |
|
||||
gmeBranchesView.showGeneralDialog("", "", INTERNET); |
|
||||
} |
|
||||
} |
|
@ -1,174 +0,0 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.gme_branches.view; |
|
||||
|
|
||||
import android.app.ProgressDialog; |
|
||||
import android.os.Bundle; |
|
||||
import android.support.v7.app.AppCompatActivity; |
|
||||
import android.support.v7.widget.LinearLayoutManager; |
|
||||
import android.text.Editable; |
|
||||
import android.text.TextWatcher; |
|
||||
import android.util.Log; |
|
||||
import android.view.View; |
|
||||
import android.widget.EditText; |
|
||||
import android.widget.ImageView; |
|
||||
import android.widget.LinearLayout; |
|
||||
import android.widget.Toast; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.R; |
|
||||
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.GMEBranchesContract; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.adapter.GmeBranchAdapter; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.GMEBranchesModel; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.Branch; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData; |
|
||||
import com.gmeremit.online.gmeremittance_native.gme_branches.presenter.GmeBranchesPresenter; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.KeyboardUtils; |
|
||||
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.Collections; |
|
||||
import java.util.List; |
|
||||
|
|
||||
import butterknife.BindView; |
|
||||
import butterknife.ButterKnife; |
|
||||
import butterknife.OnClick; |
|
||||
import fastscroll.app.fastscrollalphabetindex.AlphabetIndexFastScrollRecyclerView; |
|
||||
|
|
||||
public class GmeBranchesActivity extends AppCompatActivity implements GMEBranchesContract.GMEBranchesView { |
|
||||
|
|
||||
@BindView(R.id.iv_back) |
|
||||
ImageView ivBack; |
|
||||
@BindView(R.id.toolbar_title) |
|
||||
GmeTextView toolbarTitle; |
|
||||
@BindView(R.id.iv_cancel) |
|
||||
GmeTextView ivCancel; |
|
||||
@BindView(R.id.iv_search) |
|
||||
EditText ivSearch; |
|
||||
@BindView(R.id.recyclerView) |
|
||||
AlphabetIndexFastScrollRecyclerView recyclerView; |
|
||||
GmeBranchAdapter gmeBranchAdapter; |
|
||||
List<Branch> branchList; |
|
||||
@BindView(R.id.searchLayout) |
|
||||
LinearLayout searchLayout; |
|
||||
|
|
||||
private GMEBranchesContract.GMEBranchesPresenter gmeBranchesPresenter; |
|
||||
private ProgressDialog progressDialog; |
|
||||
|
|
||||
@Override |
|
||||
protected void onCreate(Bundle savedInstanceState) { |
|
||||
super.onCreate(savedInstanceState); |
|
||||
setContentView(R.layout.activity_gme_branches); |
|
||||
ButterKnife.bind(this); |
|
||||
toolbarTitle.setText("GME Branches"); |
|
||||
ivCancel.setVisibility(View.GONE); |
|
||||
branchList = new ArrayList<>(); |
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); |
|
||||
recyclerView.setIndexBarVisibility(false); |
|
||||
|
|
||||
progressDialog = new ProgressDialog(this); |
|
||||
progressDialog.setMessage(""); |
|
||||
progressDialog.setCancelable(false); |
|
||||
|
|
||||
gmeBranchesPresenter = new GmeBranchesPresenter(this, new GMEBranchesModel(this)); |
|
||||
gmeBranchesPresenter.gmeBranches(); |
|
||||
|
|
||||
|
|
||||
KeyboardUtils.addKeyboardToggleListener(GmeBranchesActivity.this, new KeyboardUtils.SoftKeyboardToggleListener() { |
|
||||
@Override |
|
||||
public void onToggleSoftKeyboard(boolean isVisible) { |
|
||||
Log.d("keyboard", "keyboard visible: " + isVisible); |
|
||||
if (isVisible) { |
|
||||
recyclerView.setIndexBarVisibility(false); |
|
||||
} else { |
|
||||
recyclerView.setIndexBarVisibility(true); |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
ivSearch.addTextChangedListener(new TextWatcher() { |
|
||||
@Override |
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { |
|
||||
if (charSequence != null) { |
|
||||
gmeBranchAdapter.getFilter().filter(charSequence.toString()); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void afterTextChanged(Editable editable) { |
|
||||
|
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
private void init(List<PayoutLocationData> body) { |
|
||||
for (PayoutLocationData gmeLocation : body) { |
|
||||
if (gmeLocation.latitude == null && gmeLocation.longitude == null) { |
|
||||
branchList.add(new Branch(gmeLocation.name, gmeLocation.address, gmeLocation.phone, Double.parseDouble("0.0"), Double.parseDouble("0.0"))); |
|
||||
} else { |
|
||||
branchList.add(new Branch(gmeLocation.name, gmeLocation.address, gmeLocation.phone, Double.parseDouble(gmeLocation.latitude), Double.parseDouble(gmeLocation.longitude))); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@OnClick(R.id.iv_back) |
|
||||
public void onViewClicked() { |
|
||||
finish(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onBackPressed() { |
|
||||
if (ivSearch.getText().length() > 0) { |
|
||||
ivSearch.setText(""); |
|
||||
} else { |
|
||||
finish(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void updateLayout(List<PayoutLocationData> body) { |
|
||||
searchLayout.setVisibility(View.VISIBLE); |
|
||||
recyclerView.setIndexBarVisibility(true); |
|
||||
|
|
||||
if (body.size() > 0) { |
|
||||
setAdapter(body); |
|
||||
} else { |
|
||||
Toast.makeText(this, "No Payout Location Available", Toast.LENGTH_LONG).show(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private void setAdapter(List<PayoutLocationData> body) { |
|
||||
init(body); |
|
||||
Collections.sort(branchList, Branch.addressNameComparator); |
|
||||
gmeBranchAdapter = new GmeBranchAdapter(branchList); |
|
||||
recyclerView.setAdapter(gmeBranchAdapter); |
|
||||
recyclerView.setIndexBarColor("#cdced2"); |
|
||||
recyclerView.setIndexBarTextColor("#4a4a4a"); |
|
||||
recyclerView.setIndexBarHighLateTextVisibility(true); |
|
||||
recyclerView.setIndexbarHighLateTextColor("#ed1c24"); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void showProgressDialog() { |
|
||||
progressDialog.show(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void dismissProgressDialog() { |
|
||||
if (progressDialog.isShowing()) { |
|
||||
progressDialog.dismiss(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void showGeneralDialog(String title, String message, String type) { |
|
||||
Utils.showDialog(this, title, message, type); |
|
||||
recyclerView.setIndexBarVisibility(false); |
|
||||
searchLayout.setVisibility(View.GONE); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
@ -1,241 +1,9 @@ |
|||||
package com.gmeremit.online.gmeremittance_native.utils; |
package com.gmeremit.online.gmeremittance_native.utils; |
||||
|
|
||||
import android.app.Notification; |
|
||||
import android.app.NotificationManager; |
|
||||
import android.app.PendingIntent; |
|
||||
import android.content.Context; |
|
||||
import android.content.Intent; |
|
||||
import android.content.res.Resources; |
|
||||
import android.graphics.Color; |
|
||||
import android.media.RingtoneManager; |
|
||||
import android.net.Uri; |
|
||||
import android.os.Environment; |
|
||||
import android.support.v4.app.NotificationCompat; |
|
||||
import android.webkit.MimeTypeMap; |
|
||||
import android.widget.Toast; |
|
||||
|
|
||||
import com.gmeremit.online.gmeremittance_native.R; |
|
||||
import com.gmeremit.online.gmeremittance_native.push_notifications.NotificationHelper; |
|
||||
import com.itextpdf.text.BaseColor; |
|
||||
import com.itextpdf.text.Document; |
|
||||
import com.itextpdf.text.DocumentException; |
|
||||
import com.itextpdf.text.Element; |
|
||||
import com.itextpdf.text.Font; |
|
||||
import com.itextpdf.text.PageSize; |
|
||||
import com.itextpdf.text.Paragraph; |
|
||||
import com.itextpdf.text.Rectangle; |
|
||||
import com.itextpdf.text.pdf.PdfPCell; |
|
||||
import com.itextpdf.text.pdf.PdfPTable; |
|
||||
import com.itextpdf.text.pdf.PdfWriter; |
|
||||
|
|
||||
import java.io.File; |
|
||||
import java.io.FileNotFoundException; |
|
||||
import java.io.FileOutputStream; |
|
||||
|
|
||||
import static android.content.Context.NOTIFICATION_SERVICE; |
|
||||
|
|
||||
/** |
/** |
||||
* Created by frantic on 12/27/17. |
* Created by frantic on 12/27/17. |
||||
*/ |
*/ |
||||
|
|
||||
public class CreatePdf { |
public class CreatePdf { |
||||
public static void makepdf(Context context){ |
|
||||
String filepath = Environment.getExternalStorageDirectory().toString() |
|
||||
+ "/PDF/" + "Gme.pdf"; |
|
||||
|
|
||||
// Add Permission into Manifest.xml |
|
||||
// <uses-permission |
|
||||
// android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
|
||||
|
|
||||
// Create New Blank Document |
|
||||
Document document = new Document(PageSize.A4); |
|
||||
|
|
||||
// Create Directory in External Storage |
|
||||
String root = Environment.getExternalStorageDirectory().toString(); |
|
||||
File myDir = new File(root + "/PDF"); |
|
||||
myDir.mkdirs(); |
|
||||
|
|
||||
// Create Pdf Writer for Writting into New Created Document |
|
||||
try { |
|
||||
PdfWriter.getInstance(document, new FileOutputStream(filepath)); |
|
||||
|
|
||||
// Open Document for Writting into document |
|
||||
document.open(); |
|
||||
|
|
||||
// User Define Method |
|
||||
addMetaData(document); |
|
||||
addTitlePage(document); |
|
||||
} catch (FileNotFoundException e) { |
|
||||
// TODO Auto-generated catch block |
|
||||
e.printStackTrace(); |
|
||||
} catch (DocumentException e) { |
|
||||
// TODO Auto-generated catch block |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
// Close Document after writting all content |
|
||||
document.close(); |
|
||||
|
|
||||
Toast.makeText(context, "PDF File is Created. Location : " + filepath, |
|
||||
Toast.LENGTH_LONG).show(); |
|
||||
showNotification(context); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
// Set PDF document Properties |
|
||||
public static void addMetaData(Document document) |
|
||||
|
|
||||
{ |
|
||||
document.addTitle("Transaction"); |
|
||||
document.addSubject("Person Info"); |
|
||||
document.addKeywords("transaction,detail"); |
|
||||
document.addAuthor("GME"); |
|
||||
document.addCreator("GME"); |
|
||||
} |
|
||||
|
|
||||
public static void addTitlePage(Document document) throws DocumentException { |
|
||||
// Font Style for Document |
|
||||
Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD); |
|
||||
Font titleFont = new Font(Font.FontFamily.TIMES_ROMAN, 22, Font.BOLD |
|
||||
| Font.UNDERLINE, BaseColor.GRAY); |
|
||||
Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); |
|
||||
Font normal = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL); |
|
||||
|
|
||||
// Start New Paragraph |
|
||||
Paragraph prHead = new Paragraph(); |
|
||||
// Set Font in this Paragraph |
|
||||
prHead.setFont(titleFont); |
|
||||
// Add item into Paragraph |
|
||||
prHead.add("Transaction Detail\n"); |
|
||||
|
|
||||
// Create Table into Document with 1 Row |
|
||||
PdfPTable myTable = new PdfPTable(1); |
|
||||
// 100.0f mean width of table is same as Document size |
|
||||
myTable.setWidthPercentage(100.0f); |
|
||||
|
|
||||
// Create New Cell into Table |
|
||||
PdfPCell myCell = new PdfPCell(new Paragraph("")); |
|
||||
myCell.setBorder(Rectangle.BOTTOM); |
|
||||
|
|
||||
// Add Cell into Table |
|
||||
myTable.addCell(myCell); |
|
||||
|
|
||||
prHead.setFont(catFont); |
|
||||
prHead.add("\nTransaction Detail of Kapil Maharjan\n \n"); |
|
||||
prHead.setAlignment(Element.ALIGN_CENTER); |
|
||||
|
|
||||
// Add all above details into Document |
|
||||
document.add(prHead); |
|
||||
document.add(myTable); |
|
||||
|
|
||||
document.add(myTable); |
|
||||
|
|
||||
// Now Start another New Paragraph |
|
||||
Paragraph prPersinalInfo = new Paragraph(); |
|
||||
prPersinalInfo.setFont(smallBold); |
|
||||
prPersinalInfo.add("\n\n"); |
|
||||
prPersinalInfo.add("Transaction Date : 28/12/2017\n"); |
|
||||
prPersinalInfo.add("Transaction No. : 1004015\n \n \n"); |
|
||||
prPersinalInfo.add("Receiver : Sujal Manandhar\n"); |
|
||||
prPersinalInfo.add("Relation : Friend\n"); |
|
||||
prPersinalInfo.add("Address : Kalimati, Kathmandu, Nepal\n"); |
|
||||
prPersinalInfo.add("Country: Nepal\n"); |
|
||||
prPersinalInfo.add("Mobile No. : 9812731823\n"); |
|
||||
prPersinalInfo.add("Email : sujal@fusemachines.com\n \n \n"); |
|
||||
|
|
||||
prPersinalInfo.setAlignment(Element.ALIGN_CENTER); |
|
||||
|
|
||||
document.add(prPersinalInfo); |
|
||||
document.add(myTable); |
|
||||
|
|
||||
document.add(myTable); |
|
||||
|
|
||||
Paragraph prProfile = new Paragraph(); |
|
||||
prProfile.setFont(smallBold); |
|
||||
prProfile.add("\n \n Profile : \n "); |
|
||||
prProfile.setFont(normal); |
|
||||
prProfile |
|
||||
.add("\nThis is very Confidential"); |
|
||||
|
|
||||
prProfile.setFont(smallBold); |
|
||||
document.add(prProfile); |
|
||||
|
|
||||
// Create new Page in PDF |
|
||||
document.newPage(); |
|
||||
} |
|
||||
|
|
||||
public static void showNotification(Context context) { |
|
||||
String filePath = Environment.getExternalStorageDirectory().toString() |
|
||||
+ "/PDF/" + "Gme.pdf"; |
|
||||
|
|
||||
File file = new File(filePath); |
|
||||
MimeTypeMap map = MimeTypeMap.getSingleton(); |
|
||||
String ext = MimeTypeMap.getFileExtensionFromUrl(file.getName()); |
|
||||
String type = map.getMimeTypeFromExtension(ext); |
|
||||
|
|
||||
if (type == null) |
|
||||
type = "*/*"; |
|
||||
|
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW); |
|
||||
// intent.setAction(android.content.Intent.ACTION_VIEW); |
|
||||
// File file = new File(files); // set your audio path |
|
||||
intent.setDataAndType(Uri.fromFile(file), type); |
|
||||
|
|
||||
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0); |
|
||||
|
|
||||
Notification noti = new NotificationCompat.Builder(context) |
|
||||
.setContentTitle("Download completed") |
|
||||
.setContentText("Click her to view the file") |
|
||||
.setSmallIcon(R.drawable.ic_gme_logo_white) |
|
||||
.setContentIntent(pIntent).build(); |
|
||||
|
|
||||
noti.flags |= Notification.FLAG_AUTO_CANCEL; |
|
||||
|
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); |
|
||||
notificationManager.notify(0, noti); |
|
||||
} |
|
||||
|
|
||||
public static void showNotification(Context context,String filepath) { |
|
||||
|
|
||||
File file = new File(filepath); |
|
||||
MimeTypeMap map = MimeTypeMap.getSingleton(); |
|
||||
String ext = MimeTypeMap.getFileExtensionFromUrl(file.getName()); |
|
||||
String type = map.getMimeTypeFromExtension(ext); |
|
||||
|
|
||||
if (type == null) |
|
||||
type = "*/*"; |
|
||||
|
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW); |
|
||||
// intent.setAction(android.content.Intent.ACTION_VIEW); |
|
||||
// File file = new File(files); // set your audio path |
|
||||
intent.setDataAndType(Uri.fromFile(file), type); |
|
||||
|
|
||||
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0); |
|
||||
|
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { |
|
||||
NotificationHelper noti = new NotificationHelper(context); |
|
||||
Notification.Builder nb = noti.getNotification1("Download completed", "Click here to view the file",pIntent); |
|
||||
if (nb != null) { |
|
||||
noti.notify(0, nb); |
|
||||
} |
|
||||
}else { |
|
||||
Notification noti = new NotificationCompat.Builder(context) |
|
||||
.setContentTitle("Download completed") |
|
||||
.setContentText("Click her to view the file") |
|
||||
.setWhen(System.currentTimeMillis()) |
|
||||
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) |
|
||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) |
|
||||
.setLights(Color.GREEN, 3000, 3000) |
|
||||
.setSmallIcon(R.drawable.ic_gme_logo_white) |
|
||||
.setContentIntent(pIntent).build(); |
|
||||
|
|
||||
noti.flags |= Notification.FLAG_AUTO_CANCEL; |
|
||||
noti.defaults |= Notification.DEFAULT_VIBRATE; |
|
||||
noti.defaults |= Notification.DEFAULT_SOUND; |
|
||||
|
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); |
|
||||
notificationManager.notify(0, noti); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue