Skip to content

Commit

Permalink
hrishikesh prateek
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishikeshprateek committed Aug 2, 2020
1 parent 282f651 commit f1b02c3
Show file tree
Hide file tree
Showing 19 changed files with 398 additions and 218 deletions.
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.activity.WeightConverter"></activity>
<activity android:name=".ui.activity.PdfLoader"></activity>
<activity android:name=".ui.activity.WeightConverter" />
<activity android:name=".ui.activity.TemperatureConverter" />
<activity android:name=".ui.activity.LengthConverter" />
<activity android:name=".ui.activity.AreaConverter" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.thundersharp.cadmin.core.globalAdapters;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.github.barteksc.pdfviewer.PDFView;
import com.thundersharp.cadmin.R;
import com.thundersharp.cadmin.ui.activity.PdfLoader;

import java.util.List;

Expand Down Expand Up @@ -44,11 +44,17 @@ public int getItemCount() {
}else return 0;
}

public class ViewHolder extends RecyclerView.ViewHolder{
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView pdfView;
public ViewHolder(@NonNull View itemView) {
super(itemView);
pdfView = itemView.findViewById(R.id.pdf_viewer);
itemView.setOnClickListener(this);
}

@Override
public void onClick(View view) {
context.startActivity(new Intent(context, PdfLoader.class).putExtra("url",pdfuri.get(getAdapterPosition())));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.util.List;

import thundersharp.timeline.TimelineView;

public class WorkForceAdapter extends RecyclerView.Adapter<WorkForceAdapter.CustomViewHolder> {

Context context;
Expand All @@ -35,7 +37,7 @@ public WorkForceAdapter(Context context,List<WorkforceModel> data,AddProject_mod
@Override
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item_work_force,null);
return new CustomViewHolder(view);
return new CustomViewHolder(view,viewType);
}

@Override
Expand All @@ -61,17 +63,20 @@ class CustomViewHolder extends RecyclerView.ViewHolder implements View.OnClickLi
ImageView iv;
TextView starttime,name_proj,id_proj,desc_proj,end_time;
Button evpand;
TimelineView timelineView;

public CustomViewHolder(@NonNull View itemView) {
public CustomViewHolder(@NonNull View itemView ,int viewtype) {
super(itemView);
iv = itemView.findViewById(R.id.iv);
evpand = itemView.findViewById(R.id.recyclertodo);
evpand.setOnClickListener(this);
//evpand = itemView.findViewById(R.id.recyclertodo);
//evpand.setOnClickListener(this);
starttime = itemView.findViewById(R.id.starttime);
end_time = itemView.findViewById(R.id.end_time);
desc_proj = itemView.findViewById(R.id.desc_proj);
id_proj = itemView.findViewById(R.id.id_proj);
name_proj = itemView.findViewById(R.id.name_proj);
timelineView = itemView.findViewById(R.id.timeline);
timelineView.initLine(viewtype);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.thundersharp.cadmin.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import com.thundersharp.cadmin.R;

public class PdfLoader extends AppCompatActivity {

WebView webView;
ProgressBar progressBar;
String url;
Vibrator vibrator;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdf_loader);

webView = findViewById(R.id.webview);

url = getIntent().getStringExtra("url");
progressBar = findViewById(R.id.prooooo);

vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);

//---you need this to prevent the webview from
// launching another browser when a url
// redirection occurs---
webView.setWebViewClient(new Callback());
Uri uri = Uri.parse(url);

webView.loadUrl(uri.toString());

}

private class Callback extends WebViewClient {
boolean loadingFinished = true;
boolean redirect = false;

@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
if (!loadingFinished) {
redirect = true;
}

loadingFinished = false;
view.loadUrl(urlNewString);
return false;
}

@Override
public void onPageStarted(WebView view, String url, Bitmap facIcon) {
loadingFinished = false;
//SHOW LOADING IF IT ISNT ALREADY VISIBLE
progressBar.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(WebView view, String url) {
if(!redirect){
loadingFinished = true;
}

if(loadingFinished && !redirect){
//HIDE LOADING IT HAS FINISHED
progressBar.setVisibility(View.GONE);
/* if (settingsData.getvibratePdf() && settingsData.getHaptic()){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(VibrationEffect.createOneShot(200, VibrationEffect.EFFECT_HEAVY_CLICK));
} else {
//deprecated in API 26
vibrator.vibrate(200);
}
}*/


} else{
redirect = false;
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public void onNothingSelected(AdapterView<?> adapterView) {
public void loadDataFromServer(final String key,@NonNull final String orgid){
//TODO UPDATE THE VALUES TO BE LOADED FROM SHARED PREFRENCES SAVED
//TODO @GET FROM SPF @DESC (NOT NECESSARY)
workforceModels.clear();
FirebaseDatabase.getInstance()
.getReference("organisation")
.child(orgid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import com.google.firebase.storage.UploadTask;
import com.thundersharp.cadmin.R;
import com.thundersharp.cadmin.core.globalAdapters.PdfAdapter;
import com.thundersharp.cadmin.ui.activity.MainActivity;

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

import static android.app.Activity.RESULT_OK;
import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton;

public class Files extends Fragment {

Expand All @@ -61,26 +63,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_files, container, false);

MainActivity.floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_outline_note_add_24,getActivity().getTheme()));

MainActivity.floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

selectPdf();

}
});
imageView = view.findViewById(R.id.imageView_files);
textView = view.findViewById(R.id.tv_files);
fab1 = view.findViewById(R.id.upload_files);
storage = FirebaseStorage.getInstance();
database = FirebaseDatabase.getInstance();

url = new ArrayList<>();
sharedPreferences =getActivity().getSharedPreferences("selected_org", Context.MODE_PRIVATE);
filesRecycler= view.findViewById(R.id.recycler_view_all_files);
filesRecycler.setHasFixedSize(true);
filesRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 4));
filesRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));


fab1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectPdf();
}
});

org_id = sharedPreferences.getString("selected",null);

project_key = ProjectDetails.project_key;
Expand All @@ -105,7 +109,7 @@ private void loadImagesfromServer(String org_id, String project_key) {
.child(org_id)
.child("projects")
.child(project_key)
.child("images")
.child("pdfFiles")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
Expand Down Expand Up @@ -167,24 +171,30 @@ private void uploadPdfFile(Uri data) {
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
String url = taskSnapshot.getMetadata().toString();
DatabaseReference reference = database.getReference("organisation")
.child(org_id)
.child("projects")
.child(project_key)
.child("pdfFiles");
reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener<Void>() {
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
progressDialog.dismiss();
Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show();
} else {
progressDialog.dismiss();
Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show();
}
public void onSuccess(Uri uri) {
String url = uri.toString();
DatabaseReference reference = database.getReference("organisation")
.child(org_id)
.child("projects")
.child(project_key)
.child("pdfFiles");
reference.child(fileName).setValue(url).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
progressDialog.dismiss();
Toast.makeText(getContext(), "File Successfully Uploaded", Toast.LENGTH_SHORT).show();
} else {
progressDialog.dismiss();
Toast.makeText(getContext(), "File not uploaded", Toast.LENGTH_SHORT).show();
}
}
});
}
});

}
}).addOnFailureListener(new OnFailureListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.ArrayList;
import java.util.List;

import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton;


public class Photo extends Fragment {

Expand All @@ -42,6 +44,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
View view= inflater.inflate(R.layout.fragment_photo, container, false);

floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_outline_add_photo_alternate_24,getActivity().getTheme()));

floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

//selectPdf();

}
});

url = new ArrayList<>();
sharedPreferences =getActivity().getSharedPreferences("selected_org",Context.MODE_PRIVATE);
gallaryrecuycler= view.findViewById(R.id.gallaryrecuycler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ public void onClick(View view) {
tabLayout.setupWithViewPager(viewPager);
viewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

}

@Override
public void onPageSelected(int position) {

}

@Override
public void onPageScrollStateChanged(int state) {

}
});

tabLayout.getTabAt(0).setIcon(R.drawable.ic_outline_photo_library_24);
tabLayout.getTabAt(1).setIcon(R.drawable.ic_outline_file_copy_24);
tabLayout.getTabAt(2).setIcon(R.drawable.ic_outline_video_library_24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;

import static android.app.Activity.RESULT_OK;
import static com.thundersharp.cadmin.ui.activity.MainActivity.floatingActionButton;

public class Video extends Fragment {

Expand All @@ -65,9 +66,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_video, container, false);

floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_slow_motion_video_24,getActivity().getTheme()));

floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

selectVideo();

}
});
imageView = view.findViewById(R.id.imageView_video);
textView = view.findViewById(R.id.tv_video);
fabVideo = view.findViewById(R.id.upload_videos);

imageView.setVisibility(View.VISIBLE);
imageView.setImageResource(R.drawable.sad);
Expand All @@ -82,14 +92,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
videoRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 3));



fabVideo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectVideo();
}
});

org_id = sharedPreferences.getString("selected",null);

project_key = ProjectDetails.project_key;
Expand Down
Loading

0 comments on commit f1b02c3

Please sign in to comment.